wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 7 | |
| 8 | #include "effects/GrXfermodeFragmentProcessor.h" |
| 9 | |
| 10 | #include "GrFragmentProcessor.h" |
| 11 | #include "effects/GrConstColorProcessor.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" |
| 15 | #include "glsl/GrGLSLProgramBuilder.h" |
bsalomon | f276ac5 | 2015-10-09 13:36:42 -0700 | [diff] [blame] | 16 | #include "SkGrPriv.h" |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 17 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 18 | class ComposeTwoFragmentProcessor : public GrFragmentProcessor { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 19 | public: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 20 | ComposeTwoFragmentProcessor(const GrFragmentProcessor* src, const GrFragmentProcessor* dst, |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 21 | SkXfermode::Mode mode) |
| 22 | : fMode(mode) { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 23 | this->initClassID<ComposeTwoFragmentProcessor>(); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 24 | SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(src); |
| 25 | SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(dst); |
| 26 | SkASSERT(0 == shaderAChildIndex); |
| 27 | SkASSERT(1 == shaderBChildIndex); |
| 28 | } |
| 29 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 30 | const char* name() const override { return "ComposeTwo"; } |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 31 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 32 | void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 33 | b->add32(fMode); |
| 34 | } |
| 35 | |
| 36 | SkXfermode::Mode getMode() const { return fMode; } |
| 37 | |
| 38 | protected: |
| 39 | bool onIsEqual(const GrFragmentProcessor& other) const override { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 40 | const ComposeTwoFragmentProcessor& cs = other.cast<ComposeTwoFragmentProcessor>(); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 41 | return fMode == cs.fMode; |
| 42 | } |
| 43 | |
| 44 | void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 45 | inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
| 46 | } |
| 47 | |
| 48 | private: |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 49 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 50 | |
| 51 | SkXfermode::Mode fMode; |
| 52 | |
| 53 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 54 | |
| 55 | typedef GrFragmentProcessor INHERITED; |
| 56 | }; |
| 57 | |
| 58 | ///////////////////////////////////////////////////////////////////// |
| 59 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 60 | class GLComposeTwoFragmentProcessor : public GrGLSLFragmentProcessor { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 61 | public: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 62 | GLComposeTwoFragmentProcessor(const GrProcessor& processor) {} |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 63 | |
| 64 | void emitCode(EmitArgs&) override; |
| 65 | |
| 66 | private: |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 67 | typedef GrGLSLFragmentProcessor INHERITED; |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | ///////////////////////////////////////////////////////////////////// |
| 71 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 72 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 73 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 74 | const GrFragmentProcessor* ComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 75 | // Create two random frag procs. |
bsalomon | 506c802 | 2015-09-14 13:16:26 -0700 | [diff] [blame] | 76 | SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChildFP(d)); |
| 77 | SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChildFP(d)); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 78 | |
| 79 | SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 80 | d->fRandom->nextRangeU(0, SkXfermode::kLastMode)); |
| 81 | return new ComposeTwoFragmentProcessor(fpA, fpB, mode); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 82 | } |
| 83 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 84 | GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() const{ |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 85 | return new GLComposeTwoFragmentProcessor(*this); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | ///////////////////////////////////////////////////////////////////// |
| 89 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 90 | void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 91 | |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 92 | GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 93 | const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProcessor>(); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 94 | |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 95 | const char* inputColor = nullptr; |
bsalomon | b5b6032 | 2015-09-14 12:26:33 -0700 | [diff] [blame] | 96 | if (args.fInputColor) { |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 97 | inputColor = "inputColor"; |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 98 | fragBuilder->codeAppendf("vec4 inputColor = vec4(%s.rgb, 1.0);", args.fInputColor); |
bsalomon | b5b6032 | 2015-09-14 12:26:33 -0700 | [diff] [blame] | 99 | } |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 100 | |
| 101 | // declare outputColor and emit the code for each of the two children |
bsalomon | 38ddbad | 2015-09-24 06:00:00 -0700 | [diff] [blame] | 102 | SkString srcColor("src"); |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 103 | this->emitChild(0, inputColor, &srcColor, args); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 104 | |
bsalomon | 38ddbad | 2015-09-24 06:00:00 -0700 | [diff] [blame] | 105 | SkString dstColor("dst"); |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 106 | this->emitChild(1, inputColor, &dstColor, args); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 107 | |
| 108 | // emit blend code |
| 109 | SkXfermode::Mode mode = cs.getMode(); |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 110 | fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkXfermode::ModeName(mode)); |
| 111 | GrGLSLBlend::AppendMode(fragBuilder, |
| 112 | srcColor.c_str(), |
| 113 | dstColor.c_str(), |
| 114 | args.fOutputColor, |
| 115 | mode); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 116 | |
| 117 | // re-multiply the output color by the input color's alpha |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 118 | if (args.fInputColor) { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 119 | fragBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, args.fInputColor); |
bsalomon | b5b6032 | 2015-09-14 12:26:33 -0700 | [diff] [blame] | 120 | } |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 121 | } |
| 122 | |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 123 | const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromTwoProcessors( |
| 124 | const GrFragmentProcessor* src, const GrFragmentProcessor* dst, SkXfermode::Mode mode) { |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 125 | switch (mode) { |
| 126 | case SkXfermode::kClear_Mode: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 127 | return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 128 | GrConstColorProcessor::kIgnore_InputMode); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 129 | case SkXfermode::kSrc_Mode: |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 130 | return SkRef(src); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 131 | case SkXfermode::kDst_Mode: |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 132 | return SkRef(dst); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 133 | default: |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 134 | return new ComposeTwoFragmentProcessor(src, dst, mode); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | ////////////////////////////////////////////////////////////////////////////// |
| 139 | |
| 140 | class ComposeOneFragmentProcessor : public GrFragmentProcessor { |
| 141 | public: |
| 142 | enum Child { |
| 143 | kDst_Child, |
| 144 | kSrc_Child, |
| 145 | }; |
| 146 | |
| 147 | ComposeOneFragmentProcessor(const GrFragmentProcessor* dst, SkXfermode::Mode mode, Child child) |
| 148 | : fMode(mode) |
| 149 | , fChild(child) { |
| 150 | this->initClassID<ComposeOneFragmentProcessor>(); |
| 151 | SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst); |
| 152 | SkASSERT(0 == dstIndex); |
| 153 | } |
| 154 | |
| 155 | const char* name() const override { return "ComposeOne"; } |
| 156 | |
robertphillips | 783a4da | 2015-11-19 14:00:02 -0800 | [diff] [blame^] | 157 | SkString dumpInfo() const override { |
| 158 | SkString str; |
| 159 | |
| 160 | for (int i = 0; i < this->numChildProcessors(); ++i) { |
| 161 | str.append(this->childProcessor(i).dumpInfo()); |
| 162 | } |
| 163 | return str; |
| 164 | } |
| 165 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 166 | void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 167 | GR_STATIC_ASSERT((SkXfermode::kLastMode & SK_MaxU16) == SkXfermode::kLastMode); |
| 168 | b->add32(fMode | (fChild << 16)); |
| 169 | } |
| 170 | |
| 171 | SkXfermode::Mode mode() const { return fMode; } |
| 172 | |
| 173 | Child child() const { return fChild; } |
| 174 | |
| 175 | protected: |
| 176 | bool onIsEqual(const GrFragmentProcessor& that) const override { |
| 177 | return fMode == that.cast<ComposeOneFragmentProcessor>().fMode; |
| 178 | } |
| 179 | |
| 180 | void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 181 | SkXfermode::Coeff skSrcCoeff, skDstCoeff; |
| 182 | if (SkXfermode::ModeAsCoeff(fMode, &skSrcCoeff, &skDstCoeff)) { |
| 183 | GrBlendCoeff srcCoeff = SkXfermodeCoeffToGrBlendCoeff(skSrcCoeff); |
| 184 | GrBlendCoeff dstCoeff = SkXfermodeCoeffToGrBlendCoeff(skDstCoeff); |
| 185 | GrInvariantOutput childOutput(0xFFFFFFFF, kRGBA_GrColorComponentFlags, false); |
| 186 | this->childProcessor(0).computeInvariantOutput(&childOutput); |
| 187 | GrColor blendColor; |
| 188 | GrColorComponentFlags blendFlags; |
| 189 | if (kDst_Child == fChild) { |
| 190 | GrGetCoeffBlendKnownComponents(srcCoeff, dstCoeff, |
| 191 | inout->color(), inout->validFlags(), |
| 192 | childOutput.color(), childOutput.validFlags(), |
| 193 | &blendColor, &blendFlags); |
| 194 | } else { |
| 195 | GrGetCoeffBlendKnownComponents(srcCoeff, dstCoeff, |
| 196 | childOutput.color(), childOutput.validFlags(), |
| 197 | inout->color(), inout->validFlags(), |
| 198 | &blendColor, &blendFlags); |
| 199 | } |
| 200 | // will the shader code reference the input color? |
| 201 | GrInvariantOutput::ReadInput readsInput = GrInvariantOutput::kWillNot_ReadInput; |
| 202 | if (kDst_Child == fChild) { |
| 203 | if (kZero_GrBlendCoeff != srcCoeff || GrBlendCoeffRefsSrc(dstCoeff)) { |
| 204 | readsInput = GrInvariantOutput::kWill_ReadInput; |
| 205 | } |
| 206 | } else { |
| 207 | if (kZero_GrBlendCoeff != dstCoeff || GrBlendCoeffRefsDst(srcCoeff)) { |
| 208 | readsInput = GrInvariantOutput::kWill_ReadInput; |
| 209 | } |
| 210 | } |
| 211 | inout->setToOther(blendFlags, blendColor, readsInput); |
| 212 | } else { |
| 213 | inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | private: |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 218 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 219 | |
| 220 | SkXfermode::Mode fMode; |
| 221 | Child fChild; |
| 222 | |
| 223 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 224 | |
| 225 | typedef GrFragmentProcessor INHERITED; |
| 226 | }; |
| 227 | |
| 228 | ////////////////////////////////////////////////////////////////////////////// |
| 229 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 230 | class GLComposeOneFragmentProcessor : public GrGLSLFragmentProcessor { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 231 | public: |
| 232 | GLComposeOneFragmentProcessor(const GrProcessor& processor) {} |
| 233 | |
| 234 | void emitCode(EmitArgs& args) override { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 235 | GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 236 | SkXfermode::Mode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mode(); |
| 237 | ComposeOneFragmentProcessor::Child child = |
| 238 | args.fFp.cast<ComposeOneFragmentProcessor>().child(); |
bsalomon | 38ddbad | 2015-09-24 06:00:00 -0700 | [diff] [blame] | 239 | SkString childColor("child"); |
| 240 | this->emitChild(0, nullptr, &childColor, args); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 241 | |
| 242 | const char* inputColor = args.fInputColor; |
| 243 | // We don't try to optimize for this case at all |
| 244 | if (!inputColor) { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 245 | fragBuilder->codeAppendf("const vec4 ones = vec4(1);"); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 246 | inputColor = "ones"; |
| 247 | } |
| 248 | |
| 249 | // emit blend code |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 250 | fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkXfermode::ModeName(mode)); |
bsalomon | 38ddbad | 2015-09-24 06:00:00 -0700 | [diff] [blame] | 251 | const char* childStr = childColor.c_str(); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 252 | if (ComposeOneFragmentProcessor::kDst_Child == child) { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 253 | GrGLSLBlend::AppendMode(fragBuilder, inputColor, childStr, args.fOutputColor, mode); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 254 | } else { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 255 | GrGLSLBlend::AppendMode(fragBuilder, childStr, inputColor, args.fOutputColor, mode); |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 256 | } |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | private: |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 260 | typedef GrGLSLFragmentProcessor INHERITED; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | ///////////////////////////////////////////////////////////////////// |
| 264 | |
| 265 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeOneFragmentProcessor); |
| 266 | |
| 267 | const GrFragmentProcessor* ComposeOneFragmentProcessor::TestCreate(GrProcessorTestData* d) { |
| 268 | // Create one random frag procs. |
| 269 | // For now, we'll prevent either children from being a shader with children to prevent the |
| 270 | // possibility of an arbitrarily large tree of procs. |
| 271 | SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d)); |
| 272 | SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( |
| 273 | d->fRandom->nextRangeU(0, SkXfermode::kLastMode)); |
| 274 | ComposeOneFragmentProcessor::Child child = d->fRandom->nextBool() ? |
| 275 | ComposeOneFragmentProcessor::kDst_Child : |
| 276 | ComposeOneFragmentProcessor::kSrc_Child; |
| 277 | return new ComposeOneFragmentProcessor(dst, mode, child); |
| 278 | } |
| 279 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 280 | GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() const { |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 281 | return new GLComposeOneFragmentProcessor(*this); |
| 282 | } |
| 283 | |
| 284 | ////////////////////////////////////////////////////////////////////////////// |
| 285 | |
| 286 | const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromDstProcessor( |
| 287 | const GrFragmentProcessor* dst, SkXfermode::Mode mode) { |
| 288 | switch (mode) { |
| 289 | case SkXfermode::kClear_Mode: |
| 290 | return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, |
| 291 | GrConstColorProcessor::kIgnore_InputMode); |
| 292 | case SkXfermode::kSrc_Mode: |
| 293 | return nullptr; |
| 294 | default: |
| 295 | return new ComposeOneFragmentProcessor(dst, mode, |
| 296 | ComposeOneFragmentProcessor::kDst_Child); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromSrcProcessor( |
| 301 | const GrFragmentProcessor* src, SkXfermode::Mode mode) { |
| 302 | switch (mode) { |
| 303 | case SkXfermode::kClear_Mode: |
| 304 | return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, |
| 305 | GrConstColorProcessor::kIgnore_InputMode); |
| 306 | case SkXfermode::kDst_Mode: |
| 307 | return nullptr; |
| 308 | default: |
| 309 | return new ComposeOneFragmentProcessor(src, mode, |
| 310 | ComposeOneFragmentProcessor::kSrc_Child); |
wangyix | 809e5af | 2015-09-09 12:58:32 -0700 | [diff] [blame] | 311 | } |
| 312 | } |