OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 /** | 53 /** |
54 * The shader may modify the blend coefficients. Params are in/out. | 54 * The shader may modify the blend coefficients. Params are in/out. |
55 */ | 55 */ |
56 void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const; | 56 void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const; |
57 | 57 |
58 const GrGLProgramDesc& getDesc() { return fDesc; } | 58 const GrGLProgramDesc& getDesc() { return fDesc; } |
59 | 59 |
60 /** | 60 /** |
61 * Gets the GL program ID for this program. | 61 * Gets the GL program ID for this program. |
62 */ | 62 */ |
63 GrGLuint programID() const { return fProgramID; } | 63 GrGLuint programID() const { return fBuilderOutput.fProgramID; } |
64 | 64 |
65 bool hasVertexShader() const { return fHasVertexShader; } | 65 bool hasVertexShader() const { return fBuilderOutput.fHasVertexShader; } |
66 | 66 |
67 /** | 67 /** |
68 * Some GL state that is relevant to programs is not stored per-program. In
particular color | 68 * Some GL state that is relevant to programs is not stored per-program. In
particular color |
69 * and coverage attributes can be global state. This struct is read and upda
ted by | 69 * and coverage attributes can be global state. This struct is read and upda
ted by |
70 * GrGLProgram::setColor and GrGLProgram::setCoverage to allow us to avoid s
etting this state | 70 * GrGLProgram::setColor and GrGLProgram::setCoverage to allow us to avoid s
etting this state |
71 * redundantly. | 71 * redundantly. |
72 */ | 72 */ |
73 struct SharedGLState { | 73 struct SharedGLState { |
74 GrColor fConstAttribColor; | 74 GrColor fConstAttribColor; |
75 int fConstAttribColorIndex; | 75 int fConstAttribColorIndex; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 */ | 157 */ |
158 void setData(GrDrawState::BlendOptFlags, | 158 void setData(GrDrawState::BlendOptFlags, |
159 const GrEffectStage* colorStages[], | 159 const GrEffectStage* colorStages[], |
160 const GrEffectStage* coverageStages[], | 160 const GrEffectStage* coverageStages[], |
161 const GrDeviceCoordTexture* dstCopy, // can be NULL | 161 const GrDeviceCoordTexture* dstCopy, // can be NULL |
162 SharedGLState*); | 162 SharedGLState*); |
163 | 163 |
164 private: | 164 private: |
165 typedef GrGLUniformManager::UniformHandle UniformHandle; | 165 typedef GrGLUniformManager::UniformHandle UniformHandle; |
166 | 166 |
167 GrGLProgram(GrGpuGL* gpu, | 167 GrGLProgram(GrGpuGL*, |
168 const GrGLProgramDesc& desc, | 168 const GrGLProgramDesc&, |
169 GrGLUniformManager* uman, | 169 GrGLUniformManager*, |
170 const GrGLShaderBuilder::GenProgramOutput& builderOutput); | 170 const GrGLShaderBuilder::GenProgramOutput&); |
171 | 171 |
172 // Sets the texture units for samplers | 172 // Sets the texture units for samplers. |
173 void initSamplerUniforms(); | 173 void initSamplerUniforms(); |
174 | 174 |
175 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not | 175 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not |
176 // per-vertex colors. | 176 // per-vertex colors. |
177 void setColor(const GrDrawState&, GrColor color, SharedGLState*); | 177 void setColor(const GrDrawState&, GrColor color, SharedGLState*); |
178 | 178 |
179 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not | 179 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not |
180 // per-vertex coverages. | 180 // per-vertex coverages. |
181 void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*); | 181 void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*); |
182 | 182 |
183 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 183 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
184 void setMatrixAndRenderTargetHeight(const GrDrawState&); | 184 void setMatrixAndRenderTargetHeight(const GrDrawState&); |
185 | 185 |
186 // GL program ID | |
187 GrGLuint fProgramID; | |
188 | |
189 // these reflect the current values of uniforms (GL uniform values travel wi
th program) | 186 // these reflect the current values of uniforms (GL uniform values travel wi
th program) |
190 MatrixState fMatrixState; | 187 MatrixState fMatrixState; |
191 GrColor fColor; | 188 GrColor fColor; |
192 GrColor fCoverage; | 189 GrColor fCoverage; |
193 int fDstCopyTexUnit; | 190 int fDstCopyTexUnit; |
194 | 191 |
195 SkAutoTDelete<GrGLProgramEffects> fColorEffects; | 192 GrGLShaderBuilder::GenProgramOutput fBuilderOutput; |
196 SkAutoTDelete<GrGLProgramEffects> fCoverageEffects; | |
197 | 193 |
198 GrGLProgramDesc fDesc; | 194 GrGLProgramDesc fDesc; |
199 | |
200 GrGpuGL* fGpu; | 195 GrGpuGL* fGpu; |
201 | 196 |
202 SkAutoTUnref<GrGLUniformManager> fUniformManager; | 197 SkAutoTUnref<GrGLUniformManager> fUniformManager; |
203 GrGLShaderBuilder::UniformHandles fUniformHandles; | |
204 | |
205 bool fHasVertexShader; | |
206 int fTexCoordSetCnt; | |
207 | 198 |
208 typedef SkRefCnt INHERITED; | 199 typedef SkRefCnt INHERITED; |
209 }; | 200 }; |
210 | 201 |
211 #endif | 202 #endif |
OLD | NEW |