| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; | 41 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; |
| 42 | 42 |
| 43 virtual ~GrGLProgram(); | 43 virtual ~GrGLProgram(); |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Call to abandon GL objects owned by this program. | 46 * Call to abandon GL objects owned by this program. |
| 47 */ | 47 */ |
| 48 void abandon(); | 48 void abandon(); |
| 49 | 49 |
| 50 const GrGLProgramDesc& getDesc() { return fDesc; } | 50 const GrProgramDesc& getDesc() { return fDesc; } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Gets the GL program ID for this program. | 53 * Gets the GL program ID for this program. |
| 54 */ | 54 */ |
| 55 GrGLuint programID() const { return fProgramID; } | 55 GrGLuint programID() const { return fProgramID; } |
| 56 | 56 |
| 57 /* | 57 /* |
| 58 * The base class always has a vertex shader, only the NVPR variants may omi
t a vertex shader | 58 * The base class always has a vertex shader, only the NVPR variants may omi
t a vertex shader |
| 59 */ | 59 */ |
| 60 virtual bool hasVertexShader() const { return true; } | 60 virtual bool hasVertexShader() const { return true; } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void setData(const GrOptDrawState&, | 153 void setData(const GrOptDrawState&, |
| 154 GrGpu::DrawType, | 154 GrGpu::DrawType, |
| 155 const GrDeviceCoordTexture* dstCopy, // can be NULL | 155 const GrDeviceCoordTexture* dstCopy, // can be NULL |
| 156 SharedGLState*); | 156 SharedGLState*); |
| 157 | 157 |
| 158 protected: | 158 protected: |
| 159 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 159 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 160 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 160 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 161 | 161 |
| 162 GrGLProgram(GrGpuGL*, | 162 GrGLProgram(GrGpuGL*, |
| 163 const GrGLProgramDesc&, | 163 const GrProgramDesc&, |
| 164 const BuiltinUniformHandles&, | 164 const BuiltinUniformHandles&, |
| 165 GrGLuint programID, | 165 GrGLuint programID, |
| 166 const UniformInfoArray&, | 166 const UniformInfoArray&, |
| 167 GrGLInstalledGeoProc* geometryProcessor, | 167 GrGLInstalledGeoProc* geometryProcessor, |
| 168 GrGLInstalledFragProcs* fragmentProcessors); | 168 GrGLInstalledFragProcs* fragmentProcessors); |
| 169 | 169 |
| 170 // Sets the texture units for samplers. | 170 // Sets the texture units for samplers. |
| 171 void initSamplerUniforms(); | 171 void initSamplerUniforms(); |
| 172 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); | 172 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); |
| 173 | 173 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 199 GrColor fColor; | 199 GrColor fColor; |
| 200 GrColor fCoverage; | 200 GrColor fCoverage; |
| 201 int fDstCopyTexUnit; | 201 int fDstCopyTexUnit; |
| 202 BuiltinUniformHandles fBuiltinUniformHandles; | 202 BuiltinUniformHandles fBuiltinUniformHandles; |
| 203 GrGLuint fProgramID; | 203 GrGLuint fProgramID; |
| 204 | 204 |
| 205 // the installed effects | 205 // the installed effects |
| 206 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; | 206 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; |
| 207 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 207 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
| 208 | 208 |
| 209 GrGLProgramDesc fDesc; | 209 GrProgramDesc fDesc; |
| 210 GrGpuGL* fGpu; | 210 GrGpuGL* fGpu; |
| 211 GrGLProgramDataManager fProgramDataManager; | 211 GrGLProgramDataManager fProgramDataManager; |
| 212 | 212 |
| 213 friend class GrGLProgramBuilder; | 213 friend class GrGLProgramBuilder; |
| 214 | 214 |
| 215 typedef SkRefCnt INHERITED; | 215 typedef SkRefCnt INHERITED; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 /* | 218 /* |
| 219 * Below are slight specializations of the program object for the different type
s of programs | 219 * Below are slight specializations of the program object for the different type
s of programs |
| 220 * The default GrGL programs consist of at the very least a vertex and fragment
shader. | 220 * The default GrGL programs consist of at the very least a vertex and fragment
shader. |
| 221 * Legacy Nvpr only has a fragment shader, 1.3+ Nvpr ignores the vertex shader,
but both require | 221 * Legacy Nvpr only has a fragment shader, 1.3+ Nvpr ignores the vertex shader,
but both require |
| 222 * specialized methods for setting transform data. Both types of NVPR also requi
re setting the | 222 * specialized methods for setting transform data. Both types of NVPR also requi
re setting the |
| 223 * projection matrix through a special function call | 223 * projection matrix through a special function call |
| 224 */ | 224 */ |
| 225 class GrGLNvprProgramBase : public GrGLProgram { | 225 class GrGLNvprProgramBase : public GrGLProgram { |
| 226 protected: | 226 protected: |
| 227 GrGLNvprProgramBase(GrGpuGL*, | 227 GrGLNvprProgramBase(GrGpuGL*, |
| 228 const GrGLProgramDesc&, | 228 const GrProgramDesc&, |
| 229 const BuiltinUniformHandles&, | 229 const BuiltinUniformHandles&, |
| 230 GrGLuint programID, | 230 GrGLuint programID, |
| 231 const UniformInfoArray&, | 231 const UniformInfoArray&, |
| 232 GrGLInstalledFragProcs* fragmentProcessors); | 232 GrGLInstalledFragProcs* fragmentProcessors); |
| 233 virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDr
awState&); | 233 virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDr
awState&); |
| 234 | 234 |
| 235 typedef GrGLProgram INHERITED; | 235 typedef GrGLProgram INHERITED; |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 class GrGLNvprProgram : public GrGLNvprProgramBase { | 238 class GrGLNvprProgram : public GrGLNvprProgramBase { |
| 239 public: | 239 public: |
| 240 virtual bool hasVertexShader() const SK_OVERRIDE { return true; } | 240 virtual bool hasVertexShader() const SK_OVERRIDE { return true; } |
| 241 | 241 |
| 242 private: | 242 private: |
| 243 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; | 243 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; |
| 244 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; | 244 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; |
| 245 GrGLNvprProgram(GrGpuGL*, | 245 GrGLNvprProgram(GrGpuGL*, |
| 246 const GrGLProgramDesc&, | 246 const GrProgramDesc&, |
| 247 const BuiltinUniformHandles&, | 247 const BuiltinUniformHandles&, |
| 248 GrGLuint programID, | 248 GrGLuint programID, |
| 249 const UniformInfoArray&, | 249 const UniformInfoArray&, |
| 250 GrGLInstalledFragProcs* fragmentProcessors, | 250 GrGLInstalledFragProcs* fragmentProcessors, |
| 251 const SeparableVaryingInfoArray& separableVaryings); | 251 const SeparableVaryingInfoArray& separableVaryings); |
| 252 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 252 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
| 253 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; | 253 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; |
| 254 | 254 |
| 255 struct Varying { | 255 struct Varying { |
| 256 GrGLint fLocation; | 256 GrGLint fLocation; |
| 257 SkDEBUGCODE( | 257 SkDEBUGCODE( |
| 258 GrSLType fType; | 258 GrSLType fType; |
| 259 ); | 259 ); |
| 260 }; | 260 }; |
| 261 SkTArray<Varying, true> fVaryings; | 261 SkTArray<Varying, true> fVaryings; |
| 262 | 262 |
| 263 friend class GrGLNvprProgramBuilder; | 263 friend class GrGLNvprProgramBuilder; |
| 264 | 264 |
| 265 typedef GrGLNvprProgramBase INHERITED; | 265 typedef GrGLNvprProgramBase INHERITED; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { | 268 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { |
| 269 public: | 269 public: |
| 270 virtual bool hasVertexShader() const SK_OVERRIDE { return false; } | 270 virtual bool hasVertexShader() const SK_OVERRIDE { return false; } |
| 271 | 271 |
| 272 private: | 272 private: |
| 273 GrGLLegacyNvprProgram(GrGpuGL* gpu, | 273 GrGLLegacyNvprProgram(GrGpuGL* gpu, |
| 274 const GrGLProgramDesc& desc, | 274 const GrProgramDesc& desc, |
| 275 const BuiltinUniformHandles&, | 275 const BuiltinUniformHandles&, |
| 276 GrGLuint programID, | 276 GrGLuint programID, |
| 277 const UniformInfoArray&, | 277 const UniformInfoArray&, |
| 278 GrGLInstalledFragProcs* fragmentProcessors, | 278 GrGLInstalledFragProcs* fragmentProcessors, |
| 279 int texCoordSetCnt); | 279 int texCoordSetCnt); |
| 280 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 280 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
| 281 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; | 281 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; |
| 282 | 282 |
| 283 int fTexCoordSetCnt; | 283 int fTexCoordSetCnt; |
| 284 | 284 |
| 285 friend class GrGLLegacyNvprProgramBuilder; | 285 friend class GrGLLegacyNvprProgramBuilder; |
| 286 | 286 |
| 287 typedef GrGLNvprProgramBase INHERITED; | 287 typedef GrGLNvprProgramBase INHERITED; |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 #endif | 290 #endif |
| OLD | NEW |