Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Unified Diff: src/image/SkImage_Generator.cpp

Issue 1778393002: add Make variations to return SkImage by sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: roll in fmalitas comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/image/SkImage_Generator.cpp
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index 95cc426a43225d8819a107ddf50ae40bbabb0bb1..62b492e2881cab8c585174b3ca26c3d613bc7e30 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -25,7 +25,7 @@ public:
SkImageCacherator* peekCacherator() const override { return fCache; }
SkData* onRefEncoded(GrContext*) const override;
bool isOpaque() const override { return fCache->info().isOpaque(); }
- SkImage* onNewSubset(const SkIRect&) const override;
+ sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
bool getROPixels(SkBitmap*, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
bool onIsLazyGenerated() const override { return true; }
@@ -73,7 +73,7 @@ GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams
return fCache->lockAsTexture(ctx, params, this);
}
-SkImage* SkImage_Generator::onNewSubset(const SkIRect& subset) const {
+sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const {
// TODO: make this lazy, by wrapping the subset inside a new generator or something
// For now, we do effectively what we did before, make it a raster
@@ -86,13 +86,16 @@ SkImage* SkImage_Generator::onNewSubset(const SkIRect& subset) const {
surface->getCanvas()->clear(0);
surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToScalar(-subset.y()),
nullptr);
- return surface->newImageSnapshot();
+ return sk_sp<SkImage>(surface->newImageSnapshot());
}
-SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* subset) {
+sk_sp<SkImage> SkImage::MakeFromGenerator(SkImageGenerator* generator, const SkIRect* subset) {
+ if (!generator) {
+ return nullptr;
+ }
SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, subset);
if (!cache) {
return nullptr;
}
- return new SkImage_Generator(cache);
+ return sk_make_sp<SkImage_Generator>(cache);
}
« src/image/SkImage.cpp ('K') | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698