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 "gl/GrGLXferProcessor.h" | 10 #include "gl/GrGLXferProcessor.h" |
11 #include "gl/builders/GrGLFragmentShaderBuilder.h" | 11 #include "gl/builders/GrGLFragmentShaderBuilder.h" |
12 #include "gl/builders/GrGLProgramBuilder.h" | 12 #include "gl/builders/GrGLProgramBuilder.h" |
| 13 #include "glsl/GrGLSLProgramDataManager.h" |
13 | 14 |
14 /** | 15 /** |
15 * 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 |
16 * occurs. This XP is usful for things like stenciling. | 17 * occurs. This XP is usful for things like stenciling. |
17 */ | 18 */ |
18 class DisableColorXP : public GrXferProcessor { | 19 class DisableColorXP : public GrXferProcessor { |
19 public: | 20 public: |
20 static GrXferProcessor* Create() { return new DisableColorXP; } | 21 static GrXferProcessor* Create() { return new DisableColorXP; } |
21 | 22 |
22 ~DisableColorXP() override {}; | 23 ~DisableColorXP() override {}; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 private: | 61 private: |
61 void emitOutputsForBlendState(const EmitArgs& args) override { | 62 void emitOutputsForBlendState(const EmitArgs& args) override { |
62 // This emit code should be empty. However, on the nexus 6 there is a dr
iver bug where if | 63 // This emit code should be empty. However, on the nexus 6 there is a dr
iver bug where if |
63 // you do not give gl_FragColor a value, the gl context is lost and we e
nd up drawing | 64 // you do not give gl_FragColor a value, the gl context is lost and we e
nd up drawing |
64 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. | 65 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. |
65 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 66 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
66 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); | 67 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); |
67 } | 68 } |
68 | 69 |
69 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} | 70 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} |
70 | 71 |
71 typedef GrGLXferProcessor INHERITED; | 72 typedef GrGLXferProcessor INHERITED; |
72 }; | 73 }; |
73 | 74 |
74 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
75 | 76 |
76 DisableColorXP::DisableColorXP() { | 77 DisableColorXP::DisableColorXP() { |
77 this->initClassID<DisableColorXP>(); | 78 this->initClassID<DisableColorXP>(); |
78 } | 79 } |
79 | 80 |
(...skipping 21 matching lines...) Expand all Loading... |
101 const DstTexture* dst) const { | 102 const DstTexture* dst) const { |
102 return DisableColorXP::Create(); | 103 return DisableColorXP::Create(); |
103 } | 104 } |
104 | 105 |
105 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); | 106 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); |
106 | 107 |
107 const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) { | 108 const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) { |
108 return GrDisableColorXPFactory::Create(); | 109 return GrDisableColorXPFactory::Create(); |
109 } | 110 } |
110 | 111 |
OLD | NEW |