wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 1 | /* |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 7 | |
Robert Phillips | 54cbcd7 | 2017-04-20 17:20:24 -0400 | [diff] [blame] | 8 | #include "GrXfermodeFragmentProcessor.h" |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 9 | |
Robert Phillips | 54cbcd7 | 2017-04-20 17:20:24 -0400 | [diff] [blame] | 10 | #include "GrConstColorProcessor.h" |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 11 | #include "GrFragmentProcessor.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 12 | #include "glsl/GrGLSLFragmentProcessor.h" |
| 13 | #include "glsl/GrGLSLBlend.h" |
egdaniel | 2d721d3 | 2015-11-11 13:06:05 -0800 | [diff] [blame] | 14 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
Brian Osman | 3b65598 | 2017-03-07 16:58:08 -0500 | [diff] [blame] | 15 | #include "SkGr.h" |
Mike Reed | 6b3542a | 2017-06-06 10:41:18 -0400 | [diff] [blame] | 16 | #include "SkXfermodePriv.h" |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 17 | |
Brian Salomon | 246a3c2 | 2017-02-10 16:16:21 -0500 | [diff] [blame] | 18 | // Some of the cpu implementations of blend modes differ too much from the GPU enough that |
| 19 | // we can't use the cpu implementation to implement constantOutputForConstantInput. |
| 20 | static inline bool does_cpu_blend_impl_match_gpu(SkBlendMode mode) { |
| 21 | // The non-seperable modes differ too much. So does SoftLight. ColorBurn differs too much on our |
| 22 | // test iOS device (but we just disable it across the aboard since it may happen on untested |
| 23 | // GPUs). |
| 24 | return mode <= SkBlendMode::kLastSeparableMode && mode != SkBlendMode::kSoftLight && |
| 25 | mode != SkBlendMode::kColorBurn; |
| 26 | } |
| 27 | |
| 28 | ////////////////////////////////////////////////////////////////////////////// |
| 29 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 30 | class ComposeTwoFragmentProcessor : public GrFragmentProcessor { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 31 | public: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 32 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> src, |
| 33 | std::unique_ptr<GrFragmentProcessor> dst, |
| 34 | SkBlendMode mode) { |
| 35 | return std::unique_ptr<GrFragmentProcessor>( |
| 36 | new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), mode)); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 37 | } |
| 38 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 39 | const char* name() const override { return "ComposeTwo"; } |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 40 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 41 | #ifdef SK_DEBUG |
Brian Osman | bd1f76f | 2017-03-15 11:33:12 -0400 | [diff] [blame] | 42 | SkString dumpInfo() const override { |
| 43 | SkString str; |
| 44 | |
| 45 | str.appendf("Mode: %s", SkBlendMode_Name(fMode)); |
| 46 | |
| 47 | for (int i = 0; i < this->numChildProcessors(); ++i) { |
| 48 | str.appendf(" [%s %s]", |
| 49 | this->childProcessor(i).name(), this->childProcessor(i).dumpInfo().c_str()); |
| 50 | } |
| 51 | return str; |
| 52 | } |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 53 | #endif |
Brian Osman | bd1f76f | 2017-03-15 11:33:12 -0400 | [diff] [blame] | 54 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 55 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 56 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 57 | SkBlendMode getMode() const { return fMode; } |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 58 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 59 | private: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 60 | ComposeTwoFragmentProcessor(std::unique_ptr<GrFragmentProcessor> src, |
| 61 | std::unique_ptr<GrFragmentProcessor> dst, |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 62 | SkBlendMode mode) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 63 | : INHERITED(kComposeTwoFragmentProcessor_ClassID, OptFlags(src.get(), dst.get(), mode)) |
| 64 | , fMode(mode) { |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 65 | SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(std::move(src)); |
| 66 | SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(std::move(dst)); |
| 67 | SkASSERT(0 == shaderAChildIndex); |
| 68 | SkASSERT(1 == shaderBChildIndex); |
| 69 | } |
| 70 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 71 | static OptimizationFlags OptFlags(const GrFragmentProcessor* src, |
| 72 | const GrFragmentProcessor* dst, SkBlendMode mode) { |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 73 | OptimizationFlags flags; |
| 74 | switch (mode) { |
| 75 | case SkBlendMode::kClear: |
| 76 | case SkBlendMode::kSrc: |
| 77 | case SkBlendMode::kDst: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 78 | SK_ABORT("Should never create clear, src, or dst compose two FP."); |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 79 | flags = kNone_OptimizationFlags; |
| 80 | break; |
| 81 | |
| 82 | // Produces opaque if both src and dst are opaque. |
| 83 | case SkBlendMode::kSrcIn: |
| 84 | case SkBlendMode::kDstIn: |
| 85 | case SkBlendMode::kModulate: |
| 86 | flags = src->preservesOpaqueInput() && dst->preservesOpaqueInput() |
| 87 | ? kPreservesOpaqueInput_OptimizationFlag |
| 88 | : kNone_OptimizationFlags; |
| 89 | break; |
| 90 | |
| 91 | // Produces zero when both are opaque, indeterminate if one is opaque. |
| 92 | case SkBlendMode::kSrcOut: |
| 93 | case SkBlendMode::kDstOut: |
| 94 | case SkBlendMode::kXor: |
| 95 | flags = kNone_OptimizationFlags; |
| 96 | break; |
| 97 | |
| 98 | // Is opaque if the dst is opaque. |
| 99 | case SkBlendMode::kSrcATop: |
| 100 | flags = dst->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 101 | : kNone_OptimizationFlags; |
| 102 | break; |
| 103 | |
| 104 | // DstATop is the converse of kSrcATop. Screen is also opaque if the src is a opaque. |
| 105 | case SkBlendMode::kDstATop: |
| 106 | case SkBlendMode::kScreen: |
| 107 | flags = src->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 108 | : kNone_OptimizationFlags; |
| 109 | break; |
| 110 | |
| 111 | // These modes are all opaque if either src or dst is opaque. All the advanced modes |
| 112 | // compute alpha as src-over. |
| 113 | case SkBlendMode::kSrcOver: |
| 114 | case SkBlendMode::kDstOver: |
| 115 | case SkBlendMode::kPlus: |
| 116 | case SkBlendMode::kOverlay: |
| 117 | case SkBlendMode::kDarken: |
| 118 | case SkBlendMode::kLighten: |
| 119 | case SkBlendMode::kColorDodge: |
| 120 | case SkBlendMode::kColorBurn: |
| 121 | case SkBlendMode::kHardLight: |
| 122 | case SkBlendMode::kSoftLight: |
| 123 | case SkBlendMode::kDifference: |
| 124 | case SkBlendMode::kExclusion: |
| 125 | case SkBlendMode::kMultiply: |
| 126 | case SkBlendMode::kHue: |
| 127 | case SkBlendMode::kSaturation: |
| 128 | case SkBlendMode::kColor: |
| 129 | case SkBlendMode::kLuminosity: |
| 130 | flags = src->preservesOpaqueInput() || dst->preservesOpaqueInput() |
| 131 | ? kPreservesOpaqueInput_OptimizationFlag |
| 132 | : kNone_OptimizationFlags; |
| 133 | break; |
| 134 | } |
Brian Salomon | 246a3c2 | 2017-02-10 16:16:21 -0500 | [diff] [blame] | 135 | if (does_cpu_blend_impl_match_gpu(mode) && src->hasConstantOutputForConstantInput() && |
| 136 | dst->hasConstantOutputForConstantInput()) { |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 137 | flags |= kConstantOutputForConstantInput_OptimizationFlag; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 138 | } |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 139 | return flags; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 140 | } |
| 141 | |
Brian Salomon | fb7c83a | 2017-07-26 13:57:33 -0400 | [diff] [blame] | 142 | void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { |
| 143 | b->add32((int)fMode); |
| 144 | } |
| 145 | |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 146 | bool onIsEqual(const GrFragmentProcessor& other) const override { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 147 | const ComposeTwoFragmentProcessor& cs = other.cast<ComposeTwoFragmentProcessor>(); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 148 | return fMode == cs.fMode; |
| 149 | } |
| 150 | |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 151 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { |
| 152 | SkPMColor4f opaqueInput = { input.fR, input.fG, input.fB, 1 }; |
| 153 | SkPMColor4f src = ConstantOutputForConstantInput(this->childProcessor(0), opaqueInput); |
| 154 | SkPMColor4f dst = ConstantOutputForConstantInput(this->childProcessor(1), opaqueInput); |
Brian Osman | d25b7c1 | 2018-09-21 16:01:59 -0400 | [diff] [blame] | 155 | SkPMColor4f res = SkBlendMode_Apply(fMode, src, dst); |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 156 | return res * input.fA; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 157 | } |
| 158 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 159 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 160 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 161 | SkBlendMode fMode; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 162 | |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 163 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 164 | |
| 165 | typedef GrFragmentProcessor INHERITED; |
| 166 | }; |
| 167 | |
| 168 | ///////////////////////////////////////////////////////////////////// |
| 169 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 170 | class GLComposeTwoFragmentProcessor : public GrGLSLFragmentProcessor { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 171 | public: |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 172 | void emitCode(EmitArgs&) override; |
| 173 | |
| 174 | private: |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 175 | typedef GrGLSLFragmentProcessor INHERITED; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | ///////////////////////////////////////////////////////////////////// |
| 179 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 180 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 181 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 182 | #if GR_TEST_UTILS |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 183 | std::unique_ptr<GrFragmentProcessor> ComposeTwoFragmentProcessor::TestCreate( |
| 184 | GrProcessorTestData* d) { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 185 | // Create two random frag procs. |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 186 | std::unique_ptr<GrFragmentProcessor> fpA(GrProcessorUnitTest::MakeChildFP(d)); |
| 187 | std::unique_ptr<GrFragmentProcessor> fpB(GrProcessorUnitTest::MakeChildFP(d)); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 188 | |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 189 | SkBlendMode mode; |
| 190 | do { |
| 191 | mode = static_cast<SkBlendMode>(d->fRandom->nextRangeU(0, (int)SkBlendMode::kLastMode)); |
| 192 | } while (SkBlendMode::kClear == mode || SkBlendMode::kSrc == mode || SkBlendMode::kDst == mode); |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 193 | return std::unique_ptr<GrFragmentProcessor>( |
| 194 | new ComposeTwoFragmentProcessor(std::move(fpA), std::move(fpB), mode)); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 195 | } |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 196 | #endif |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 197 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 198 | std::unique_ptr<GrFragmentProcessor> ComposeTwoFragmentProcessor::clone() const { |
Brian Salomon | fb7c83a | 2017-07-26 13:57:33 -0400 | [diff] [blame] | 199 | auto src = this->childProcessor(0).clone(); |
| 200 | auto dst = this->childProcessor(1).clone(); |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 201 | return std::unique_ptr<GrFragmentProcessor>( |
Brian Salomon | fb7c83a | 2017-07-26 13:57:33 -0400 | [diff] [blame] | 202 | new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), fMode)); |
| 203 | } |
| 204 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 205 | GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() const{ |
robertphillips | 9cdb992 | 2016-02-03 12:25:40 -0800 | [diff] [blame] | 206 | return new GLComposeTwoFragmentProcessor; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | ///////////////////////////////////////////////////////////////////// |
| 210 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 211 | void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 212 | |
cdalton | 8528541 | 2016-02-18 12:37:07 -0800 | [diff] [blame] | 213 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 214 | const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProcessor>(); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 215 | |
Ethan Nicholas | 62ae664 | 2017-07-10 17:43:15 +0000 | [diff] [blame] | 216 | const char* inputColor = nullptr; |
| 217 | if (args.fInputColor) { |
| 218 | inputColor = "inputColor"; |
Ethan Nicholas | f7b8820 | 2017-09-18 14:10:39 -0400 | [diff] [blame] | 219 | fragBuilder->codeAppendf("half4 inputColor = half4(%s.rgb, 1.0);", args.fInputColor); |
Ethan Nicholas | 62ae664 | 2017-07-10 17:43:15 +0000 | [diff] [blame] | 220 | } |
| 221 | |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 222 | // declare outputColor and emit the code for each of the two children |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 223 | SkString srcColor("xfer_src"); |
Ethan Nicholas | 62ae664 | 2017-07-10 17:43:15 +0000 | [diff] [blame] | 224 | this->emitChild(0, inputColor, &srcColor, args); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 225 | |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 226 | SkString dstColor("xfer_dst"); |
Ethan Nicholas | 62ae664 | 2017-07-10 17:43:15 +0000 | [diff] [blame] | 227 | this->emitChild(1, inputColor, &dstColor, args); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 228 | |
| 229 | // emit blend code |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 230 | SkBlendMode mode = cs.getMode(); |
Mike Reed | cde9031 | 2017-06-07 23:05:45 -0400 | [diff] [blame] | 231 | fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkBlendMode_Name(mode)); |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 232 | GrGLSLBlend::AppendMode(fragBuilder, |
| 233 | srcColor.c_str(), |
| 234 | dstColor.c_str(), |
| 235 | args.fOutputColor, |
| 236 | mode); |
Ethan Nicholas | 62ae664 | 2017-07-10 17:43:15 +0000 | [diff] [blame] | 237 | |
| 238 | // re-multiply the output color by the input color's alpha |
| 239 | if (args.fInputColor) { |
| 240 | fragBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, args.fInputColor); |
| 241 | } |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 244 | std::unique_ptr<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromTwoProcessors( |
| 245 | std::unique_ptr<GrFragmentProcessor> src, |
| 246 | std::unique_ptr<GrFragmentProcessor> dst, |
| 247 | SkBlendMode mode) { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 248 | switch (mode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 249 | case SkBlendMode::kClear: |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 250 | return GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT, |
Ethan Nicholas | e9d172a | 2017-11-20 12:12:24 -0500 | [diff] [blame] | 251 | GrConstColorProcessor::InputMode::kIgnore); |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 252 | case SkBlendMode::kSrc: |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 253 | return src; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 254 | case SkBlendMode::kDst: |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 255 | return dst; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 256 | default: |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 257 | return ComposeTwoFragmentProcessor::Make(std::move(src), std::move(dst), mode); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
| 261 | ////////////////////////////////////////////////////////////////////////////// |
| 262 | |
| 263 | class ComposeOneFragmentProcessor : public GrFragmentProcessor { |
| 264 | public: |
| 265 | enum Child { |
| 266 | kDst_Child, |
| 267 | kSrc_Child, |
| 268 | }; |
| 269 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 270 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp, |
| 271 | SkBlendMode mode, Child child) { |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 272 | if (!fp) { |
| 273 | return nullptr; |
| 274 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 275 | return std::unique_ptr<GrFragmentProcessor>( |
| 276 | new ComposeOneFragmentProcessor(std::move(fp), mode, child)); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | const char* name() const override { return "ComposeOne"; } |
| 280 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 281 | #ifdef SK_DEBUG |
robertphillips | 783a4da | 2015-11-19 14:00:02 -0800 | [diff] [blame] | 282 | SkString dumpInfo() const override { |
| 283 | SkString str; |
| 284 | |
Brian Osman | bd1f76f | 2017-03-15 11:33:12 -0400 | [diff] [blame] | 285 | str.appendf("Mode: %s, Child: %s", |
| 286 | SkBlendMode_Name(fMode), kDst_Child == fChild ? "Dst" : "Src"); |
| 287 | |
robertphillips | 783a4da | 2015-11-19 14:00:02 -0800 | [diff] [blame] | 288 | for (int i = 0; i < this->numChildProcessors(); ++i) { |
Brian Osman | bd1f76f | 2017-03-15 11:33:12 -0400 | [diff] [blame] | 289 | str.appendf(" [%s %s]", |
| 290 | this->childProcessor(i).name(), this->childProcessor(i).dumpInfo().c_str()); |
robertphillips | 783a4da | 2015-11-19 14:00:02 -0800 | [diff] [blame] | 291 | } |
| 292 | return str; |
| 293 | } |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 294 | #endif |
robertphillips | 783a4da | 2015-11-19 14:00:02 -0800 | [diff] [blame] | 295 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 296 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 297 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 298 | SkBlendMode mode() const { return fMode; } |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 299 | |
| 300 | Child child() const { return fChild; } |
| 301 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 302 | private: |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 303 | OptimizationFlags OptFlags(const GrFragmentProcessor* fp, SkBlendMode mode, Child child) { |
| 304 | OptimizationFlags flags; |
| 305 | switch (mode) { |
| 306 | case SkBlendMode::kClear: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 307 | SK_ABORT("Should never create clear compose one FP."); |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 308 | flags = kNone_OptimizationFlags; |
| 309 | break; |
| 310 | |
| 311 | case SkBlendMode::kSrc: |
| 312 | SkASSERT(child == kSrc_Child); |
| 313 | flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 314 | : kNone_OptimizationFlags; |
| 315 | break; |
| 316 | |
| 317 | case SkBlendMode::kDst: |
| 318 | SkASSERT(child == kDst_Child); |
| 319 | flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 320 | : kNone_OptimizationFlags; |
| 321 | break; |
| 322 | |
| 323 | // Produces opaque if both src and dst are opaque. These also will modulate the child's |
Brian Salomon | e026511 | 2017-02-21 14:19:07 -0500 | [diff] [blame] | 324 | // output by either the input color or alpha. However, if the child is not compatible |
| 325 | // with the coverage as alpha then it may produce a color that is not valid premul. |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 326 | case SkBlendMode::kSrcIn: |
| 327 | case SkBlendMode::kDstIn: |
| 328 | case SkBlendMode::kModulate: |
Brian Salomon | e026511 | 2017-02-21 14:19:07 -0500 | [diff] [blame] | 329 | if (fp->compatibleWithCoverageAsAlpha()) { |
| 330 | if (fp->preservesOpaqueInput()) { |
| 331 | flags = kPreservesOpaqueInput_OptimizationFlag | |
| 332 | kCompatibleWithCoverageAsAlpha_OptimizationFlag; |
| 333 | } else { |
| 334 | flags = kCompatibleWithCoverageAsAlpha_OptimizationFlag; |
| 335 | } |
Brian Salomon | f3b995b | 2017-02-15 10:22:23 -0500 | [diff] [blame] | 336 | } else { |
Brian Salomon | e026511 | 2017-02-21 14:19:07 -0500 | [diff] [blame] | 337 | flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 338 | : kNone_OptimizationFlags; |
Brian Salomon | f3b995b | 2017-02-15 10:22:23 -0500 | [diff] [blame] | 339 | } |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 340 | break; |
| 341 | |
| 342 | // Produces zero when both are opaque, indeterminate if one is opaque. |
| 343 | case SkBlendMode::kSrcOut: |
| 344 | case SkBlendMode::kDstOut: |
| 345 | case SkBlendMode::kXor: |
| 346 | flags = kNone_OptimizationFlags; |
| 347 | break; |
| 348 | |
| 349 | // Is opaque if the dst is opaque. |
| 350 | case SkBlendMode::kSrcATop: |
| 351 | if (child == kDst_Child) { |
| 352 | flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 353 | : kNone_OptimizationFlags; |
| 354 | } else { |
| 355 | flags = kPreservesOpaqueInput_OptimizationFlag; |
| 356 | } |
| 357 | break; |
| 358 | |
| 359 | // DstATop is the converse of kSrcATop. Screen is also opaque if the src is a opaque. |
| 360 | case SkBlendMode::kDstATop: |
| 361 | case SkBlendMode::kScreen: |
| 362 | if (child == kSrc_Child) { |
| 363 | flags = fp->preservesOpaqueInput() ? kPreservesOpaqueInput_OptimizationFlag |
| 364 | : kNone_OptimizationFlags; |
| 365 | } else { |
| 366 | flags = kPreservesOpaqueInput_OptimizationFlag; |
| 367 | } |
| 368 | break; |
| 369 | |
| 370 | // These modes are all opaque if either src or dst is opaque. All the advanced modes |
| 371 | // compute alpha as src-over. |
| 372 | case SkBlendMode::kSrcOver: |
| 373 | case SkBlendMode::kDstOver: |
| 374 | case SkBlendMode::kPlus: |
| 375 | case SkBlendMode::kOverlay: |
| 376 | case SkBlendMode::kDarken: |
| 377 | case SkBlendMode::kLighten: |
| 378 | case SkBlendMode::kColorDodge: |
| 379 | case SkBlendMode::kColorBurn: |
| 380 | case SkBlendMode::kHardLight: |
| 381 | case SkBlendMode::kSoftLight: |
| 382 | case SkBlendMode::kDifference: |
| 383 | case SkBlendMode::kExclusion: |
| 384 | case SkBlendMode::kMultiply: |
| 385 | case SkBlendMode::kHue: |
| 386 | case SkBlendMode::kSaturation: |
| 387 | case SkBlendMode::kColor: |
| 388 | case SkBlendMode::kLuminosity: |
| 389 | flags = kPreservesOpaqueInput_OptimizationFlag; |
| 390 | break; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 391 | } |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 392 | if (does_cpu_blend_impl_match_gpu(mode) && fp->hasConstantOutputForConstantInput()) { |
| 393 | flags |= kConstantOutputForConstantInput_OptimizationFlag; |
| 394 | } |
| 395 | return flags; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 396 | } |
| 397 | |
Brian Salomon | fb7c83a | 2017-07-26 13:57:33 -0400 | [diff] [blame] | 398 | void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { |
Ben Wagner | b089765 | 2018-06-15 15:37:57 +0000 | [diff] [blame] | 399 | GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & UINT16_MAX) == (int)SkBlendMode::kLastMode); |
Brian Salomon | fb7c83a | 2017-07-26 13:57:33 -0400 | [diff] [blame] | 400 | b->add32((int)fMode | (fChild << 16)); |
| 401 | } |
| 402 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 403 | bool onIsEqual(const GrFragmentProcessor& that) const override { |
| 404 | return fMode == that.cast<ComposeOneFragmentProcessor>().fMode; |
| 405 | } |
| 406 | |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 407 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& inputColor) const override { |
| 408 | SkPMColor4f childColor = ConstantOutputForConstantInput(this->childProcessor(0), |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 409 | SK_PMColor4fWHITE); |
Brian Osman | d25b7c1 | 2018-09-21 16:01:59 -0400 | [diff] [blame] | 410 | SkPMColor4f src, dst; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 411 | if (kSrc_Child == fChild) { |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 412 | src = childColor; |
| 413 | dst = inputColor; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 414 | } else { |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 415 | src = inputColor; |
| 416 | dst = childColor; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 417 | } |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 418 | return SkBlendMode_Apply(fMode, src, dst); |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 419 | } |
| 420 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 421 | private: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 422 | ComposeOneFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp, SkBlendMode mode, |
| 423 | Child child) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 424 | : INHERITED(kComposeOneFragmentProcessor_ClassID, OptFlags(fp.get(), mode, child)) |
| 425 | , fMode(mode) |
| 426 | , fChild(child) { |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 427 | SkDEBUGCODE(int dstIndex =) this->registerChildProcessor(std::move(fp)); |
| 428 | SkASSERT(0 == dstIndex); |
| 429 | } |
| 430 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 431 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 432 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 433 | SkBlendMode fMode; |
| 434 | Child fChild; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 435 | |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 436 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 437 | |
| 438 | typedef GrFragmentProcessor INHERITED; |
| 439 | }; |
| 440 | |
| 441 | ////////////////////////////////////////////////////////////////////////////// |
| 442 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 443 | class GLComposeOneFragmentProcessor : public GrGLSLFragmentProcessor { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 444 | public: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 445 | void emitCode(EmitArgs& args) override { |
cdalton | 8528541 | 2016-02-18 12:37:07 -0800 | [diff] [blame] | 446 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 447 | SkBlendMode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mode(); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 448 | ComposeOneFragmentProcessor::Child child = |
| 449 | args.fFp.cast<ComposeOneFragmentProcessor>().child(); |
bsalomon | 38ddbad | 2015-09-24 06:00:00 -0700 | [diff] [blame] | 450 | SkString childColor("child"); |
Ethan Nicholas | 2983f40 | 2017-05-08 09:36:08 -0400 | [diff] [blame] | 451 | this->emitChild(0, &childColor, args); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 452 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 453 | // emit blend code |
Mike Reed | cde9031 | 2017-06-07 23:05:45 -0400 | [diff] [blame] | 454 | fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkBlendMode_Name(mode)); |
bsalomon | 38ddbad | 2015-09-24 06:00:00 -0700 | [diff] [blame] | 455 | const char* childStr = childColor.c_str(); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 456 | if (ComposeOneFragmentProcessor::kDst_Child == child) { |
Michael Ludwig | 231de03 | 2018-08-30 14:33:01 -0400 | [diff] [blame] | 457 | GrGLSLBlend::AppendMode(fragBuilder, args.fInputColor, childStr, args.fOutputColor, mode); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 458 | } else { |
Michael Ludwig | 231de03 | 2018-08-30 14:33:01 -0400 | [diff] [blame] | 459 | GrGLSLBlend::AppendMode(fragBuilder, childStr, args.fInputColor, args.fOutputColor, mode); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 460 | } |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | private: |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 464 | typedef GrGLSLFragmentProcessor INHERITED; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 465 | }; |
| 466 | |
| 467 | ///////////////////////////////////////////////////////////////////// |
| 468 | |
| 469 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeOneFragmentProcessor); |
| 470 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 471 | #if GR_TEST_UTILS |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 472 | std::unique_ptr<GrFragmentProcessor> ComposeOneFragmentProcessor::TestCreate( |
| 473 | GrProcessorTestData* d) { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 474 | // Create one random frag procs. |
| 475 | // For now, we'll prevent either children from being a shader with children to prevent the |
| 476 | // possibility of an arbitrarily large tree of procs. |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 477 | std::unique_ptr<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d)); |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 478 | SkBlendMode mode; |
| 479 | ComposeOneFragmentProcessor::Child child; |
| 480 | do { |
| 481 | mode = static_cast<SkBlendMode>(d->fRandom->nextRangeU(0, (int)SkBlendMode::kLastMode)); |
| 482 | child = d->fRandom->nextBool() ? kDst_Child : kSrc_Child; |
| 483 | } while (SkBlendMode::kClear == mode || (SkBlendMode::kDst == mode && child == kSrc_Child) || |
| 484 | (SkBlendMode::kSrc == mode && child == kDst_Child)); |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 485 | return std::unique_ptr<GrFragmentProcessor>( |
| 486 | new ComposeOneFragmentProcessor(std::move(dst), mode, child)); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 487 | } |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 488 | #endif |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 489 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 490 | GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() const { |
robertphillips | 9cdb992 | 2016-02-03 12:25:40 -0800 | [diff] [blame] | 491 | return new GLComposeOneFragmentProcessor; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 494 | std::unique_ptr<GrFragmentProcessor> ComposeOneFragmentProcessor::clone() const { |
| 495 | return std::unique_ptr<GrFragmentProcessor>( |
Brian Salomon | 96271cd | 2017-07-31 16:27:23 -0400 | [diff] [blame] | 496 | new ComposeOneFragmentProcessor(this->childProcessor(0).clone(), fMode, fChild)); |
Brian Salomon | fb7c83a | 2017-07-26 13:57:33 -0400 | [diff] [blame] | 497 | } |
| 498 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 499 | ////////////////////////////////////////////////////////////////////////////// |
| 500 | |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 501 | // It may seems as though when the input FP is the dst and the mode is kDst (or same for src/kSrc) |
| 502 | // that these factories could simply return the input FP. However, that doesn't have quite |
| 503 | // the same effect as the returned compose FP will replace the FP's input with solid white and |
| 504 | // ignore the original input. This could be implemented as: |
Brian Osman | c6444d2 | 2019-01-09 16:30:12 -0500 | [diff] [blame] | 505 | // RunInSeries(ConstColor(WHITE, kIgnoreInput), inputFP). |
Brian Salomon | a12c153 | 2017-02-13 12:41:44 -0500 | [diff] [blame] | 506 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 507 | std::unique_ptr<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromDstProcessor( |
| 508 | std::unique_ptr<GrFragmentProcessor> dst, SkBlendMode mode) { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 509 | switch (mode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 510 | case SkBlendMode::kClear: |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 511 | return GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT, |
Ethan Nicholas | e9d172a | 2017-11-20 12:12:24 -0500 | [diff] [blame] | 512 | GrConstColorProcessor::InputMode::kIgnore); |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 513 | case SkBlendMode::kSrc: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 514 | return nullptr; |
| 515 | default: |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 516 | return ComposeOneFragmentProcessor::Make(std::move(dst), mode, |
| 517 | ComposeOneFragmentProcessor::kDst_Child); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 521 | std::unique_ptr<GrFragmentProcessor> GrXfermodeFragmentProcessor::MakeFromSrcProcessor( |
| 522 | std::unique_ptr<GrFragmentProcessor> src, SkBlendMode mode) { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 523 | switch (mode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 524 | case SkBlendMode::kClear: |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 525 | return GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT, |
Ethan Nicholas | e9d172a | 2017-11-20 12:12:24 -0500 | [diff] [blame] | 526 | GrConstColorProcessor::InputMode::kIgnore); |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 527 | case SkBlendMode::kDst: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 528 | return nullptr; |
| 529 | default: |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 530 | return ComposeOneFragmentProcessor::Make(std::move(src), mode, |
| 531 | ComposeOneFragmentProcessor::kSrc_Child); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 532 | } |
| 533 | } |