update textblob api to use sk_sp
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2236013002 NOTREECHECKS=True Review-Url: https://codereview.chromium.org/2236013002
This commit is contained in:
parent
568de46cb1
commit
2ab9057b31
@ -1071,6 +1071,9 @@ public:
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
|
||||
void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) {
|
||||
this->drawTextBlob(blob.get(), x, y, paint);
|
||||
}
|
||||
|
||||
/** Draw the picture into this canvas. This method effective brackets the
|
||||
playback of the picture's draw calls with save/restore, so the state
|
||||
|
@ -43,7 +43,11 @@ public:
|
||||
* @return A new SkTextBlob representing the serialized data, or NULL if the buffer is
|
||||
* invalid.
|
||||
*/
|
||||
static const SkTextBlob* CreateFromBuffer(SkReadBuffer&);
|
||||
static sk_sp<SkTextBlob> MakeFromBuffer(SkReadBuffer&);
|
||||
|
||||
static const SkTextBlob* CreateFromBuffer(SkReadBuffer& buffer) {
|
||||
return MakeFromBuffer(buffer).release();
|
||||
}
|
||||
|
||||
enum GlyphPositioning {
|
||||
kDefault_Positioning = 0, // Default glyph advances -- zero scalars per glyph.
|
||||
@ -99,7 +103,11 @@ public:
|
||||
* Returns an immutable SkTextBlob for the current runs/glyphs. The builder is reset and
|
||||
* can be reused.
|
||||
*/
|
||||
const SkTextBlob* build();
|
||||
sk_sp<SkTextBlob> make();
|
||||
|
||||
const SkTextBlob* build() {
|
||||
return this->make().release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Glyph and position buffers associated with a run.
|
||||
|
@ -246,7 +246,7 @@ void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
|
||||
SkASSERT(0 == runCount);
|
||||
}
|
||||
|
||||
const SkTextBlob* SkTextBlob::CreateFromBuffer(SkReadBuffer& reader) {
|
||||
sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
|
||||
int runCount = reader.read32();
|
||||
if (runCount < 0) {
|
||||
return nullptr;
|
||||
@ -290,7 +290,7 @@ const SkTextBlob* SkTextBlob::CreateFromBuffer(SkReadBuffer& reader) {
|
||||
}
|
||||
}
|
||||
|
||||
return blobBuilder.build();
|
||||
return blobBuilder.make();
|
||||
}
|
||||
|
||||
unsigned SkTextBlob::ScalarsPerGlyph(GlyphPositioning pos) {
|
||||
@ -613,7 +613,7 @@ const SkTextBlobBuilder::RunBuffer& SkTextBlobBuilder::allocRunPos(const SkPaint
|
||||
return fCurrentRunBuffer;
|
||||
}
|
||||
|
||||
const SkTextBlob* SkTextBlobBuilder::build() {
|
||||
sk_sp<SkTextBlob> SkTextBlobBuilder::make() {
|
||||
SkASSERT((fRunCount > 0) == (nullptr != fStorage.get()));
|
||||
|
||||
this->updateDeferredBounds();
|
||||
@ -624,7 +624,7 @@ const SkTextBlob* SkTextBlobBuilder::build() {
|
||||
fStorage.realloc(fStorageUsed);
|
||||
}
|
||||
|
||||
const SkTextBlob* blob = new (fStorage.release()) SkTextBlob(fRunCount, fBounds);
|
||||
SkTextBlob* blob = new (fStorage.release()) SkTextBlob(fRunCount, fBounds);
|
||||
SkDEBUGCODE(const_cast<SkTextBlob*>(blob)->fStorageSize = fStorageSize;)
|
||||
|
||||
SkDEBUGCODE(
|
||||
@ -644,5 +644,5 @@ const SkTextBlob* SkTextBlobBuilder::build() {
|
||||
fLastRun = 0;
|
||||
fBounds.setEmpty();
|
||||
|
||||
return blob;
|
||||
return sk_sp<SkTextBlob>(blob);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user