diff options
author | Ben Wagner <bungeman@google.com> | 2018-05-15 14:12:14 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-16 18:53:12 +0000 |
commit | bdf5433ab49b00df7c0f9185a68fc39f74cda409 (patch) | |
tree | fec7980683ba47019b3100161c95185bb6ba4294 | |
parent | 94f585ed091e252cd3cc741b19c8a226fe4a5eec (diff) |
SkImage::onRefEncoded to return sk_sp.
This changes SkImage::onRefEncoded and downstack calls to return sk_sp.
All of the values returned are already sk_sp, so this just updates the
API. This change is currently behind the new flag
SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE so that Chromium can be updated.
Change-Id: Ic53a88ae23fa8b3b41b84c4abdc4b74e9879da38
Reviewed-on: https://skia-review.googlesource.com/128311
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
-rw-r--r-- | include/core/SkData.h | 3 | ||||
-rw-r--r-- | include/core/SkImageGenerator.h | 10 | ||||
-rw-r--r-- | src/codec/SkCodecImageGenerator.cpp | 6 | ||||
-rw-r--r-- | src/codec/SkCodecImageGenerator.h | 4 | ||||
-rw-r--r-- | src/core/SkStreamPriv.h | 4 | ||||
-rw-r--r-- | src/image/SkImage_Base.h | 4 | ||||
-rw-r--r-- | src/image/SkImage_Lazy.cpp | 11 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorCG.cpp | 6 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorCG.h | 4 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorWIC.cpp | 6 | ||||
-rw-r--r-- | src/ports/SkImageGeneratorWIC.h | 4 |
11 files changed, 56 insertions, 6 deletions
diff --git a/include/core/SkData.h b/include/core/SkData.h index 0622c9f0fa..8eca45095f 100644 --- a/include/core/SkData.h +++ b/include/core/SkData.h @@ -171,9 +171,6 @@ private: // Ensure the unsized delete is called. void operator delete(void* p) { ::operator delete(p); } - // Called the first time someone calls NewEmpty to initialize the singleton. - friend SkData* sk_new_empty_data(); - // shared internal factory static sk_sp<SkData> PrivateNewWithCopy(const void* srcOrNull, size_t length); diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index 2763ef9c33..6a9919ce1a 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -41,9 +41,15 @@ public: * If non-NULL is returned, the caller is responsible for calling * unref() on the data when it is finished. */ +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* refEncodedData() { return this->onRefEncodedData(); } +#else + sk_sp<SkData> refEncodedData() { + return this->onRefEncodedData(); + } +#endif /** * Return the ImageInfo associated with this generator. @@ -174,7 +180,11 @@ protected: SkImageGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID); +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE virtual SkData* onRefEncodedData() { return nullptr; } +#else + virtual sk_sp<SkData> onRefEncodedData() { return nullptr; } +#endif virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; } virtual bool onIsValid(GrContext*) const { return true; } virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { return false; } diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp index 3f03b2f03e..65702616a3 100644 --- a/src/codec/SkCodecImageGenerator.cpp +++ b/src/codec/SkCodecImageGenerator.cpp @@ -35,9 +35,15 @@ SkCodecImageGenerator::SkCodecImageGenerator(std::unique_ptr<SkCodec> codec, sk_ , fData(std::move(data)) {} +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* SkCodecImageGenerator::onRefEncodedData() { return SkRef(fData.get()); } +#else +sk_sp<SkData> SkCodecImageGenerator::onRefEncodedData() { + return fData; +} +#endif bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& requestInfo, void* requestPixels, size_t requestRowBytes, const Options& opts) { diff --git a/src/codec/SkCodecImageGenerator.h b/src/codec/SkCodecImageGenerator.h index 1b2cbc28b2..e608d8e717 100644 --- a/src/codec/SkCodecImageGenerator.h +++ b/src/codec/SkCodecImageGenerator.h @@ -21,7 +21,11 @@ public: static std::unique_ptr<SkImageGenerator> MakeFromEncodedCodec(sk_sp<SkData>); protected: +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* onRefEncodedData() override; +#else + sk_sp<SkData> onRefEncodedData() override; +#endif bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts) override; diff --git a/src/core/SkStreamPriv.h b/src/core/SkStreamPriv.h index ac822c1110..6bec5f8288 100644 --- a/src/core/SkStreamPriv.h +++ b/src/core/SkStreamPriv.h @@ -21,9 +21,7 @@ class SkWStream; * but is not at the beginning, this call will fail (return NULL). * * @param stream SkStream to be copied into data. - * @return SkData* The resulting SkData after the copy. This data - * will have a ref count of one upon return and belongs to the - * caller. Returns nullptr on failure. + * @return The resulting SkData after the copy, nullptr on failure. */ sk_sp<SkData> SkCopyStreamToData(SkStream* stream); diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index c74a7b97e0..ba89585cf4 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -76,7 +76,11 @@ public: virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0; +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE virtual SkData* onRefEncoded() const { return nullptr; } +#else + virtual sk_sp<SkData> onRefEncoded() const { return nullptr; } +#endif virtual bool onAsLegacyBitmap(SkBitmap*) const; diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 9ca9d0d782..c627f2224e 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -85,7 +85,11 @@ public: sk_sp<SkColorSpace>*, SkScalar scaleAdjust[2]) const override; #endif +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* onRefEncoded() const override; +#else + sk_sp<SkData> onRefEncoded() const override; +#endif sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override; bool onIsLazyGenerated() const override { return true; } @@ -568,10 +572,17 @@ bool SkImage_Lazy::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz return false; } +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* SkImage_Lazy::onRefEncoded() const { ScopedGenerator generator(fSharedGenerator); return generator->refEncodedData(); } +#else +sk_sp<SkData> SkImage_Lazy::onRefEncoded() const { + ScopedGenerator generator(fSharedGenerator); + return generator->refEncodedData(); +} +#endif bool SkImage_Lazy::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace, CachingHint chint) const { diff --git a/src/ports/SkImageGeneratorCG.cpp b/src/ports/SkImageGeneratorCG.cpp index 2d2c3d3bd5..c3d2f77cfe 100644 --- a/src/ports/SkImageGeneratorCG.cpp +++ b/src/ports/SkImageGeneratorCG.cpp @@ -97,9 +97,15 @@ SkImageGeneratorCG::SkImageGeneratorCG(const SkImageInfo& info, const void* imag , fOrigin(origin) {} +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* SkImageGeneratorCG::onRefEncodedData() { return SkRef(fData.get()); } +#else +sk_sp<SkData> SkImageGeneratorCG::onRefEncodedData() { + return fData; +} +#endif bool SkImageGeneratorCG::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&) { diff --git a/src/ports/SkImageGeneratorCG.h b/src/ports/SkImageGeneratorCG.h index 58aac4f01a..4f5a3a98b3 100644 --- a/src/ports/SkImageGeneratorCG.h +++ b/src/ports/SkImageGeneratorCG.h @@ -27,7 +27,11 @@ public: static std::unique_ptr<SkImageGenerator> MakeFromEncodedCG(sk_sp<SkData>); protected: +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* onRefEncodedData() override; +#else + sk_sp<SkData> onRefEncodedData() override; +#endif bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&) override; diff --git a/src/ports/SkImageGeneratorWIC.cpp b/src/ports/SkImageGeneratorWIC.cpp index e69b2ee2e9..19d4080960 100644 --- a/src/ports/SkImageGeneratorWIC.cpp +++ b/src/ports/SkImageGeneratorWIC.cpp @@ -132,9 +132,15 @@ SkImageGeneratorWIC::SkImageGeneratorWIC(const SkImageInfo& info, , fData(SkRef(data)) {} +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* SkImageGeneratorWIC::onRefEncodedData() { return SkRef(fData.get()); } +#else +sk_sp<SkData> SkImageGeneratorWIC::onRefEncodedData() { + return fData; +} +#endif bool SkImageGeneratorWIC::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&) { diff --git a/src/ports/SkImageGeneratorWIC.h b/src/ports/SkImageGeneratorWIC.h index 4770ee2111..c0ace676f4 100644 --- a/src/ports/SkImageGeneratorWIC.h +++ b/src/ports/SkImageGeneratorWIC.h @@ -39,7 +39,11 @@ public: static SkImageGenerator* NewFromEncodedWIC(SkData* data); protected: +#if SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE SkData* onRefEncodedData() override; +#else + sk_sp<SkData> onRefEncodedData() override; +#endif bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&) override; |