Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43b692d9 authored by Victoria Lease's avatar Victoria Lease
Browse files

Deprecate Android-specific SkPaint functions.

The following functions were problematic:
 const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*);
 const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*);
 const void* findImage(const SkGlyph&, const SkMatrix*);

Replacing them with calls through SkGlyphCache solved a nasty crash
bug, so they have all been deprecated.

Bug: 11968757
Change-Id: Id746315d41aec5b211b78b172a883c2061130f08
parent d786a190
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);

+7 −4
Original line number Diff line number Diff line
@@ -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;

+2 −2
Original line number Diff line number Diff line
@@ -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