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>
This commit is contained in:
parent
94f585ed09
commit
bdf5433ab4
@ -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);
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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&) {
|
||||
|
@ -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;
|
||||
|
@ -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&) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user