diff options
| author | Victoria Lease <violets@google.com> | 2013-12-03 23:30:30 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-12-03 23:30:30 +0000 |
| commit | 385739be8c05ea40cd9c17ae02530dd90e0157bd (patch) | |
| tree | 4b4e36112a2851a475fad7d6a6e8d197f38a6210 | |
| parent | bf1aee7ba20e72c5356b9a1d9de434acbde93ac7 (diff) | |
| parent | 43b692d9a18224e89fc09a0e68d097322e0ef6bb (diff) | |
| download | frameworks_base-385739be8c05ea40cd9c17ae02530dd90e0157bd.zip frameworks_base-385739be8c05ea40cd9c17ae02530dd90e0157bd.tar.gz frameworks_base-385739be8c05ea40cd9c17ae02530dd90e0157bd.tar.bz2 | |
Merge "Deprecate Android-specific SkPaint functions."
| -rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 5 | ||||
| -rw-r--r-- | libs/hwui/font/Font.cpp | 11 | ||||
| -rw-r--r-- | libs/hwui/font/FontUtil.h | 4 |
3 files changed, 12 insertions, 8 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 92d253f..144ac39 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -20,6 +20,7 @@ #include "TextLayoutCache.h" #include "TextLayout.h" +#include "SkGlyphCache.h" #include "SkTypeface_android.h" #include "HarfBuzzNGFaceSkia.h" #include <unicode/unistr.h> @@ -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); diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index 18983d8..3e0124c 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -23,6 +23,7 @@ #include <utils/Trace.h> #include <SkGlyph.h> +#include <SkGlyphCache.h> #include <SkUtils.h> #include "FontUtil.h" @@ -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 { @@ -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); @@ -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; diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h index cdcb23c..c2fd5f5 100644 --- a/libs/hwui/font/FontUtil.h +++ b/libs/hwui/font/FontUtil.h @@ -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 @@ -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 |
