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 | 13 |
14 class GrGLDisableColorXP : public GrGLXferProcessor { | 14 class GrGLDisableColorXP : public GrGLXferProcessor { |
15 public: | 15 public: |
16 GrGLDisableColorXP(const GrProcessor&) {} | 16 GrGLDisableColorXP(const GrProcessor&) {} |
17 | 17 |
18 ~GrGLDisableColorXP() SK_OVERRIDE {} | 18 ~GrGLDisableColorXP() SK_OVERRIDE {} |
19 | 19 |
20 void emitCode(const EmitArgs& args) SK_OVERRIDE { | 20 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde
r*) {} |
| 21 |
| 22 private: |
| 23 void onEmitCode(const EmitArgs& args) SK_OVERRIDE { |
21 // This emit code should be empty. However, on the nexus 6 there is a dr
iver bug where if | 24 // This emit code should be empty. However, on the nexus 6 there is a dr
iver bug where if |
22 // you do not give gl_FragColor a value, the gl context is lost and we e
nd up drawing | 25 // you do not give gl_FragColor a value, the gl context is lost and we e
nd up drawing |
23 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. | 26 // nothing. So this fix just sets the gl_FragColor arbitrarily to 0. |
24 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 27 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
25 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); | 28 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); |
26 } | 29 } |
27 | 30 |
28 void setData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVERR
IDE {} | 31 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVE
RRIDE {} |
29 | 32 |
30 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde
r*) {} | |
31 | |
32 private: | |
33 typedef GrGLXferProcessor INHERITED; | 33 typedef GrGLXferProcessor INHERITED; |
34 }; | 34 }; |
35 | 35 |
36 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
37 | 37 |
38 GrDisableColorXP::GrDisableColorXP() { | 38 GrDisableColorXP::GrDisableColorXP() { |
39 this->initClassID<GrDisableColorXP>(); | 39 this->initClassID<GrDisableColorXP>(); |
40 } | 40 } |
41 | 41 |
42 void GrDisableColorXP::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBui
lder* b) const { | 42 void GrDisableColorXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyB
uilder* b) const { |
43 GrGLDisableColorXP::GenKey(*this, caps, b); | 43 GrGLDisableColorXP::GenKey(*this, caps, b); |
44 } | 44 } |
45 | 45 |
46 GrGLXferProcessor* GrDisableColorXP::createGLInstance() const { | 46 GrGLXferProcessor* GrDisableColorXP::createGLInstance() const { |
47 return SkNEW_ARGS(GrGLDisableColorXP, (*this)); | 47 return SkNEW_ARGS(GrGLDisableColorXP, (*this)); |
48 } | 48 } |
49 | 49 |
50 void GrDisableColorXP::getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const
{ | 50 void GrDisableColorXP::getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const
{ |
51 blendInfo->fWriteColor = false; | 51 blendInfo->fWriteColor = false; |
52 } | 52 } |
53 | 53 |
54 /////////////////////////////////////////////////////////////////////////////// | 54 /////////////////////////////////////////////////////////////////////////////// |
55 | 55 |
56 GrDisableColorXPFactory::GrDisableColorXPFactory() { | 56 GrDisableColorXPFactory::GrDisableColorXPFactory() { |
57 this->initClassID<GrDisableColorXPFactory>(); | 57 this->initClassID<GrDisableColorXPFactory>(); |
58 } | 58 } |
59 | 59 |
60 GrXferProcessor* GrDisableColorXPFactory::createXferProcessor(const GrProcOptInf
o& colorPOI, | 60 GrXferProcessor* |
61 const GrProcOptInf
o& covPOI) const { | 61 GrDisableColorXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI, |
| 62 const GrProcOptInfo& covPOI, |
| 63 const GrDeviceCoordTexture* dstCo
py, |
| 64 int32_t dstReadKey) const { |
62 return GrDisableColorXP::Create(); | 65 return GrDisableColorXP::Create(); |
63 } | 66 } |
64 | 67 |
65 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); | 68 GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); |
66 | 69 |
67 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, | 70 GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, |
68 GrContext*, | 71 GrContext*, |
69 const GrDrawTargetCaps&, | 72 const GrDrawTargetCaps&, |
70 GrTexture*[]) { | 73 GrTexture*[]) { |
71 return GrDisableColorXPFactory::Create(); | 74 return GrDisableColorXPFactory::Create(); |
72 } | 75 } |
73 | 76 |
OLD | NEW |