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

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

Issue 1847583002: Update SkMergeImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to To 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 | « include/core/SkImageFilter.h ('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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 SkMergeImageFilter_DEFINED 8 #ifndef SkMergeImageFilter_DEFINED
9 #define SkMergeImageFilter_DEFINED 9 #define SkMergeImageFilter_DEFINED
10 10
11 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
12 12
13 #include "SkXfermode.h" 13 #include "SkXfermode.h"
14 14
15 class SK_API SkMergeImageFilter : public SkImageFilter { 15 class SK_API SkMergeImageFilter : public SkImageFilter {
16 public: 16 public:
17 ~SkMergeImageFilter() override; 17 ~SkMergeImageFilter() override;
18 18
19 static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second, 19 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilter> first, sk_sp<SkImageFi lter> second,
20 SkXfermode::Mode mode = SkXfermode::kSrcOver_Mo de, 20 SkXfermode::Mode mode = SkXfermode::kSrcOve r_Mode,
21 const CropRect* cropRect = NULL) { 21 const CropRect* cropRect = nullptr) {
22 SkImageFilter* inputs[2] = { first, second }; 22 sk_sp<SkImageFilter> inputs[2] = { first, second };
23 SkXfermode::Mode modes[2] = { mode, mode }; 23 SkXfermode::Mode modes[2] = { mode, mode };
24 return new SkMergeImageFilter(inputs, 2, modes, cropRect); 24 return sk_sp<SkImageFilter>(new SkMergeImageFilter(inputs, 2, modes, cro pRect));
25 } 25 }
26 26
27 static SkImageFilter* Create(SkImageFilter* filters[], int count, 27 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilter> filters[],
28 const SkXfermode::Mode modes[] = NULL, 28 int count,
29 const CropRect* cropRect = NULL) { 29 const SkXfermode::Mode modes[] = nullptr,
30 return new SkMergeImageFilter(filters, count, modes, cropRect); 30 const CropRect* cropRect = nullptr) {
31 return sk_sp<SkImageFilter>(new SkMergeImageFilter(filters, count, modes , cropRect));
31 } 32 }
32 33
33 SK_TO_STRING_OVERRIDE() 34 SK_TO_STRING_OVERRIDE()
34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) 35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
35 36
37 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
38 static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
39 SkXfermode::Mode mode = SkXfermode::kSrcOver_Mo de,
40 const CropRect* cropRect = nullptr) {
41 return Make(sk_ref_sp<SkImageFilter>(first),
42 sk_ref_sp<SkImageFilter>(second),
43 mode, cropRect).release();
44 }
45
46 static SkImageFilter* Create(SkImageFilter* filters[], int count,
47 const SkXfermode::Mode modes[] = nullptr,
48 const CropRect* cropRect = nullptr) {
49 SkAutoTDeleteArray<sk_sp<SkImageFilter>> temp(new sk_sp<SkImageFilter>[c ount]);
50 for (int i = 0; i < count; ++i) {
51 temp[i] = sk_ref_sp<SkImageFilter>(filters[i]);
52 }
53 return Make(temp.get(), count, modes, cropRect).release();
54 }
55 #endif
56
36 protected: 57 protected:
37 void flatten(SkWriteBuffer&) const override; 58 void flatten(SkWriteBuffer&) const override;
38 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, 59 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
39 SkIPoint* offset) const override; 60 SkIPoint* offset) const override;
40 61
41 private: 62 private:
42 SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mo de modes[], 63 SkMergeImageFilter(sk_sp<SkImageFilter> filters[], int count, const SkXfermo de::Mode modes[],
43 const CropRect* cropRect); 64 const CropRect* cropRect);
44 65
45 uint8_t* fModes; // SkXfermode::Mode 66 uint8_t* fModes; // SkXfermode::Mode
46 67
47 // private storage, to avoid dynamically allocating storage for our copy 68 // private storage, to avoid dynamically allocating storage for our copy
48 // of the modes (unless the count is so large we can't fit). 69 // of the modes (unless the count is so large we can't fit).
49 intptr_t fStorage[16]; 70 intptr_t fStorage[16];
50 71
51 void initAllocModes(); 72 void initAllocModes();
52 void initModes(const SkXfermode::Mode []); 73 void initModes(const SkXfermode::Mode []);
53 74
54 typedef SkImageFilter INHERITED; 75 typedef SkImageFilter INHERITED;
55 }; 76 };
56 77
57 #endif 78 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698