Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/gpu/effects/GrCoverageSetOpXP.cpp

Issue 1170553002: Apply coverage in XP base class when using dst reads (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_reenablebea
Patch Set: names Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrXferProcessor.cpp ('k') | src/gpu/effects/GrCustomXfermode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "effects/GrCoverageSetOpXP.h" 9 #include "effects/GrCoverageSetOpXP.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrProcessor.h" 12 #include "GrProcessor.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "gl/GrGLXferProcessor.h" 14 #include "gl/GrGLXferProcessor.h"
15 #include "gl/builders/GrGLFragmentShaderBuilder.h" 15 #include "gl/builders/GrGLFragmentShaderBuilder.h"
16 #include "gl/builders/GrGLProgramBuilder.h" 16 #include "gl/builders/GrGLProgramBuilder.h"
17 17
18 class CoverageSetOpXP : public GrXferProcessor { 18 class CoverageSetOpXP : public GrXferProcessor {
19 public: 19 public:
20 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { 20 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) {
21 return SkNEW_ARGS(CoverageSetOpXP, (regionOp, invertCoverage)); 21 return SkNEW_ARGS(CoverageSetOpXP, (regionOp, invertCoverage));
22 } 22 }
23 23
24 ~CoverageSetOpXP() override; 24 ~CoverageSetOpXP() override;
25 25
26 const char* name() const override { return "Coverage Set Op"; } 26 const char* name() const override { return "Coverage Set Op"; }
27 27
28 GrGLXferProcessor* createGLInstance() const override; 28 GrGLXferProcessor* createGLInstance() const override;
29 29
30 bool hasSecondaryOutput() const override { return false; }
31
32 bool invertCoverage() const { return fInvertCoverage; } 30 bool invertCoverage() const { return fInvertCoverage; }
33 31
34 private: 32 private:
35 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); 33 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage);
36 34
37 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, 35 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
38 const GrProcOptInfo& coveragePO I, 36 const GrProcOptInfo& coveragePO I,
39 bool doesStencilWrite, 37 bool doesStencilWrite,
40 GrColor* color, 38 GrColor* color,
41 const GrCaps& caps) override; 39 const GrCaps& caps) override;
(...skipping 23 matching lines...) Expand all
65 ~GLCoverageSetOpXP() override {} 63 ~GLCoverageSetOpXP() override {}
66 64
67 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, 65 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
68 GrProcessorKeyBuilder* b) { 66 GrProcessorKeyBuilder* b) {
69 const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>(); 67 const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>();
70 uint32_t key = xp.invertCoverage() ? 0x0 : 0x1; 68 uint32_t key = xp.invertCoverage() ? 0x0 : 0x1;
71 b->add32(key); 69 b->add32(key);
72 }; 70 };
73 71
74 private: 72 private:
75 void onEmitCode(const EmitArgs& args) override { 73 void emitOutputsForBlendState(const EmitArgs& args) override {
76 const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>(); 74 const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>();
77 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 75 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
78 76
79 if (xp.invertCoverage()) { 77 if (xp.invertCoverage()) {
80 fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.f InputCoverage); 78 fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.f InputCoverage);
81 } else { 79 } else {
82 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC overage); 80 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC overage);
83 } 81 }
84 } 82 }
85 83
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 238
241 GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random, 239 GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random,
242 GrContext*, 240 GrContext*,
243 const GrCaps&, 241 const GrCaps&,
244 GrTexture*[]) { 242 GrTexture*[]) {
245 SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp + 1)); 243 SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp + 1));
246 bool invertCoverage = random->nextBool(); 244 bool invertCoverage = random->nextBool();
247 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); 245 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage);
248 } 246 }
249 247
OLDNEW
« no previous file with comments | « src/gpu/GrXferProcessor.cpp ('k') | src/gpu/effects/GrCustomXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698