summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2011-03-02 13:51:36 -0800
committerChet Haase <chet@google.com>2011-03-02 14:02:19 -0800
commit8668f8a633d9299091556c3b2e5ae07be8dce360 (patch)
treeeddc2f604fc72622f49d8e5370b02a3e1148eb40 /libs
parent108500ab225a9b0b275e45620b9db9dbce0d9925 (diff)
downloadframeworks_base-8668f8a633d9299091556c3b2e5ae07be8dce360.zip
frameworks_base-8668f8a633d9299091556c3b2e5ae07be8dce360.tar.gz
frameworks_base-8668f8a633d9299091556c3b2e5ae07be8dce360.tar.bz2
Fix problem with glyph cache and textScaleX property
Glyphs drawn with paints that had different textScaleX values were not being recognized as different, so the glyph cache was being used regardless of different scaleX values. This change adds the scaleX attribute to the native Font object to allow the cache to distinguish between this difference and cache accordingly. Change-Id: I5d8fc26d47460b27dc8e373a473d46b2f1b8dc30
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/FontRenderer.cpp15
-rw-r--r--libs/hwui/FontRenderer.h6
2 files changed, 13 insertions, 8 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 8bae684..aa9b40e 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -40,9 +40,9 @@ namespace uirenderer {
///////////////////////////////////////////////////////////////////////////////
Font::Font(FontRenderer* state, uint32_t fontId, float fontSize,
- int flags, uint32_t italicStyle) :
+ int flags, uint32_t italicStyle, uint32_t scaleX) :
mState(state), mFontId(fontId), mFontSize(fontSize),
- mFlags(flags), mItalicStyle(italicStyle) {
+ mFlags(flags), mItalicStyle(italicStyle), mScaleX(scaleX) {
}
@@ -279,18 +279,19 @@ Font::CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, int32_t glyph) {
}
Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize,
- int flags, uint32_t italicStyle) {
+ int flags, uint32_t italicStyle, uint32_t scaleX) {
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 && font->mItalicStyle == italicStyle) {
+ font->mFlags == flags && font->mItalicStyle == italicStyle &&
+ font->mScaleX == scaleX) {
return font;
}
}
- Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle);
+ Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle, scaleX);
activeFonts.push(newFont);
return newFont;
}
@@ -657,7 +658,9 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) {
const float skewX = paint->getTextSkewX();
uint32_t italicStyle = *(uint32_t*) &skewX;
- mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle);
+ const float scaleXFloat = paint->getTextScaleX();
+ uint32_t scaleX = *(uint32_t*) &scaleXFloat;
+ mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle, scaleX);
const float maxPrecacheFontSize = 40.0f;
bool isNewFont = currentNumFonts != mActiveFonts.size();
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 46f332e..3a7aa96 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -58,7 +58,7 @@ public:
* Creates a new font associated with the specified font state.
*/
static Font* create(FontRenderer* state, uint32_t fontId, float fontSize,
- int flags, uint32_t italicStyle);
+ int flags, uint32_t italicStyle, uint32_t scaleX);
protected:
friend class FontRenderer;
@@ -104,7 +104,8 @@ protected:
SkFixed mRsbDelta;
};
- Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle);
+ Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle,
+ uint32_t scaleX);
DefaultKeyedVector<int32_t, CachedGlyphInfo*> mCachedGlyphs;
@@ -124,6 +125,7 @@ protected:
float mFontSize;
int mFlags;
uint32_t mItalicStyle;
+ uint32_t mScaleX;
};
class FontRenderer {