diff --git a/include/core/SkTextBlob.h b/include/core/SkTextBlob.h index e15bf918a8..4457c8f358 100644 --- a/include/core/SkTextBlob.h +++ b/include/core/SkTextBlob.h @@ -50,10 +50,6 @@ public: */ static sk_sp MakeFromBuffer(SkReadBuffer&); - static const SkTextBlob* CreateFromBuffer(SkReadBuffer& buffer) { - return MakeFromBuffer(buffer).release(); - } - enum GlyphPositioning : uint8_t { kDefault_Positioning = 0, // Default glyph advances -- zero scalars per glyph. kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar per glyph. diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp index 40ce54e4d8..e3501f9015 100644 --- a/src/core/SkPictureData.cpp +++ b/src/core/SkPictureData.cpp @@ -484,31 +484,25 @@ bool SkPictureData::parseStreamTag(SkStream* stream, return true; // success } -static const SkImage* create_image_from_buffer(SkReadBuffer& buffer) { - return buffer.readImage().release(); +static sk_sp create_image_from_buffer(SkReadBuffer& buffer) { + return buffer.readImage(); } -static const SkVertices* create_vertices_from_buffer(SkReadBuffer& buffer) { +static sk_sp create_vertices_from_buffer(SkReadBuffer& buffer) { auto data = buffer.readByteArrayAsData(); - return data ? SkVertices::Decode(data->data(), data->size()).release() : nullptr; + return data ? SkVertices::Decode(data->data(), data->size()) : nullptr; } -static const SkImage* create_bitmap_image_from_buffer(SkReadBuffer& buffer) { - return buffer.readBitmapAsImage().release(); +static sk_sp create_bitmap_image_from_buffer(SkReadBuffer& buffer) { + return buffer.readBitmapAsImage(); } -// Need a shallow wrapper to return const SkPicture* to match the other factories, -// as SkPicture::CreateFromBuffer() returns SkPicture* -static const SkPicture* create_picture_from_buffer(SkReadBuffer& buffer) { - return SkPicture::MakeFromBuffer(buffer).release(); -} - -static const SkDrawable* create_drawable_from_buffer(SkReadBuffer& buffer) { - return (SkDrawable*) buffer.readFlattenable(SkFlattenable::kSkDrawable_Type); +static sk_sp create_drawable_from_buffer(SkReadBuffer& buffer) { + return sk_sp((SkDrawable*)buffer.readFlattenable(SkFlattenable::kSkDrawable_Type)); } template bool new_array_from_buffer(SkReadBuffer& buffer, uint32_t inCount, - const T*** array, int* outCount, const T* (*factory)(SkReadBuffer&)) { + const T*** array, int* outCount, sk_sp (*factory)(SkReadBuffer&)) { if (!buffer.validate((0 == *outCount) && (nullptr == *array))) { return false; } @@ -524,7 +518,7 @@ bool new_array_from_buffer(SkReadBuffer& buffer, uint32_t inCount, bool success = true; int i = 0; for (; i < *outCount; i++) { - (*array)[i] = factory(buffer); + (*array)[i] = factory(buffer).release(); if (nullptr == (*array)[i]) { success = false; break; @@ -572,7 +566,7 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t } break; case SK_PICT_TEXTBLOB_BUFFER_TAG: if (!new_array_from_buffer(buffer, size, &fTextBlobRefs, &fTextBlobCount, - SkTextBlob::CreateFromBuffer)) { + SkTextBlob::MakeFromBuffer)) { return false; } break; @@ -599,7 +593,7 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t } break; case SK_PICT_PICTURE_TAG: if (!new_array_from_buffer(buffer, size, &fPictureRefs, &fPictureCount, - create_picture_from_buffer)) { + SkPicture::MakeFromBuffer)) { return false; } break;