Add support for GL_ARB_texture_swizzle
Review URL: http://codereview.appspot.com/5347042/
git-svn-id: http://skia.googlecode.com/svn/trunk@2615 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpuGLShaders.cpp b/src/gpu/GrGpuGLShaders.cpp
index c287a30..e3d2c2e 100644
--- a/src/gpu/GrGpuGLShaders.cpp
+++ b/src/gpu/GrGpuGLShaders.cpp
@@ -204,8 +204,8 @@
pdesc.fVertexLayout = 0;
pdesc.fEmitsPointSize = random.nextF() > .5f;
- pdesc.fColorType = static_cast<int>(random.nextF() *
- ProgramDesc::kColorTypeCnt);
+ pdesc.fColorInput = static_cast<int>(random.nextF() *
+ ProgramDesc::kColorInputCnt);
int idx = (int)(random.nextF() * (SkXfermode::kCoeffModesCnt));
pdesc.fColorFilterXfermode = (SkXfermode::Mode)idx;
@@ -270,7 +270,7 @@
idx = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_OPTS));
StageDesc& stage = pdesc.fStages[s];
stage.fOptFlags = STAGE_OPTS[idx];
- stage.fModulation = random_val(&random, StageDesc::kModulationCnt);
+ stage.fInputConfig = random_val(&random, StageDesc::kInputConfigCnt);
stage.fCoordMapping = random_val(&random, StageDesc::kCoordMappingCnt);
stage.fFetchMode = random_val(&random, StageDesc::kFetchModeCnt);
// convolution shaders don't work with persp tex matrix
@@ -605,8 +605,8 @@
// invalidate the const vertex attrib color
fHWDrawState.fColor = GrColor_ILLEGAL;
} else {
- switch (desc.fColorType) {
- case ProgramDesc::kAttribute_ColorType:
+ switch (desc.fColorInput) {
+ case ProgramDesc::kAttribute_ColorInput:
if (fHWDrawState.fColor != color) {
// OpenGL ES only supports the float varities of glVertexAttrib
float c[] = GR_COLOR_TO_VEC4(color);
@@ -615,7 +615,7 @@
fHWDrawState.fColor = color;
}
break;
- case ProgramDesc::kUniform_ColorType:
+ case ProgramDesc::kUniform_ColorInput:
if (fProgramData->fColor != color) {
// OpenGL ES only supports the float varities of glVertexAttrib
float c[] = GR_COLOR_TO_VEC4(color);
@@ -626,8 +626,8 @@
fProgramData->fColor = color;
}
break;
- case ProgramDesc::kSolidWhite_ColorType:
- case ProgramDesc::kTransBlack_ColorType:
+ case ProgramDesc::kSolidWhite_ColorInput:
+ case ProgramDesc::kTransBlack_ColorInput:
break;
default:
GrCrash("Unknown color type.");
@@ -882,7 +882,7 @@
bool requiresAttributeColors =
!skipColor && SkToBool(desc.fVertexLayout & kColor_VertexLayoutBit);
- // fColorType records how colors are specified for the program. Strip
+ // fColorInput records how colors are specified for the program. Strip
// the bit from the layout to avoid false negatives when searching for an
// existing program in the cache.
desc.fVertexLayout &= ~(kColor_VertexLayoutBit);
@@ -903,13 +903,13 @@
(!requiresAttributeColors &&
0xffffffff == fCurrDrawState.fColor);
if (GR_AGGRESSIVE_SHADER_OPTS && colorIsTransBlack) {
- desc.fColorType = ProgramDesc::kTransBlack_ColorType;
+ desc.fColorInput = ProgramDesc::kTransBlack_ColorInput;
} else if (GR_AGGRESSIVE_SHADER_OPTS && colorIsSolidWhite) {
- desc.fColorType = ProgramDesc::kSolidWhite_ColorType;
+ desc.fColorInput = ProgramDesc::kSolidWhite_ColorInput;
} else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeColors) {
- desc.fColorType = ProgramDesc::kUniform_ColorType;
+ desc.fColorInput = ProgramDesc::kUniform_ColorInput;
} else {
- desc.fColorType = ProgramDesc::kAttribute_ColorType;
+ desc.fColorInput = ProgramDesc::kAttribute_ColorInput;
}
desc.fEdgeAANumEdges = skipCoverage ? 0 : fCurrDrawState.fEdgeAANumEdges;
@@ -999,10 +999,14 @@
stage.fOptFlags |= StageDesc::kCustomTextureDomain_OptFlagBit;
}
- if (GrPixelConfigIsAlphaOnly(texture->config())) {
- stage.fModulation = StageDesc::kAlpha_Modulation;
+ if (!this->glCaps().fTextureSwizzle &&
+ GrPixelConfigIsAlphaOnly(texture->config())) {
+ // if we don't have texture swizzle support then
+ // the shader must do an alpha smear after reading
+ // the texture
+ stage.fInputConfig = StageDesc::kAlphaOnly_InputConfig;
} else {
- stage.fModulation = StageDesc::kColor_Modulation;
+ stage.fInputConfig = StageDesc::kColor_InputConfig;
}
if (sampler.getFilter() == GrSamplerState::kConvolution_Filter) {
stage.fKernelWidth = sampler.getKernelWidth();
@@ -1012,9 +1016,9 @@
} else {
stage.fOptFlags = 0;
stage.fCoordMapping = (StageDesc::CoordMapping)0;
- stage.fModulation = (StageDesc::Modulation)0;
- stage.fFetchMode = (StageDesc::FetchMode) 0;
- stage.fKernelWidth = 0;
+ stage.fInputConfig = (StageDesc::InputConfig)0;
+ stage.fFetchMode = (StageDesc::FetchMode) 0;
+ stage.fKernelWidth = 0;
}
}