OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "effects/GrDisableColorXP.h" | 8 #include "effects/GrDisableColorXP.h" |
9 #include "GrProcessor.h" | 9 #include "GrProcessor.h" |
10 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 10 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
11 #include "glsl/GrGLSLProgramBuilder.h" | 11 #include "glsl/GrGLSLProgramBuilder.h" |
12 #include "glsl/GrGLSLProgramDataManager.h" | 12 #include "glsl/GrGLSLProgramDataManager.h" |
13 #include "glsl/GrGLSLXferProcessor.h" | 13 #include "glsl/GrGLSLXferProcessor.h" |
14 | 14 |
15 /** | 15 /** |
16 * This xfer processor disables color writing. Thus color and coverage and ignor
ed and no blending | 16 * This xfer processor disables color writing. Thus color and coverage and ignor
ed and no blending |
17 * occurs. This XP is usful for things like stenciling. | 17 * occurs. This XP is usful for things like stenciling. |
18 */ | 18 */ |
19 class DisableColorXP : public GrXferProcessor { | 19 class DisableColorXP : public GrXferProcessor { |
20 public: | 20 public: |
21 static GrXferProcessor* Create() { return new DisableColorXP; } | 21 static GrXferProcessor* Create() { return new DisableColorXP; } |
22 | 22 |
23 ~DisableColorXP() override {}; | 23 ~DisableColorXP() override {}; |
24 | 24 |
25 const char* name() const override { return "Disable Color"; } | 25 const char* name() const override { return "Disable Color"; } |
26 | 26 |
27 GrGLSLXferProcessor* createGLInstance() const override; | 27 GrGLSLXferProcessor* createGLSLInstance() const override; |
28 | 28 |
29 private: | 29 private: |
30 DisableColorXP(); | 30 DisableColorXP(); |
31 | 31 |
32 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 32 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
33 const GrProcOptInfo& coveragePO
I, | 33 const GrProcOptInfo& coveragePO
I, |
34 bool doesStencilWrite, | 34 bool doesStencilWrite, |
35 GrColor* color, | 35 GrColor* color, |
36 const GrCaps& caps) override { | 36 const GrCaps& caps) override { |
37 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; | 37 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; |
38 } | 38 } |
39 | 39 |
40 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 40 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; |
41 | 41 |
42 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; | 42 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
43 | 43 |
44 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 44 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
45 return true; | 45 return true; |
46 } | 46 } |
47 | 47 |
48 typedef GrXferProcessor INHERITED; | 48 typedef GrXferProcessor INHERITED; |
49 }; | 49 }; |
50 | 50 |
(...skipping 20 matching lines...) Expand all Loading... |
71 | 71 |
72 typedef GrGLSLXferProcessor INHERITED; | 72 typedef GrGLSLXferProcessor INHERITED; |
73 }; | 73 }; |
74 | 74 |
75 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
76 | 76 |
77 DisableColorXP::DisableColorXP() { | 77 DisableColorXP::DisableColorXP() { |
78 this->initClassID<DisableColorXP>(); | 78 this->initClassID<DisableColorXP>(); |
79 } | 79 } |
80 | 80 |
81 void DisableColorXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { | 81 void DisableColorXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b) const { |
82 GLDisableColorXP::GenKey(*this, caps, b); | 82 GLDisableColorXP::GenKey(*this, caps, b); |
83 } | 83 } |
84 | 84 |
85 GrGLSLXferProcessor* DisableColorXP::createGLInstance() const { return new GLDis
ableColorXP(*this); } | 85 GrGLSLXferProcessor* DisableColorXP::createGLSLInstance() const { return new GLD
isableColorXP(*this); } |
86 | 86 |
87 void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const
{ | 87 void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const
{ |
88 blendInfo->fWriteColor = false; | 88 blendInfo->fWriteColor = false; |
89 } | 89 } |
90 | 90 |
91 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
92 | 92 |
93 GrDisableColorXPFactory::GrDisableColorXPFactory() { | 93 GrDisableColorXPFactory::GrDisableColorXPFactory() { |
94 this->initClassID<GrDisableColorXPFactory>(); | 94 this->initClassID<GrDisableColorXPFactory>(); |
95 } | 95 } |
96 | 96 |
97 GrXferProcessor* | 97 GrXferProcessor* |
98 GrDisableColorXPFactory::onCreateXferProcessor(const GrCaps& caps, | 98 GrDisableColorXPFactory::onCreateXferProcessor(const GrCaps& caps, |
99 const GrProcOptInfo& colorPOI, | 99 const GrProcOptInfo& colorPOI, |
100 const GrProcOptInfo& covPOI, | 100 const GrProcOptInfo& covPOI, |
101 bool hasMixedSamples, | 101 bool hasMixedSamples, |
102 const DstTexture* dst) const { | 102 const DstTexture* dst) const { |
103 return DisableColorXP::Create(); | 103 return DisableColorXP::Create(); |
104 } | 104 } |
105 | 105 |
106 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); | 106 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); |
107 | 107 |
108 const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) { | 108 const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) { |
109 return GrDisableColorXPFactory::Create(); | 109 return GrDisableColorXPFactory::Create(); |
110 } | 110 } |
111 | 111 |
OLD | NEW |