OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2013 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 SkBlendImageFilter_DEFINED | 8 #ifndef SkXfermodeImageFilter_DEFINED |
9 #define SkBlendImageFilter_DEFINED | 9 #define SkXfermodeImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 #include "SkBitmap.h" | |
13 | 12 |
14 class SK_API SkBlendImageFilter : public SkImageFilter { | 13 class SkBitmap; |
| 14 class SkXfermode; |
| 15 |
| 16 class SK_API SkXfermodeImageFilter : public SkImageFilter { |
| 17 /** |
| 18 * This filter takes an xfermode, and uses it to composite the foreground |
| 19 * over the background. If foreground or background is NULL, the input |
| 20 * bitmap (src) is used instead. |
| 21 */ |
| 22 |
15 public: | 23 public: |
16 enum Mode { | 24 SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* background, SkImageFi
lter* foreground = NULL); |
17 kNormal_Mode, | |
18 kMultiply_Mode, | |
19 kScreen_Mode, | |
20 kDarken_Mode, | |
21 kLighten_Mode, | |
22 }; | |
23 SkBlendImageFilter(Mode mode, SkImageFilter* background, SkImageFilter* fore
ground = NULL); | |
24 | 25 |
25 ~SkBlendImageFilter(); | 26 virtual ~SkXfermodeImageFilter(); |
26 | 27 |
27 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlendImageFilter) | 28 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) |
28 | 29 |
29 virtual bool onFilterImage(Proxy* proxy, | 30 virtual bool onFilterImage(Proxy* proxy, |
30 const SkBitmap& src, | 31 const SkBitmap& src, |
31 const SkMatrix& ctm, | 32 const SkMatrix& ctm, |
32 SkBitmap* dst, | 33 SkBitmap* dst, |
33 SkIPoint* offset) SK_OVERRIDE; | 34 SkIPoint* offset) SK_OVERRIDE; |
34 #if SK_SUPPORT_GPU | 35 #if SK_SUPPORT_GPU |
35 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } | 36 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } |
36 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* res
ult) SK_OVERRIDE; | 37 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* res
ult) SK_OVERRIDE; |
37 #endif | 38 #endif |
38 | 39 |
39 protected: | 40 protected: |
40 explicit SkBlendImageFilter(SkFlattenableReadBuffer& buffer); | 41 explicit SkXfermodeImageFilter(SkFlattenableReadBuffer& buffer); |
41 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 42 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
42 | 43 |
43 private: | 44 private: |
44 Mode fMode; | 45 SkXfermode* fMode; |
45 typedef SkImageFilter INHERITED; | 46 typedef SkImageFilter INHERITED; |
46 SkImageFilter* getBackgroundInput() { return getInput(0); } | |
47 SkImageFilter* getForegroundInput() { return getInput(1); } | |
48 }; | 47 }; |
49 | 48 |
50 #endif | 49 #endif |
OLD | NEW |