OLD | NEW |
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 "GrColor.h" | 10 #include "GrColor.h" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.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() SK_OVERRIDE; | 24 ~CoverageSetOpXP() override; |
25 | 25 |
26 const char* name() const SK_OVERRIDE { return "Coverage Set Op"; } | 26 const char* name() const override { return "Coverage Set Op"; } |
27 | 27 |
28 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | 28 GrGLXferProcessor* createGLInstance() const override; |
29 | 29 |
30 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } | 30 bool hasSecondaryOutput() const override { return false; } |
31 | 31 |
32 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 32 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
33 const GrProcOptInfo& coveragePOI, | 33 const GrProcOptInfo& coveragePOI, |
34 bool doesStencilWrite, | 34 bool doesStencilWrite, |
35 GrColor* color, | 35 GrColor* color, |
36 const GrDrawTargetCaps& caps) SK_
OVERRIDE; | 36 const GrDrawTargetCaps& caps) ove
rride; |
37 | 37 |
38 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; | 38 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
39 | 39 |
40 bool invertCoverage() const { return fInvertCoverage; } | 40 bool invertCoverage() const { return fInvertCoverage; } |
41 | 41 |
42 private: | 42 private: |
43 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); | 43 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
44 | 44 |
45 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st SK_OVERRIDE; | 45 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st override; |
46 | 46 |
47 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { | 47 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
48 const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); | 48 const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); |
49 return (fRegionOp == xp.fRegionOp && | 49 return (fRegionOp == xp.fRegionOp && |
50 fInvertCoverage == xp.fInvertCoverage); | 50 fInvertCoverage == xp.fInvertCoverage); |
51 } | 51 } |
52 | 52 |
53 SkRegion::Op fRegionOp; | 53 SkRegion::Op fRegionOp; |
54 bool fInvertCoverage; | 54 bool fInvertCoverage; |
55 | 55 |
56 typedef GrXferProcessor INHERITED; | 56 typedef GrXferProcessor INHERITED; |
57 }; | 57 }; |
58 | 58 |
59 /////////////////////////////////////////////////////////////////////////////// | 59 /////////////////////////////////////////////////////////////////////////////// |
60 | 60 |
61 class GLCoverageSetOpXP : public GrGLXferProcessor { | 61 class GLCoverageSetOpXP : public GrGLXferProcessor { |
62 public: | 62 public: |
63 GLCoverageSetOpXP(const GrProcessor&) {} | 63 GLCoverageSetOpXP(const GrProcessor&) {} |
64 | 64 |
65 ~GLCoverageSetOpXP() SK_OVERRIDE {} | 65 ~GLCoverageSetOpXP() override {} |
66 | 66 |
67 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, | 67 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, |
68 GrProcessorKeyBuilder* b) { | 68 GrProcessorKeyBuilder* b) { |
69 const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>(); | 69 const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>(); |
70 uint32_t key = xp.invertCoverage() ? 0x0 : 0x1; | 70 uint32_t key = xp.invertCoverage() ? 0x0 : 0x1; |
71 b->add32(key); | 71 b->add32(key); |
72 }; | 72 }; |
73 | 73 |
74 private: | 74 private: |
75 void onEmitCode(const EmitArgs& args) SK_OVERRIDE { | 75 void onEmitCode(const EmitArgs& args) override { |
76 const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>(); | 76 const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>(); |
77 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 77 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
78 | 78 |
79 if (xp.invertCoverage()) { | 79 if (xp.invertCoverage()) { |
80 fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.f
InputCoverage); | 80 fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.f
InputCoverage); |
81 } else { | 81 } else { |
82 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC
overage); | 82 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC
overage); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVE
RRIDE {}; | 86 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {}; |
87 | 87 |
88 typedef GrGLXferProcessor INHERITED; | 88 typedef GrGLXferProcessor INHERITED; |
89 }; | 89 }; |
90 | 90 |
91 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
92 | 92 |
93 CoverageSetOpXP::CoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage) | 93 CoverageSetOpXP::CoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage) |
94 : fRegionOp(regionOp) | 94 : fRegionOp(regionOp) |
95 , fInvertCoverage(invertCoverage) { | 95 , fInvertCoverage(invertCoverage) { |
96 this->initClassID<CoverageSetOpXP>(); | 96 this->initClassID<CoverageSetOpXP>(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random, | 253 GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random, |
254 GrContext*, | 254 GrContext*, |
255 const GrDrawTargetCaps&, | 255 const GrDrawTargetCaps&, |
256 GrTexture*[]) { | 256 GrTexture*[]) { |
257 SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp
+ 1)); | 257 SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp
+ 1)); |
258 bool invertCoverage = random->nextBool(); | 258 bool invertCoverage = random->nextBool(); |
259 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); | 259 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); |
260 } | 260 } |
261 | 261 |
OLD | NEW |