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

Commit dede54a3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "All non-blob variants of drawText are deprecated"

parents f569bb29 3905e83b
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -41,10 +41,6 @@ X(DrawImage)
X(DrawImageNine) 
X(DrawImageNine) 
X(DrawImageRect) 
X(DrawImageRect) 
X(DrawImageLattice)
X(DrawImageLattice)
X(DrawText) 
X(DrawPosText) 
X(DrawPosTextH)
X(DrawTextRSXform) 
X(DrawTextBlob)
X(DrawTextBlob)
X(DrawPatch) 
X(DrawPatch) 
X(DrawPoints) 
X(DrawPoints) 
+0 −82
Original line number Original line Diff line number Diff line
@@ -373,61 +373,6 @@ struct DrawImageLattice final : Op {
    }
    }
};
};


struct DrawText final : Op {
    static const auto kType = Type::DrawText;
    DrawText(size_t bytes, SkScalar x, SkScalar y, const SkPaint& paint)
            : bytes(bytes), x(x), y(y), paint(paint) {}
    size_t bytes;
    SkScalar x, y;
    SkPaint paint;
    void draw(SkCanvas* c, const SkMatrix&) const {
        c->drawText(pod<void>(this), bytes, x, y, paint);
    }
};
struct DrawPosText final : Op {
    static const auto kType = Type::DrawPosText;
    DrawPosText(size_t bytes, const SkPaint& paint, int n) : bytes(bytes), paint(paint), n(n) {}
    size_t bytes;
    SkPaint paint;
    int n;
    void draw(SkCanvas* c, const SkMatrix&) const {
        auto points = pod<SkPoint>(this);
        auto text = pod<void>(this, n * sizeof(SkPoint));
        c->drawPosText(text, bytes, points, paint);
    }
};
struct DrawPosTextH final : Op {
    static const auto kType = Type::DrawPosTextH;
    DrawPosTextH(size_t bytes, SkScalar y, const SkPaint& paint, int n)
            : bytes(bytes), y(y), paint(paint), n(n) {}
    size_t bytes;
    SkScalar y;
    SkPaint paint;
    int n;
    void draw(SkCanvas* c, const SkMatrix&) const {
        auto xs = pod<SkScalar>(this);
        auto text = pod<void>(this, n * sizeof(SkScalar));
        c->drawPosTextH(text, bytes, xs, y, paint);
    }
};
struct DrawTextRSXform final : Op {
    static const auto kType = Type::DrawTextRSXform;
    DrawTextRSXform(size_t bytes, int xforms, const SkRect* cull, const SkPaint& paint)
            : bytes(bytes), xforms(xforms), paint(paint) {
        if (cull) {
            this->cull = *cull;
        }
    }
    size_t bytes;
    int xforms;
    SkRect cull = kUnset;
    SkPaint paint;
    void draw(SkCanvas* c, const SkMatrix&) const {
        // For alignment, the SkRSXforms are first in the pod section, followed by the text.
        c->drawTextRSXform(pod<void>(this, xforms * sizeof(SkRSXform)), bytes, pod<SkRSXform>(this),
                           maybe_unset(cull), paint);
    }
};
struct DrawTextBlob final : Op {
struct DrawTextBlob final : Op {
    static const auto kType = Type::DrawTextBlob;
    static const auto kType = Type::DrawTextBlob;
    DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)
    DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)
@@ -682,33 +627,6 @@ void DisplayListData::drawImageLattice(sk_sp<const SkImage> image, const SkCanva
           fs);
           fs);
}
}


void DisplayListData::drawText(const void* text, size_t bytes, SkScalar x, SkScalar y,
                               const SkPaint& paint) {
    void* pod = this->push<DrawText>(bytes, bytes, x, y, paint);
    copy_v(pod, (const char*)text, bytes);
    mHasText = true;
}
void DisplayListData::drawPosText(const void* text, size_t bytes, const SkPoint pos[],
                                  const SkPaint& paint) {
    int n = paint.countText(text, bytes);
    void* pod = this->push<DrawPosText>(n * sizeof(SkPoint) + bytes, bytes, paint, n);
    copy_v(pod, pos, n, (const char*)text, bytes);
    mHasText = true;
}
void DisplayListData::drawPosTextH(const void* text, size_t bytes, const SkScalar xs[], SkScalar y,
                                   const SkPaint& paint) {
    int n = paint.countText(text, bytes);
    void* pod = this->push<DrawPosTextH>(n * sizeof(SkScalar) + bytes, bytes, y, paint, n);
    copy_v(pod, xs, n, (const char*)text, bytes);
    mHasText = true;
}
void DisplayListData::drawTextRSXform(const void* text, size_t bytes, const SkRSXform xforms[],
                                      const SkRect* cull, const SkPaint& paint) {
    int n = paint.countText(text, bytes);
    void* pod = this->push<DrawTextRSXform>(bytes + n * sizeof(SkRSXform), bytes, n, cull, paint);
    copy_v(pod, xforms, n, (const char*)text, bytes);
    mHasText = true;
}
void DisplayListData::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
void DisplayListData::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
                                   const SkPaint& paint) {
                                   const SkPaint& paint) {
    this->push<DrawTextBlob>(0, blob, x, y, paint);
    this->push<DrawTextBlob>(0, blob, x, y, paint);
+0 −4
Original line number Original line Diff line number Diff line
@@ -101,10 +101,6 @@ private:
    void drawDrawable(SkDrawable*, const SkMatrix*);
    void drawDrawable(SkDrawable*, const SkMatrix*);
    void drawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
    void drawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);


    void drawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&);
    void drawPosText(const void*, size_t, const SkPoint[], const SkPaint&);
    void drawPosTextH(const void*, size_t, const SkScalar[], SkScalar, const SkPaint&);
    void drawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*, const SkPaint&);
    void drawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&);
    void drawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&);


    void drawImage(sk_sp<const SkImage>, SkScalar, SkScalar, const SkPaint*, BitmapPalette palette);
    void drawImage(sk_sp<const SkImage>, SkScalar, SkScalar, const SkPaint*, BitmapPalette palette);
+7 −5
Original line number Original line Diff line number Diff line
@@ -16,7 +16,7 @@


#include "TestSceneBase.h"
#include "TestSceneBase.h"
#include "tests/common/TestListViewSceneBase.h"
#include "tests/common/TestListViewSceneBase.h"

#include <SkFont.h>
#include <cstdio>
#include <cstdio>


class ListViewAnimation;
class ListViewAnimation;
@@ -46,11 +46,13 @@ class ListViewAnimation : public TestListViewSceneBase {
                SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) <
                SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) <
                128 * 3;
                128 * 3;
        paint.setColor(bgDark ? Color::White : Color::Grey_700);
        paint.setColor(bgDark ? Color::White : Color::Grey_700);
        paint.setTextSize(size / 2);

	SkFont font;
        font.setSize(size / 2);
        char charToShow = 'A' + (rand() % 26);
        char charToShow = 'A' + (rand() % 26);
        const SkPoint pos[] = {{SkIntToScalar(size / 2),
        const SkPoint pos = {SkIntToScalar(size / 2),
                                /*approximate centering*/ SkFloatToScalar(size * 0.7f)}};
                                /*approximate centering*/ SkFloatToScalar(size * 0.7f)};
        canvas.drawPosText(&charToShow, 1, pos, paint);
        canvas.drawSimpleText(&charToShow, 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
        return bitmap;
        return bitmap;
    }
    }