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

Side by Side Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.h

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Compiler warning Created 5 years, 7 months 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/gl/GrGLGpu.cpp ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.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 #ifndef GrGLFragmentShaderBuilder_DEFINED 8 #ifndef GrGLFragmentShaderBuilder_DEFINED
9 #define GrGLFragmentShaderBuilder_DEFINED 9 #define GrGLFragmentShaderBuilder_DEFINED
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 * just call it FPShaderBuilder 59 * just call it FPShaderBuilder
60 */ 60 */
61 class GrGLXPFragmentBuilder : public GrGLFragmentBuilder { 61 class GrGLXPFragmentBuilder : public GrGLFragmentBuilder {
62 public: 62 public:
63 GrGLXPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} 63 GrGLXPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
64 64
65 /** Returns the variable name that holds the color of the destination pixel. This may be NULL if 65 /** Returns the variable name that holds the color of the destination pixel. This may be NULL if
66 no effect advertised that it will read the destination. */ 66 no effect advertised that it will read the destination. */
67 virtual const char* dstColor() = 0; 67 virtual const char* dstColor() = 0;
68 68
69 /** Adds any necessary layout qualifiers in order to legalize the supplied b lend equation with
70 this shader. It is only legal to call this method with an advanced blend equation, and only
71 if these equations are supported. */
72 virtual void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) = 0;
73
69 private: 74 private:
70 typedef GrGLFragmentBuilder INHERITED; 75 typedef GrGLFragmentBuilder INHERITED;
71 }; 76 };
72 77
73 // TODO rename to Fragment Builder 78 // TODO rename to Fragment Builder
74 class GrGLFragmentShaderBuilder : public GrGLXPFragmentBuilder { 79 class GrGLFragmentShaderBuilder : public GrGLXPFragmentBuilder {
75 public: 80 public:
76 typedef uint8_t DstReadKey; 81 typedef uint8_t DstReadKey;
77 typedef uint8_t FragPosKey; 82 typedef uint8_t FragPosKey;
78 83
79 /** Returns a key for adding code to read the copy-of-dst color in service of effects that 84 /** Returns a key for adding code to read the copy-of-dst color in service of effects that
80 require reading the dst. It must not return 0 because 0 indicates that t here is no dst 85 require reading the dst. It must not return 0 because 0 indicates that t here is no dst
81 copy read at all (in which case this function should not be called). */ 86 copy read at all (in which case this function should not be called). */
82 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); 87 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
83 88
84 /** Returns a key for reading the fragment location. This should only be cal led if there is an 89 /** Returns a key for reading the fragment location. This should only be cal led if there is an
85 effect that will requires the fragment position. If the fragment position is not required, 90 effect that will requires the fragment position. If the fragment position is not required,
86 the key is 0. */ 91 the key is 0. */
87 static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const Gr GLCaps&); 92 static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const Gr GLCaps&);
88 93
89 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, uint8_t fragPosKey); 94 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, uint8_t fragPosKey);
90 95
91 // true public interface, defined explicitly in the abstract interfaces abov e 96 // true public interface, defined explicitly in the abstract interfaces abov e
92 bool enableFeature(GLSLFeature) override; 97 bool enableFeature(GLSLFeature) override;
93 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra y& coords, 98 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra y& coords,
94 int index) override; 99 int index) override;
95 const char* fragmentPosition() override; 100 const char* fragmentPosition() override;
96 const char* dstColor() override; 101 const char* dstColor() override;
97 102
103 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override;
104
98 private: 105 private:
99 // Private public interface, used by GrGLProgramBuilder to build a fragment shader 106 // Private public interface, used by GrGLProgramBuilder to build a fragment shader
100 void enableCustomOutput(); 107 void enableCustomOutput();
101 void enableSecondaryOutput(); 108 void enableSecondaryOutput();
102 const char* getPrimaryColorOutputName() const; 109 const char* getPrimaryColorOutputName() const;
103 const char* getSecondaryColorOutputName() const; 110 const char* getSecondaryColorOutputName() const;
104 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader Ids); 111 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader Ids);
105 void bindFragmentShaderLocations(GrGLuint programID); 112 void bindFragmentShaderLocations(GrGLuint programID);
106 113
107 // As GLProcessors emit code, there are some conditions we need to verify. We use the below 114 // As GLProcessors emit code, there are some conditions we need to verify. We use the below
108 // state to track this. The reset call is called per processor emitted. 115 // state to track this. The reset call is called per processor emitted.
109 bool hasReadDstColor() const { return fHasReadDstColor; } 116 bool hasReadDstColor() const { return fHasReadDstColor; }
110 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } 117 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; }
111 void reset() { 118 void reset() {
112 fHasReadDstColor = false; 119 fHasReadDstColor = false;
113 fHasReadFragmentPosition = false; 120 fHasReadFragmentPosition = false;
114 } 121 }
115 122
116 /* 123 /*
117 * An internal call for GrGLProgramBuilder to use to add varyings to the ver tex shader 124 * An internal call for GrGLProgramBuilder to use to add varyings to the ver tex shader
118 */ 125 */
119 void addVarying(GrGLVarying*, GrSLPrecision); 126 void addVarying(GrGLVarying*, GrSLPrecision);
120 127
121 /** 128 /**
122 * Features that should only be enabled by GrGLFragmentShaderBuilder itself. 129 * Features that should only be enabled by GrGLFragmentShaderBuilder itself.
123 */ 130 */
124 enum GLSLPrivateFeature { 131 enum GLSLPrivateFeature {
125 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, 132 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1,
126 kLastGLSLPrivateFeature = kFragCoordConventions_GLSLPrivateFeature 133 kBlendEquationAdvanced_GLSLPrivateFeature,
134 kLastGLSLPrivateFeature = kBlendEquationAdvanced_GLSLPrivateFeature
127 }; 135 };
128 136
129 // Interpretation of DstReadKey when generating code 137 // Interpretation of DstReadKey when generating code
130 enum { 138 enum {
131 kNoDstRead_DstReadKey = 0, 139 kNoDstRead_DstReadKey = 0,
132 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. 140 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read.
133 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alph a only. 141 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alph a only.
134 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top- left. 142 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top- left.
135 }; 143 };
136 144
(...skipping 16 matching lines...) Expand all
153 // the program creator 161 // the program creator
154 bool fHasReadDstColor; 162 bool fHasReadDstColor;
155 bool fHasReadFragmentPosition; 163 bool fHasReadFragmentPosition;
156 164
157 friend class GrGLProgramBuilder; 165 friend class GrGLProgramBuilder;
158 166
159 typedef GrGLXPFragmentBuilder INHERITED; 167 typedef GrGLXPFragmentBuilder INHERITED;
160 }; 168 };
161 169
162 #endif 170 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698