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

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

Issue 1440073002: Move XferProcessors to glsl (Closed) Base URL: https://skia.googlesource.com/skia.git@fragProcs
Patch Set: Created 5 years, 1 month 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/effects/SkArithmeticMode_gpu.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"
15 #include "glsl/GrGLSLProgramBuilder.h" 14 #include "glsl/GrGLSLProgramBuilder.h"
16 #include "glsl/GrGLSLFragmentShaderBuilder.h" 15 #include "glsl/GrGLSLFragmentShaderBuilder.h"
16 #include "glsl/GrGLSLXferProcessor.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 new CoverageSetOpXP(regionOp, invertCoverage); 21 return new 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 GrGLSLXferProcessor* createGLInstance() const override;
29 29
30 bool invertCoverage() const { return fInvertCoverage; } 30 bool invertCoverage() const { return fInvertCoverage; }
31 31
32 private: 32 private:
33 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); 33 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage);
34 34
35 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, 35 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
36 const GrProcOptInfo& coveragePO I, 36 const GrProcOptInfo& coveragePO I,
37 bool doesStencilWrite, 37 bool doesStencilWrite,
38 GrColor* color, 38 GrColor* color,
(...skipping 10 matching lines...) Expand all
49 } 49 }
50 50
51 SkRegion::Op fRegionOp; 51 SkRegion::Op fRegionOp;
52 bool fInvertCoverage; 52 bool fInvertCoverage;
53 53
54 typedef GrXferProcessor INHERITED; 54 typedef GrXferProcessor INHERITED;
55 }; 55 };
56 56
57 /////////////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////////////
58 58
59 class GLCoverageSetOpXP : public GrGLXferProcessor { 59 class GLCoverageSetOpXP : public GrGLSLXferProcessor {
60 public: 60 public:
61 GLCoverageSetOpXP(const GrProcessor&) {} 61 GLCoverageSetOpXP(const GrProcessor&) {}
62 62
63 ~GLCoverageSetOpXP() override {} 63 ~GLCoverageSetOpXP() override {}
64 64
65 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, 65 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
66 GrProcessorKeyBuilder* b) { 66 GrProcessorKeyBuilder* b) {
67 const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>(); 67 const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>();
68 uint32_t key = xp.invertCoverage() ? 0x0 : 0x1; 68 uint32_t key = xp.invertCoverage() ? 0x0 : 0x1;
69 b->add32(key); 69 b->add32(key);
70 }; 70 };
71 71
72 private: 72 private:
73 void emitOutputsForBlendState(const EmitArgs& args) override { 73 void emitOutputsForBlendState(const EmitArgs& args) override {
74 const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>(); 74 const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>();
75 GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( ); 75 GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( );
76 76
77 if (xp.invertCoverage()) { 77 if (xp.invertCoverage()) {
78 fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.f InputCoverage); 78 fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.f InputCoverage);
79 } else { 79 } else {
80 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC overage); 80 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC overage);
81 } 81 }
82 } 82 }
83 83
84 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {}; 84 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {};
85 85
86 typedef GrGLXferProcessor INHERITED; 86 typedef GrGLSLXferProcessor INHERITED;
87 }; 87 };
88 88
89 /////////////////////////////////////////////////////////////////////////////// 89 ///////////////////////////////////////////////////////////////////////////////
90 90
91 CoverageSetOpXP::CoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage) 91 CoverageSetOpXP::CoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage)
92 : fRegionOp(regionOp) 92 : fRegionOp(regionOp)
93 , fInvertCoverage(invertCoverage) { 93 , fInvertCoverage(invertCoverage) {
94 this->initClassID<CoverageSetOpXP>(); 94 this->initClassID<CoverageSetOpXP>();
95 } 95 }
96 96
97 CoverageSetOpXP::~CoverageSetOpXP() { 97 CoverageSetOpXP::~CoverageSetOpXP() {
98 } 98 }
99 99
100 void CoverageSetOpXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey Builder* b) const { 100 void CoverageSetOpXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey Builder* b) const {
101 GLCoverageSetOpXP::GenKey(*this, caps, b); 101 GLCoverageSetOpXP::GenKey(*this, caps, b);
102 } 102 }
103 103
104 GrGLXferProcessor* CoverageSetOpXP::createGLInstance() const { 104 GrGLSLXferProcessor* CoverageSetOpXP::createGLInstance() const {
105 return new GLCoverageSetOpXP(*this); 105 return new GLCoverageSetOpXP(*this);
106 } 106 }
107 107
108 GrXferProcessor::OptFlags 108 GrXferProcessor::OptFlags
109 CoverageSetOpXP::onGetOptimizations(const GrProcOptInfo& colorPOI, 109 CoverageSetOpXP::onGetOptimizations(const GrProcOptInfo& colorPOI,
110 const GrProcOptInfo& coveragePOI, 110 const GrProcOptInfo& coveragePOI,
111 bool doesStencilWrite, 111 bool doesStencilWrite,
112 GrColor* color, 112 GrColor* color,
113 const GrCaps& caps) { 113 const GrCaps& caps) {
114 // We never look at the color input 114 // We never look at the color input
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); 246 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory);
247 247
248 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) { 248 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) {
249 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa stOp + 1)); 249 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa stOp + 1));
250 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne xtBool(); 250 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne xtBool();
251 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); 251 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage);
252 } 252 }
253 253
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/gpu/effects/GrCustomXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698