Use sk_sp text blob APIs
SkTextBlobBuilder::build() -> make() SkAutoTUnref<const SkTextBlob> -> sk_sp<SkTextBlob> drawTextBlob(const SkTextBlob*) -> drawTextBlob(const sk_sp<SkTextBlob>&) BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2335493005 Review-Url: https://codereview.chromium.org/2335493005
This commit is contained in:
parent
ec44099979
commit
37283c28aa
@ -44,7 +44,7 @@ protected:
|
||||
nullptr);
|
||||
memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
|
||||
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
const char* onGetName() override {
|
||||
@ -62,9 +62,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
SkTDArray<uint16_t> fGlyphs;
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
SkTDArray<uint16_t> fGlyphs;
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
@ -32,9 +32,9 @@ DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
|
||||
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
canvas->drawTextBlob(blob.get(), 10, 200, blurPaint);
|
||||
canvas->drawTextBlob(blob.get(), 10, 200, paint);
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
canvas->drawTextBlob(blob, 10, 200, blurPaint);
|
||||
canvas->drawTextBlob(blob, 10, 200, paint);
|
||||
|
||||
size_t len = strlen(text);
|
||||
canvas->drawText(text, len, 10, 500, blurPaint);
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
paint.setSubpixelText(true);
|
||||
paint.setLCDRenderText(true);
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkISize onISize() override { return SkISize::Make(kWidth, kHeight); }
|
||||
@ -90,7 +90,7 @@ protected:
|
||||
|
||||
private:
|
||||
SkScalar fTextHeight;
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
typedef skiagm::GM INHERITED;
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ protected:
|
||||
text = "aA";
|
||||
paint.setTypeface(fReallyBigATypeface);
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, corruptedAx, corruptedAy);
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -138,7 +138,7 @@ protected:
|
||||
|
||||
size_t count = sizeof(clipRects) / sizeof(SkRect);
|
||||
for (size_t x = 0; x < count; ++x) {
|
||||
draw_blob(canvas, fBlob, paint, clipRects[x]);
|
||||
draw_blob(canvas, fBlob.get(), paint, clipRects[x]);
|
||||
if (x == (count >> 1) - 1) {
|
||||
canvas->translate(SkScalarFloorToScalar(bounds.width() + SkIntToScalar(25)),
|
||||
-(x * SkScalarFloorToScalar(bounds.height() +
|
||||
@ -153,7 +153,7 @@ private:
|
||||
sk_sp<SkTypeface> fEmojiTypeface;
|
||||
sk_sp<SkTypeface> fReallyBigATypeface;
|
||||
const char* fEmojiText;
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
|
||||
static constexpr int kWidth = 1250;
|
||||
static constexpr int kHeight = 700;
|
||||
|
@ -92,7 +92,7 @@ protected:
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
for (unsigned b = 0; b < SK_ARRAY_COUNT(blobConfigs); ++b) {
|
||||
SkAutoTUnref<const SkTextBlob> blob(this->makeBlob(b));
|
||||
sk_sp<SkTextBlob> blob(this->makeBlob(b));
|
||||
|
||||
SkPaint p;
|
||||
SkPoint offset = SkPoint::Make(SkIntToScalar(10 + 300 * (b % 2)),
|
||||
@ -110,7 +110,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
const SkTextBlob* makeBlob(unsigned blobIndex) {
|
||||
sk_sp<SkTextBlob> makeBlob(unsigned blobIndex) {
|
||||
SkTextBlobBuilder builder;
|
||||
|
||||
SkPaint font;
|
||||
@ -177,7 +177,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
return builder.make();
|
||||
}
|
||||
|
||||
SkTDArray<uint16_t> fGlyphs;
|
||||
|
@ -35,7 +35,7 @@ protected:
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, yOffset - 30);
|
||||
|
||||
// build
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -77,7 +77,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
|
||||
static constexpr int kWidth = 275;
|
||||
static constexpr int kHeight = 200;
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, yOffset - 8);
|
||||
|
||||
// build
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
|
||||
static constexpr int kWidth = 675;
|
||||
static constexpr int kHeight = 1600;
|
||||
|
@ -40,7 +40,7 @@ protected:
|
||||
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10);
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200);
|
||||
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
||||
@ -55,12 +55,12 @@ protected:
|
||||
SkPaint rectPaint;
|
||||
rectPaint.setColor(0xffffffff);
|
||||
canvas->drawRect(rect, rectPaint);
|
||||
canvas->drawTextBlob(blob.get(), 10, 50, paint);
|
||||
canvas->drawTextBlob(blob, 10, 50, paint);
|
||||
|
||||
// This should not look garbled since we should disable LCD text in this case
|
||||
// (i.e., unknown pixel geometry)
|
||||
c->clear(0x00ffffff);
|
||||
c->drawTextBlob(blob.get(), 10, 150, paint);
|
||||
c->drawTextBlob(blob, 10, 150, paint);
|
||||
surface->draw(canvas, 0, 0, nullptr);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ protected:
|
||||
paint.setAntiAlias(true);
|
||||
sk_tool_utils::set_portable_typeface(&paint);
|
||||
add_to_text_blob(&builder, text, paint, 0, 0);
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
|
||||
// create a looper which sandwhiches an effect in two normal draws
|
||||
LooperSettings looperSandwhich[] = {
|
||||
@ -245,7 +245,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
SkTArray<sk_sp<SkDrawLooper>, true> fLoopers;
|
||||
|
||||
typedef GM INHERITED;
|
||||
|
@ -80,7 +80,7 @@ protected:
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, yOffset);
|
||||
|
||||
// build
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -177,7 +177,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
|
||||
static constexpr int kWidth = 2100;
|
||||
static constexpr int kHeight = 1900;
|
||||
|
@ -77,7 +77,7 @@ protected:
|
||||
}
|
||||
|
||||
// build
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -136,7 +136,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
|
||||
static constexpr int kWidth = 2000;
|
||||
static constexpr int kHeight = 1600;
|
||||
|
@ -56,7 +56,7 @@ protected:
|
||||
run->pos[i * 2 + 1] = 150 + 5 * sinf((float)i * 8 / glyphCount);
|
||||
}
|
||||
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
|
||||
SkColor colors[2];
|
||||
colors[0] = SK_ColorRED;
|
||||
@ -102,9 +102,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkTDArray<uint16_t> fGlyphs;
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkShader> fShader;
|
||||
SkTDArray<uint16_t> fGlyphs;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
sk_sp<SkShader> fShader;
|
||||
|
||||
typedef skiagm::GM INHERITED;
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ protected:
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset, -yOffset - 10);
|
||||
|
||||
// build
|
||||
fBlob.reset(builder.build());
|
||||
fBlob = builder.make();
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -158,7 +158,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
|
||||
static constexpr int kWidth = 1000;
|
||||
static constexpr int kHeight = 1200;
|
||||
|
@ -47,18 +47,18 @@ protected:
|
||||
|
||||
sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10);
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
|
||||
// draw textblob
|
||||
SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f);
|
||||
SkPaint rectPaint;
|
||||
rectPaint.setColor(0xffffffff);
|
||||
canvas->drawRect(rect, rectPaint);
|
||||
canvas->drawTextBlob(blob.get(), 10, 50, paint);
|
||||
canvas->drawTextBlob(blob, 10, 50, paint);
|
||||
|
||||
// This text should look fine
|
||||
canvas->getGrContext()->freeGpuResources();
|
||||
canvas->drawTextBlob(blob.get(), 10, 150, paint);
|
||||
canvas->drawTextBlob(blob, 10, 150, paint);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -351,7 +351,7 @@ DEF_SIMPLE_GM(fancyposunderline, canvas, 900, 1350) {
|
||||
|
||||
namespace {
|
||||
|
||||
sk_sp<const SkTextBlob> MakeFancyBlob(const SkPaint& paint, const char* text) {
|
||||
sk_sp<SkTextBlob> MakeFancyBlob(const SkPaint& paint, const char* text) {
|
||||
SkPaint blobPaint(paint);
|
||||
|
||||
const size_t textLen = strlen(text);
|
||||
@ -411,7 +411,7 @@ sk_sp<const SkTextBlob> MakeFancyBlob(const SkPaint& paint, const char* text) {
|
||||
}
|
||||
}
|
||||
|
||||
return sk_sp<const SkTextBlob>(blobBuilder.build());
|
||||
return blobBuilder.make();
|
||||
}
|
||||
|
||||
} // anonymous ns
|
||||
@ -431,8 +431,8 @@ DEF_SIMPLE_GM(fancyblobunderline, canvas, 1480, 1380) {
|
||||
paint.setStrokeWidth(uWidth);
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
|
||||
sk_sp<const SkTextBlob> blob = MakeFancyBlob(paint, test);
|
||||
canvas->drawTextBlob(blob.get(), blobOffset.x(), blobOffset.y(), paint);
|
||||
sk_sp<SkTextBlob> blob = MakeFancyBlob(paint, test);
|
||||
canvas->drawTextBlob(blob, blobOffset.x(), blobOffset.y(), paint);
|
||||
|
||||
const SkScalar uPos = uWidth;
|
||||
const SkScalar bounds[2] = { uPos - uWidth / 2, uPos + uWidth / 2 };
|
||||
|
@ -106,9 +106,11 @@ public:
|
||||
*/
|
||||
sk_sp<SkTextBlob> make();
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_TEXTBLOB_BUILDER
|
||||
const SkTextBlob* build() {
|
||||
return this->make().release();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Glyph and position buffers associated with a run.
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
int countLines() const;
|
||||
SkScalar getTextHeight() const;
|
||||
|
||||
SkTextBlob* snapshotTextBlob(SkScalar* computedBottom) const;
|
||||
sk_sp<SkTextBlob> snapshotTextBlob(SkScalar* computedBottom) const;
|
||||
|
||||
class Visitor {
|
||||
public:
|
||||
|
@ -612,6 +612,7 @@ DEFINES_ALL = [
|
||||
"SK_SUPPORT_LEGACY_XFERMODE_PTR",
|
||||
"SK_SUPPORT_LEGACY_PICTUREINSTALLPIXELREF",
|
||||
"SK_SUPPORT_LEGACY_STREAM_DATA",
|
||||
"SK_SUPPORT_LEGACY_TEXTBLOB_BUILDER",
|
||||
]
|
||||
|
||||
################################################################################
|
||||
|
@ -486,7 +486,7 @@ SkTextBlobBuilder::~SkTextBlobBuilder() {
|
||||
if (nullptr != fStorage.get()) {
|
||||
// We are abandoning runs and must destruct the associated font data.
|
||||
// The easiest way to accomplish that is to use the blob destructor.
|
||||
build()->unref();
|
||||
this->make();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ public:
|
||||
|
||||
void appendGlyph(uint16_t glyphId, const SkPoint& pos);
|
||||
|
||||
const SkTextBlob* buildIfNeeded(int* count);
|
||||
sk_sp<SkTextBlob> makeIfNeeded(int* count);
|
||||
|
||||
private:
|
||||
enum { kWriteBufferSize = 1024 };
|
||||
@ -521,7 +521,7 @@ void GrStencilAndCoverTextContext::TextRun::setText(const char text[], size_t by
|
||||
y += SkFloatToScalar(glyph.fAdvanceY) * fTextRatio;
|
||||
}
|
||||
|
||||
fFallbackTextBlob.reset(fallback.buildIfNeeded(&fFallbackGlyphCount));
|
||||
fFallbackTextBlob = fallback.makeIfNeeded(&fFallbackGlyphCount);
|
||||
}
|
||||
|
||||
void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t byteLength,
|
||||
@ -557,7 +557,7 @@ void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t
|
||||
pos += scalarsPerPosition;
|
||||
}
|
||||
|
||||
fFallbackTextBlob.reset(fallback.buildIfNeeded(&fFallbackGlyphCount));
|
||||
fFallbackTextBlob = fallback.makeIfNeeded(&fFallbackGlyphCount);
|
||||
}
|
||||
|
||||
GrPathRange* GrStencilAndCoverTextContext::TextRun::createGlyphs(GrContext* ctx) const {
|
||||
@ -654,7 +654,8 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
|
||||
}
|
||||
|
||||
fallbackTextContext->drawTextBlob(ctx, drawContext, clip, fallbackSkPaint, viewMatrix,
|
||||
props, fFallbackTextBlob, x, y, nullptr, clipBounds);
|
||||
props, fFallbackTextBlob.get(), x, y, nullptr,
|
||||
clipBounds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,11 +729,11 @@ void GrStencilAndCoverTextContext::FallbackBlobBuilder::flush() {
|
||||
fBuffIdx = 0;
|
||||
}
|
||||
|
||||
const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeeded(int *count) {
|
||||
sk_sp<SkTextBlob> GrStencilAndCoverTextContext::FallbackBlobBuilder::makeIfNeeded(int *count) {
|
||||
*count = fCount;
|
||||
if (fCount) {
|
||||
this->flush();
|
||||
return fBuilder->build();
|
||||
return fBuilder->make();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -97,18 +97,18 @@ private:
|
||||
GrPathRange* createGlyphs(GrContext*) const;
|
||||
void appendGlyph(const SkGlyph&, const SkPoint&, FallbackBlobBuilder*);
|
||||
|
||||
GrStyle fStyle;
|
||||
SkPaint fFont;
|
||||
SkScalar fTextRatio;
|
||||
float fTextInverseRatio;
|
||||
bool fUsingRawGlyphPaths;
|
||||
GrUniqueKey fGlyphPathsKey;
|
||||
int fTotalGlyphCount;
|
||||
SkAutoTUnref<InstanceData> fInstanceData;
|
||||
int fFallbackGlyphCount;
|
||||
SkAutoTUnref<const SkTextBlob> fFallbackTextBlob;
|
||||
mutable SkGlyphCache* fDetachedGlyphCache;
|
||||
mutable uint32_t fLastDrawnGlyphsID;
|
||||
GrStyle fStyle;
|
||||
SkPaint fFont;
|
||||
SkScalar fTextRatio;
|
||||
float fTextInverseRatio;
|
||||
bool fUsingRawGlyphPaths;
|
||||
GrUniqueKey fGlyphPathsKey;
|
||||
int fTotalGlyphCount;
|
||||
SkAutoTUnref<InstanceData> fInstanceData;
|
||||
int fFallbackGlyphCount;
|
||||
sk_sp<SkTextBlob> fFallbackTextBlob;
|
||||
mutable SkGlyphCache* fDetachedGlyphCache;
|
||||
mutable uint32_t fLastDrawnGlyphsID;
|
||||
};
|
||||
|
||||
// Text blobs/caches.
|
||||
|
@ -2076,8 +2076,7 @@ static int lsk_newTextBlob(lua_State* L) {
|
||||
box.setText(text, strlen(text), paint);
|
||||
|
||||
SkScalar newBottom;
|
||||
SkAutoTUnref<SkTextBlob> blob(box.snapshotTextBlob(&newBottom));
|
||||
push_ref<SkTextBlob>(L, blob);
|
||||
push_ref<SkTextBlob>(L, box.snapshotTextBlob(&newBottom));
|
||||
SkLua(L).pushScalar(newBottom);
|
||||
return 2;
|
||||
}
|
||||
|
@ -292,11 +292,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
SkTextBlob* SkTextBox::snapshotTextBlob(SkScalar* computedBottom) const {
|
||||
sk_sp<SkTextBlob> SkTextBox::snapshotTextBlob(SkScalar* computedBottom) const {
|
||||
TextBlobVisitor visitor;
|
||||
SkScalar newB = this->visit(visitor, fText, fLen, *fPaint);
|
||||
if (computedBottom) {
|
||||
*computedBottom = newB;
|
||||
}
|
||||
return (SkTextBlob*)visitor.fBuilder.build();
|
||||
return visitor.fBuilder.make();
|
||||
}
|
||||
|
@ -27,19 +27,11 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrTest.h"
|
||||
|
||||
struct TextBlobWrapper {
|
||||
// This class assumes it 'owns' the textblob it wraps, and thus does not need to take a ref
|
||||
explicit TextBlobWrapper(const SkTextBlob* blob) : fBlob(blob) {}
|
||||
TextBlobWrapper(const TextBlobWrapper& blob) : fBlob(SkRef(blob.fBlob.get())) {}
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
};
|
||||
|
||||
static void draw(SkCanvas* canvas, int redraw, const SkTArray<TextBlobWrapper>& blobs) {
|
||||
static void draw(SkCanvas* canvas, int redraw, const SkTArray<sk_sp<SkTextBlob>>& blobs) {
|
||||
int yOffset = 0;
|
||||
for (int r = 0; r < redraw; r++) {
|
||||
for (int i = 0; i < blobs.count(); i++) {
|
||||
const SkTextBlob* blob = blobs[i].fBlob.get();
|
||||
const auto& blob = blobs[i];
|
||||
const SkRect& bounds = blob->bounds();
|
||||
yOffset += SkScalarCeilToInt(bounds.height());
|
||||
SkPaint paint;
|
||||
@ -85,7 +77,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
|
||||
}
|
||||
|
||||
// generate textblobs
|
||||
SkTArray<TextBlobWrapper> blobs;
|
||||
SkTArray<sk_sp<SkTextBlob>> blobs;
|
||||
for (int i = 0; i < count; i++) {
|
||||
SkPaint paint;
|
||||
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
@ -124,7 +116,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
|
||||
}
|
||||
}
|
||||
}
|
||||
blobs.emplace_back(builder.build());
|
||||
blobs.emplace_back(builder.make());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,28 +104,28 @@ public:
|
||||
|
||||
// Explicit bounds.
|
||||
{
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds().isEmpty());
|
||||
}
|
||||
|
||||
{
|
||||
SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
|
||||
builder.allocRun(font, 16, 0, 0, &r1);
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds() == r1);
|
||||
}
|
||||
|
||||
{
|
||||
SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
|
||||
builder.allocRunPosH(font, 16, 0, &r1);
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds() == r1);
|
||||
}
|
||||
|
||||
{
|
||||
SkRect r1 = SkRect::MakeXYWH(10, 10, 20, 20);
|
||||
builder.allocRunPos(font, 16, &r1);
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds() == r1);
|
||||
}
|
||||
|
||||
@ -138,13 +138,13 @@ public:
|
||||
builder.allocRunPosH(font, 16, 0, &r2);
|
||||
builder.allocRunPos(font, 16, &r3);
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds() == SkRect::MakeXYWH(0, 5, 65, 65));
|
||||
}
|
||||
|
||||
{
|
||||
// Verify empty blob bounds after building some non-empty blobs.
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds().isEmpty());
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ public:
|
||||
p.textToGlyphs(txt, txtLen, buffer.glyphs);
|
||||
|
||||
memset(buffer.pos, 0, sizeof(SkScalar) * glyphCount * 2);
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
REPORTER_ASSERT(reporter, blob->bounds().isEmpty());
|
||||
}
|
||||
}
|
||||
@ -224,9 +224,9 @@ public:
|
||||
AddRun(font, 1, SkTextBlob::kDefault_Positioning, SkPoint::Make(0, 0), builder);
|
||||
AddRun(font, 1, SkTextBlob::kHorizontal_Positioning, SkPoint::Make(0, 0), builder);
|
||||
AddRun(font, 1, SkTextBlob::kFull_Positioning, SkPoint::Make(0, 0), builder);
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
|
||||
SkTextBlobRunIterator it(blob);
|
||||
SkTextBlobRunIterator it(blob.get());
|
||||
while (!it.done()) {
|
||||
SkPaint paint;
|
||||
it.applyFontToPaint(&paint);
|
||||
@ -278,9 +278,9 @@ private:
|
||||
posCount += in[i].count * in[i].pos;
|
||||
}
|
||||
|
||||
SkAutoTUnref<const SkTextBlob> blob(builder.build());
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
|
||||
SkTextBlobRunIterator it(blob);
|
||||
SkTextBlobRunIterator it(blob.get());
|
||||
for (unsigned i = 0; i < outCount; ++i) {
|
||||
REPORTER_ASSERT(reporter, !it.done());
|
||||
REPORTER_ASSERT(reporter, out[i].pos == it.positioning());
|
||||
@ -368,7 +368,7 @@ DEF_TEST(TextBlob_extended, reporter) {
|
||||
for (int i = 0; i < glyphCount; ++i) {
|
||||
run.clusters[i] = SkTMin(SkToU32(i), SkToU32(strlen(text2)));
|
||||
}
|
||||
sk_sp<const SkTextBlob> blob(textBlobBuilder.build());
|
||||
sk_sp<SkTextBlob> blob(textBlobBuilder.make());
|
||||
REPORTER_ASSERT(reporter, blob);
|
||||
|
||||
for (SkTextBlobRunIterator it(blob.get()); !it.done(); it.next()) {
|
||||
|
@ -9,8 +9,9 @@
|
||||
#include "SkClipStack.h"
|
||||
#include "SkDebugCanvas.h"
|
||||
#include "SkDrawCommand.h"
|
||||
#include "SkPaintFilterCanvas.h"
|
||||
#include "SkOverdrawMode.h"
|
||||
#include "SkPaintFilterCanvas.h"
|
||||
#include "SkTextBlob.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrAuditTrail.h"
|
||||
@ -677,7 +678,8 @@ void SkDebugCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const
|
||||
|
||||
void SkDebugCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint) {
|
||||
this->addDrawCommand(new SkDrawTextBlobCommand(blob, x, y, paint));
|
||||
this->addDrawCommand(new SkDrawTextBlobCommand(sk_ref_sp(const_cast<SkTextBlob*>(blob)),
|
||||
x, y, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
|
@ -2796,10 +2796,10 @@ static const char* gPositioningLabels[] = {
|
||||
"kFull_Positioning",
|
||||
};
|
||||
|
||||
SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
SkDrawTextBlobCommand::SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint)
|
||||
: INHERITED(kDrawTextBlob_OpType)
|
||||
, fBlob(SkRef(blob))
|
||||
, fBlob(std::move(blob))
|
||||
, fXPos(x)
|
||||
, fYPos(y)
|
||||
, fPaint(paint) {
|
||||
@ -2813,7 +2813,7 @@ SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
|
||||
|
||||
unsigned runs = 0;
|
||||
SkPaint runPaint(paint);
|
||||
SkTextBlobRunIterator iter(blob);
|
||||
SkTextBlobRunIterator iter(blob.get());
|
||||
while (!iter.done()) {
|
||||
SkAutoTDelete<SkString> tmpStr(new SkString);
|
||||
tmpStr->printf("==== Run [%d] ====", runs++);
|
||||
@ -2846,7 +2846,7 @@ bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const {
|
||||
SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos);
|
||||
xlate_and_scale_to_bounds(canvas, bounds);
|
||||
|
||||
canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint);
|
||||
canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
|
||||
|
||||
canvas->restore();
|
||||
|
||||
@ -2949,7 +2949,7 @@ SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command,
|
||||
SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat();
|
||||
SkPaint paint;
|
||||
extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint);
|
||||
return new SkDrawTextBlobCommand(builder.build(), x, y, paint);
|
||||
return new SkDrawTextBlobCommand(builder.make(), x, y, paint);
|
||||
}
|
||||
|
||||
SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
|
||||
|
@ -625,7 +625,7 @@ private:
|
||||
|
||||
class SkDrawTextBlobCommand : public SkDrawCommand {
|
||||
public:
|
||||
SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
|
||||
SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y, const SkPaint& paint);
|
||||
|
||||
void execute(SkCanvas* canvas) const override;
|
||||
bool render(SkCanvas* canvas) const override;
|
||||
@ -633,10 +633,10 @@ public:
|
||||
static SkDrawTextBlobCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkTextBlob> fBlob;
|
||||
SkScalar fXPos;
|
||||
SkScalar fYPos;
|
||||
SkPaint fPaint;
|
||||
sk_sp<SkTextBlob> fBlob;
|
||||
SkScalar fXPos;
|
||||
SkScalar fYPos;
|
||||
SkPaint fPaint;
|
||||
|
||||
typedef SkDrawCommand INHERITED;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user