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

Commit 2b0863a2 authored by Mike Reed's avatar Mike Reed Committed by Android (Google) Code Review
Browse files

Merge "remove unused layout method in TestUtils"

parents 4b17b1b3 3ad4f8ae
Loading
Loading
Loading
Loading
+1 −38
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include "DeferredLayerUpdater.h"
#include "hwui/Paint.h"

#include <SkClipStack.h>
#include <minikin/Layout.h>
#include <pipeline/skia/SkiaOpenGLPipeline.h>
#include <pipeline/skia/SkiaVulkanPipeline.h>
@@ -27,7 +26,7 @@
#include <renderthread/VulkanManager.h>
#include <utils/Unicode.h>

#include <SkGlyphCache.h>
#include "SkColorData.h"

namespace android {
namespace uirenderer {
@@ -80,42 +79,6 @@ sp<DeferredLayerUpdater> TestUtils::createTextureLayerUpdater(
    return layerUpdater;
}

void TestUtils::layoutTextUnscaled(const SkPaint& paint, const char* text,
                                   std::vector<glyph_t>* outGlyphs,
                                   std::vector<float>* outPositions, float* outTotalAdvance,
                                   Rect* outBounds) {
    Rect bounds;
    float totalAdvance = 0;
    SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry);
    SkAutoGlyphCacheNoGamma autoCache(paint, &surfaceProps, &SkMatrix::I());
    while (*text != '\0') {
        size_t nextIndex = 0;
        int32_t unichar = utf32_from_utf8_at(text, 4, 0, &nextIndex);
        text += nextIndex;

        glyph_t glyph = autoCache->unicharToGlyph(unichar);
        autoCache->unicharToGlyph(unichar);

        // push glyph and its relative position
        outGlyphs->push_back(glyph);
        outPositions->push_back(totalAdvance);
        outPositions->push_back(0);

        // compute bounds
        SkGlyph skGlyph = autoCache->getUnicharMetrics(unichar);
        Rect glyphBounds(skGlyph.fWidth, skGlyph.fHeight);
        glyphBounds.translate(totalAdvance + skGlyph.fLeft, skGlyph.fTop);
        bounds.unionWith(glyphBounds);

        // advance next character
        SkScalar skWidth;
        paint.getTextWidths(&glyph, sizeof(glyph), &skWidth, NULL);
        totalAdvance += skWidth;
    }
    *outBounds = bounds;
    *outTotalAdvance = totalAdvance;
}

void TestUtils::drawUtf8ToCanvas(Canvas* canvas, const char* text, const SkPaint& paint, float x,
                                 float y) {
    auto utf16 = asciiToUtf16(text);
+0 −5
Original line number Diff line number Diff line
@@ -300,11 +300,6 @@ public:

    static SkColor interpolateColor(float fraction, SkColor start, SkColor end);

    static void layoutTextUnscaled(const SkPaint& paint, const char* text,
                                   std::vector<glyph_t>* outGlyphs,
                                   std::vector<float>* outPositions, float* outTotalAdvance,
                                   Rect* outBounds);

    static void drawUtf8ToCanvas(Canvas* canvas, const char* text, const SkPaint& paint, float x,
                                 float y);