| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ | 161 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ |
| 162 const char* fragmentPosition(); | 162 const char* fragmentPosition(); |
| 163 | 163 |
| 164 /** Returns the color of the destination pixel. This may be NULL if no effec
t advertised | 164 /** Returns the color of the destination pixel. This may be NULL if no effec
t advertised |
| 165 that it will read the destination. */ | 165 that it will read the destination. */ |
| 166 const char* dstColor(); | 166 const char* dstColor(); |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Interfaces used by GrGLProgram. | 169 * Interfaces used by GrGLProgram. |
| 170 */ | 170 */ |
| 171 const GrGLSLExpr<4>& getInputColor() const { | 171 const GrGLSLExpr4& getInputColor() const { |
| 172 return fInputColor; | 172 return fInputColor; |
| 173 } | 173 } |
| 174 const GrGLSLExpr<4>& getInputCoverage() const { | 174 const GrGLSLExpr4& getInputCoverage() const { |
| 175 return fInputCoverage; | 175 return fInputCoverage; |
| 176 } | 176 } |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * Adds code for effects and returns a GrGLProgramEffects* object. The calle
r is responsible for | 179 * Adds code for effects and returns a GrGLProgramEffects* object. The calle
r is responsible for |
| 180 * deleting it when finished. effectStages contains the effects to add. effe
ctKeys[i] is the key | 180 * deleting it when finished. effectStages contains the effects to add. effe
ctKeys[i] is the key |
| 181 * generated from effectStages[i]. inOutFSColor specifies the input color to
the first stage and | 181 * generated from effectStages[i]. inOutFSColor specifies the input color to
the first stage and |
| 182 * is updated to be the output color of the last stage. | 182 * is updated to be the output color of the last stage. |
| 183 * The handles to texture samplers for effectStage[i] are added to | 183 * The handles to texture samplers for effectStage[i] are added to |
| 184 * effectSamplerHandles[i]. | 184 * effectSamplerHandles[i]. |
| 185 */ | 185 */ |
| 186 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], | 186 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], |
| 187 const EffectKey effectKeys[
], | 187 const EffectKey effectKeys[
], |
| 188 int effectCnt, | 188 int effectCnt, |
| 189 GrGLSLExpr<4>* inOutFSColor
) = 0; | 189 GrGLSLExpr4* inOutFSColor)
= 0; |
| 190 | 190 |
| 191 const char* getColorOutputName() const; | 191 const char* getColorOutputName() const; |
| 192 const char* enableSecondaryOutput(); | 192 const char* enableSecondaryOutput(); |
| 193 | 193 |
| 194 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei
ghtUniform; } | 194 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei
ghtUniform; } |
| 195 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const { | 195 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const { |
| 196 return fDstCopyTopLeftUniform; | 196 return fDstCopyTopLeftUniform; |
| 197 } | 197 } |
| 198 GrGLUniformManager::UniformHandle getDstCopyScaleUniform() const { | 198 GrGLUniformManager::UniformHandle getDstCopyScaleUniform() const { |
| 199 return fDstCopyScaleUniform; | 199 return fDstCopyScaleUniform; |
| 200 } | 200 } |
| 201 GrGLUniformManager::UniformHandle getColorUniform() const { return fColorUni
form; } | 201 GrGLUniformManager::UniformHandle getColorUniform() const { return fColorUni
form; } |
| 202 GrGLUniformManager::UniformHandle getCoverageUniform() const { return fCover
ageUniform; } | 202 GrGLUniformManager::UniformHandle getCoverageUniform() const { return fCover
ageUniform; } |
| 203 GrGLUniformManager::UniformHandle getDstCopySamplerUniform() const { | 203 GrGLUniformManager::UniformHandle getDstCopySamplerUniform() const { |
| 204 return fDstCopySamplerUniform; | 204 return fDstCopySamplerUniform; |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool finish(GrGLuint* outProgramId); | 207 bool finish(GrGLuint* outProgramId); |
| 208 | 208 |
| 209 const GrGLContextInfo& ctxInfo() const; | 209 const GrGLContextInfo& ctxInfo() const; |
| 210 | 210 |
| 211 protected: | 211 protected: |
| 212 GrGpuGL* gpu() const { return fGpu; } | 212 GrGpuGL* gpu() const { return fGpu; } |
| 213 | 213 |
| 214 void setInputColor(const GrGLSLExpr<4>& inputColor) { fInputColor = inputCol
or; } | 214 void setInputColor(const GrGLSLExpr4& inputColor) { fInputColor = inputColor
; } |
| 215 void setInputCoverage(const GrGLSLExpr<4>& inputCoverage) { fInputCoverage =
inputCoverage; } | 215 void setInputCoverage(const GrGLSLExpr4& inputCoverage) { fInputCoverage = i
nputCoverage; } |
| 216 | 216 |
| 217 /** Add input/output variable declarations (i.e. 'varying') to the fragment
shader. */ | 217 /** Add input/output variable declarations (i.e. 'varying') to the fragment
shader. */ |
| 218 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); } | 218 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); } |
| 219 | 219 |
| 220 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 220 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
| 221 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 221 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
| 222 // generating stage code. | 222 // generating stage code. |
| 223 void nameVariable(SkString* out, char prefix, const char* name); | 223 void nameVariable(SkString* out, char prefix, const char* name); |
| 224 | 224 |
| 225 // Helper for emitEffects(). | 225 // Helper for emitEffects(). |
| 226 void createAndEmitEffects(GrGLProgramEffectsBuilder*, | 226 void createAndEmitEffects(GrGLProgramEffectsBuilder*, |
| 227 const GrEffectStage* effectStages[], | 227 const GrEffectStage* effectStages[], |
| 228 const EffectKey effectKeys[], | 228 const EffectKey effectKeys[], |
| 229 int effectCnt, | 229 int effectCnt, |
| 230 GrGLSLExpr<4>* inOutFSColor); | 230 GrGLSLExpr4* inOutFSColor); |
| 231 | 231 |
| 232 virtual bool compileAndAttachShaders(GrGLuint programId) const; | 232 virtual bool compileAndAttachShaders(GrGLuint programId) const; |
| 233 virtual void bindProgramLocations(GrGLuint programId) const; | 233 virtual void bindProgramLocations(GrGLuint programId) const; |
| 234 | 234 |
| 235 void appendDecls(const VarArray&, SkString*) const; | 235 void appendDecls(const VarArray&, SkString*) const; |
| 236 void appendUniformDecls(ShaderVisibility, SkString*) const; | 236 void appendUniformDecls(ShaderVisibility, SkString*) const; |
| 237 | 237 |
| 238 private: | 238 private: |
| 239 class CodeStage : public SkNoncopyable { | 239 class CodeStage : public SkNoncopyable { |
| 240 public: | 240 public: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 SkString fFSExtensions; | 322 SkString fFSExtensions; |
| 323 VarArray fFSInputs; | 323 VarArray fFSInputs; |
| 324 VarArray fFSOutputs; | 324 VarArray fFSOutputs; |
| 325 GrGLUniformManager::BuilderUniformArray fUniforms; | 325 GrGLUniformManager::BuilderUniformArray fUniforms; |
| 326 | 326 |
| 327 SkString fFSCode; | 327 SkString fFSCode; |
| 328 | 328 |
| 329 bool fSetupFragPosition; | 329 bool fSetupFragPosition; |
| 330 GrGLUniformManager::UniformHandle fDstCopySamplerUniform; | 330 GrGLUniformManager::UniformHandle fDstCopySamplerUniform; |
| 331 | 331 |
| 332 GrGLSLExpr<4> fInputColor; | 332 GrGLSLExpr4 fInputColor; |
| 333 GrGLSLExpr<4> fInputCoverage; | 333 GrGLSLExpr4 fInputCoverage; |
| 334 | 334 |
| 335 bool fHasCustomColorOutput; | 335 bool fHasCustomColorOutput; |
| 336 bool fHasSecondaryOutput; | 336 bool fHasSecondaryOutput; |
| 337 | 337 |
| 338 GrGLUniformManager::UniformHandle fRTHeightUniform; | 338 GrGLUniformManager::UniformHandle fRTHeightUniform; |
| 339 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; | 339 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; |
| 340 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; | 340 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; |
| 341 GrGLUniformManager::UniformHandle fColorUniform; | 341 GrGLUniformManager::UniformHandle fColorUniform; |
| 342 GrGLUniformManager::UniformHandle fCoverageUniform; | 342 GrGLUniformManager::UniformHandle fCoverageUniform; |
| 343 | 343 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 */ | 389 */ |
| 390 bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVa
r); } | 390 bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVa
r); } |
| 391 | 391 |
| 392 bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& n
ame); | 392 bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& n
ame); |
| 393 const SkString* getEffectAttributeName(int attributeIndex) const; | 393 const SkString* getEffectAttributeName(int attributeIndex) const; |
| 394 | 394 |
| 395 virtual GrGLProgramEffects* createAndEmitEffects( | 395 virtual GrGLProgramEffects* createAndEmitEffects( |
| 396 const GrEffectStage* effectStages[], | 396 const GrEffectStage* effectStages[], |
| 397 const EffectKey effectKeys[], | 397 const EffectKey effectKeys[], |
| 398 int effectCnt, | 398 int effectCnt, |
| 399 GrGLSLExpr<4>* inOutFSColor) SK_OVERRIDE; | 399 GrGLSLExpr4* inOutFSColor) SK_OVERRIDE; |
| 400 | 400 |
| 401 GrGLUniformManager::UniformHandle getViewMatrixUniform() const { | 401 GrGLUniformManager::UniformHandle getViewMatrixUniform() const { |
| 402 return fViewMatrixUniform; | 402 return fViewMatrixUniform; |
| 403 } | 403 } |
| 404 | 404 |
| 405 protected: | 405 protected: |
| 406 virtual bool compileAndAttachShaders(GrGLuint programId) const SK_OVERRIDE; | 406 virtual bool compileAndAttachShaders(GrGLuint programId) const SK_OVERRIDE; |
| 407 virtual void bindProgramLocations(GrGLuint programId) const SK_OVERRIDE; | 407 virtual void bindProgramLocations(GrGLuint programId) const SK_OVERRIDE; |
| 408 | 408 |
| 409 private: | 409 private: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 438 public: | 438 public: |
| 439 GrGLFragmentOnlyShaderBuilder(GrGpuGL*, GrGLUniformManager&, const GrGLProgr
amDesc&); | 439 GrGLFragmentOnlyShaderBuilder(GrGpuGL*, GrGLUniformManager&, const GrGLProgr
amDesc&); |
| 440 | 440 |
| 441 int getNumTexCoordSets() const { return fNumTexCoordSets; } | 441 int getNumTexCoordSets() const { return fNumTexCoordSets; } |
| 442 int addTexCoordSets(int count); | 442 int addTexCoordSets(int count); |
| 443 | 443 |
| 444 virtual GrGLProgramEffects* createAndEmitEffects( | 444 virtual GrGLProgramEffects* createAndEmitEffects( |
| 445 const GrEffectStage* effectStages[], | 445 const GrEffectStage* effectStages[], |
| 446 const EffectKey effectKeys[], | 446 const EffectKey effectKeys[], |
| 447 int effectCnt, | 447 int effectCnt, |
| 448 GrGLSLExpr<4>* inOutFSColor) SK_OVERRIDE; | 448 GrGLSLExpr4* inOutFSColor) SK_OVERRIDE; |
| 449 | 449 |
| 450 private: | 450 private: |
| 451 int fNumTexCoordSets; | 451 int fNumTexCoordSets; |
| 452 | 452 |
| 453 typedef GrGLShaderBuilder INHERITED; | 453 typedef GrGLShaderBuilder INHERITED; |
| 454 }; | 454 }; |
| 455 | 455 |
| 456 #endif | 456 #endif |
| OLD | NEW |