Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: src/gpu/effects/GrDisableColorXP.cpp

Issue 1440073002: Move XferProcessors to glsl (Closed) Base URL: https://skia.googlesource.com/skia.git@fragProcs
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" 10 #include "glsl/GrGLSLFragmentShaderBuilder.h"
12 #include "glsl/GrGLSLProgramBuilder.h" 11 #include "glsl/GrGLSLProgramBuilder.h"
13 #include "glsl/GrGLSLProgramDataManager.h" 12 #include "glsl/GrGLSLProgramDataManager.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 GrGLXferProcessor* createGLInstance() const override; 27 GrGLSLXferProcessor* createGLInstance() 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 onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c onst 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
51 /////////////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////////////
52 52
53 class GLDisableColorXP : public GrGLXferProcessor { 53 class GLDisableColorXP : public GrGLSLXferProcessor {
54 public: 54 public:
55 GLDisableColorXP(const GrProcessor&) {} 55 GLDisableColorXP(const GrProcessor&) {}
56 56
57 ~GLDisableColorXP() override {} 57 ~GLDisableColorXP() override {}
58 58
59 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der*) {} 59 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der*) {}
60 60
61 private: 61 private:
62 void emitOutputsForBlendState(const EmitArgs& args) override { 62 void emitOutputsForBlendState(const EmitArgs& args) override {
63 // 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
64 // 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
65 // 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.
66 GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( ); 66 GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder( );
67 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); 67 fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
68 } 68 }
69 69
70 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {} 70 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {}
71 71
72 typedef GrGLXferProcessor 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::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB uilder* b) const {
82 GLDisableColorXP::GenKey(*this, caps, b); 82 GLDisableColorXP::GenKey(*this, caps, b);
83 } 83 }
84 84
85 GrGLXferProcessor* DisableColorXP::createGLInstance() const { return new GLDisab leColorXP(*this); } 85 GrGLSLXferProcessor* DisableColorXP::createGLInstance() const { return new GLDis ableColorXP(*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
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698