Loading libs/hwui/FontRenderer.cpp +30 −26 Original line number Diff line number Diff line Loading @@ -38,8 +38,8 @@ namespace uirenderer { // Font /////////////////////////////////////////////////////////////////////////////// Font::Font(FontRenderer* state, uint32_t fontId, float fontSize) : mState(state), mFontId(fontId), mFontSize(fontSize) { Font::Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags) : mState(state), mFontId(fontId), mFontSize(fontSize), mFlags(flags) { } Loading Loading @@ -275,17 +275,17 @@ Font::CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, int32_t glyph) { return newGlyph; } Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize) { Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize, int flags) { 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) { if (font->mFontId == fontId && font->mFontSize == fontSize && font->mFlags == flags) { return font; } } Font* newFont = new Font(state, fontId, fontSize); Font* newFont = new Font(state, fontId, fontSize, flags); activeFonts.push(newFont); return newFont; } Loading Loading @@ -634,7 +634,11 @@ void FontRenderer::precacheLatin(SkPaint* paint) { void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) { uint32_t currentNumFonts = mActiveFonts.size(); mCurrentFont = Font::create(this, fontId, fontSize); int flags = 0; if (paint->isFakeBoldText()) { flags |= Font::kFakeBold; } mCurrentFont = Font::create(this, fontId, fontSize, flags); const float maxPrecacheFontSize = 40.0f; bool isNewFont = currentNumFonts != mActiveFonts.size(); Loading Loading @@ -757,7 +761,7 @@ void FontRenderer::horizontalBlur(float* weights, int32_t radius, blurredPixel = 0.0f; const float* gPtr = weights; // Optimization for non-border pixels if ((x > radius) && (x < (width - radius))) { if (x > radius && x < (width - radius)) { const uint8_t *i = input + (x - radius); for (int r = -radius; r <= radius; r ++) { currentPixel = (float) (*i); Loading @@ -776,7 +780,7 @@ void FontRenderer::horizontalBlur(float* weights, int32_t radius, validW = width - 1; } currentPixel = (float)(input[validW]); currentPixel = (float) input[validW]; blurredPixel += currentPixel * gPtr[0]; gPtr++; } Loading @@ -801,7 +805,7 @@ void FontRenderer::verticalBlur(float* weights, int32_t radius, const float* gPtr = weights; const uint8_t* input = source + x; // Optimization for non-border pixels if ((y > radius) && (y < (height - radius))) { if (y > radius && y < (height - radius)) { const uint8_t *i = input + ((y - radius) * width); for (int32_t r = -radius; r <= radius; r ++) { currentPixel = (float)(*i); Loading libs/hwui/FontRenderer.h +7 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ class FontRenderer; */ class Font { public: enum Style { kFakeBold }; ~Font(); /** Loading @@ -53,7 +57,7 @@ public: /** * Creates a new font associated with the specified font state. */ static Font* create(FontRenderer* state, uint32_t fontId, float fontSize); static Font* create(FontRenderer* state, uint32_t fontId, float fontSize, int flags); protected: friend class FontRenderer; Loading Loading @@ -99,7 +103,7 @@ protected: SkFixed mRsbDelta; }; Font(FontRenderer* state, uint32_t fontId, float fontSize); Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags); DefaultKeyedVector<int32_t, CachedGlyphInfo*> mCachedGlyphs; Loading @@ -117,6 +121,7 @@ protected: FontRenderer* mState; uint32_t mFontId; float mFontSize; int mFlags; }; class FontRenderer { Loading Loading
libs/hwui/FontRenderer.cpp +30 −26 Original line number Diff line number Diff line Loading @@ -38,8 +38,8 @@ namespace uirenderer { // Font /////////////////////////////////////////////////////////////////////////////// Font::Font(FontRenderer* state, uint32_t fontId, float fontSize) : mState(state), mFontId(fontId), mFontSize(fontSize) { Font::Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags) : mState(state), mFontId(fontId), mFontSize(fontSize), mFlags(flags) { } Loading Loading @@ -275,17 +275,17 @@ Font::CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, int32_t glyph) { return newGlyph; } Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize) { Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize, int flags) { 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) { if (font->mFontId == fontId && font->mFontSize == fontSize && font->mFlags == flags) { return font; } } Font* newFont = new Font(state, fontId, fontSize); Font* newFont = new Font(state, fontId, fontSize, flags); activeFonts.push(newFont); return newFont; } Loading Loading @@ -634,7 +634,11 @@ void FontRenderer::precacheLatin(SkPaint* paint) { void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) { uint32_t currentNumFonts = mActiveFonts.size(); mCurrentFont = Font::create(this, fontId, fontSize); int flags = 0; if (paint->isFakeBoldText()) { flags |= Font::kFakeBold; } mCurrentFont = Font::create(this, fontId, fontSize, flags); const float maxPrecacheFontSize = 40.0f; bool isNewFont = currentNumFonts != mActiveFonts.size(); Loading Loading @@ -757,7 +761,7 @@ void FontRenderer::horizontalBlur(float* weights, int32_t radius, blurredPixel = 0.0f; const float* gPtr = weights; // Optimization for non-border pixels if ((x > radius) && (x < (width - radius))) { if (x > radius && x < (width - radius)) { const uint8_t *i = input + (x - radius); for (int r = -radius; r <= radius; r ++) { currentPixel = (float) (*i); Loading @@ -776,7 +780,7 @@ void FontRenderer::horizontalBlur(float* weights, int32_t radius, validW = width - 1; } currentPixel = (float)(input[validW]); currentPixel = (float) input[validW]; blurredPixel += currentPixel * gPtr[0]; gPtr++; } Loading @@ -801,7 +805,7 @@ void FontRenderer::verticalBlur(float* weights, int32_t radius, const float* gPtr = weights; const uint8_t* input = source + x; // Optimization for non-border pixels if ((y > radius) && (y < (height - radius))) { if (y > radius && y < (height - radius)) { const uint8_t *i = input + ((y - radius) * width); for (int32_t r = -radius; r <= radius; r ++) { currentPixel = (float)(*i); Loading
libs/hwui/FontRenderer.h +7 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ class FontRenderer; */ class Font { public: enum Style { kFakeBold }; ~Font(); /** Loading @@ -53,7 +57,7 @@ public: /** * Creates a new font associated with the specified font state. */ static Font* create(FontRenderer* state, uint32_t fontId, float fontSize); static Font* create(FontRenderer* state, uint32_t fontId, float fontSize, int flags); protected: friend class FontRenderer; Loading Loading @@ -99,7 +103,7 @@ protected: SkFixed mRsbDelta; }; Font(FontRenderer* state, uint32_t fontId, float fontSize); Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags); DefaultKeyedVector<int32_t, CachedGlyphInfo*> mCachedGlyphs; Loading @@ -117,6 +121,7 @@ protected: FontRenderer* mState; uint32_t mFontId; float mFontSize; int mFlags; }; class FontRenderer { Loading