senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkXfermodeImageFilter_DEFINED |
| 9 | #define SkXfermodeImageFilter_DEFINED |
| 10 | |
| 11 | #include "SkImageFilter.h" |
| 12 | |
| 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 | |
| 23 | public: |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 24 | virtual ~SkXfermodeImageFilter(); |
| 25 | |
reed | 2d6ba66 | 2015-12-20 20:08:42 -0800 | [diff] [blame^] | 26 | static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background, |
| 27 | SkImageFilter* foreground = NULL, |
| 28 | const CropRect* cropRect = NULL) { |
senorblanco | 9ea3d57 | 2014-07-08 09:16:22 -0700 | [diff] [blame] | 29 | SkImageFilter* inputs[2] = { background, foreground }; |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 30 | return new SkXfermodeImageFilter(mode, inputs, cropRect); |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 31 | } |
| 32 | |
robertphillips | f3f5bad | 2014-12-19 13:49:15 -0800 | [diff] [blame] | 33 | SK_TO_STRING_OVERRIDE() |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 34 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) |
| 35 | |
robertphillips | 31dc1b2 | 2015-07-07 10:05:18 -0700 | [diff] [blame] | 36 | bool onFilterImage(Proxy* proxy, |
| 37 | const SkBitmap& src, |
| 38 | const Context& ctx, |
| 39 | SkBitmap* dst, |
| 40 | SkIPoint* offset) const override; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 41 | #if SK_SUPPORT_GPU |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 42 | bool canFilterImageGPU() const override; |
robertphillips | 31dc1b2 | 2015-07-07 10:05:18 -0700 | [diff] [blame] | 43 | bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, |
| 44 | SkBitmap* result, SkIPoint* offset) const override; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 45 | #endif |
| 46 | |
| 47 | protected: |
senorblanco | 9ea3d57 | 2014-07-08 09:16:22 -0700 | [diff] [blame] | 48 | SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2], |
senorblanco | 24e06d5 | 2015-03-18 12:11:33 -0700 | [diff] [blame] | 49 | const CropRect* cropRect); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 50 | void flatten(SkWriteBuffer&) const override; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 51 | |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 52 | private: |
| 53 | SkXfermode* fMode; |
| 54 | typedef SkImageFilter INHERITED; |
| 55 | }; |
| 56 | |
| 57 | #endif |