| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #ifndef GrGLShaderBuilder_DEFINED | 8 #ifndef GrGLShaderBuilder_DEFINED |
| 9 #define GrGLShaderBuilder_DEFINED | 9 #define GrGLShaderBuilder_DEFINED |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 struct GenProgramOutput { | 63 struct GenProgramOutput { |
| 64 GrGLProgramEffects* fColorEffects; | 64 GrGLProgramEffects* fColorEffects; |
| 65 GrGLProgramEffects* fCoverageEffects; | 65 GrGLProgramEffects* fCoverageEffects; |
| 66 UniformHandles fUniformHandles; | 66 UniformHandles fUniformHandles; |
| 67 bool fHasVS; | 67 bool fHasVS; |
| 68 int fNumTexCoordSets; | 68 int fNumTexCoordSets; |
| 69 GrGLuint fProgramID; | 69 GrGLuint fProgramID; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 static bool GenProgram(GrGpuGL* gpu, | 72 static bool GenProgram(GrGpuGL* gpu, |
| 73 GrGLUniformManager& uman, | 73 GrGLUniformManager* uman, |
| 74 const GrGLProgramDesc& desc, | 74 const GrGLProgramDesc& desc, |
| 75 const GrEffectStage* inColorStages[], | 75 const GrEffectStage* inColorStages[], |
| 76 const GrEffectStage* inCoverageStages[], | 76 const GrEffectStage* inCoverageStages[], |
| 77 GenProgramOutput* output); | 77 GenProgramOutput* output); |
| 78 | 78 |
| 79 virtual ~GrGLShaderBuilder() {} | 79 virtual ~GrGLShaderBuilder() {} |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile | 82 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile |
| 83 * if code is added that uses one of these features without calling enableFe
ature() | 83 * if code is added that uses one of these features without calling enableFe
ature() |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 const char** outName = NULL) { | 167 const char** outName = NULL) { |
| 168 return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNon
Array, outName); | 168 return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNon
Array, outName); |
| 169 } | 169 } |
| 170 GrGLUniformManager::UniformHandle addUniformArray(uint32_t visibility, | 170 GrGLUniformManager::UniformHandle addUniformArray(uint32_t visibility, |
| 171 GrSLType type, | 171 GrSLType type, |
| 172 const char* name, | 172 const char* name, |
| 173 int arrayCount, | 173 int arrayCount, |
| 174 const char** outName = NUL
L); | 174 const char** outName = NUL
L); |
| 175 | 175 |
| 176 const GrGLShaderVar& getUniformVariable(GrGLUniformManager::UniformHandle u)
const { | 176 const GrGLShaderVar& getUniformVariable(GrGLUniformManager::UniformHandle u)
const { |
| 177 return fUniformManager.getBuilderUniform(fUniforms, u).fVariable; | 177 return fUniformManager->getBuilderUniform(fUniforms, u).fVariable; |
| 178 } | 178 } |
| 179 | 179 |
| 180 /** | 180 /** |
| 181 * Shortcut for getUniformVariable(u).c_str() | 181 * Shortcut for getUniformVariable(u).c_str() |
| 182 */ | 182 */ |
| 183 const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const { | 183 const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const { |
| 184 return this->getUniformVariable(u).c_str(); | 184 return this->getUniformVariable(u).c_str(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in | 188 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in |
| 189 * the fragment shader. If the coordinates at index are 3-dimensional, it im
mediately emits a | 189 * the fragment shader. If the coordinates at index are 3-dimensional, it im
mediately emits a |
| 190 * perspective divide into the fragment shader (xy / z) to convert them to 2
D. | 190 * perspective divide into the fragment shader (xy / z) to convert them to 2
D. |
| 191 */ | 191 */ |
| 192 SkString ensureFSCoords2D(const TransformedCoordsArray&, int index); | 192 SkString ensureFSCoords2D(const TransformedCoordsArray&, int index); |
| 193 | 193 |
| 194 /** Returns a variable name that represents the position of the fragment in
the FS. The position | 194 /** Returns a variable name that represents the position of the fragment in
the FS. The position |
| 195 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ | 195 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ |
| 196 const char* fragmentPosition(); | 196 const char* fragmentPosition(); |
| 197 | 197 |
| 198 /** Returns the color of the destination pixel. This may be NULL if no effec
t advertised | 198 /** Returns the variable name that holds the color of the destination pixel.
This may be NULL if |
| 199 that it will read the destination. */ | 199 no effect advertised that it will read the destination. */ |
| 200 const char* dstColor(); | 200 const char* dstColor(); |
| 201 | 201 |
| 202 /** | |
| 203 * Interfaces used by GrGLProgram. | |
| 204 */ | |
| 205 const GrGLSLExpr4& getInputColor() const { | |
| 206 return fInputColor; | |
| 207 } | |
| 208 const GrGLSLExpr4& getInputCoverage() const { | |
| 209 return fInputCoverage; | |
| 210 } | |
| 211 | |
| 212 /** | |
| 213 * Adds code for effects and returns a GrGLProgramEffects* object. The calle
r is responsible for | |
| 214 * deleting it when finished. effectStages contains the effects to add. effe
ctKeys[i] is the key | |
| 215 * generated from effectStages[i]. inOutFSColor specifies the input color to
the first stage and | |
| 216 * is updated to be the output color of the last stage. | |
| 217 * The handles to texture samplers for effectStage[i] are added to | |
| 218 * effectSamplerHandles[i]. | |
| 219 */ | |
| 220 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], | |
| 221 const EffectKey effectKeys[
], | |
| 222 int effectCnt, | |
| 223 GrGLSLExpr4* inOutFSColor)
= 0; | |
| 224 | |
| 225 const char* getColorOutputName() const; | |
| 226 const char* enableSecondaryOutput(); | |
| 227 | |
| 228 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei
ghtUniform; } | |
| 229 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const { | |
| 230 return fDstCopyTopLeftUniform; | |
| 231 } | |
| 232 GrGLUniformManager::UniformHandle getDstCopyScaleUniform() const { | |
| 233 return fDstCopyScaleUniform; | |
| 234 } | |
| 235 GrGLUniformManager::UniformHandle getColorUniform() const { return fColorUni
form; } | |
| 236 GrGLUniformManager::UniformHandle getCoverageUniform() const { return fCover
ageUniform; } | |
| 237 GrGLUniformManager::UniformHandle getDstCopySamplerUniform() const { | |
| 238 return fDstCopySamplerUniform; | |
| 239 } | |
| 240 | |
| 241 bool finish(GrGLuint* outProgramId); | |
| 242 | |
| 243 const GrGLContextInfo& ctxInfo() const; | 202 const GrGLContextInfo& ctxInfo() const; |
| 244 | 203 |
| 245 /** | 204 /** |
| 246 * Helper for begining and ending a block in the fragment code. TODO: Make G
rGLShaderBuilder | 205 * Helper for begining and ending a block in the fragment code. TODO: Make G
rGLShaderBuilder |
| 247 * aware of all blocks and turn single \t's into the correct number of tabs
(or spaces) so that | 206 * aware of all blocks and turn single \t's into the correct number of tabs
(or spaces) so that |
| 248 * our shaders print pretty without effect writers tracking indentation. | 207 * our shaders print pretty without effect writers tracking indentation. |
| 249 */ | 208 */ |
| 250 class FSBlock { | 209 class FSBlock { |
| 251 public: | 210 public: |
| 252 FSBlock(GrGLShaderBuilder* builder) : fBuilder(builder) { | 211 FSBlock(GrGLShaderBuilder* builder) : fBuilder(builder) { |
| 253 SkASSERT(NULL != builder); | 212 SkASSERT(NULL != builder); |
| 254 fBuilder->fsCodeAppend("\t{\n"); | 213 fBuilder->fsCodeAppend("\t{\n"); |
| 255 } | 214 } |
| 256 | 215 |
| 257 ~FSBlock() { | 216 ~FSBlock() { |
| 258 fBuilder->fsCodeAppend("\t}\n"); | 217 fBuilder->fsCodeAppend("\t}\n"); |
| 259 } | 218 } |
| 260 private: | 219 private: |
| 261 GrGLShaderBuilder* fBuilder; | 220 GrGLShaderBuilder* fBuilder; |
| 262 }; | 221 }; |
| 263 | 222 |
| 264 protected: | 223 protected: |
| 265 GrGLShaderBuilder(GrGpuGL*, GrGLUniformManager&, const GrGLProgramDesc&); | 224 GrGLShaderBuilder(GrGpuGL*, GrGLUniformManager*, const GrGLProgramDesc&); |
| 266 | 225 |
| 267 GrGpuGL* gpu() const { return fGpu; } | 226 GrGpuGL* gpu() const { return fGpu; } |
| 268 | 227 |
| 269 const GrGLProgramDesc& desc() const { return fDesc; } | 228 const GrGLProgramDesc& desc() const { return fDesc; } |
| 270 | 229 |
| 271 void setInputColor(const GrGLSLExpr4& inputColor) { fInputColor = inputColor
; } | 230 void setInputColor(const GrGLSLExpr4& inputColor) { fInputColor = inputColor
; } |
| 272 void setInputCoverage(const GrGLSLExpr4& inputCoverage) { fInputCoverage = i
nputCoverage; } | 231 void setInputCoverage(const GrGLSLExpr4& inputCoverage) { fInputCoverage = i
nputCoverage; } |
| 273 | 232 |
| 274 /** Add input/output variable declarations (i.e. 'varying') to the fragment
shader. */ | 233 /** Add input/output variable declarations (i.e. 'varying') to the fragment
shader. */ |
| 275 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); } | 234 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); } |
| 276 | 235 |
| 277 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | |
| 278 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | |
| 279 // generating stage code. | |
| 280 void nameVariable(SkString* out, char prefix, const char* name); | |
| 281 | |
| 282 // Helper for emitEffects(). | 236 // Helper for emitEffects(). |
| 283 void createAndEmitEffects(GrGLProgramEffectsBuilder*, | 237 void createAndEmitEffects(GrGLProgramEffectsBuilder*, |
| 284 const GrEffectStage* effectStages[], | 238 const GrEffectStage* effectStages[], |
| 285 const EffectKey effectKeys[], | 239 const EffectKey effectKeys[], |
| 286 int effectCnt, | 240 int effectCnt, |
| 287 GrGLSLExpr4* inOutFSColor); | 241 GrGLSLExpr4* inOutFSColor); |
| 288 | 242 |
| 243 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
| 244 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
| 245 // generating stage code. |
| 246 void nameVariable(SkString* out, char prefix, const char* name); |
| 247 |
| 289 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>
* shaderIds) const; | 248 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>
* shaderIds) const; |
| 249 |
| 290 virtual void bindProgramLocations(GrGLuint programId) const; | 250 virtual void bindProgramLocations(GrGLuint programId) const; |
| 291 | 251 |
| 292 void appendDecls(const VarArray&, SkString*) const; | 252 void appendDecls(const VarArray&, SkString*) const; |
| 293 void appendUniformDecls(ShaderVisibility, SkString*) const; | 253 void appendUniformDecls(ShaderVisibility, SkString*) const; |
| 294 | 254 |
| 295 private: | 255 private: |
| 296 class CodeStage : SkNoncopyable { | 256 class CodeStage : SkNoncopyable { |
| 297 public: | 257 public: |
| 298 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {} | 258 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {} |
| 299 | 259 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 int fNextIndex; | 302 int fNextIndex; |
| 343 int fCurrentIndex; | 303 int fCurrentIndex; |
| 344 const GrEffectStage* fEffectStage; | 304 const GrEffectStage* fEffectStage; |
| 345 } fCodeStage; | 305 } fCodeStage; |
| 346 | 306 |
| 347 bool genProgram(const GrEffectStage* colorStages[], | 307 bool genProgram(const GrEffectStage* colorStages[], |
| 348 const GrEffectStage* coverageStages[], | 308 const GrEffectStage* coverageStages[], |
| 349 GenProgramOutput* output); | 309 GenProgramOutput* output); |
| 350 | 310 |
| 351 /** | 311 /** |
| 312 * Adds code for effects and returns a GrGLProgramEffects* object. The caller
is responsible for |
| 313 * deleting it when finished. effectStages contains the effects to add. effec
tKeys[i] is the key |
| 314 * generated from effectStages[i]. inOutFSColor specifies the input color to
the first stage and |
| 315 * is updated to be the output color of the last stage. |
| 316 * The handles to texture samplers for effectStage[i] are added to |
| 317 * effectSamplerHandles[i]. |
| 318 */ |
| 319 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], |
| 320 const EffectKey effectKeys[
], |
| 321 int effectCnt, |
| 322 GrGLSLExpr4* inOutFSColor)
= 0; |
| 323 |
| 324 /** Enables using the secondary color output and returns the name of the var
in which it is |
| 325 to be stored */ |
| 326 const char* enableSecondaryOutput(); |
| 327 /** Gets the name of the primary color output. */ |
| 328 const char* getColorOutputName() const; |
| 329 |
| 330 bool finish(GrGLuint* outProgramId); |
| 331 |
| 332 const GrGLSLExpr4& getInputColor() const { |
| 333 return fInputColor; |
| 334 } |
| 335 |
| 336 const GrGLSLExpr4& getInputCoverage() const { |
| 337 return fInputCoverage; |
| 338 } |
| 339 |
| 340 /** |
| 352 * Features that should only be enabled by GrGLShaderBuilder itself. | 341 * Features that should only be enabled by GrGLShaderBuilder itself. |
| 353 */ | 342 */ |
| 354 enum GLSLPrivateFeature { | 343 enum GLSLPrivateFeature { |
| 355 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, | 344 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, |
| 356 kEXTShaderFramebufferFetch_GLSLPrivateFeature, | 345 kEXTShaderFramebufferFetch_GLSLPrivateFeature, |
| 357 kNVShaderFramebufferFetch_GLSLPrivateFeature, | 346 kNVShaderFramebufferFetch_GLSLPrivateFeature, |
| 358 }; | 347 }; |
| 359 bool enablePrivateFeature(GLSLPrivateFeature); | 348 bool enablePrivateFeature(GLSLPrivateFeature); |
| 360 | 349 |
| 361 // If we ever have VS/GS features we can expand this to take a bitmask of Sh
aderVisibility and | 350 // If we ever have VS/GS features we can expand this to take a bitmask of Sh
aderVisibility and |
| 362 // track the enables separately for each shader. | 351 // track the enables separately for each shader. |
| 363 void addFSFeature(uint32_t featureBit, const char* extensionName); | 352 void addFSFeature(uint32_t featureBit, const char* extensionName); |
| 364 | 353 |
| 365 // Interpretation of DstReadKey when generating code | 354 // Interpretation of DstReadKey when generating code |
| 366 enum { | 355 enum { |
| 367 kNoDstRead_DstReadKey = 0, | 356 kNoDstRead_DstReadKey = 0, |
| 368 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. | 357 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. |
| 369 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha
only. | 358 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha
only. |
| 370 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-le
ft. | 359 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-le
ft. |
| 371 }; | 360 }; |
| 372 | 361 |
| 373 enum { | 362 enum { |
| 374 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil
l not be needed. | 363 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil
l not be needed. |
| 375 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t
op-left. | 364 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t
op-left. |
| 376 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b
ottom-left. | 365 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b
ottom-left. |
| 377 }; | 366 }; |
| 378 | 367 |
| 379 const GrGLProgramDesc& fDesc; | 368 const GrGLProgramDesc& fDesc; |
| 380 GrGpuGL* fGpu; | 369 GrGpuGL* fGpu; |
| 381 GrGLUniformManager& fUniformManager; | 370 SkAutoTUnref<GrGLUniformManager> fUniformManager; |
| 382 uint32_t fFSFeaturesAddedMask; | 371 uint32_t fFSFeaturesAddedMask; |
| 383 SkString fFSFunctions; | 372 SkString fFSFunctions; |
| 384 SkString fFSExtensions; | 373 SkString fFSExtensions; |
| 385 VarArray fFSInputs; | 374 VarArray fFSInputs; |
| 386 VarArray fFSOutputs; | 375 VarArray fFSOutputs; |
| 387 GrGLUniformManager::BuilderUniformArray fUniforms; | 376 GrGLUniformManager::BuilderUniformArray fUniforms; |
| 388 | 377 |
| 389 SkString fFSCode; | 378 SkString fFSCode; |
| 390 | 379 |
| 391 bool fSetupFragPosition; | 380 bool fSetupFragPosition; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 403 GrGLUniformManager::UniformHandle fColorUniform; | 392 GrGLUniformManager::UniformHandle fColorUniform; |
| 404 GrGLUniformManager::UniformHandle fCoverageUniform; | 393 GrGLUniformManager::UniformHandle fCoverageUniform; |
| 405 | 394 |
| 406 bool fTopLeftFragPosRead; | 395 bool fTopLeftFragPosRead; |
| 407 }; | 396 }; |
| 408 | 397 |
| 409 //////////////////////////////////////////////////////////////////////////////// | 398 //////////////////////////////////////////////////////////////////////////////// |
| 410 | 399 |
| 411 class GrGLFullShaderBuilder : public GrGLShaderBuilder { | 400 class GrGLFullShaderBuilder : public GrGLShaderBuilder { |
| 412 public: | 401 public: |
| 413 GrGLFullShaderBuilder(GrGpuGL*, GrGLUniformManager&, const GrGLProgramDesc&)
; | 402 GrGLFullShaderBuilder(GrGpuGL*, GrGLUniformManager*, const GrGLProgramDesc&)
; |
| 414 | 403 |
| 415 /** | 404 /** |
| 416 * Called by GrGLEffects to add code to one of the shaders. | 405 * Called by GrGLEffects to add code to one of the shaders. |
| 417 */ | 406 */ |
| 418 void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { | 407 void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { |
| 419 va_list args; | 408 va_list args; |
| 420 va_start(args, format); | 409 va_start(args, format); |
| 421 fVSCode.appendVAList(format, args); | 410 fVSCode.appendVAList(format, args); |
| 422 va_end(args); | 411 va_end(args); |
| 423 } | 412 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 447 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
} | 436 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
} |
| 448 | 437 |
| 449 /** | 438 /** |
| 450 * Are explicit local coordinates provided as input to the vertex shader. | 439 * Are explicit local coordinates provided as input to the vertex shader. |
| 451 */ | 440 */ |
| 452 bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVa
r); } | 441 bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVa
r); } |
| 453 | 442 |
| 454 bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& n
ame); | 443 bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& n
ame); |
| 455 const SkString* getEffectAttributeName(int attributeIndex) const; | 444 const SkString* getEffectAttributeName(int attributeIndex) const; |
| 456 | 445 |
| 457 virtual GrGLProgramEffects* createAndEmitEffects( | |
| 458 const GrEffectStage* effectStages[], | |
| 459 const EffectKey effectKeys[], | |
| 460 int effectCnt, | |
| 461 GrGLSLExpr4* inOutFSColor) SK_OVERRIDE; | |
| 462 | |
| 463 /** | 446 /** |
| 464 * The view matrix uniform is only valid in the VS. It is always mat33. | 447 * The view matrix uniform is only valid in the VS. It is always mat33. |
| 465 */ | 448 */ |
| 466 GrGLUniformManager::UniformHandle getViewMatrixUniform() const { | 449 GrGLUniformManager::UniformHandle getViewMatrixUniform() const { |
| 467 return fViewMatrixUniform; | 450 return fViewMatrixUniform; |
| 468 } | 451 } |
| 469 | 452 |
| 470 GrGLUniformManager::UniformHandle getRTAdjustmentVecUniform() const { | 453 GrGLUniformManager::UniformHandle getRTAdjustmentVecUniform() const { |
| 471 return fRTAdustmentVecUniform; | 454 return fRTAdustmentVecUniform; |
| 472 } | 455 } |
| 473 | 456 |
| 474 protected: | 457 private: |
| 475 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>
* shaderIds) const SK_OVERRIDE; | 458 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], |
| 459 const EffectKey effectKeys[
], |
| 460 int effectCnt, |
| 461 GrGLSLExpr4* inOutFSColor)
SK_OVERRIDE; |
| 462 virtual bool compileAndAttachShaders(GrGLuint programId, |
| 463 SkTDArray<GrGLuint>* shaderIds) const S
K_OVERRIDE; |
| 464 |
| 476 virtual void bindProgramLocations(GrGLuint programId) const SK_OVERRIDE; | 465 virtual void bindProgramLocations(GrGLuint programId) const SK_OVERRIDE; |
| 477 | 466 |
| 478 private: | |
| 479 VarArray fVSAttrs; | 467 VarArray fVSAttrs; |
| 480 VarArray fVSOutputs; | 468 VarArray fVSOutputs; |
| 481 VarArray fGSInputs; | 469 VarArray fGSInputs; |
| 482 VarArray fGSOutputs; | 470 VarArray fGSOutputs; |
| 483 | 471 |
| 484 SkString fVSCode; | 472 SkString fVSCode; |
| 485 | 473 |
| 486 struct AttributePair { | 474 struct AttributePair { |
| 487 void set(int index, const SkString& name) { | 475 void set(int index, const SkString& name) { |
| 488 fIndex = index; fName = name; | 476 fIndex = index; fName = name; |
| 489 } | 477 } |
| 490 int fIndex; | 478 int fIndex; |
| 491 SkString fName; | 479 SkString fName; |
| 492 }; | 480 }; |
| 493 SkSTArray<10, AttributePair, true> fEffectAttributes; | 481 SkSTArray<10, AttributePair, true> fEffectAttributes; |
| 494 | 482 |
| 495 GrGLUniformManager::UniformHandle fViewMatrixUniform; | 483 GrGLUniformManager::UniformHandle fViewMatrixUniform; |
| 496 GrGLUniformManager::UniformHandle fRTAdustmentVecUniform; | 484 GrGLUniformManager::UniformHandle fRTAdustmentVecUniform; |
| 497 GrGLShaderVar* fPositionVar; | 485 GrGLShaderVar* fPositionVar; |
| 498 GrGLShaderVar* fLocalCoordsVar; | 486 GrGLShaderVar* fLocalCoordsVar; |
| 499 | 487 |
| 500 typedef GrGLShaderBuilder INHERITED; | 488 typedef GrGLShaderBuilder INHERITED; |
| 501 }; | 489 }; |
| 502 | 490 |
| 503 //////////////////////////////////////////////////////////////////////////////// | 491 //////////////////////////////////////////////////////////////////////////////// |
| 504 | 492 |
| 505 class GrGLFragmentOnlyShaderBuilder : public GrGLShaderBuilder { | 493 class GrGLFragmentOnlyShaderBuilder : public GrGLShaderBuilder { |
| 506 public: | 494 public: |
| 507 GrGLFragmentOnlyShaderBuilder(GrGpuGL*, GrGLUniformManager&, const GrGLProgr
amDesc&); | 495 GrGLFragmentOnlyShaderBuilder(GrGpuGL*, GrGLUniformManager*, const GrGLProgr
amDesc&); |
| 508 | 496 |
| 509 int getNumTexCoordSets() const { return fNumTexCoordSets; } | 497 int getNumTexCoordSets() const { return fNumTexCoordSets; } |
| 510 int addTexCoordSets(int count); | 498 int addTexCoordSets(int count); |
| 511 | 499 |
| 512 virtual GrGLProgramEffects* createAndEmitEffects( | 500 private: |
| 513 const GrEffectStage* effectStages[], | |
| 514 const EffectKey effectKeys[], | |
| 515 int effectCnt, | |
| 516 GrGLSLExpr4* inOutFSColor) SK_OVERRIDE; | |
| 517 | 501 |
| 518 private: | 502 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], |
| 503 const EffectKey effectKeys[
], |
| 504 int effectCnt, |
| 505 GrGLSLExpr4* inOutFSColor)
SK_OVERRIDE; |
| 506 |
| 519 int fNumTexCoordSets; | 507 int fNumTexCoordSets; |
| 520 | 508 |
| 521 typedef GrGLShaderBuilder INHERITED; | 509 typedef GrGLShaderBuilder INHERITED; |
| 522 }; | 510 }; |
| 523 | 511 |
| 524 #endif | 512 #endif |
| OLD | NEW |