diff options
author | Romain Guy <romainguy@google.com> | 2011-08-02 17:32:41 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-08-02 17:32:41 -0700 |
commit | bd496bc3d481f9cfc39007d22372d3a1a8809f96 (patch) | |
tree | 1c69e8c136dd81e68459c8b9870e0fac4bd6ae10 /libs/hwui | |
parent | 6805545649f2b194859033df94602492b9ec086e (diff) | |
download | frameworks_base-bd496bc3d481f9cfc39007d22372d3a1a8809f96.zip frameworks_base-bd496bc3d481f9cfc39007d22372d3a1a8809f96.tar.gz frameworks_base-bd496bc3d481f9cfc39007d22372d3a1a8809f96.tar.bz2 |
Paint style and stroke width affect text rendering.
Bug #5112207
Change-Id: Ic34037ace21a5058ba23dd15e51aae58c998454d
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 21 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.h | 7 |
2 files changed, 20 insertions, 8 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 9bf3de8..9acf99b 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -44,9 +44,11 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// Font::Font(FontRenderer* state, uint32_t fontId, float fontSize, - int flags, uint32_t italicStyle, uint32_t scaleX) : + int flags, uint32_t italicStyle, uint32_t scaleX, + SkPaint::Style style, uint32_t strokeWidth) : mState(state), mFontId(fontId), mFontSize(fontSize), - mFlags(flags), mItalicStyle(italicStyle), mScaleX(scaleX) { + mFlags(flags), mItalicStyle(italicStyle), mScaleX(scaleX), + mStyle(style), mStrokeWidth(mStrokeWidth) { } @@ -283,19 +285,22 @@ Font::CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, glyph_t glyph) { } Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize, - int flags, uint32_t italicStyle, uint32_t scaleX) { + int flags, uint32_t italicStyle, uint32_t scaleX, + SkPaint::Style style, uint32_t strokeWidth) { 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->mScaleX == scaleX) { + font->mScaleX == scaleX && font->mStyle == style && + (style == SkPaint::kFill_Style || font->mStrokeWidth == strokeWidth)) { return font; } } - Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle, scaleX); + Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle, + scaleX, style, strokeWidth); activeFonts.push(newFont); return newFont; } @@ -690,7 +695,11 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) { uint32_t italicStyle = *(uint32_t*) &skewX; const float scaleXFloat = paint->getTextScaleX(); uint32_t scaleX = *(uint32_t*) &scaleXFloat; - mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle, scaleX); + SkPaint::Style style = paint->getStyle(); + const float strokeWidthFloat = paint->getStrokeWidth(); + uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat; + mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle, + scaleX, style, strokeWidth); const float maxPrecacheFontSize = 40.0f; bool isNewFont = currentNumFonts != mActiveFonts.size(); diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h index 24ed6fa..1922812 100644 --- a/libs/hwui/FontRenderer.h +++ b/libs/hwui/FontRenderer.h @@ -82,7 +82,8 @@ 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, uint32_t scaleX); + int flags, uint32_t italicStyle, uint32_t scaleX, SkPaint::Style style, + uint32_t strokeWidth); protected: friend class FontRenderer; @@ -128,7 +129,7 @@ protected: }; Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle, - uint32_t scaleX); + uint32_t scaleX, SkPaint::Style style, uint32_t strokeWidth); // Cache of glyphs DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs; @@ -157,6 +158,8 @@ protected: int mFlags; uint32_t mItalicStyle; uint32_t mScaleX; + SkPaint::Style mStyle; + uint32_t mStrokeWidth; }; /////////////////////////////////////////////////////////////////////////////// |