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 | |
Mike Reed | 71fecc3 | 2016-11-18 17:19:54 -0500 | [diff] [blame] | 11 | #include "SkBlendMode.h" |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 12 | #include "SkImageFilter.h" |
| 13 | |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 14 | class SK_API SkMergeImageFilter : public SkImageFilter { |
| 15 | public: |
robertphillips | 393aa36 | 2016-03-10 04:44:20 -0800 | [diff] [blame] | 16 | ~SkMergeImageFilter() override; |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 17 | |
robertphillips | 2238c9d | 2016-03-30 13:34:16 -0700 | [diff] [blame] | 18 | static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilter> first, sk_sp<SkImageFilter> second, |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 19 | SkBlendMode, const CropRect* cropRect = nullptr); |
| 20 | static sk_sp<SkImageFilter> MakeN(sk_sp<SkImageFilter>[], int count, const SkBlendMode[], |
robertphillips | 225db44 | 2016-04-17 14:27:05 -0700 | [diff] [blame] | 21 | const CropRect* cropRect = nullptr); |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 22 | |
robertphillips | f3f5bad | 2014-12-19 13:49:15 -0800 | [diff] [blame] | 23 | SK_TO_STRING_OVERRIDE() |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 24 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) |
| 25 | |
| 26 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 27 | void flatten(SkWriteBuffer&) const override; |
robertphillips | 2302de9 | 2016-03-24 07:26:32 -0700 | [diff] [blame] | 28 | sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
| 29 | SkIPoint* offset) const override; |
Matt Sarett | 6d72ed9 | 2017-04-10 16:35:33 -0400 | [diff] [blame^] | 30 | sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override; |
reed | 96a04f3 | 2016-04-25 09:25:15 -0700 | [diff] [blame] | 31 | bool onCanHandleComplexCTM() const override { return true; } |
commit-bot@chromium.org | bd0be25 | 2014-05-15 15:40:41 +0000 | [diff] [blame] | 32 | |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 33 | private: |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 34 | SkMergeImageFilter(sk_sp<SkImageFilter> filters[], int count, const SkBlendMode modes[], |
reed | 5ea95df | 2015-10-06 14:05:32 -0700 | [diff] [blame] | 35 | const CropRect* cropRect); |
| 36 | |
Mike Reed | 71fecc3 | 2016-11-18 17:19:54 -0500 | [diff] [blame] | 37 | uint8_t* fModes; // SkBlendMode |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 38 | |
| 39 | // private storage, to avoid dynamically allocating storage for our copy |
| 40 | // of the modes (unless the count is so large we can't fit). |
| 41 | intptr_t fStorage[16]; |
| 42 | |
| 43 | void initAllocModes(); |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 44 | void initModes(const SkBlendMode[]); |
senorblanco@chromium.org | 4a9a612 | 2012-12-04 14:18:50 +0000 | [diff] [blame] | 45 | |
| 46 | typedef SkImageFilter INHERITED; |
| 47 | }; |
| 48 | |
| 49 | #endif |