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
This commit is contained in:
tomhudson@google.com 2012-08-02 20:13:12 +00:00
parent 534aa5b946
commit de788237c2
3 changed files with 12 additions and 16 deletions

View File

@ -1068,15 +1068,7 @@ void GrGLProgram::genStageCode(int stageNum,
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);

View File

@ -31,7 +31,6 @@ static SkString build_sampler_string(GrGLShaderBuilder::SamplerMode samplerMode)
sampler.append("Proj");
break;
case GrGLShaderBuilder::kExplicitDivide_SamplerMode:
GrAssert(false); // Not Implemented
break;
}
@ -120,18 +119,22 @@ void GrGLShaderBuilder::computeModulate(const char* fsInColor) {
}
}
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 @@ void GrGLShaderBuilder::setupTextureAccess(SamplerMode samplerMode,
fSampleCoords = retval;
break;
}
fTexFunc = build_sampler_string(mode);
fComplexCoord = false;
}

View File

@ -45,7 +45,7 @@ public:
/** 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. */