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

Unified Diff: src/core/SkSpecialSurface.cpp

Issue 1913743002: Add another dollop of sk_sp to SkSpecialImage and SkSpecialSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rm std::move Created 4 years, 8 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
« no previous file with comments | « src/core/SkSpecialSurface.h ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSpecialSurface.cpp
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 2e2d8cc54a64ea87cb348e2411673eb3688bd91c..2973aa1f9b98f5eeaf50f1949f552d0267d3ac69 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -112,11 +112,11 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Gpu(GrTexture* texture,
+ SkSpecialSurface_Gpu(sk_sp<GrTexture> texture,
const SkIRect& subset,
const SkSurfaceProps* props)
: INHERITED(subset, props)
- , fTexture(SkRef(texture)) {
+ , fTexture(std::move(texture)) {
SkASSERT(fTexture->asRenderTarget());
@@ -133,25 +133,27 @@ public:
~SkSpecialSurface_Gpu() override { }
sk_sp<SkSpecialImage> onMakeImageSnapshot() override {
+ // Note: we are intentionally zeroing out 'fTexture' here
return SkSpecialImage::MakeFromGpu(this->subset(),
- kNeedNewImageUniqueID_SpecialImage, fTexture,
+ kNeedNewImageUniqueID_SpecialImage,
+ std::move(fTexture),
&this->props());
}
private:
- SkAutoTUnref<GrTexture> fTexture;
+ sk_sp<GrTexture> fTexture;
typedef SkSpecialSurface_Base INHERITED;
};
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset,
- GrTexture* texture,
+ sk_sp<GrTexture> texture,
const SkSurfaceProps* props) {
if (!texture->asRenderTarget()) {
return nullptr;
}
- return sk_make_sp<SkSpecialSurface_Gpu>(texture, subset, props);
+ return sk_make_sp<SkSpecialSurface_Gpu>(std::move(texture), subset, props);
}
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
@@ -161,28 +163,14 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
return nullptr;
}
- SkAutoTUnref<GrTexture> temp(context->textureProvider()->createApproxTexture(desc));
+ sk_sp<GrTexture> temp(context->textureProvider()->createApproxTexture(desc));
if (!temp) {
return nullptr;
}
const SkIRect subset = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
- return sk_make_sp<SkSpecialSurface_Gpu>(temp, subset, props);
-}
-
-#else
-
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset,
- GrTexture*,
- const SkSurfaceProps*) {
- return nullptr;
-}
-
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
- const GrSurfaceDesc& desc,
- const SkSurfaceProps* props) {
- return nullptr;
+ return sk_make_sp<SkSpecialSurface_Gpu>(std::move(temp), subset, props);
}
#endif
« no previous file with comments | « src/core/SkSpecialSurface.h ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698