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; |