egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2014 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | #include "effects/GrCoverageSetOpXP.h" |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 10 | #include "GrCaps.h" |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 11 | #include "GrColor.h" |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 12 | #include "GrPipeline.h" |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 13 | #include "GrProcessor.h" |
| 14 | #include "GrProcOptInfo.h" |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 15 | #include "glsl/GrGLSLBlend.h" |
egdaniel | 2d721d3 | 2015-11-11 13:06:05 -0800 | [diff] [blame] | 16 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 17 | #include "glsl/GrGLSLUniformHandler.h" |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 18 | #include "glsl/GrGLSLXferProcessor.h" |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 19 | |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 20 | class CoverageSetOpXP : public GrXferProcessor { |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 21 | public: |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 22 | static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 23 | return new CoverageSetOpXP(regionOp, invertCoverage); |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 24 | } |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 25 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 26 | ~CoverageSetOpXP() override; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 27 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 28 | const char* name() const override { return "Coverage Set Op"; } |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 29 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 30 | GrGLSLXferProcessor* createGLSLInstance() const override; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 31 | |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 32 | bool invertCoverage() const { return fInvertCoverage; } |
| 33 | |
| 34 | private: |
| 35 | CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
| 36 | |
ethannicholas | de4166a | 2015-11-30 08:57:38 -0800 | [diff] [blame] | 37 | GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations& optimizations, |
egdaniel | c19cdc2 | 2015-05-10 08:45:18 -0700 | [diff] [blame] | 38 | bool doesStencilWrite, |
| 39 | GrColor* color, |
egdaniel | 56cf6dc | 2015-11-30 10:15:58 -0800 | [diff] [blame] | 40 | const GrCaps& caps) const override; |
egdaniel | c19cdc2 | 2015-05-10 08:45:18 -0700 | [diff] [blame] | 41 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 42 | void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override; |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 43 | |
cdalton | f4f2b44 | 2015-04-23 09:40:23 -0700 | [diff] [blame] | 44 | void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
| 45 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 46 | bool onIsEqual(const GrXferProcessor& xpBase) const override { |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 47 | const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); |
| 48 | return (fRegionOp == xp.fRegionOp && |
| 49 | fInvertCoverage == xp.fInvertCoverage); |
| 50 | } |
| 51 | |
| 52 | SkRegion::Op fRegionOp; |
| 53 | bool fInvertCoverage; |
| 54 | |
| 55 | typedef GrXferProcessor INHERITED; |
| 56 | }; |
| 57 | |
| 58 | /////////////////////////////////////////////////////////////////////////////// |
| 59 | |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 60 | class GLCoverageSetOpXP : public GrGLSLXferProcessor { |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 61 | public: |
| 62 | GLCoverageSetOpXP(const GrProcessor&) {} |
| 63 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 64 | ~GLCoverageSetOpXP() override {} |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 65 | |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 66 | static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 67 | GrProcessorKeyBuilder* b) { |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 68 | const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>(); |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 69 | uint32_t key = xp.invertCoverage() ? 0x0 : 0x1; |
| 70 | b->add32(key); |
| 71 | }; |
| 72 | |
| 73 | private: |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 74 | void emitOutputsForBlendState(const EmitArgs& args) override { |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 75 | const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>(); |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 76 | GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 77 | |
| 78 | if (xp.invertCoverage()) { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 79 | fragBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.fInputCoverage); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 80 | } else { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 81 | fragBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputCoverage); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 85 | void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 86 | |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 87 | typedef GrGLSLXferProcessor INHERITED; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /////////////////////////////////////////////////////////////////////////////// |
| 91 | |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 92 | CoverageSetOpXP::CoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage) |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 93 | : fRegionOp(regionOp) |
| 94 | , fInvertCoverage(invertCoverage) { |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 95 | this->initClassID<CoverageSetOpXP>(); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 96 | } |
| 97 | |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 98 | CoverageSetOpXP::~CoverageSetOpXP() { |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 99 | } |
| 100 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 101 | void CoverageSetOpXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 102 | GrProcessorKeyBuilder* b) const { |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 103 | GLCoverageSetOpXP::GenKey(*this, caps, b); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 104 | } |
| 105 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 106 | GrGLSLXferProcessor* CoverageSetOpXP::createGLSLInstance() const { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 107 | return new GLCoverageSetOpXP(*this); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | GrXferProcessor::OptFlags |
ethannicholas | de4166a | 2015-11-30 08:57:38 -0800 | [diff] [blame] | 111 | CoverageSetOpXP::onGetOptimizations(const GrPipelineOptimizations& optimizations, |
egdaniel | c19cdc2 | 2015-05-10 08:45:18 -0700 | [diff] [blame] | 112 | bool doesStencilWrite, |
| 113 | GrColor* color, |
egdaniel | 56cf6dc | 2015-11-30 10:15:58 -0800 | [diff] [blame] | 114 | const GrCaps& caps) const { |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 115 | // We never look at the color input |
| 116 | return GrXferProcessor::kIgnoreColor_OptFlag; |
| 117 | } |
| 118 | |
cdalton | f4f2b44 | 2015-04-23 09:40:23 -0700 | [diff] [blame] | 119 | void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const { |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 120 | switch (fRegionOp) { |
| 121 | case SkRegion::kReplace_Op: |
| 122 | blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
| 123 | blendInfo->fDstBlend = kZero_GrBlendCoeff; |
| 124 | break; |
| 125 | case SkRegion::kIntersect_Op: |
| 126 | blendInfo->fSrcBlend = kDC_GrBlendCoeff; |
| 127 | blendInfo->fDstBlend = kZero_GrBlendCoeff; |
| 128 | break; |
| 129 | case SkRegion::kUnion_Op: |
| 130 | blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
| 131 | blendInfo->fDstBlend = kISC_GrBlendCoeff; |
| 132 | break; |
| 133 | case SkRegion::kXOR_Op: |
| 134 | blendInfo->fSrcBlend = kIDC_GrBlendCoeff; |
| 135 | blendInfo->fDstBlend = kISC_GrBlendCoeff; |
| 136 | break; |
| 137 | case SkRegion::kDifference_Op: |
| 138 | blendInfo->fSrcBlend = kZero_GrBlendCoeff; |
| 139 | blendInfo->fDstBlend = kISC_GrBlendCoeff; |
| 140 | break; |
| 141 | case SkRegion::kReverseDifference_Op: |
| 142 | blendInfo->fSrcBlend = kIDC_GrBlendCoeff; |
| 143 | blendInfo->fDstBlend = kZero_GrBlendCoeff; |
| 144 | break; |
| 145 | } |
| 146 | blendInfo->fBlendConstant = 0; |
| 147 | } |
| 148 | |
| 149 | /////////////////////////////////////////////////////////////////////////////// |
| 150 | |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 151 | class ShaderCSOXferProcessor : public GrXferProcessor { |
| 152 | public: |
| 153 | ShaderCSOXferProcessor(const DstTexture* dstTexture, |
| 154 | bool hasMixedSamples, |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 155 | SkRegion::Op regionOp, |
| 156 | bool invertCoverage) |
| 157 | : INHERITED(dstTexture, true, hasMixedSamples) |
| 158 | , fRegionOp(regionOp) |
| 159 | , fInvertCoverage(invertCoverage) { |
| 160 | this->initClassID<ShaderCSOXferProcessor>(); |
| 161 | } |
| 162 | |
| 163 | const char* name() const override { return "Coverage Set Op Shader"; } |
| 164 | |
| 165 | GrGLSLXferProcessor* createGLSLInstance() const override; |
| 166 | |
| 167 | SkRegion::Op regionOp() const { return fRegionOp; } |
| 168 | bool invertCoverage() const { return fInvertCoverage; } |
| 169 | |
| 170 | private: |
| 171 | GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&, bool, GrColor*, |
| 172 | const GrCaps&) const override { |
| 173 | // We never look at the color input |
| 174 | return GrXferProcessor::kIgnoreColor_OptFlag; |
| 175 | } |
| 176 | |
| 177 | void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override; |
| 178 | |
| 179 | bool onIsEqual(const GrXferProcessor& xpBase) const override { |
| 180 | const ShaderCSOXferProcessor& xp = xpBase.cast<ShaderCSOXferProcessor>(); |
| 181 | return (fRegionOp == xp.fRegionOp && |
| 182 | fInvertCoverage == xp.fInvertCoverage); |
| 183 | } |
| 184 | |
| 185 | SkRegion::Op fRegionOp; |
| 186 | bool fInvertCoverage; |
| 187 | |
| 188 | typedef GrXferProcessor INHERITED; |
| 189 | }; |
| 190 | |
| 191 | /////////////////////////////////////////////////////////////////////////////// |
| 192 | |
| 193 | class GLShaderCSOXferProcessor : public GrGLSLXferProcessor { |
| 194 | public: |
| 195 | static void GenKey(const GrProcessor& processor, GrProcessorKeyBuilder* b) { |
| 196 | const ShaderCSOXferProcessor& xp = processor.cast<ShaderCSOXferProcessor>(); |
| 197 | b->add32(xp.regionOp()); |
| 198 | uint32_t key = xp.invertCoverage() ? 0x0 : 0x1; |
| 199 | b->add32(key); |
| 200 | } |
| 201 | |
| 202 | private: |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 203 | void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder, |
| 204 | GrGLSLUniformHandler* uniformHandler, |
egdaniel | f34b293 | 2015-12-01 13:54:06 -0800 | [diff] [blame] | 205 | const char* srcColor, |
| 206 | const char* srcCoverage, |
| 207 | const char* dstColor, |
| 208 | const char* outColor, |
| 209 | const char* outColorSecondary, |
| 210 | const GrXferProcessor& proc) override { |
| 211 | const ShaderCSOXferProcessor& xp = proc.cast<ShaderCSOXferProcessor>(); |
| 212 | |
| 213 | if (xp.invertCoverage()) { |
| 214 | fragBuilder->codeAppendf("%s = 1.0 - %s;", outColor, srcCoverage); |
| 215 | } else { |
| 216 | fragBuilder->codeAppendf("%s = %s;", outColor, srcCoverage); |
| 217 | } |
| 218 | |
| 219 | GrGLSLBlend::AppendRegionOp(fragBuilder, outColor, dstColor, outColor, xp.regionOp()); |
| 220 | } |
| 221 | |
| 222 | void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {} |
| 223 | |
| 224 | typedef GrGLSLXferProcessor INHERITED; |
| 225 | }; |
| 226 | |
| 227 | /////////////////////////////////////////////////////////////////////////////// |
| 228 | |
| 229 | void ShaderCSOXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&, |
| 230 | GrProcessorKeyBuilder* b) const { |
| 231 | GLShaderCSOXferProcessor::GenKey(*this, b); |
| 232 | } |
| 233 | |
| 234 | GrGLSLXferProcessor* ShaderCSOXferProcessor::createGLSLInstance() const { |
| 235 | return new GLShaderCSOXferProcessor; |
| 236 | } |
| 237 | |
| 238 | /////////////////////////////////////////////////////////////////////////////// |
| 239 | // |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 240 | GrCoverageSetOpXPFactory::GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) |
| 241 | : fRegionOp(regionOp) |
| 242 | , fInvertCoverage(invertCoverage) { |
| 243 | this->initClassID<GrCoverageSetOpXPFactory>(); |
| 244 | } |
| 245 | |
| 246 | GrXPFactory* GrCoverageSetOpXPFactory::Create(SkRegion::Op regionOp, bool invertCoverage) { |
| 247 | switch (regionOp) { |
| 248 | case SkRegion::kReplace_Op: { |
| 249 | if (invertCoverage) { |
| 250 | static GrCoverageSetOpXPFactory gReplaceCDXPFI(regionOp, invertCoverage); |
| 251 | return SkRef(&gReplaceCDXPFI); |
| 252 | } else { |
| 253 | static GrCoverageSetOpXPFactory gReplaceCDXPF(regionOp, invertCoverage); |
| 254 | return SkRef(&gReplaceCDXPF); |
| 255 | } |
| 256 | break; |
| 257 | } |
| 258 | case SkRegion::kIntersect_Op: { |
| 259 | if (invertCoverage) { |
| 260 | static GrCoverageSetOpXPFactory gIntersectCDXPFI(regionOp, invertCoverage); |
| 261 | return SkRef(&gIntersectCDXPFI); |
| 262 | } else { |
| 263 | static GrCoverageSetOpXPFactory gIntersectCDXPF(regionOp, invertCoverage); |
| 264 | return SkRef(&gIntersectCDXPF); |
| 265 | } |
| 266 | break; |
| 267 | } |
| 268 | case SkRegion::kUnion_Op: { |
| 269 | if (invertCoverage) { |
| 270 | static GrCoverageSetOpXPFactory gUnionCDXPFI(regionOp, invertCoverage); |
| 271 | return SkRef(&gUnionCDXPFI); |
| 272 | } else { |
| 273 | static GrCoverageSetOpXPFactory gUnionCDXPF(regionOp, invertCoverage); |
| 274 | return SkRef(&gUnionCDXPF); |
| 275 | } |
| 276 | break; |
| 277 | } |
| 278 | case SkRegion::kXOR_Op: { |
| 279 | if (invertCoverage) { |
| 280 | static GrCoverageSetOpXPFactory gXORCDXPFI(regionOp, invertCoverage); |
| 281 | return SkRef(&gXORCDXPFI); |
| 282 | } else { |
| 283 | static GrCoverageSetOpXPFactory gXORCDXPF(regionOp, invertCoverage); |
| 284 | return SkRef(&gXORCDXPF); |
| 285 | } |
| 286 | break; |
| 287 | } |
| 288 | case SkRegion::kDifference_Op: { |
| 289 | if (invertCoverage) { |
| 290 | static GrCoverageSetOpXPFactory gDifferenceCDXPFI(regionOp, invertCoverage); |
| 291 | return SkRef(&gDifferenceCDXPFI); |
| 292 | } else { |
| 293 | static GrCoverageSetOpXPFactory gDifferenceCDXPF(regionOp, invertCoverage); |
| 294 | return SkRef(&gDifferenceCDXPF); |
| 295 | } |
| 296 | break; |
| 297 | } |
| 298 | case SkRegion::kReverseDifference_Op: { |
| 299 | if (invertCoverage) { |
| 300 | static GrCoverageSetOpXPFactory gRevDiffCDXPFI(regionOp, invertCoverage); |
| 301 | return SkRef(&gRevDiffCDXPFI); |
| 302 | } else { |
| 303 | static GrCoverageSetOpXPFactory gRevDiffCDXPF(regionOp, invertCoverage); |
| 304 | return SkRef(&gRevDiffCDXPF); |
| 305 | } |
| 306 | break; |
| 307 | } |
| 308 | default: |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 309 | return nullptr; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 310 | } |
| 311 | } |
| 312 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 313 | GrXferProcessor* |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 314 | GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps, |
ethannicholas | de4166a | 2015-11-30 08:57:38 -0800 | [diff] [blame] | 315 | const GrPipelineOptimizations& optimizations, |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 316 | bool hasMixedSamples, |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 317 | const DstTexture* dst) const { |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 318 | // We don't support inverting coverage with mixed samples. We don't expect to ever want this in |
| 319 | // the future, however we could at some point make this work using an inverted coverage |
| 320 | // modulation table. Note that an inverted table still won't work if there are coverage procs. |
| 321 | if (fInvertCoverage && hasMixedSamples) { |
| 322 | SkASSERT(false); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 323 | return nullptr; |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 324 | } |
| 325 | |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 326 | if (optimizations.fOverrides.fUsePLSDstRead) { |
| 327 | return new ShaderCSOXferProcessor(dst, hasMixedSamples, fRegionOp, fInvertCoverage); |
| 328 | } |
egdaniel | 41d4f09 | 2015-02-09 07:51:00 -0800 | [diff] [blame] | 329 | return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 330 | } |
| 331 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 332 | void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 333 | InvariantBlendedColor* blendedColor) const { |
| 334 | blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; |
| 335 | blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 336 | } |
| 337 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 338 | GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); |
| 339 | |
bsalomon | c21b09e | 2015-08-28 18:46:56 -0700 | [diff] [blame] | 340 | const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) { |
joshualitt | 0067ff5 | 2015-07-08 14:26:19 -0700 | [diff] [blame] | 341 | SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLastOp + 1)); |
cdalton | c94cd7c | 2015-11-12 12:11:04 -0800 | [diff] [blame] | 342 | bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->nextBool(); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 343 | return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); |
| 344 | } |
| 345 | |