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: |
reed | 5e1ddb1 | 2015-12-21 08:52:45 -0800 | [diff] [blame] | 24 | static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background, |
| 25 | SkImageFilter* foreground = NULL, |
| 26 | const CropRect* cropRect = NULL) { |
senorblanco | 9ea3d57 | 2014-07-08 09:16:22 -0700 | [diff] [blame] | 27 | SkImageFilter* inputs[2] = { background, foreground }; |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 28 | return new SkXfermodeImageFilter(mode, inputs, cropRect); |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 29 | } |
| 30 | |
robertphillips | f3f5bad | 2014-12-19 13:49:15 -0800 | [diff] [blame] | 31 | SK_TO_STRING_OVERRIDE() |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 32 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) |
| 33 | |
robertphillips | 48e7846 | 2016-02-17 13:57:16 -0800 | [diff] [blame^] | 34 | bool onFilterImageDeprecated(Proxy* proxy, |
| 35 | const SkBitmap& src, |
| 36 | const Context& ctx, |
| 37 | SkBitmap* dst, |
| 38 | SkIPoint* offset) const override; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 39 | #if SK_SUPPORT_GPU |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 40 | bool canFilterImageGPU() const override; |
robertphillips | 48e7846 | 2016-02-17 13:57:16 -0800 | [diff] [blame^] | 41 | bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx, |
| 42 | SkBitmap* result, SkIPoint* offset) const override; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 43 | #endif |
| 44 | |
| 45 | protected: |
senorblanco | 9ea3d57 | 2014-07-08 09:16:22 -0700 | [diff] [blame] | 46 | SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2], |
senorblanco | 24e06d5 | 2015-03-18 12:11:33 -0700 | [diff] [blame] | 47 | const CropRect* cropRect); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 48 | void flatten(SkWriteBuffer&) const override; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 49 | |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 50 | private: |
robertphillips | 4f03794 | 2016-02-09 05:09:27 -0800 | [diff] [blame] | 51 | SkAutoTUnref<SkXfermode> fMode; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 52 | typedef SkImageFilter INHERITED; |
| 53 | }; |
| 54 | |
| 55 | #endif |