Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.h

Issue 23471008: Add a requiresVertexShader method to GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 enum ShaderVisibility { 101 enum ShaderVisibility {
102 kVertex_Visibility = 0x1, 102 kVertex_Visibility = 0x1,
103 kGeometry_Visibility = 0x2, 103 kGeometry_Visibility = 0x2,
104 kFragment_Visibility = 0x4, 104 kFragment_Visibility = 0x4,
105 }; 105 };
106 106
107 GrGLShaderBuilder(const GrGLContextInfo&, 107 GrGLShaderBuilder(const GrGLContextInfo&,
108 GrGLUniformManager&, 108 GrGLUniformManager&,
109 const GrGLProgramDesc&, 109 const GrGLProgramDesc&,
110 bool needsVertexShader); 110 bool requiresVertexShader);
111 111
112 /** 112 /**
113 * Use of these features may require a GLSL extension to be enabled. Shaders may not compile 113 * Use of these features may require a GLSL extension to be enabled. Shaders may not compile
114 * if code is added that uses one of these features without calling enableFe ature() 114 * if code is added that uses one of these features without calling enableFe ature()
115 */ 115 */
116 enum GLSLFeature { 116 enum GLSLFeature {
117 kStandardDerivatives_GLSLFeature = 0, 117 kStandardDerivatives_GLSLFeature = 0,
118 118
119 kLastGLSLFeature = kStandardDerivatives_GLSLFeature 119 kLastGLSLFeature = kStandardDerivatives_GLSLFeature
120 }; 120 };
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 * Adds code for effects. effectStages contains the effects to add. effectKe ys[i] is the key 249 * Adds code for effects. effectStages contains the effects to add. effectKe ys[i] is the key
250 * generated from effectStages[i]. An entry in effectStages can be NULL, in which case it is 250 * generated from effectStages[i]. An entry in effectStages can be NULL, in which case it is
251 * skipped. Moreover, if the corresponding key is GrGLEffect::NoEffectKey th en it is skipped. 251 * skipped. Moreover, if the corresponding key is GrGLEffect::NoEffectKey th en it is skipped.
252 * inOutFSColor specifies the input color to the first stage and is updated to be the 252 * inOutFSColor specifies the input color to the first stage and is updated to be the
253 * output color of the last stage. fsInOutColorKnownValue specifies whether the input color 253 * output color of the last stage. fsInOutColorKnownValue specifies whether the input color
254 * has a known constant value and is updated to refer to the status of the o utput color. 254 * has a known constant value and is updated to refer to the status of the o utput color.
255 * The handles to texture samplers for effectStage[i] are added to effectSam plerHandles[i]. The 255 * The handles to texture samplers for effectStage[i] are added to effectSam plerHandles[i]. The
256 * glEffects array is updated to contain the GrGLEffect generated for each e ntry in 256 * glEffects array is updated to contain the GrGLEffect generated for each e ntry in
257 * effectStages. 257 * effectStages.
258 */ 258 */
259 void emitEffects(const GrEffectStage* effectStages[], 259 void emitEffects(GrGLEffect* const glEffects[],
260 const GrBackendEffectFactory::EffectKey effectKeys[], 260 GrDrawEffect const drawEffects[],
261 GrBackendEffectFactory::EffectKey const effectKeys[],
bsalomon 2013/09/06 14:10:03 what's with the const placement?
Chris Dalton 2013/09/06 17:17:24 For GrDrawEffect and GrBackendEffectFactory, it me
Chris Dalton 2013/09/06 17:31:37 Oh yeah, I forgot. The GrGLEffects can't be const
bsalomon 2013/09/06 17:37:17 Gotcha
261 int effectCnt, 262 int effectCnt,
262 SkString* inOutFSColor, 263 SkString* inOutFSColor,
263 GrSLConstantVec* fsInOutColorKnownValue, 264 GrSLConstantVec* fsInOutColorKnownValue,
264 SkTArray<GrGLUniformManager::UniformHandle, true>* effectSa mplerHandles[], 265 SkTArray<GrGLUniformManager::UniformHandle, true>* effectSa mplerHandles[]);
265 GrGLEffect* glEffects[]);
266 266
267 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei ghtUniform; } 267 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei ghtUniform; }
268 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const { 268 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const {
269 return fDstCopyTopLeftUniform; 269 return fDstCopyTopLeftUniform;
270 } 270 }
271 GrGLUniformManager::UniformHandle getDstCopyScaleUniform() const { 271 GrGLUniformManager::UniformHandle getDstCopyScaleUniform() const {
272 return fDstCopyScaleUniform; 272 return fDstCopyScaleUniform;
273 } 273 }
274 GrGLUniformManager::UniformHandle getDstCopySamplerUniform() const { 274 GrGLUniformManager::UniformHandle getDstCopySamplerUniform() const {
275 return fDstCopySampler.fSamplerUniform; 275 return fDstCopySampler.fSamplerUniform;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 private: 381 private:
382 void appendDecls(const VarArray&, SkString*) const; 382 void appendDecls(const VarArray&, SkString*) const;
383 void appendUniformDecls(ShaderVisibility, SkString*) const; 383 void appendUniformDecls(ShaderVisibility, SkString*) const;
384 384
385 typedef GrGLUniformManager::BuilderUniform BuilderUniform; 385 typedef GrGLUniformManager::BuilderUniform BuilderUniform;
386 GrGLUniformManager::BuilderUniformArray fUniforms; 386 GrGLUniformManager::BuilderUniformArray fUniforms;
387 387
388 private: 388 private:
389 class CodeStage : GrNoncopyable { 389 class CodeStage : GrNoncopyable {
390 public: 390 public:
391 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {} 391 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffect(NULL) {}
392 392
393 bool inStageCode() const { 393 bool inStageCode() const {
394 this->validate(); 394 this->validate();
395 return NULL != fEffectStage; 395 return NULL != fEffect;
396 } 396 }
397 397
398 const GrEffectStage* effectStage() const { 398 const GrEffectRef* effect() const {
399 this->validate(); 399 this->validate();
400 return fEffectStage; 400 return fEffect;
401 } 401 }
402 402
403 int stageIndex() const { 403 int stageIndex() const {
404 this->validate(); 404 this->validate();
405 return fCurrentIndex; 405 return fCurrentIndex;
406 } 406 }
407 407
408 class AutoStageRestore : GrNoncopyable { 408 class AutoStageRestore : GrNoncopyable {
409 public: 409 public:
410 AutoStageRestore(CodeStage* codeStage, const GrEffectStage* newStage ) { 410 AutoStageRestore(CodeStage* codeStage, const GrEffectRef* effect) {
411 SkASSERT(NULL != codeStage); 411 SkASSERT(NULL != codeStage);
412 fSavedIndex = codeStage->fCurrentIndex; 412 fSavedIndex = codeStage->fCurrentIndex;
413 fSavedEffectStage = codeStage->fEffectStage; 413 fSavedEffect = codeStage->fEffect;
414 414
415 if (NULL == newStage) { 415 if (NULL == effect) {
416 codeStage->fCurrentIndex = -1; 416 codeStage->fCurrentIndex = -1;
417 } else { 417 } else {
418 codeStage->fCurrentIndex = codeStage->fNextIndex++; 418 codeStage->fCurrentIndex = codeStage->fNextIndex++;
419 } 419 }
420 codeStage->fEffectStage = newStage; 420 codeStage->fEffect = effect;
421 421
422 fCodeStage = codeStage; 422 fCodeStage = codeStage;
423 } 423 }
424 ~AutoStageRestore() { 424 ~AutoStageRestore() {
425 fCodeStage->fCurrentIndex = fSavedIndex; 425 fCodeStage->fCurrentIndex = fSavedIndex;
426 fCodeStage->fEffectStage = fSavedEffectStage; 426 fCodeStage->fEffect = fSavedEffect;
427 } 427 }
428 private: 428 private:
429 CodeStage* fCodeStage; 429 CodeStage* fCodeStage;
430 int fSavedIndex; 430 int fSavedIndex;
431 const GrEffectStage* fSavedEffectStage; 431 const GrEffectRef* fSavedEffect;
432 }; 432 };
433 private: 433 private:
434 void validate() const { SkASSERT((NULL == fEffectStage) == (-1 == fCurre ntIndex)); } 434 void validate() const { SkASSERT((NULL == fEffect) == (-1 == fCurrentInd ex)); }
435 int fNextIndex; 435 int fNextIndex;
436 int fCurrentIndex; 436 int fCurrentIndex;
437 const GrEffectStage* fEffectStage; 437 const GrEffectRef* fEffect;
438 } fCodeStage; 438 } fCodeStage;
439 439
440 /** 440 /**
441 * Features that should only be enabled by GrGLShaderBuilder itself. 441 * Features that should only be enabled by GrGLShaderBuilder itself.
442 */ 442 */
443 enum GLSLPrivateFeature { 443 enum GLSLPrivateFeature {
444 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, 444 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1,
445 kEXTShaderFramebufferFetch_GLSLPrivateFeature, 445 kEXTShaderFramebufferFetch_GLSLPrivateFeature,
446 kNVShaderFramebufferFetch_GLSLPrivateFeature, 446 kNVShaderFramebufferFetch_GLSLPrivateFeature,
447 }; 447 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 GrGLUniformManager::UniformHandle fRTHeightUniform; 486 GrGLUniformManager::UniformHandle fRTHeightUniform;
487 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; 487 GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform;
488 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; 488 GrGLUniformManager::UniformHandle fDstCopyScaleUniform;
489 489
490 bool fTopLeftFragPosRead; 490 bool fTopLeftFragPosRead;
491 491
492 SkAutoTDelete<VertexBuilder> fVertexBuilder; 492 SkAutoTDelete<VertexBuilder> fVertexBuilder;
493 }; 493 };
494 494
495 #endif 495 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698