Reduce usage of GrGLShaderBuilder::SamplerMode
http://codereview.appspot.com/6453080/
git-svn-id: http://skia.googlecode.com/svn/trunk@4940 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 3590428..ebbd267 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -1068,15 +1068,7 @@
builder->fSampleCoords = varyingFSName;
- GrGLShaderBuilder::SamplerMode sampleMode =
- GrGLShaderBuilder::kExplicitDivide_SamplerMode;
- if (desc.fOptFlags & (StageDesc::kIdentityMatrix_OptFlagBit |
- StageDesc::kNoPerspective_OptFlagBit)) {
- sampleMode = GrGLShaderBuilder::kDefault_SamplerMode;
- } else if (NULL == customStage) {
- sampleMode = GrGLShaderBuilder::kProj_SamplerMode;
- }
- builder->setupTextureAccess(sampleMode, stageNum);
+ builder->setupTextureAccess(stageNum);
builder->computeSwizzle(desc.fInConfigFlags);
builder->computeModulate(fsInColor);
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index 7171029..fb70556 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -31,7 +31,6 @@
sampler.append("Proj");
break;
case GrGLShaderBuilder::kExplicitDivide_SamplerMode:
- GrAssert(false); // Not Implemented
break;
}
@@ -120,18 +119,22 @@
}
}
-void GrGLShaderBuilder::setupTextureAccess(SamplerMode samplerMode,
- int stageNum) {
+void GrGLShaderBuilder::setupTextureAccess(int stageNum) {
SkString retval;
- fTexFunc = "texture2D";
- switch (samplerMode) {
+ SamplerMode mode = kDefault_SamplerMode;
+ // FIXME: we aren't currently using Proj.
+ if (fVaryingDims != fCoordDims) {
+ mode = kExplicitDivide_SamplerMode;
+ }
+
+ switch (mode) {
case kDefault_SamplerMode:
GrAssert(fVaryingDims == fCoordDims);
// Do nothing
break;
case kProj_SamplerMode:
- fTexFunc.append("Proj");
+ // Do nothing
break;
case kExplicitDivide_SamplerMode:
retval = "inCoord";
@@ -147,6 +150,7 @@
fSampleCoords = retval;
break;
}
+ fTexFunc = build_sampler_string(mode);
fComplexCoord = false;
}
diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h
index 16a11e2..ab0792b 100644
--- a/src/gpu/gl/GrGLShaderBuilder.h
+++ b/src/gpu/gl/GrGLShaderBuilder.h
@@ -45,7 +45,7 @@
/** Determines whether we should use texture2D() or texture2Dproj(), and if an explicit divide
is required for the sample coordinates, creates the new variable and emits the code to
initialize it. */
- void setupTextureAccess(SamplerMode samplerMode, int stageNum);
+ void setupTextureAccess(int stageNum);
/** texture2D(samplerName, coordName), with projection if necessary; if coordName is not
specified, uses fSampleCoords. */