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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const char* body, | 186 const char* body, |
187 SkString* outName); | 187 SkString* outName); |
188 | 188 |
189 /** Generates a EffectKey for the shader code based on the texture access pa
rameters and the | 189 /** Generates a EffectKey for the shader code based on the texture access pa
rameters and the |
190 capabilities of the GL context. This is useful for keying the shader pr
ograms that may | 190 capabilities of the GL context. This is useful for keying the shader pr
ograms that may |
191 have multiple representations, based on the type/format of textures used
. */ | 191 have multiple representations, based on the type/format of textures used
. */ |
192 static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTexture
Access&, | 192 static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTexture
Access&, |
193 const GrGLCaps&
); | 193 const GrGLCaps&
); |
194 | 194 |
195 typedef uint8_t DstReadKey; | 195 typedef uint8_t DstReadKey; |
| 196 typedef uint8_t FragPosKey; |
196 | 197 |
197 /** Returns a key for adding code to read the copy-of-dst color in service
of effects that | 198 /** Returns a key for adding code to read the copy-of-dst color in service
of effects that |
198 require reading the dst. It must not return 0 because 0 indicates that
there is no dst | 199 require reading the dst. It must not return 0 because 0 indicates that
there is no dst |
199 copy read at all. */ | 200 copy read at all (in which case this function should not be called). */ |
200 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); | 201 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); |
201 | 202 |
| 203 /** Returns a key for reading the fragment location. This should only be cal
led if there is an |
| 204 effect that will requires the fragment position. If the fragment positio
n is not required, |
| 205 the key is 0. */ |
| 206 static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const Gr
GLCaps&); |
| 207 |
202 /** If texture swizzling is available using tex parameters then it is prefer
red over mangling | 208 /** If texture swizzling is available using tex parameters then it is prefer
red over mangling |
203 the generated shader code. This potentially allows greater reuse of cach
ed shaders. */ | 209 the generated shader code. This potentially allows greater reuse of cach
ed shaders. */ |
204 static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCa
ps& caps); | 210 static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCa
ps& caps); |
205 | 211 |
206 /** Add a uniform variable to the current program, that has visibility in on
e or more shaders. | 212 /** Add a uniform variable to the current program, that has visibility in on
e or more shaders. |
207 visibility is a bitfield of ShaderType values indicating from which shad
ers the uniform | 213 visibility is a bitfield of ShaderType values indicating from which shad
ers the uniform |
208 should be accessible. At least one bit must be set. Geometry shader unif
orms are not | 214 should be accessible. At least one bit must be set. Geometry shader unif
orms are not |
209 supported at this time. The actual uniform name will be mangled. If outN
ame is not NULL then | 215 supported at this time. The actual uniform name will be mangled. If outN
ame is not NULL then |
210 it will refer to the final uniform name after return. Use the addUniform
Array variant to add | 216 it will refer to the final uniform name after return. Use the addUniform
Array variant to add |
211 an array of uniforms. | 217 an array of uniforms. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 void nameVariable(SkString* out, char prefix, const char* name); | 423 void nameVariable(SkString* out, char prefix, const char* name); |
418 | 424 |
419 // Interpretation of DstReadKey when generating code | 425 // Interpretation of DstReadKey when generating code |
420 enum { | 426 enum { |
421 kNoDstRead_DstReadKey = 0, | 427 kNoDstRead_DstReadKey = 0, |
422 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. | 428 kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. |
423 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha
only. | 429 kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha
only. |
424 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-le
ft. | 430 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-le
ft. |
425 }; | 431 }; |
426 | 432 |
| 433 enum { |
| 434 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil
l not be needed. |
| 435 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t
op-left. |
| 436 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b
ottom-left. |
| 437 }; |
| 438 |
427 const GrGLContextInfo& fCtxInfo; | 439 const GrGLContextInfo& fCtxInfo; |
428 GrGLUniformManager& fUniformManager; | 440 GrGLUniformManager& fUniformManager; |
429 uint32_t fFSFeaturesAddedMask; | 441 uint32_t fFSFeaturesAddedMask; |
430 SkString fFSFunctions; | 442 SkString fFSFunctions; |
431 SkString fFSExtensions; | 443 SkString fFSExtensions; |
432 | 444 |
433 bool fUsesGS; | 445 bool fUsesGS; |
434 | 446 |
435 SkString fFSCode; | 447 SkString fFSCode; |
436 SkString fVSCode; | 448 SkString fVSCode; |
437 SkString fGSCode; | 449 SkString fGSCode; |
438 | 450 |
439 bool fSetupFragPosition; | 451 bool fSetupFragPosition; |
440 TextureSampler fDstCopySampler; | 452 TextureSampler fDstCopySampler; |
441 | 453 |
442 GrGLUniformManager::UniformHandle fRTHeightUniform; | 454 GrGLUniformManager::UniformHandle fRTHeightUniform; |
443 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; | 455 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; |
444 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; | 456 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; |
445 | 457 |
| 458 bool fTopLeftFragPosRead; |
| 459 |
446 SkSTArray<10, AttributePair, true> fEffectAttributes; | 460 SkSTArray<10, AttributePair, true> fEffectAttributes; |
447 | 461 |
448 GrGLShaderVar* fPositionVar; | 462 GrGLShaderVar* fPositionVar; |
449 GrGLShaderVar* fLocalCoordsVar; | 463 GrGLShaderVar* fLocalCoordsVar; |
450 | 464 |
451 }; | 465 }; |
452 | 466 |
453 #endif | 467 #endif |
OLD | NEW |