| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 */ | 131 */ |
| 132 void setData(const GrOptDrawState&, | 132 void setData(const GrOptDrawState&, |
| 133 GrGpu::DrawType, | 133 GrGpu::DrawType, |
| 134 const GrDeviceCoordTexture* dstCopy /* can be NULL*/); | 134 const GrDeviceCoordTexture* dstCopy /* can be NULL*/); |
| 135 | 135 |
| 136 protected: | 136 protected: |
| 137 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 137 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 138 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 138 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 139 | 139 |
| 140 GrGLProgram(GrGpuGL*, | 140 GrGLProgram(GrGpuGL*, |
| 141 const GrGLProgramDesc&, | 141 const GrProgramDesc&, |
| 142 const BuiltinUniformHandles&, | 142 const BuiltinUniformHandles&, |
| 143 GrGLuint programID, | 143 GrGLuint programID, |
| 144 const UniformInfoArray&, | 144 const UniformInfoArray&, |
| 145 GrGLInstalledGeoProc* geometryProcessor, | 145 GrGLInstalledGeoProc* geometryProcessor, |
| 146 GrGLInstalledFragProcs* fragmentProcessors); | 146 GrGLInstalledFragProcs* fragmentProcessors); |
| 147 | 147 |
| 148 // Sets the texture units for samplers. | 148 // Sets the texture units for samplers. |
| 149 void initSamplerUniforms(); | 149 void initSamplerUniforms(); |
| 150 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); | 150 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); |
| 151 | 151 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 177 GrColor fColor; | 177 GrColor fColor; |
| 178 GrColor fCoverage; | 178 GrColor fCoverage; |
| 179 int fDstCopyTexUnit; | 179 int fDstCopyTexUnit; |
| 180 BuiltinUniformHandles fBuiltinUniformHandles; | 180 BuiltinUniformHandles fBuiltinUniformHandles; |
| 181 GrGLuint fProgramID; | 181 GrGLuint fProgramID; |
| 182 | 182 |
| 183 // the installed effects | 183 // the installed effects |
| 184 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; | 184 SkAutoTDelete<GrGLInstalledGeoProc> fGeometryProcessor; |
| 185 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 185 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
| 186 | 186 |
| 187 GrGLProgramDesc fDesc; | 187 GrProgramDesc fDesc; |
| 188 GrGpuGL* fGpu; | 188 GrGpuGL* fGpu; |
| 189 GrGLProgramDataManager fProgramDataManager; | 189 GrGLProgramDataManager fProgramDataManager; |
| 190 | 190 |
| 191 friend class GrGLProgramBuilder; | 191 friend class GrGLProgramBuilder; |
| 192 | 192 |
| 193 typedef SkRefCnt INHERITED; | 193 typedef SkRefCnt INHERITED; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 /* | 196 /* |
| 197 * 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 |
| 198 * 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. |
| 199 * 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 |
| 200 * 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 |
| 201 * projection matrix through a special function call | 201 * projection matrix through a special function call |
| 202 */ | 202 */ |
| 203 class GrGLNvprProgramBase : public GrGLProgram { | 203 class GrGLNvprProgramBase : public GrGLProgram { |
| 204 protected: | 204 protected: |
| 205 GrGLNvprProgramBase(GrGpuGL*, | 205 GrGLNvprProgramBase(GrGpuGL*, |
| 206 const GrGLProgramDesc&, | 206 const GrProgramDesc&, |
| 207 const BuiltinUniformHandles&, | 207 const BuiltinUniformHandles&, |
| 208 GrGLuint programID, | 208 GrGLuint programID, |
| 209 const UniformInfoArray&, | 209 const UniformInfoArray&, |
| 210 GrGLInstalledFragProcs* fragmentProcessors); | 210 GrGLInstalledFragProcs* fragmentProcessors); |
| 211 virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDr
awState&); | 211 virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDr
awState&); |
| 212 | 212 |
| 213 typedef GrGLProgram INHERITED; | 213 typedef GrGLProgram INHERITED; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 class GrGLNvprProgram : public GrGLNvprProgramBase { | 216 class GrGLNvprProgram : public GrGLNvprProgramBase { |
| 217 public: | 217 public: |
| 218 virtual bool hasVertexShader() const SK_OVERRIDE { return true; } | 218 virtual bool hasVertexShader() const SK_OVERRIDE { return true; } |
| 219 | 219 |
| 220 private: | 220 private: |
| 221 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; | 221 typedef GrGLNvprProgramBuilder::SeparableVaryingInfo SeparableVaryingInfo; |
| 222 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; | 222 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn
foArray; |
| 223 GrGLNvprProgram(GrGpuGL*, | 223 GrGLNvprProgram(GrGpuGL*, |
| 224 const GrGLProgramDesc&, | 224 const GrProgramDesc&, |
| 225 const BuiltinUniformHandles&, | 225 const BuiltinUniformHandles&, |
| 226 GrGLuint programID, | 226 GrGLuint programID, |
| 227 const UniformInfoArray&, | 227 const UniformInfoArray&, |
| 228 GrGLInstalledFragProcs* fragmentProcessors, | 228 GrGLInstalledFragProcs* fragmentProcessors, |
| 229 const SeparableVaryingInfoArray& separableVaryings); | 229 const SeparableVaryingInfoArray& separableVaryings); |
| 230 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 230 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
| 231 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; | 231 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; |
| 232 | 232 |
| 233 struct Varying { | 233 struct Varying { |
| 234 GrGLint fLocation; | 234 GrGLint fLocation; |
| 235 SkDEBUGCODE( | 235 SkDEBUGCODE( |
| 236 GrSLType fType; | 236 GrSLType fType; |
| 237 ); | 237 ); |
| 238 }; | 238 }; |
| 239 SkTArray<Varying, true> fVaryings; | 239 SkTArray<Varying, true> fVaryings; |
| 240 | 240 |
| 241 friend class GrGLNvprProgramBuilder; | 241 friend class GrGLNvprProgramBuilder; |
| 242 | 242 |
| 243 typedef GrGLNvprProgramBase INHERITED; | 243 typedef GrGLNvprProgramBase INHERITED; |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { | 246 class GrGLLegacyNvprProgram : public GrGLNvprProgramBase { |
| 247 public: | 247 public: |
| 248 virtual bool hasVertexShader() const SK_OVERRIDE { return false; } | 248 virtual bool hasVertexShader() const SK_OVERRIDE { return false; } |
| 249 | 249 |
| 250 private: | 250 private: |
| 251 GrGLLegacyNvprProgram(GrGpuGL* gpu, | 251 GrGLLegacyNvprProgram(GrGpuGL* gpu, |
| 252 const GrGLProgramDesc& desc, | 252 const GrProgramDesc& desc, |
| 253 const BuiltinUniformHandles&, | 253 const BuiltinUniformHandles&, |
| 254 GrGLuint programID, | 254 GrGLuint programID, |
| 255 const UniformInfoArray&, | 255 const UniformInfoArray&, |
| 256 GrGLInstalledFragProcs* fragmentProcessors, | 256 GrGLInstalledFragProcs* fragmentProcessors, |
| 257 int texCoordSetCnt); | 257 int texCoordSetCnt); |
| 258 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 258 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
| 259 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; | 259 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; |
| 260 | 260 |
| 261 int fTexCoordSetCnt; | 261 int fTexCoordSetCnt; |
| 262 | 262 |
| 263 friend class GrGLLegacyNvprProgramBuilder; | 263 friend class GrGLLegacyNvprProgramBuilder; |
| 264 | 264 |
| 265 typedef GrGLNvprProgramBase INHERITED; | 265 typedef GrGLNvprProgramBase INHERITED; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 #endif | 268 #endif |
| OLD | NEW |