From 4285accf5af574e6c826d5d09f0359c6149fd717 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 22 Oct 2012 14:11:24 +0000 Subject: Make GrGLProgram be responsible for calling setData on custom stages. R=robertphillips@google.com Review URL: https://codereview.appspot.com/6752044 git-svn-id: http://skia.googlecode.com/svn/trunk@6027 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGLProgram.cpp | 13 +++++++++++++ src/gpu/gl/GrGLProgram.h | 24 +++++++++++------------- src/gpu/gl/GrGpuGL_program.cpp | 9 ++------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 3c3d852511..fcf00af552 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -971,3 +971,16 @@ GrGLProgramStage* GrGLProgram::GenStageCode(const GrCustomStage* stage, return glStage; } + +void GrGLProgram::setData(const GrDrawState& drawState) const { + for (int s = 0; s < GrDrawState::kNumStages; ++s) { + if (NULL != fProgramStage[s]) { + const GrSamplerState& sampler = drawState.getSampler(s); + GrAssert(NULL != sampler.getCustomStage()); + fProgramStage[s]->setData(fUniformManager, + *sampler.getCustomStage(), + drawState.getRenderTarget(), + s); + } + } +} diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h index cdb2c4b6a2..5f504f25cb 100644 --- a/src/gpu/gl/GrGLProgram.h +++ b/src/gpu/gl/GrGLProgram.h @@ -51,7 +51,7 @@ public: void abandon(); /** - * The shader may modify the blend coeffecients. Params are in/out + * The shader may modify the blend coefficients. Params are in/out */ void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const; @@ -68,19 +68,18 @@ public: } static int EdgeAttributeIdx() { return 3 + GrDrawState::kMaxTexCoords; } - static int ViewMatrixAttributeIdx() { - return 4 + GrDrawState::kMaxTexCoords; - } - static int TextureMatrixAttributeIdx(int stage) { - return 7 + GrDrawState::kMaxTexCoords + 3 * stage; - } + /** + * This function uploads uniforms and calls each GrCustomStage's setData. It is called before a + * draw occurs using the program after the program has already been bound. + */ + void setData(const GrDrawState& drawState) const; // Parameters that affect code generation // These structs should be kept compact; they are the input to an // expensive hash key generator. struct Desc { Desc() { - // since we use this as part of a key we can't have any unitialized + // since we use this as part of a key we can't have any uninitialized // padding memset(this, 0, sizeof(Desc)); } @@ -115,8 +114,7 @@ public: } }; - // Specifies where the intitial color comes from before the stages are - // applied. + // Specifies where the initial color comes from before the stages are applied. enum ColorInput { kSolidWhite_ColorInput, kTransBlack_ColorInput, @@ -126,7 +124,7 @@ public: kColorInputCnt }; // Dual-src blending makes use of a secondary output color that can be - // used as a per-pixel blend coeffecient. This controls whether a + // used as a per-pixel blend coefficient. This controls whether a // secondary source is output and what value it holds. enum DualSrcOutput { kNone_DualSrcOutput, @@ -139,7 +137,7 @@ public: GrDrawState::VertexEdgeType fVertexEdgeType; - // stripped of bits that don't affect prog generation + // stripped of bits that don't affect program generation GrVertexLayout fVertexLayout; StageDesc fStages[GrDrawState::kNumStages]; @@ -173,7 +171,7 @@ private: bool succeeded() const { return 0 != fProgramID; } /** - * This is the heavy initilization routine for building a GLProgram. + * This is the heavy initialization routine for building a GLProgram. */ bool genProgram(const GrCustomStage** customStages); diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index 5f5a3a6f95..343923098e 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -383,18 +383,13 @@ bool GrGpuGL::flushGraphicsState(DrawType type) { this->flushColor(color); this->flushCoverage(coverage); + fCurrentProgram->setData(drawState); + for (int s = 0; s < GrDrawState::kNumStages; ++s) { if (this->isStageEnabled(s)) { this->flushBoundTextureAndParams(s); this->flushTextureMatrix(s); - - if (NULL != fCurrentProgram->fProgramStage[s]) { - const GrSamplerState& sampler = this->getDrawState().getSampler(s); - fCurrentProgram->fProgramStage[s]->setData(fCurrentProgram->fUniformManager, - *sampler.getCustomStage(), - drawState.getRenderTarget(), s); - } } } } -- cgit v1.2.3