reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 1 | /* |
reed | c7141eb | 2016-01-11 13:08:59 -0800 | [diff] [blame] | 2 | * Copyright 2016 Google Inc. |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 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 | |||||
reed | c7141eb | 2016-01-11 13:08:59 -0800 | [diff] [blame] | 8 | #include "SkColorFilter.h" |
reed | c7141eb | 2016-01-11 13:08:59 -0800 | [diff] [blame] | 9 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 10 | #ifndef SkModeColorFilter_DEFINED |
11 | #define SkModeColorFilter_DEFINED | ||||
12 | |||||
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 13 | class SkModeColorFilter : public SkColorFilter { |
14 | public: | ||||
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 15 | static sk_sp<SkColorFilter> Make(SkColor color, SkBlendMode mode) { |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 16 | return sk_sp<SkColorFilter>(new SkModeColorFilter(color, mode)); |
reed | 4c9776b | 2016-03-22 08:10:17 -0700 | [diff] [blame] | 17 | } |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 18 | |
19 | SkColor getColor() const { return fColor; } | ||||
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 20 | SkPMColor getPMColor() const { return fPMColor; } |
21 | |||||
Mike Reed | faba371 | 2016-11-03 14:45:31 -0400 | [diff] [blame] | 22 | bool asColorMode(SkColor*, SkBlendMode*) const override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 23 | uint32_t getFlags() const override; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 24 | |
25 | #ifndef SK_IGNORE_TO_STRING | ||||
reed | c7141eb | 2016-01-11 13:08:59 -0800 | [diff] [blame] | 26 | void toString(SkString* str) const override; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 27 | #endif |
28 | |||||
29 | #if SK_SUPPORT_GPU | ||||
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 30 | std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrContext*, |
31 | SkColorSpace*) const override; | ||||
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 32 | #endif |
33 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter) | ||||
34 | |||||
35 | protected: | ||||
Mike Reed | ce9514c | 2017-06-11 22:14:14 -0400 | [diff] [blame] | 36 | SkModeColorFilter(SkColor color, SkBlendMode mode); |
reed | f028003 | 2015-10-12 11:10:10 -0700 | [diff] [blame] | 37 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 38 | void flatten(SkWriteBuffer&) const override; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 39 | |
Mike Klein | fdf3103 | 2017-05-09 14:57:58 -0400 | [diff] [blame] | 40 | void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, |
Mike Klein | 744908e | 2016-11-11 12:51:36 -0500 | [diff] [blame] | 41 | bool shaderIsOpaque) const override; |
Mike Klein | 96b333a | 2016-10-12 11:05:05 -0400 | [diff] [blame] | 42 | |
Mike Klein | 4e92b82 | 2017-04-26 13:45:36 -0400 | [diff] [blame] | 43 | sk_sp<SkColorFilter> onMakeColorSpace(SkColorSpaceXformer*) const override; |
44 | |||||
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 45 | private: |
Mike Reed | ce9514c | 2017-06-11 22:14:14 -0400 | [diff] [blame] | 46 | SkColor fColor; |
47 | SkBlendMode fMode; | ||||
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 48 | // cache |
Mike Reed | ce9514c | 2017-06-11 22:14:14 -0400 | [diff] [blame] | 49 | SkPMColor fPMColor; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 50 | |
reed | c7141eb | 2016-01-11 13:08:59 -0800 | [diff] [blame] | 51 | friend class SkColorFilter; |
52 | |||||
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 53 | typedef SkColorFilter INHERITED; |
54 | }; | ||||
55 | |||||
56 | #endif |