Add support for Paint::setTextSkewX in OpenGLRenderer.
Bug #3360888
Change-Id: I42e81a1f10bf7b9ae1c63ca8add1878fd59a1e8a
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index d1fbfba..c080501 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -38,8 +38,10 @@
// Font
///////////////////////////////////////////////////////////////////////////////
-Font::Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags) :
- mState(state), mFontId(fontId), mFontSize(fontSize), mFlags(flags) {
+Font::Font(FontRenderer* state, uint32_t fontId, float fontSize,
+ int flags, uint32_t italicStyle) :
+ mState(state), mFontId(fontId), mFontSize(fontSize),
+ mFlags(flags), mItalicStyle(italicStyle) {
}
@@ -275,17 +277,19 @@
return newGlyph;
}
-Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize, int flags) {
+Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize,
+ int flags, uint32_t italicStyle) {
Vector<Font*> &activeFonts = state->mActiveFonts;
for (uint32_t i = 0; i < activeFonts.size(); i++) {
Font* font = activeFonts[i];
- if (font->mFontId == fontId && font->mFontSize == fontSize && font->mFlags == flags) {
+ if (font->mFontId == fontId && font->mFontSize == fontSize &&
+ font->mFlags == flags && font->mItalicStyle == italicStyle) {
return font;
}
}
- Font* newFont = new Font(state, fontId, fontSize, flags);
+ Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle);
activeFonts.push(newFont);
return newFont;
}
@@ -638,7 +642,10 @@
if (paint->isFakeBoldText()) {
flags |= Font::kFakeBold;
}
- mCurrentFont = Font::create(this, fontId, fontSize, flags);
+
+ const float skewX = paint->getTextSkewX();
+ uint32_t italicStyle = *(uint32_t*) &skewX;
+ mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle);
const float maxPrecacheFontSize = 40.0f;
bool isNewFont = currentNumFonts != mActiveFonts.size();
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 40572c6..1005812 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -57,7 +57,8 @@
/**
* Creates a new font associated with the specified font state.
*/
- static Font* create(FontRenderer* state, uint32_t fontId, float fontSize, int flags);
+ static Font* create(FontRenderer* state, uint32_t fontId, float fontSize,
+ int flags, uint32_t italicStyle);
protected:
friend class FontRenderer;
@@ -103,7 +104,7 @@
SkFixed mRsbDelta;
};
- Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags);
+ Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle);
DefaultKeyedVector<int32_t, CachedGlyphInfo*> mCachedGlyphs;
@@ -122,6 +123,7 @@
uint32_t mFontId;
float mFontSize;
int mFlags;
+ uint32_t mItalicStyle;
};
class FontRenderer {