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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const GrProcOptInfo& coveragePOI, | 33 const GrProcOptInfo& coveragePOI, |
34 bool doesStencilWrite, | 34 bool doesStencilWrite, |
35 GrColor* color, | 35 GrColor* color, |
36 const GrDrawTargetCaps& caps) ove
rride { | 36 const GrDrawTargetCaps& caps) ove
rride { |
37 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; | 37 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 DisableColorXP(); | 41 DisableColorXP(); |
42 | 42 |
43 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | 43 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
44 | 44 |
45 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; | 45 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
46 | 46 |
47 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 47 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 typedef GrXferProcessor INHERITED; | 51 typedef GrXferProcessor INHERITED; |
52 }; | 52 }; |
53 | 53 |
54 /////////////////////////////////////////////////////////////////////////////// | 54 /////////////////////////////////////////////////////////////////////////////// |
55 | 55 |
56 class GLDisableColorXP : public GrGLXferProcessor { | 56 class GLDisableColorXP : public GrGLXferProcessor { |
57 public: | 57 public: |
58 GLDisableColorXP(const GrProcessor&) {} | 58 GLDisableColorXP(const GrProcessor&) {} |
59 | 59 |
60 ~GLDisableColorXP() override {} | 60 ~GLDisableColorXP() override {} |
61 | 61 |
62 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde
r*) {} | 62 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} |
63 | 63 |
64 private: | 64 private: |
65 void onEmitCode(const EmitArgs& args) override { | 65 void onEmitCode(const EmitArgs& args) override { |
66 // This emit code should be empty. However, on the nexus 6 there is a dr
iver bug where if | 66 // This emit code should be empty. However, on the nexus 6 there is a dr
iver bug where if |
67 // you do not give gl_FragColor a value, the gl context is lost and we e
nd up drawing | 67 // you do not give gl_FragColor a value, the gl context is lost and we e
nd up drawing |
68 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. | 68 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. |
69 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 69 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
70 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); | 70 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); |
71 } | 71 } |
72 | 72 |
73 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} | 73 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} |
74 | 74 |
75 typedef GrGLXferProcessor INHERITED; | 75 typedef GrGLXferProcessor INHERITED; |
76 }; | 76 }; |
77 | 77 |
78 /////////////////////////////////////////////////////////////////////////////// | 78 /////////////////////////////////////////////////////////////////////////////// |
79 | 79 |
80 DisableColorXP::DisableColorXP() { | 80 DisableColorXP::DisableColorXP() { |
81 this->initClassID<DisableColorXP>(); | 81 this->initClassID<DisableColorXP>(); |
82 } | 82 } |
83 | 83 |
84 void DisableColorXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBui
lder* b) const { | 84 void DisableColorXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { |
85 GLDisableColorXP::GenKey(*this, caps, b); | 85 GLDisableColorXP::GenKey(*this, caps, b); |
86 } | 86 } |
87 | 87 |
88 GrGLXferProcessor* DisableColorXP::createGLInstance() const { | 88 GrGLXferProcessor* DisableColorXP::createGLInstance() const { |
89 return SkNEW_ARGS(GLDisableColorXP, (*this)); | 89 return SkNEW_ARGS(GLDisableColorXP, (*this)); |
90 } | 90 } |
91 | 91 |
92 void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const
{ | 92 void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const
{ |
93 blendInfo->fWriteColor = false; | 93 blendInfo->fWriteColor = false; |
94 } | 94 } |
(...skipping 14 matching lines...) Expand all Loading... |
109 | 109 |
110 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); | 110 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); |
111 | 111 |
112 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, | 112 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, |
113 GrContext*, | 113 GrContext*, |
114 const GrDrawTargetCaps&, | 114 const GrDrawTargetCaps&, |
115 GrTexture*[]) { | 115 GrTexture*[]) { |
116 return GrDisableColorXPFactory::Create(); | 116 return GrDisableColorXPFactory::Create(); |
117 } | 117 } |
118 | 118 |
OLD | NEW |