Loading core/jni/android/graphics/TextLayoutCache.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "TextLayoutCache.h" #include "TextLayout.h" #include "SkGlyphCache.h" #include "SkTypeface_android.h" #include "HarfBuzzNGFaceSkia.h" #include <unicode/unistr.h> Loading Loading @@ -757,8 +758,8 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* conte outPos->add(ypos); totalAdvance += xAdvance; // TODO: consider using glyph cache const SkGlyph& metrics = mShapingPaint.getGlyphMetrics(glyphId, NULL); SkAutoGlyphCache autoCache(mShapingPaint, NULL, NULL); const SkGlyph& metrics = autoCache.getCache()->getGlyphIDMetrics(glyphId); outBounds->join(xpos + metrics.fLeft, ypos + metrics.fTop, xpos + metrics.fLeft + metrics.fWidth, ypos + metrics.fTop + metrics.fHeight); Loading libs/hwui/font/Font.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <utils/Trace.h> #include <SkGlyph.h> #include <SkGlyphCache.h> #include <SkUtils.h> #include "FontUtil.h" Loading Loading @@ -271,8 +272,8 @@ CachedGlyphInfo* Font::getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool pre if (cachedGlyph) { // Is the glyph still in texture cache? if (!cachedGlyph->mIsValid) { const SkGlyph& skiaGlyph = GET_METRICS(paint, textUnit, &mDescription.mLookupTransform); SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); const SkGlyph& skiaGlyph = GET_METRICS(autoCache.getCache(), textUnit); updateGlyphCache(paint, skiaGlyph, cachedGlyph, precaching); } } else { Loading Loading @@ -428,8 +429,9 @@ void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyp uint32_t startY = 0; // Get the bitmap for the glyph SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); if (!skiaGlyph.fImage) { paint->findImage(skiaGlyph, &mDescription.mLookupTransform); autoCache.getCache()->findImage(skiaGlyph); } mState->cacheBitmap(skiaGlyph, glyph, &startX, &startY, precaching); Loading Loading @@ -463,7 +465,8 @@ CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching CachedGlyphInfo* newGlyph = new CachedGlyphInfo(); mCachedGlyphs.add(glyph, newGlyph); const SkGlyph& skiaGlyph = GET_METRICS(paint, glyph, &mDescription.mLookupTransform); SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); const SkGlyph& skiaGlyph = GET_METRICS(autoCache.getCache(), glyph); newGlyph->mIsValid = false; newGlyph->mGlyphIndex = skiaGlyph.fID; Loading libs/hwui/font/FontUtil.h +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ #if RENDER_TEXT_AS_GLYPHS typedef uint16_t glyph_t; #define TO_GLYPH(g) g #define GET_METRICS(paint, glyph, matrix) paint->getGlyphMetrics(glyph, matrix) #define GET_METRICS(cache, glyph) cache->getGlyphIDMetrics(glyph) #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) false Loading @@ -53,7 +53,7 @@ #else typedef SkUnichar glyph_t; #define TO_GLYPH(g) ((SkUnichar) g) #define GET_METRICS(paint, glyph, matrix) paint->getUnicharMetrics(glyph, matrix) #define GET_METRICS(cache, glyph) cache->getUnicharMetrics(glyph) #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) glyph < 0 #endif Loading Loading
core/jni/android/graphics/TextLayoutCache.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "TextLayoutCache.h" #include "TextLayout.h" #include "SkGlyphCache.h" #include "SkTypeface_android.h" #include "HarfBuzzNGFaceSkia.h" #include <unicode/unistr.h> Loading Loading @@ -757,8 +758,8 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* conte outPos->add(ypos); totalAdvance += xAdvance; // TODO: consider using glyph cache const SkGlyph& metrics = mShapingPaint.getGlyphMetrics(glyphId, NULL); SkAutoGlyphCache autoCache(mShapingPaint, NULL, NULL); const SkGlyph& metrics = autoCache.getCache()->getGlyphIDMetrics(glyphId); outBounds->join(xpos + metrics.fLeft, ypos + metrics.fTop, xpos + metrics.fLeft + metrics.fWidth, ypos + metrics.fTop + metrics.fHeight); Loading
libs/hwui/font/Font.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <utils/Trace.h> #include <SkGlyph.h> #include <SkGlyphCache.h> #include <SkUtils.h> #include "FontUtil.h" Loading Loading @@ -271,8 +272,8 @@ CachedGlyphInfo* Font::getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool pre if (cachedGlyph) { // Is the glyph still in texture cache? if (!cachedGlyph->mIsValid) { const SkGlyph& skiaGlyph = GET_METRICS(paint, textUnit, &mDescription.mLookupTransform); SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); const SkGlyph& skiaGlyph = GET_METRICS(autoCache.getCache(), textUnit); updateGlyphCache(paint, skiaGlyph, cachedGlyph, precaching); } } else { Loading Loading @@ -428,8 +429,9 @@ void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyp uint32_t startY = 0; // Get the bitmap for the glyph SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); if (!skiaGlyph.fImage) { paint->findImage(skiaGlyph, &mDescription.mLookupTransform); autoCache.getCache()->findImage(skiaGlyph); } mState->cacheBitmap(skiaGlyph, glyph, &startX, &startY, precaching); Loading Loading @@ -463,7 +465,8 @@ CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching CachedGlyphInfo* newGlyph = new CachedGlyphInfo(); mCachedGlyphs.add(glyph, newGlyph); const SkGlyph& skiaGlyph = GET_METRICS(paint, glyph, &mDescription.mLookupTransform); SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); const SkGlyph& skiaGlyph = GET_METRICS(autoCache.getCache(), glyph); newGlyph->mIsValid = false; newGlyph->mGlyphIndex = skiaGlyph.fID; Loading
libs/hwui/font/FontUtil.h +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ #if RENDER_TEXT_AS_GLYPHS typedef uint16_t glyph_t; #define TO_GLYPH(g) g #define GET_METRICS(paint, glyph, matrix) paint->getGlyphMetrics(glyph, matrix) #define GET_METRICS(cache, glyph) cache->getGlyphIDMetrics(glyph) #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) false Loading @@ -53,7 +53,7 @@ #else typedef SkUnichar glyph_t; #define TO_GLYPH(g) ((SkUnichar) g) #define GET_METRICS(paint, glyph, matrix) paint->getUnicharMetrics(glyph, matrix) #define GET_METRICS(cache, glyph) cache->getUnicharMetrics(glyph) #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) glyph < 0 #endif Loading