aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrConvolutionEffect.cpp
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-30 18:26:03 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-30 18:26:03 +0000
commit23cb2299ddf8fc87df0d3f9bda78934382cf714d (patch)
tree8698b0ae92451ce5ef8e4e002cfb00983c2c7424 /src/gpu/effects/GrConvolutionEffect.cpp
parent02154c73904aa4006e3023931655c63ae192d600 (diff)
Condense setupFSUnis, setupVSUnis, setupVaryings into
GrGLProgramStage::setupVariables(). Rename appendVarying() to addVarying(), matching addUniform(). http://codereview.appspot.com/6262046/ git-svn-id: http://skia.googlecode.com/svn/trunk@4083 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects/GrConvolutionEffect.cpp')
-rw-r--r--src/gpu/effects/GrConvolutionEffect.cpp46
1 files changed, 15 insertions, 31 deletions
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 15f2aebd5f..0dd1606c81 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -19,8 +19,8 @@ public:
GrGLConvolutionEffect(const GrProgramStageFactory& factory,
const GrCustomStage* stage);
- virtual void setupVSUnis(VarArray* vsUnis, int stage) SK_OVERRIDE;
- virtual void setupFSUnis(VarArray* fsUnis, int stage) SK_OVERRIDE;
+ virtual void setupVariables(GrGLShaderBuilder* state,
+ int stage) SK_OVERRIDE;
virtual void emitVS(GrGLShaderBuilder* state,
const char* vertexCoords) SK_OVERRIDE;
virtual void emitFS(GrGLShaderBuilder* state,
@@ -38,12 +38,12 @@ public:
protected:
- unsigned int fKernelWidth;
- GrGLShaderVar* fKernelVar;
- GrGLShaderVar* fImageIncrementVar;
+ unsigned int fKernelWidth;
+ const GrGLShaderVar* fKernelVar;
+ const GrGLShaderVar* fImageIncrementVar;
- GrGLint fKernelLocation;
- GrGLint fImageIncrementLocation;
+ GrGLint fKernelLocation;
+ GrGLint fImageIncrementLocation;
private:
@@ -61,33 +61,17 @@ GrGLConvolutionEffect::GrGLConvolutionEffect(
fKernelWidth = static_cast<const GrConvolutionEffect*>(data)->width();
}
-void GrGLConvolutionEffect::setupVSUnis(VarArray* vsUnis,
- int stage) {
- fImageIncrementVar = &vsUnis->push_back();
- fImageIncrementVar->setType(kVec2f_GrSLType);
- fImageIncrementVar->setTypeModifier(
- GrGLShaderVar::kUniform_TypeModifier);
- (*fImageIncrementVar->accessName()) = "uImageIncrement";
- fImageIncrementVar->accessName()->appendS32(stage);
- fImageIncrementVar->setEmitPrecision(true);
+void GrGLConvolutionEffect::setupVariables(GrGLShaderBuilder* state,
+ int stage) {
+ fImageIncrementVar = &state->addUniform(
+ GrGLShaderBuilder::kBoth_VariableLifetime,
+ kVec2f_GrSLType, "uImageIncrement", stage);
+ fKernelVar = &state->addUniform(
+ GrGLShaderBuilder::kFragment_VariableLifetime,
+ kFloat_GrSLType, "uKernel", stage, fKernelWidth);
fImageIncrementLocation = kUseUniform;
-}
-
-void GrGLConvolutionEffect::setupFSUnis(VarArray* fsUnis,
- int stage) {
- fKernelVar = &fsUnis->push_back();
- fKernelVar->setType(kFloat_GrSLType);
- fKernelVar->setTypeModifier(
- GrGLShaderVar::kUniform_TypeModifier);
- fKernelVar->setArrayCount(fKernelWidth);
- (*fKernelVar->accessName()) = "uKernel";
- fKernelVar->accessName()->appendS32(stage);
-
fKernelLocation = kUseUniform;
-
- // Image increment is used in both vertex & fragment shaders.
- fsUnis->push_back(*fImageIncrementVar).setEmitPrecision(false);
}
void GrGLConvolutionEffect::emitVS(GrGLShaderBuilder* state,