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