egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [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/GrCustomXfermode.h" |
egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [diff] [blame] | 9 | |
| 10 | #include "GrCoordTransform.h" |
| 11 | #include "GrContext.h" |
| 12 | #include "GrFragmentProcessor.h" |
| 13 | #include "GrInvariantOutput.h" |
ethannicholas | de4166a | 2015-11-30 08:57:38 -0800 | [diff] [blame] | 14 | #include "GrPipeline.h" |
egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [diff] [blame] | 15 | #include "GrProcessor.h" |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 16 | #include "GrShaderCaps.h" |
egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [diff] [blame] | 17 | #include "GrTexture.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 18 | #include "glsl/GrGLSLBlend.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 19 | #include "glsl/GrGLSLFragmentProcessor.h" |
egdaniel | 2d721d3 | 2015-11-11 13:06:05 -0800 | [diff] [blame] | 20 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 21 | #include "glsl/GrGLSLProgramDataManager.h" |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 22 | #include "glsl/GrGLSLUniformHandler.h" |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 23 | #include "glsl/GrGLSLXferProcessor.h" |
egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [diff] [blame] | 24 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 25 | bool GrCustomXfermode::IsSupportedMode(SkBlendMode mode) { |
| 26 | return (int)mode > (int)SkBlendMode::kLastCoeffMode && |
| 27 | (int)mode <= (int)SkBlendMode::kLastMode; |
egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | /////////////////////////////////////////////////////////////////////////////// |
| 31 | // Static helpers |
| 32 | /////////////////////////////////////////////////////////////////////////////// |
| 33 | |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 34 | static constexpr GrBlendEquation hw_blend_equation(SkBlendMode mode) { |
| 35 | // In C++14 this could be a constexpr int variable. |
| 36 | #define EQ_OFFSET (kOverlay_GrBlendEquation - (int)SkBlendMode::kOverlay) |
| 37 | GR_STATIC_ASSERT(kOverlay_GrBlendEquation == (int)SkBlendMode::kOverlay + EQ_OFFSET); |
| 38 | GR_STATIC_ASSERT(kDarken_GrBlendEquation == (int)SkBlendMode::kDarken + EQ_OFFSET); |
| 39 | GR_STATIC_ASSERT(kLighten_GrBlendEquation == (int)SkBlendMode::kLighten + EQ_OFFSET); |
| 40 | GR_STATIC_ASSERT(kColorDodge_GrBlendEquation == (int)SkBlendMode::kColorDodge + EQ_OFFSET); |
| 41 | GR_STATIC_ASSERT(kColorBurn_GrBlendEquation == (int)SkBlendMode::kColorBurn + EQ_OFFSET); |
| 42 | GR_STATIC_ASSERT(kHardLight_GrBlendEquation == (int)SkBlendMode::kHardLight + EQ_OFFSET); |
| 43 | GR_STATIC_ASSERT(kSoftLight_GrBlendEquation == (int)SkBlendMode::kSoftLight + EQ_OFFSET); |
| 44 | GR_STATIC_ASSERT(kDifference_GrBlendEquation == (int)SkBlendMode::kDifference + EQ_OFFSET); |
| 45 | GR_STATIC_ASSERT(kExclusion_GrBlendEquation == (int)SkBlendMode::kExclusion + EQ_OFFSET); |
| 46 | GR_STATIC_ASSERT(kMultiply_GrBlendEquation == (int)SkBlendMode::kMultiply + EQ_OFFSET); |
| 47 | GR_STATIC_ASSERT(kHSLHue_GrBlendEquation == (int)SkBlendMode::kHue + EQ_OFFSET); |
| 48 | GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == (int)SkBlendMode::kSaturation + EQ_OFFSET); |
| 49 | GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == (int)SkBlendMode::kColor + EQ_OFFSET); |
| 50 | GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == (int)SkBlendMode::kLuminosity + EQ_OFFSET); |
| 51 | GR_STATIC_ASSERT(kGrBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + EQ_OFFSET); |
| 52 | return static_cast<GrBlendEquation>((int)mode + EQ_OFFSET); |
| 53 | #undef EQ_OFFSET |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 54 | } |
| 55 | |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 56 | static bool can_use_hw_blend_equation(GrBlendEquation equation, |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 57 | const GrPipelineAnalysis& analysis, |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 58 | const GrCaps& caps) { |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 59 | if (!caps.advancedBlendEquationSupport()) { |
| 60 | return false; |
| 61 | } |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 62 | if (analysis.fUsesPLSDstRead) { |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 63 | return false; |
| 64 | } |
Brian Salomon | aab259e | 2017-01-17 10:44:34 -0500 | [diff] [blame^] | 65 | if (analysis.fCoveragePOI.isLCDCoverage()) { |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 66 | return false; // LCD coverage must be applied after the blend equation. |
| 67 | } |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 68 | if (caps.canUseAdvancedBlendEquation(equation)) { |
| 69 | return false; |
| 70 | } |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 71 | return true; |
| 72 | } |
| 73 | |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 74 | /////////////////////////////////////////////////////////////////////////////// |
| 75 | // Xfer Processor |
| 76 | /////////////////////////////////////////////////////////////////////////////// |
| 77 | |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 78 | class CustomXP : public GrXferProcessor { |
| 79 | public: |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 80 | CustomXP(SkBlendMode mode, GrBlendEquation hwBlendEquation) |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 81 | : fMode(mode), |
| 82 | fHWBlendEquation(hwBlendEquation) { |
| 83 | this->initClassID<CustomXP>(); |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 86 | CustomXP(const DstTexture* dstTexture, bool hasMixedSamples, SkBlendMode mode) |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 87 | : INHERITED(dstTexture, true, hasMixedSamples), |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 88 | fMode(mode), |
| 89 | fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { |
| 90 | this->initClassID<CustomXP>(); |
| 91 | } |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 92 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 93 | const char* name() const override { return "Custom Xfermode"; } |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 94 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 95 | GrGLSLXferProcessor* createGLSLInstance() const override; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 96 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 97 | SkBlendMode mode() const { return fMode; } |
bsalomon | f7cc877 | 2015-05-11 11:21:14 -0700 | [diff] [blame] | 98 | bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEquation); } |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 99 | |
| 100 | GrBlendEquation hwBlendEquation() const { |
| 101 | SkASSERT(this->hasHWBlendEquation()); |
| 102 | return fHWBlendEquation; |
| 103 | } |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 104 | |
| 105 | private: |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 106 | GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineAnalysis&, |
egdaniel | c19cdc2 | 2015-05-10 08:45:18 -0700 | [diff] [blame] | 107 | bool doesStencilWrite, |
| 108 | GrColor* overrideColor, |
egdaniel | 56cf6dc | 2015-11-30 10:15:58 -0800 | [diff] [blame] | 109 | const GrCaps& caps) const override; |
egdaniel | c19cdc2 | 2015-05-10 08:45:18 -0700 | [diff] [blame] | 110 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 111 | void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 112 | |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 113 | GrXferBarrierType onXferBarrier(const GrRenderTarget*, const GrCaps&) const override; |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 114 | |
| 115 | void onGetBlendInfo(BlendInfo*) const override; |
| 116 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 117 | bool onIsEqual(const GrXferProcessor& xpBase) const override; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 118 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 119 | const SkBlendMode fMode; |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 120 | const GrBlendEquation fHWBlendEquation; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 121 | |
| 122 | typedef GrXferProcessor INHERITED; |
| 123 | }; |
| 124 | |
| 125 | /////////////////////////////////////////////////////////////////////////////// |
| 126 | |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 127 | class GLCustomXP : public GrGLSLXferProcessor { |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 128 | public: |
| 129 | GLCustomXP(const GrXferProcessor&) {} |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 130 | ~GLCustomXP() override {} |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 131 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 132 | static void GenKey(const GrXferProcessor& p, const GrShaderCaps& caps, |
| 133 | GrProcessorKeyBuilder* b) { |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 134 | const CustomXP& xp = p.cast<CustomXP>(); |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 135 | uint32_t key = 0; |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 136 | if (xp.hasHWBlendEquation()) { |
| 137 | SkASSERT(caps.advBlendEqInteraction() > 0); // 0 will mean !xp.hasHWBlendEquation(). |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 138 | key |= caps.advBlendEqInteraction(); |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 139 | GR_STATIC_ASSERT(GrShaderCaps::kLast_AdvBlendEqInteraction < 4); |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 140 | } |
| 141 | if (!xp.hasHWBlendEquation() || caps.mustEnableSpecificAdvBlendEqs()) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 142 | key |= (int)xp.mode() << 3; |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 143 | } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 144 | b->add32(key); |
| 145 | } |
| 146 | |
| 147 | private: |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 148 | void emitOutputsForBlendState(const EmitArgs& args) override { |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 149 | const CustomXP& xp = args.fXP.cast<CustomXP>(); |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 150 | SkASSERT(xp.hasHWBlendEquation()); |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 151 | |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 152 | GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder; |
| 153 | fragBuilder->enableAdvancedBlendEquationIfNeeded(xp.hwBlendEquation()); |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 154 | |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 155 | // Apply coverage by multiplying it into the src color before blending. Mixed samples will |
| 156 | // "just work" automatically. (See onGetOptimizations()) |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 157 | fragBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInputCoverage, |
| 158 | args.fInputColor); |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 159 | } |
| 160 | |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 161 | void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder, |
| 162 | GrGLSLUniformHandler* uniformHandler, |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 163 | const char* srcColor, |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 164 | const char* srcCoverage, |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 165 | const char* dstColor, |
| 166 | const char* outColor, |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 167 | const char* outColorSecondary, |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 168 | const GrXferProcessor& proc) override { |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 169 | const CustomXP& xp = proc.cast<CustomXP>(); |
| 170 | SkASSERT(!xp.hasHWBlendEquation()); |
| 171 | |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 172 | GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mode()); |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 173 | |
| 174 | // Apply coverage. |
robertphillips | f42fca4 | 2016-01-27 05:00:04 -0800 | [diff] [blame] | 175 | INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor, |
| 176 | outColorSecondary, xp); |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 177 | } |
| 178 | |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 179 | void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {} |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 180 | |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 181 | typedef GrGLSLXferProcessor INHERITED; |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | /////////////////////////////////////////////////////////////////////////////// |
| 185 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 186 | void CustomXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 187 | GLCustomXP::GenKey(*this, caps, b); |
| 188 | } |
| 189 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 190 | GrGLSLXferProcessor* CustomXP::createGLSLInstance() const { |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 191 | SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation()); |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 192 | return new GLCustomXP(*this); |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 193 | } |
| 194 | |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 195 | bool CustomXP::onIsEqual(const GrXferProcessor& other) const { |
| 196 | const CustomXP& s = other.cast<CustomXP>(); |
egdaniel | c19cdc2 | 2015-05-10 08:45:18 -0700 | [diff] [blame] | 197 | return fMode == s.fMode && fHWBlendEquation == s.fHWBlendEquation; |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 198 | } |
| 199 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 200 | GrXferProcessor::OptFlags CustomXP::onGetOptimizations(const GrPipelineAnalysis& analysis, |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 201 | bool doesStencilWrite, |
| 202 | GrColor* overrideColor, |
egdaniel | 56cf6dc | 2015-11-30 10:15:58 -0800 | [diff] [blame] | 203 | const GrCaps& caps) const { |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 204 | /* |
| 205 | Most the optimizations we do here are based on tweaking alpha for coverage. |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 206 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 207 | The general SVG blend equation is defined in the spec as follows: |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 208 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 209 | Dca' = B(Sc, Dc) * Sa * Da + Y * Sca * (1-Da) + Z * Dca * (1-Sa) |
| 210 | Da' = X * Sa * Da + Y * Sa * (1-Da) + Z * Da * (1-Sa) |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 211 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 212 | (Note that Sca, Dca indicate RGB vectors that are premultiplied by alpha, |
| 213 | and that B(Sc, Dc) is a mode-specific function that accepts non-multiplied |
| 214 | RGB colors.) |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 215 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 216 | For every blend mode supported by this class, i.e. the "advanced" blend |
| 217 | modes, X=Y=Z=1 and this equation reduces to the PDF blend equation. |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 218 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 219 | It can be shown that when X=Y=Z=1, these equations can modulate alpha for |
| 220 | coverage. |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 221 | |
| 222 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 223 | == Color == |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 224 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 225 | We substitute Y=Z=1 and define a blend() function that calculates Dca' in |
| 226 | terms of premultiplied alpha only: |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 227 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 228 | blend(Sca, Dca, Sa, Da) = {Dca : if Sa == 0, |
| 229 | Sca : if Da == 0, |
| 230 | B(Sca/Sa, Dca/Da) * Sa * Da + Sca * (1-Da) + Dca * (1-Sa) : if |
| 231 | Sa,Da != 0} |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 232 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 233 | And for coverage modulation, we use a post blend src-over model: |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 234 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 235 | Dca'' = f * blend(Sca, Dca, Sa, Da) + (1-f) * Dca |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 236 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 237 | (Where f is the fractional coverage.) |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 238 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 239 | Next we show that canTweakAlphaForCoverage() is true by proving the |
| 240 | following relationship: |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 241 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 242 | blend(f*Sca, Dca, f*Sa, Da) == f * blend(Sca, Dca, Sa, Da) + (1-f) * Dca |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 243 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 244 | General case (f,Sa,Da != 0): |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 245 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 246 | f * blend(Sca, Dca, Sa, Da) + (1-f) * Dca |
| 247 | = f * (B(Sca/Sa, Dca/Da) * Sa * Da + Sca * (1-Da) + Dca * (1-Sa)) + (1-f) * Dca [Sa,Da != |
| 248 | 0, definition of blend()] |
| 249 | = B(Sca/Sa, Dca/Da) * f*Sa * Da + f*Sca * (1-Da) + f*Dca * (1-Sa) + Dca - f*Dca |
| 250 | = B(Sca/Sa, Dca/Da) * f*Sa * Da + f*Sca - f*Sca * Da + f*Dca - f*Dca * Sa + Dca - f*Dca |
| 251 | = B(Sca/Sa, Dca/Da) * f*Sa * Da + f*Sca - f*Sca * Da - f*Dca * Sa + Dca |
| 252 | = B(Sca/Sa, Dca/Da) * f*Sa * Da + f*Sca * (1-Da) - f*Dca * Sa + Dca |
| 253 | = B(Sca/Sa, Dca/Da) * f*Sa * Da + f*Sca * (1-Da) + Dca * (1 - f*Sa) |
| 254 | = B(f*Sca/f*Sa, Dca/Da) * f*Sa * Da + f*Sca * (1-Da) + Dca * (1 - f*Sa) [f!=0] |
| 255 | = blend(f*Sca, Dca, f*Sa, Da) [definition of blend()] |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 256 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 257 | Corner cases (Sa=0, Da=0, and f=0): |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 258 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 259 | Sa=0: f * blend(Sca, Dca, Sa, Da) + (1-f) * Dca |
| 260 | = f * Dca + (1-f) * Dca [Sa=0, definition of blend()] |
| 261 | = Dca |
| 262 | = blend(0, Dca, 0, Da) [definition of blend()] |
| 263 | = blend(f*Sca, Dca, f*Sa, Da) [Sa=0] |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 264 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 265 | Da=0: f * blend(Sca, Dca, Sa, Da) + (1-f) * Dca |
| 266 | = f * Sca + (1-f) * Dca [Da=0, definition of blend()] |
| 267 | = f * Sca [Da=0] |
| 268 | = blend(f*Sca, 0, f*Sa, 0) [definition of blend()] |
| 269 | = blend(f*Sca, Dca, f*Sa, Da) [Da=0] |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 270 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 271 | f=0: f * blend(Sca, Dca, Sa, Da) + (1-f) * Dca |
| 272 | = Dca [f=0] |
| 273 | = blend(0, Dca, 0, Da) [definition of blend()] |
| 274 | = blend(f*Sca, Dca, f*Sa, Da) [f=0] |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 275 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 276 | == Alpha == |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 277 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 278 | We substitute X=Y=Z=1 and define a blend() function that calculates Da': |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 279 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 280 | blend(Sa, Da) = Sa * Da + Sa * (1-Da) + Da * (1-Sa) |
| 281 | = Sa * Da + Sa - Sa * Da + Da - Da * Sa |
| 282 | = Sa + Da - Sa * Da |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 283 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 284 | We use the same model for coverage modulation as we did with color: |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 285 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 286 | Da'' = f * blend(Sa, Da) + (1-f) * Da |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 287 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 288 | And show that canTweakAlphaForCoverage() is true by proving the following |
| 289 | relationship: |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 290 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 291 | blend(f*Sa, Da) == f * blend(Sa, Da) + (1-f) * Da |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 292 | |
| 293 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 294 | f * blend(Sa, Da) + (1-f) * Da |
| 295 | = f * (Sa + Da - Sa * Da) + (1-f) * Da |
| 296 | = f*Sa + f*Da - f*Sa * Da + Da - f*Da |
| 297 | = f*Sa - f*Sa * Da + Da |
| 298 | = f*Sa + Da - f*Sa * Da |
| 299 | = blend(f*Sa, Da) |
| 300 | */ |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 301 | |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 302 | OptFlags flags = kNone_OptFlags; |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 303 | if (analysis.fColorPOI.allStagesMultiplyInput()) { |
cdalton | 3211770 | 2015-05-11 11:21:23 -0700 | [diff] [blame] | 304 | flags |= kCanTweakAlphaForCoverage_OptFlag; |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 305 | } |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 306 | return flags; |
| 307 | } |
| 308 | |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 309 | GrXferBarrierType CustomXP::onXferBarrier(const GrRenderTarget* rt, const GrCaps& caps) const { |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 310 | if (this->hasHWBlendEquation() && !caps.advancedCoherentBlendEquationSupport()) { |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 311 | return kBlend_GrXferBarrierType; |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 312 | } |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 313 | return kNone_GrXferBarrierType; |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | void CustomXP::onGetBlendInfo(BlendInfo* blendInfo) const { |
| 317 | if (this->hasHWBlendEquation()) { |
| 318 | blendInfo->fEquation = this->hwBlendEquation(); |
| 319 | } |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | /////////////////////////////////////////////////////////////////////////////// |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 323 | |
| 324 | // See the comment above GrXPFactory's definition about this warning suppression. |
| 325 | #if defined(__GNUC__) || defined(__clang) |
| 326 | #pragma GCC diagnostic push |
| 327 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
| 328 | #endif |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 329 | class CustomXPFactory : public GrXPFactory { |
| 330 | public: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 331 | constexpr CustomXPFactory(SkBlendMode mode) |
| 332 | : fMode(mode), fHWBlendEquation(hw_blend_equation(mode)) {} |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 333 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 334 | void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 335 | GrXPFactory::InvariantBlendedColor*) const override; |
| 336 | |
| 337 | private: |
| 338 | GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 339 | const GrPipelineAnalysis&, |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 340 | bool hasMixedSamples, |
| 341 | const DstTexture*) const override; |
| 342 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 343 | bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const override; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 344 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 345 | |
| 346 | GR_DECLARE_XP_FACTORY_TEST; |
| 347 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 348 | SkBlendMode fMode; |
| 349 | GrBlendEquation fHWBlendEquation; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 350 | |
| 351 | typedef GrXPFactory INHERITED; |
| 352 | }; |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 353 | #if defined(__GNUC__) || defined(__clang) |
| 354 | #pragma GCC diagnostic pop |
| 355 | #endif |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 356 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 357 | GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 358 | const GrPipelineAnalysis& analysis, |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 359 | bool hasMixedSamples, |
| 360 | const DstTexture* dstTexture) const { |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 361 | SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 362 | if (can_use_hw_blend_equation(fHWBlendEquation, analysis, caps)) { |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 363 | SkASSERT(!dstTexture || !dstTexture->texture()); |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 364 | return new CustomXP(fMode, fHWBlendEquation); |
cdalton | f0df189 | 2015-06-05 13:26:20 -0700 | [diff] [blame] | 365 | } |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 366 | return new CustomXP(dstTexture, hasMixedSamples, fMode); |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 367 | } |
| 368 | |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 369 | bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps, |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 370 | const GrPipelineAnalysis& analysis) const { |
| 371 | return !can_use_hw_blend_equation(fHWBlendEquation, analysis, caps); |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 372 | } |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 373 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 374 | void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 375 | InvariantBlendedColor* blendedColor) const { |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 376 | blendedColor->fWillBlendWithDst = true; |
| 377 | blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 378 | } |
| 379 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 380 | GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 381 | const GrXPFactory* CustomXPFactory::TestGet(GrProcessorTestData* d) { |
Mike Reed | d470673 | 2016-11-15 16:44:34 -0500 | [diff] [blame] | 382 | int mode = d->fRandom->nextRangeU((int)SkBlendMode::kLastCoeffMode + 1, |
| 383 | (int)SkBlendMode::kLastSeparableMode); |
egdaniel | 54f0e9d | 2015-01-16 06:29:47 -0800 | [diff] [blame] | 384 | |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 385 | return GrCustomXfermode::Get((SkBlendMode)mode); |
egdaniel | 0063a9b | 2015-01-15 10:52:32 -0800 | [diff] [blame] | 386 | } |
| 387 | |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 388 | /////////////////////////////////////////////////////////////////////////////// |
| 389 | |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 390 | const GrXPFactory* GrCustomXfermode::Get(SkBlendMode mode) { |
| 391 | // If these objects are constructed as static constexpr by cl.exe (2015 SP2) the vtables are |
| 392 | // null. |
| 393 | #ifdef SK_BUILD_FOR_WIN |
| 394 | #define _CONSTEXPR_ |
| 395 | #else |
| 396 | #define _CONSTEXPR_ constexpr |
| 397 | #endif |
| 398 | static _CONSTEXPR_ const CustomXPFactory gOverlay(SkBlendMode::kOverlay); |
| 399 | static _CONSTEXPR_ const CustomXPFactory gDarken(SkBlendMode::kDarken); |
| 400 | static _CONSTEXPR_ const CustomXPFactory gLighten(SkBlendMode::kLighten); |
| 401 | static _CONSTEXPR_ const CustomXPFactory gColorDodge(SkBlendMode::kColorDodge); |
| 402 | static _CONSTEXPR_ const CustomXPFactory gColorBurn(SkBlendMode::kColorBurn); |
| 403 | static _CONSTEXPR_ const CustomXPFactory gHardLight(SkBlendMode::kHardLight); |
| 404 | static _CONSTEXPR_ const CustomXPFactory gSoftLight(SkBlendMode::kSoftLight); |
| 405 | static _CONSTEXPR_ const CustomXPFactory gDifference(SkBlendMode::kDifference); |
| 406 | static _CONSTEXPR_ const CustomXPFactory gExclusion(SkBlendMode::kExclusion); |
| 407 | static _CONSTEXPR_ const CustomXPFactory gMultiply(SkBlendMode::kMultiply); |
| 408 | static _CONSTEXPR_ const CustomXPFactory gHue(SkBlendMode::kHue); |
| 409 | static _CONSTEXPR_ const CustomXPFactory gSaturation(SkBlendMode::kSaturation); |
| 410 | static _CONSTEXPR_ const CustomXPFactory gColor(SkBlendMode::kColor); |
| 411 | static _CONSTEXPR_ const CustomXPFactory gLuminosity(SkBlendMode::kLuminosity); |
| 412 | #undef _CONSTEXPR_ |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 413 | switch (mode) { |
| 414 | case SkBlendMode::kOverlay: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 415 | return &gOverlay; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 416 | case SkBlendMode::kDarken: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 417 | return &gDarken; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 418 | case SkBlendMode::kLighten: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 419 | return &gLighten; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 420 | case SkBlendMode::kColorDodge: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 421 | return &gColorDodge; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 422 | case SkBlendMode::kColorBurn: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 423 | return &gColorBurn; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 424 | case SkBlendMode::kHardLight: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 425 | return &gHardLight; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 426 | case SkBlendMode::kSoftLight: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 427 | return &gSoftLight; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 428 | case SkBlendMode::kDifference: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 429 | return &gDifference; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 430 | case SkBlendMode::kExclusion: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 431 | return &gExclusion; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 432 | case SkBlendMode::kMultiply: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 433 | return &gMultiply; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 434 | case SkBlendMode::kHue: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 435 | return &gHue; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 436 | case SkBlendMode::kSaturation: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 437 | return &gSaturation; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 438 | case SkBlendMode::kColor: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 439 | return &gColor; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 440 | case SkBlendMode::kLuminosity: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 441 | return &gLuminosity; |
Brian Salomon | c747bb6 | 2017-01-06 16:17:50 -0500 | [diff] [blame] | 442 | default: |
| 443 | SkASSERT(!GrCustomXfermode::IsSupportedMode(mode)); |
| 444 | return nullptr; |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 445 | } |
| 446 | } |