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

Unified Diff: include/effects/SkPictureImageFilter.h

Issue 1831323003: Swap SkPictureImageFilter's factories over to smart pointers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix sk_sp bug 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
« no previous file with comments | « gm/recordopts.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/effects/SkPictureImageFilter.h
diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h
index dbc87f7768b8364a104a4f4b52ce3bc403f91ce9..59097ddf59e309964e6c442b8baf652734d2f39d 100644
--- a/include/effects/SkPictureImageFilter.h
+++ b/include/effects/SkPictureImageFilter.h
@@ -16,17 +16,19 @@ public:
/**
* Refs the passed-in picture.
*/
- static SkImageFilter* Create(const SkPicture* picture) {
- return new SkPictureImageFilter(picture);
+ static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture) {
+ return sk_sp<SkImageFilter>(new SkPictureImageFilter(std::move(picture)));
}
/**
* Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
* the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
*/
- static SkImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
- return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureResolution,
- kLow_SkFilterQuality);
+ static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture, const SkRect& cropRect) {
+ return sk_sp<SkImageFilter>(new SkPictureImageFilter(std::move(picture),
+ cropRect,
+ kDeviceSpace_PictureResolution,
+ kLow_SkFilterQuality));
}
/**
@@ -36,12 +38,30 @@ public:
* expand the destination rect when the picture is drawn. (No scaling is implied by the
* dest rect; only the CTM is applied.)
*/
+ static sk_sp<SkImageFilter> MakeForLocalSpace(sk_sp<SkPicture> picture,
+ const SkRect& cropRect,
+ SkFilterQuality filterQuality) {
+ return sk_sp<SkImageFilter>(new SkPictureImageFilter(std::move(picture),
+ cropRect,
+ kLocalSpace_PictureResolution,
+ filterQuality));
+ }
+
+#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
+ static SkImageFilter* Create(const SkPicture* picture) {
+ return Make(sk_ref_sp(const_cast<SkPicture*>(picture))).release();
+ }
+ static SkImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
+ return Make(sk_ref_sp(const_cast<SkPicture*>(picture)), cropRect).release();
+ }
static SkImageFilter* CreateForLocalSpace(const SkPicture* picture,
- const SkRect& cropRect,
- SkFilterQuality filterQuality) {
- return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureResolution,
- filterQuality);
+ const SkRect& cropRect,
+ SkFilterQuality filterQuality) {
+ return MakeForLocalSpace(sk_ref_sp(const_cast<SkPicture*>(picture)),
+ cropRect,
+ filterQuality).release();
}
+#endif
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
@@ -52,8 +72,6 @@ protected:
kLocalSpace_PictureResolution
};
- virtual ~SkPictureImageFilter();
-
/* Constructs an SkPictureImageFilter object from an SkReadBuffer.
* Note: If the SkPictureImageFilter object construction requires bitmap
* decoding, the decoder must be set on the SkReadBuffer parameter by calling
@@ -65,8 +83,8 @@ protected:
SkIPoint* offset) const override;
private:
- explicit SkPictureImageFilter(const SkPicture* picture);
- SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
+ explicit SkPictureImageFilter(sk_sp<SkPicture> picture);
+ SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRect& cropRect,
PictureResolution, SkFilterQuality);
void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBounds,
@@ -74,7 +92,7 @@ private:
void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& deviceBounds,
const Context&) const;
- const SkPicture* fPicture;
+ sk_sp<SkPicture> fPicture;
SkRect fCropRect;
PictureResolution fPictureResolution;
SkFilterQuality fFilterQuality;
« no previous file with comments | « gm/recordopts.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698