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

Commit 79abbf22 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Update HWUI tests to use minikin to layout fonts.

This update is a precondition for landing additional tests
that depend on the minkin layout implementation.

bug: 27675371
Change-Id: I9bb98bae6b39462246e42cf8acb968b7df05292d
parent 5bee0596
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -191,13 +191,16 @@ public:
            const SkPaint* paint) override;

    // Text
    virtual void drawGlyphs(const uint16_t* glyphs, const float* positions, int glyphCount,
            const SkPaint& paint, float x, float y, float boundsLeft, float boundsTop,
            float boundsRight, float boundsBottom, float totalAdvance) override;
    virtual void drawGlyphsOnPath(const uint16_t* glyphs, int glyphCount, const SkPath& path,
            float hOffset, float vOffset, const SkPaint& paint) override;
    virtual bool drawTextAbsolutePos() const override { return false; }

protected:
    virtual void drawGlyphs(const uint16_t* text, const float* positions, int count,
            const SkPaint& paint, float x, float y,
            float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
            float totalAdvance) override;
    virtual void drawGlyphsOnPath(const uint16_t* glyphs, int count, const SkPath& path,
            float hOffset, float vOffset, const SkPaint& paint) override;

private:
    const ClipBase* getRecordedClip() {
        return mState.writableSnapshot()->mutateClipArea().serializeClip(alloc());
+9 −14
Original line number Diff line number Diff line
@@ -147,13 +147,6 @@ public:
            float dstLeft, float dstTop, float dstRight, float dstBottom,
            const SkPaint* paint) override;

    virtual void drawGlyphs(const uint16_t* text, const float* positions, int count,
            const SkPaint& paint, float x, float y,
            float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
            float totalAdvance) override;
    virtual void drawGlyphsOnPath(const uint16_t* glyphs, int count, const SkPath& path,
            float hOffset, float vOffset, const SkPaint& paint) override;

    virtual bool drawTextAbsolutePos() const  override { return true; }
    virtual void drawVectorDrawable(VectorDrawableRoot* vectorDrawable) override;

@@ -169,6 +162,14 @@ public:
    virtual void drawRenderNode(uirenderer::RenderNode* renderNode) override;
    virtual void callDrawGLFunction(Functor* functor) override;

protected:
    virtual void drawGlyphs(const uint16_t* text, const float* positions, int count,
            const SkPaint& paint, float x, float y,
            float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
            float totalAdvance) override;
    virtual void drawGlyphsOnPath(const uint16_t* glyphs, int count, const SkPath& path,
            float hOffset, float vOffset, const SkPaint& paint) override;

private:
    struct SaveRec {
        int              saveCount;
@@ -761,14 +762,8 @@ void SkiaCanvas::drawGlyphs(const uint16_t* text, const float* positions, int co
        const SkPaint& paint, float x, float y,
        float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
        float totalAdvance) {
    // Set align to left for drawing, as we don't want individual
    // glyphs centered or right-aligned; the offset above takes
    // care of all alignment.
    SkPaint paintCopy(paint);
    paintCopy.setTextAlign(SkPaint::kLeft_Align);

    static_assert(sizeof(SkPoint) == sizeof(float)*2, "SkPoint is no longer two floats");
    mCanvas->drawPosText(text, count << 1, reinterpret_cast<const SkPoint*>(positions), paintCopy);
    mCanvas->drawPosText(text, count << 1, reinterpret_cast<const SkPoint*>(positions), paint);
    drawTextDecorations(x, y, totalAdvance, paint);
}

+5 −0
Original line number Diff line number Diff line
@@ -166,6 +166,11 @@ void Canvas::drawText(const uint16_t* text, int start, int count, int contextCou
        bounds.offset(x, y);
    }

    // Set align to left for drawing, as we don't want individual
    // glyphs centered or right-aligned; the offset above takes
    // care of all alignment.
    paint.setTextAlign(Paint::kLeft_Align);

    DrawTextFunctor f(layout, this, glyphs.get(), pos.get(),
            paint, x, y, bounds, layout.getAdvance());
    MinikinUtils::forFontRun(layout, &paint, f);
+17 −13
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ typedef uint32_t Flags;
} // namespace SaveFlags

namespace uirenderer {
class SkiaCanvasProxy;
namespace VectorDrawable {
class Tree;
};
@@ -205,19 +206,6 @@ public:
            float dstLeft, float dstTop, float dstRight, float dstBottom,
            const SkPaint* paint) = 0;

    // Text
    /**
     * drawText: count is of glyphs
     * totalAdvance: used to define width of text decorations (underlines, strikethroughs).
     */
    virtual void drawGlyphs(const uint16_t* glyphs, const float* positions, int count,
            const SkPaint& paint, float x, float y,
            float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
            float totalAdvance) = 0;
    /** drawTextOnPath: count is of glyphs */
    virtual void drawGlyphsOnPath(const uint16_t* glyphs, int count, const SkPath& path,
            float hOffset, float vOffset, const SkPaint& paint) = 0;

    /**
     * Specifies if the positions passed to ::drawText are absolute or relative
     * to the (x,y) value provided.
@@ -244,6 +232,22 @@ public:

protected:
    void drawTextDecorations(float x, float y, float length, const SkPaint& paint);

    /**
     * drawText: count is of glyphs
     * totalAdvance: used to define width of text decorations (underlines, strikethroughs).
     */
    virtual void drawGlyphs(const uint16_t* glyphs, const float* positions, int count,
            const SkPaint& paint, float x, float y,
            float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
            float totalAdvance) = 0;
    /** drawTextOnPath: count is of glyphs */
    virtual void drawGlyphsOnPath(const uint16_t* glyphs, int count, const SkPath& path,
            float hOffset, float vOffset, const SkPaint& paint) = 0;

    friend class DrawTextFunctor;
    friend class DrawTextOnPathFunctor;
    friend class uirenderer::SkiaCanvasProxy;
};

}; // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ class ANDROID_API Paint : public SkPaint {
public:
    Paint();
    Paint(const Paint& paint);
    Paint(const SkPaint& paint);
    ~Paint();

    Paint& operator=(const Paint& other);
Loading