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

Side by Side Diff: include/effects/SkImageSource.h

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT 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 unified diff | Download patch
« no previous file with comments | « gm/xfermodeimagefilter.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkImageSource_DEFINED 8 #ifndef SkImageSource_DEFINED
9 #define SkImageSource_DEFINED 9 #define SkImageSource_DEFINED
10 10
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkImageFilter.h" 12 #include "SkImageFilter.h"
13 13
14 class SK_API SkImageSource : public SkImageFilter { 14 class SK_API SkImageSource : public SkImageFilter {
15 public: 15 public:
16 static SkImageFilter* Create(SkImage*); 16 static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image) {
17 static SkImageFilter* Create(SkImage*, 17 if (!image) {
18 const SkRect& srcRect, 18 return nullptr;
19 const SkRect& dstRect, 19 }
20 SkFilterQuality); 20
21 return sk_sp<SkImageFilter>(new SkImageSource(std::move(image)));
22 }
23 static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image,
24 const SkRect& srcRect,
25 const SkRect& dstRect,
26 SkFilterQuality filterQuality) {
27 if (!image) {
28 return nullptr;
29 }
30
31 return sk_sp<SkImageFilter>(new SkImageSource(std::move(image),
32 srcRect, dstRect,
33 filterQuality));
34 }
21 35
22 SkRect computeFastBounds(const SkRect& src) const override; 36 SkRect computeFastBounds(const SkRect& src) const override;
23 37
24 SK_TO_STRING_OVERRIDE() 38 SK_TO_STRING_OVERRIDE()
25 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource) 39 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource)
26 40
41 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
42 static SkImageFilter* Create(SkImage* image) {
43 return Make(sk_ref_sp<SkImage>(image)).release();
44 }
45 static SkImageFilter* Create(SkImage* image,
46 const SkRect& srcRect,
47 const SkRect& dstRect,
48 SkFilterQuality filterQuality) {
49 return Make(sk_ref_sp<SkImage>(image), srcRect, dstRect, filterQuality). release();
50 }
51 #endif
52
27 protected: 53 protected:
28 void flatten(SkWriteBuffer&) const override; 54 void flatten(SkWriteBuffer&) const override;
29 55
30 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, 56 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
31 SkIPoint* offset) const override; 57 SkIPoint* offset) const override;
32 58
33 private: 59 private:
34 explicit SkImageSource(SkImage*); 60 explicit SkImageSource(sk_sp<SkImage>);
35 SkImageSource(SkImage*, 61 SkImageSource(sk_sp<SkImage>,
36 const SkRect& srcRect, 62 const SkRect& srcRect,
37 const SkRect& dstRect, 63 const SkRect& dstRect,
38 SkFilterQuality); 64 SkFilterQuality);
39 65
40 sk_sp<SkImage> fImage; 66 sk_sp<SkImage> fImage;
41 SkRect fSrcRect, fDstRect; 67 SkRect fSrcRect, fDstRect;
42 SkFilterQuality fFilterQuality; 68 SkFilterQuality fFilterQuality;
43 69
44 typedef SkImageFilter INHERITED; 70 typedef SkImageFilter INHERITED;
45 }; 71 };
46 72
47 #endif 73 #endif
OLDNEW
« no previous file with comments | « gm/xfermodeimagefilter.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698