| 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 /** | 14 /** |
| 15 * This xfer processor disables color writing. Thus color and coverage and ignor
ed and no blending | 15 * 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. | 16 * occurs. This XP is usful for things like stenciling. |
| 17 */ | 17 */ |
| 18 class DisableColorXP : public GrXferProcessor { | 18 class DisableColorXP : public GrXferProcessor { |
| 19 public: | 19 public: |
| 20 static GrXferProcessor* Create() { | 20 static GrXferProcessor* Create() { |
| 21 return SkNEW(DisableColorXP); | 21 return SkNEW(DisableColorXP); |
| 22 } | 22 } |
| 23 | 23 |
| 24 ~DisableColorXP() SK_OVERRIDE {}; | 24 ~DisableColorXP() override {}; |
| 25 | 25 |
| 26 const char* name() const SK_OVERRIDE { return "Disable Color"; } | 26 const char* name() const override { return "Disable Color"; } |
| 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 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; | 37 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; | 40 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 DisableColorXP(); | 43 DisableColorXP(); |
| 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 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() SK_OVERRIDE {} | 60 ~GLDisableColorXP() override {} |
| 61 | 61 |
| 62 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde
r*) {} | 62 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde
r*) {} |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 void onEmitCode(const EmitArgs& args) SK_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&) SK_OVE
RRIDE {} | 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 |
| (...skipping 25 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 |