senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 SkMergeImageFilter_DEFINED |
| 9 | #define SkMergeImageFilter_DEFINED |
| 10 | |
| 11 | #include "SkImageFilter.h" |
| 12 | |
| 13 | #include "SkXfermode.h" |
| 14 | |
| 15 | class SK_API SkMergeImageFilter : public SkImageFilter { |
| 16 | public: |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 17 | virtual ~SkMergeImageFilter(); |
| 18 | |
reed | 5ea95df | 2015-10-06 14:05:32 -0700 | [diff] [blame] | 19 | static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second, |
| 20 | SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode, |
| 21 | const CropRect* cropRect = NULL) { |
senorblanco | 9ea3d57 | 2014-07-08 09:16:22 -0700 | [diff] [blame] | 22 | SkImageFilter* inputs[2] = { first, second }; |
| 23 | SkXfermode::Mode modes[2] = { mode, mode }; |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 24 | return new SkMergeImageFilter(inputs, 2, modes, cropRect); |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 25 | } |
reed | 5ea95df | 2015-10-06 14:05:32 -0700 | [diff] [blame] | 26 | |
| 27 | static SkImageFilter* Create(SkImageFilter* filters[], int count, |
| 28 | const SkXfermode::Mode modes[] = NULL, |
| 29 | const CropRect* cropRect = NULL) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 30 | return new SkMergeImageFilter(filters, count, modes, 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 | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 34 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) |
| 35 | |
| 36 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 37 | void flatten(SkWriteBuffer&) const override; |
robertphillips | 48e7846 | 2016-02-17 13:57:16 -0800 | [diff] [blame^] | 38 | bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, |
| 39 | SkIPoint* loc) const override; |
commit-bot@chromium.org | bd0be25 | 2014-05-15 15:40:41 +0000 | [diff] [blame] | 40 | |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 41 | private: |
reed | 5ea95df | 2015-10-06 14:05:32 -0700 | [diff] [blame] | 42 | SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mode modes[], |
| 43 | const CropRect* cropRect); |
| 44 | |
| 45 | uint8_t* fModes; // SkXfermode::Mode |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 46 | |
| 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). |
| 49 | intptr_t fStorage[16]; |
| 50 | |
| 51 | void initAllocModes(); |
| 52 | void initModes(const SkXfermode::Mode []); |
| 53 | |
| 54 | typedef SkImageFilter INHERITED; |
| 55 | }; |
| 56 | |
| 57 | #endif |