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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 protected: | 134 protected: |
135 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 135 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
136 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 136 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
137 | 137 |
138 GrGLProgram(GrGpuGL*, | 138 GrGLProgram(GrGpuGL*, |
139 const GrProgramDesc&, | 139 const GrProgramDesc&, |
140 const BuiltinUniformHandles&, | 140 const BuiltinUniformHandles&, |
141 GrGLuint programID, | 141 GrGLuint programID, |
142 const UniformInfoArray&, | 142 const UniformInfoArray&, |
143 GrGLInstalledGeoProc* geometryProcessor, | 143 GrGLInstalledGeoProc* geometryProcessor, |
| 144 GrGLInstalledXferProc* xferProcessor, |
144 GrGLInstalledFragProcs* fragmentProcessors); | 145 GrGLInstalledFragProcs* fragmentProcessors); |
145 | 146 |
146 // Sets the texture units for samplers. | 147 // Sets the texture units for samplers. |
147 void initSamplerUniforms(); | 148 void initSamplerUniforms(); |
148 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); | 149 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); |
149 | 150 |
150 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not | 151 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not |
151 // per-vertex colors. | 152 // per-vertex colors. |
152 void setColor(const GrOptDrawState&, GrColor color); | 153 void setColor(const GrOptDrawState&, GrColor color); |
153 | 154 |
(...skipping 19 matching lines...) Expand all Loading... |
173 // these reflect the current values of uniforms (GL uniform values travel wi
th program) | 174 // these reflect the current values of uniforms (GL uniform values travel wi
th program) |
174 MatrixState fMatrixState; | 175 MatrixState fMatrixState; |
175 GrColor fColor; | 176 GrColor fColor; |
176 uint8_t fCoverage; | 177 uint8_t fCoverage; |
177 int fDstCopyTexUnit; | 178 int fDstCopyTexUnit; |
178 BuiltinUniformHandles fBuiltinUniformHandles; | 179 BuiltinUniformHandles fBuiltinUniformHandles; |
179 GrGLuint fProgramID; | 180 GrGLuint fProgramID; |
180 | 181 |
181 // the installed effects | 182 // the installed effects |
182 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; | 183 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; |
| 184 SkAutoTDelete<GrGLInstalledXferProc> fXferProcessor; |
183 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 185 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
184 | 186 |
185 GrProgramDesc fDesc; | 187 GrProgramDesc fDesc; |
186 GrGpuGL* fGpu; | 188 GrGpuGL* fGpu; |
187 GrGLProgramDataManager fProgramDataManager; | 189 GrGLProgramDataManager fProgramDataManager; |
188 | 190 |
189 friend class GrGLProgramBuilder; | 191 friend class GrGLProgramBuilder; |
190 | 192 |
191 typedef SkRefCnt INHERITED; | 193 typedef SkRefCnt INHERITED; |
192 }; | 194 }; |
193 | 195 |
194 /* | 196 /* |
195 * Below are slight specializations of the program object for the different type
s of programs | 197 * Below are slight specializations of the program object for the different type
s of programs |
196 * The default GrGL programs consist of at the very least a vertex and fragment
shader. | 198 * The default GrGL programs consist of at the very least a vertex and fragment
shader. |
197 * Legacy Nvpr only has a fragment shader, 1.3+ Nvpr ignores the vertex shader,
but both require | 199 * Legacy Nvpr only has a fragment shader, 1.3+ Nvpr ignores the vertex shader,
but both require |
198 * specialized methods for setting transform data. Both types of NVPR also requi
re setting the | 200 * specialized methods for setting transform data. Both types of NVPR also requi
re setting the |
199 * projection matrix through a special function call | 201 * projection matrix through a special function call |
200 */ | 202 */ |
201 class GrGLNvprProgramBase : public GrGLProgram { | 203 class GrGLNvprProgramBase : public GrGLProgram { |
202 protected: | 204 protected: |
203 GrGLNvprProgramBase(GrGpuGL*, | 205 GrGLNvprProgramBase(GrGpuGL*, |
204 const GrProgramDesc&, | 206 const GrProgramDesc&, |
205 const BuiltinUniformHandles&, | 207 const BuiltinUniformHandles&, |
206 GrGLuint programID, | 208 GrGLuint programID, |
207 const UniformInfoArray&, | 209 const UniformInfoArray&, |
| 210 GrGLInstalledXferProc* xferProcessor, |
208 GrGLInstalledFragProcs* fragmentProcessors); | 211 GrGLInstalledFragProcs* fragmentProcessors); |
209 virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&); | 212 virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&); |
210 | 213 |
211 typedef GrGLProgram INHERITED; | 214 typedef GrGLProgram INHERITED; |
212 }; | 215 }; |
213 | 216 |
214 class GrGLNvprProgram : public GrGLNvprProgramBase { | 217 class GrGLNvprProgram : public GrGLNvprProgramBase { |
215 public: | 218 public: |
216 virtual bool hasVertexShader() const SK_OVERRIDE { return true; } | 219 virtual bool hasVertexShader() const SK_OVERRIDE { return true; } |
217 | 220 |
218 private: | 221 private: |
219 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; | 222 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; |
220 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; | 223 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; |
221 GrGLNvprProgram(GrGpuGL*, | 224 GrGLNvprProgram(GrGpuGL*, |
222 const GrProgramDesc&, | 225 const GrProgramDesc&, |
223 const BuiltinUniformHandles&, | 226 const BuiltinUniformHandles&, |
224 GrGLuint programID, | 227 GrGLuint programID, |
225 const UniformInfoArray&, | 228 const UniformInfoArray&, |
| 229 GrGLInstalledXferProc* xferProcessor, |
226 GrGLInstalledFragProcs* fragmentProcessors, | 230 GrGLInstalledFragProcs* fragmentProcessors, |
227 const SeparableVaryingInfoArray& separableVaryings); | 231 const SeparableVaryingInfoArray& separableVaryings); |
228 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 232 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
229 virtual void setTransformData(const GrPendingFragmentStage&, | 233 virtual void setTransformData(const GrPendingFragmentStage&, |
230 GrGLInstalledFragProc*) SK_OVERRIDE; | 234 GrGLInstalledFragProc*) SK_OVERRIDE; |
231 | 235 |
232 struct Varying { | 236 struct Varying { |
233 GrGLint fLocation; | 237 GrGLint fLocation; |
234 SkDEBUGCODE( | 238 SkDEBUGCODE( |
235 GrSLType fType; | 239 GrSLType fType; |
236 ); | 240 ); |
237 }; | 241 }; |
238 SkTArray<Varying, true> fVaryings; | 242 SkTArray<Varying, true> fVaryings; |
239 | 243 |
240 friend class GrGLNvprProgramBuilder; | 244 friend class GrGLNvprProgramBuilder; |
241 | 245 |
242 typedef GrGLNvprProgramBase INHERITED; | 246 typedef GrGLNvprProgramBase INHERITED; |
243 }; | 247 }; |
244 | 248 |
245 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { | 249 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { |
246 public: | 250 public: |
247 virtual bool hasVertexShader() const SK_OVERRIDE { return false; } | 251 virtual bool hasVertexShader() const SK_OVERRIDE { return false; } |
248 | 252 |
249 private: | 253 private: |
250 GrGLLegacyNvprProgram(GrGpuGL* gpu, | 254 GrGLLegacyNvprProgram(GrGpuGL* gpu, |
251 const GrProgramDesc& desc, | 255 const GrProgramDesc& desc, |
252 const BuiltinUniformHandles&, | 256 const BuiltinUniformHandles&, |
253 GrGLuint programID, | 257 GrGLuint programID, |
254 const UniformInfoArray&, | 258 const UniformInfoArray&, |
255 GrGLInstalledFragProcs* fragmentProcessors, | 259 GrGLInstalledXferProc* xp, |
| 260 GrGLInstalledFragProcs* fps, |
256 int texCoordSetCnt); | 261 int texCoordSetCnt); |
257 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 262 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
258 virtual void setTransformData(const GrPendingFragmentStage&, | 263 virtual void setTransformData(const GrPendingFragmentStage&, |
259 GrGLInstalledFragProc*) SK_OVERRIDE; | 264 GrGLInstalledFragProc*) SK_OVERRIDE; |
260 | 265 |
261 int fTexCoordSetCnt; | 266 int fTexCoordSetCnt; |
262 | 267 |
263 friend class GrGLLegacyNvprProgramBuilder; | 268 friend class GrGLLegacyNvprProgramBuilder; |
264 | 269 |
265 typedef GrGLNvprProgramBase INHERITED; | 270 typedef GrGLNvprProgramBase INHERITED; |
266 }; | 271 }; |
267 | 272 |
268 #endif | 273 #endif |
OLD | NEW |