OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 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 SkXfermodeImageFilter_DEFINED | 8 #ifndef SkXfermodeImageFilter_DEFINED |
9 #define SkXfermodeImageFilter_DEFINED | 9 #define SkXfermodeImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 | 12 |
13 class SkBitmap; | 13 class SkBitmap; |
14 class SkXfermode; | 14 class SkXfermode; |
15 | 15 |
16 class SK_API SkXfermodeImageFilter : public SkImageFilter { | 16 class SK_API SkXfermodeImageFilter : public SkImageFilter { |
17 /** | 17 /** |
18 * This filter takes an xfermode, and uses it to composite the foreground | 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 | 19 * over the background. If foreground or background is NULL, the input |
20 * bitmap (src) is used instead. | 20 * bitmap (src) is used instead. |
21 */ | 21 */ |
22 | 22 |
23 public: | 23 public: |
24 static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter
> background, | 24 static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, SkImageFilter* back
ground, |
25 sk_sp<SkImageFilter> foreground, const Crop
Rect* cropRect); | 25 SkImageFilter* foreground, const CropRect*
cropRect); |
26 static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter
> background) { | 26 static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, SkImageFilter* back
ground) { |
27 return Make(std::move(mode), std::move(background), nullptr, nullptr); | 27 return Make(std::move(mode), background, nullptr, nullptr); |
28 } | 28 } |
29 | 29 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR |
30 #if defined(SK_SUPPORT_LEGACY_XFERMODE_PTR) || defined(SK_SUPPORT_LEGACY_IMAGEFI
LTER_PTR) | |
31 static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background, | 30 static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background, |
32 SkImageFilter* foreground = NULL, | 31 SkImageFilter* foreground = NULL, |
33 const CropRect* cropRect = NULL) { | 32 const CropRect* cropRect = NULL) { |
34 return Make(sk_ref_sp(mode), | 33 return Make(sk_ref_sp(mode), background, foreground, cropRect).release()
; |
35 sk_ref_sp(background), | |
36 sk_ref_sp(foreground), | |
37 cropRect).release(); | |
38 } | 34 } |
39 #endif | 35 #endif |
40 | 36 |
41 SK_TO_STRING_OVERRIDE() | 37 SK_TO_STRING_OVERRIDE() |
42 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) | 38 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) |
43 | 39 |
44 bool onFilterImageDeprecated(Proxy* proxy, | 40 bool onFilterImageDeprecated(Proxy* proxy, |
45 const SkBitmap& src, | 41 const SkBitmap& src, |
46 const Context& ctx, | 42 const Context& ctx, |
47 SkBitmap* dst, | 43 SkBitmap* dst, |
48 SkIPoint* offset) const override; | 44 SkIPoint* offset) const override; |
49 #if SK_SUPPORT_GPU | 45 #if SK_SUPPORT_GPU |
50 bool canFilterImageGPU() const override; | 46 bool canFilterImageGPU() const override; |
51 bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Conte
xt& ctx, | 47 bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Conte
xt& ctx, |
52 SkBitmap* result, SkIPoint* offset) const over
ride; | 48 SkBitmap* result, SkIPoint* offset) const over
ride; |
53 #endif | 49 #endif |
54 | 50 |
55 protected: | 51 protected: |
56 SkXfermodeImageFilter(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> inputs[2]
, | 52 SkXfermodeImageFilter(sk_sp<SkXfermode> mode, SkImageFilter* inputs[2], |
57 const CropRect* cropRect); | 53 const CropRect* cropRect); |
58 void flatten(SkWriteBuffer&) const override; | 54 void flatten(SkWriteBuffer&) const override; |
59 | 55 |
60 private: | 56 private: |
61 sk_sp<SkXfermode> fMode; | 57 sk_sp<SkXfermode> fMode; |
62 typedef SkImageFilter INHERITED; | 58 typedef SkImageFilter INHERITED; |
63 }; | 59 }; |
64 | 60 |
65 #endif | 61 #endif |
OLD | NEW |