OLD | NEW |
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 virtual ~SkMergeImageFilter(); | 17 virtual ~SkMergeImageFilter(); |
18 | 18 |
19 static SkMergeImageFilter* Create(SkImageFilter* first, SkImageFilter* secon
d, | 19 static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second, |
20 SkXfermode::Mode mode = SkXfermode::kSrcOv
er_Mode, | 20 SkXfermode::Mode mode = SkXfermode::kSrcOver_Mo
de, |
21 const CropRect* cropRect = NULL) { | 21 const CropRect* cropRect = NULL) { |
22 SkImageFilter* inputs[2] = { first, second }; | 22 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 new SkMergeImageFilter(inputs, 2, modes, cropRect); |
25 } | 25 } |
26 static SkMergeImageFilter* Create(SkImageFilter* filters[], int count, | 26 |
27 const SkXfermode::Mode modes[] = NULL, | 27 static SkImageFilter* Create(SkImageFilter* filters[], int count, |
28 const CropRect* cropRect = NULL) { | 28 const SkXfermode::Mode modes[] = NULL, |
| 29 const CropRect* cropRect = NULL) { |
29 return new SkMergeImageFilter(filters, count, modes, cropRect); | 30 return new SkMergeImageFilter(filters, count, modes, cropRect); |
30 } | 31 } |
31 | 32 |
32 SK_TO_STRING_OVERRIDE() | 33 SK_TO_STRING_OVERRIDE() |
33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) | 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) |
34 | 35 |
35 protected: | 36 protected: |
36 SkMergeImageFilter(SkImageFilter* filters[], int count, | |
37 const SkXfermode::Mode modes[], | |
38 const CropRect* cropRect); | |
39 void flatten(SkWriteBuffer&) const override; | 37 void flatten(SkWriteBuffer&) const override; |
40 | 38 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* re
sult, |
41 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 39 SkIPoint* loc) const override; |
42 SkBitmap* result, SkIPoint* loc) const override; | |
43 | 40 |
44 private: | 41 private: |
45 uint8_t* fModes; // SkXfermode::Mode | 42 SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mo
de modes[], |
| 43 const CropRect* cropRect); |
| 44 |
| 45 uint8_t* fModes; // SkXfermode::Mode |
46 | 46 |
47 // private storage, to avoid dynamically allocating storage for our copy | 47 // private storage, to avoid dynamically allocating storage for our copy |
48 // of the modes (unless the count is so large we can't fit). | 48 // of the modes (unless the count is so large we can't fit). |
49 intptr_t fStorage[16]; | 49 intptr_t fStorage[16]; |
50 | 50 |
51 void initAllocModes(); | 51 void initAllocModes(); |
52 void initModes(const SkXfermode::Mode []); | 52 void initModes(const SkXfermode::Mode []); |
53 | 53 |
54 typedef SkImageFilter INHERITED; | 54 typedef SkImageFilter INHERITED; |
55 }; | 55 }; |
56 | 56 |
57 #endif | 57 #endif |
OLD | NEW |