diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-30 19:43:59 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-30 19:43:59 +0000 |
commit | 74a3a2135ca82ab9324b7e499caa3280348a4fda (patch) | |
tree | 8425e08e70f47a8c602a8503fd7fa582e69c95b3 /src | |
parent | 3628ad9f1357e1f185f02d0676dda0acd3de5d05 (diff) |
Rename ShaderType enum to ShaderVisibility
Renames ShaderType in GrGLShaderBuilder to ShaderVisibility. It is now
used solely as a bitfield. Methods that previously accepted a single
ShaderType value are split into separate calls:
- getShader -> vsGetShader, gsGetShader, fsGetShader
- emiitFunction -> fsEmitFunction
- appendTextureLookup -> fsAppendTextureLookup
No change in functionality. This is a refactoring to allow us to
separate the vertex/geometry and fragment parts of GrGLShaderBuilder.
R=bsalomon@google.com
Author: cdalton@nvidia.com
Review URL: https://chromiumcodereview.appspot.com/23826002
git-svn-id: http://skia.googlecode.com/svn/trunk@11044 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
23 files changed, 270 insertions, 364 deletions
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index c9b3f39c8d..1efd9efc4b 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -952,10 +952,7 @@ public: GrSLType bgCoordsType = fBackgroundEffectMatrix.emitCode(builder, key, &bgCoords, NULL, "BG"); dstColor = "bgColor"; builder->fsCodeAppendf("\t\tvec4 %s = ", dstColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[0], - bgCoords.c_str(), - bgCoordsType); + builder->fsAppendTextureLookup(samplers[0], bgCoords.c_str(), bgCoordsType); builder->fsCodeAppendf(";\n"); } else { dstColor = builder->dstColor(); @@ -1225,12 +1222,11 @@ public: GrGLShaderVar("color", kVec3f_GrSLType), }; SkString getLumBody("\treturn dot(vec3(0.3, 0.59, 0.11), color);\n"); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kFloat_GrSLType, - "luminance", - SK_ARRAY_COUNT(getLumArgs), getLumArgs, - getLumBody.c_str(), - &getFunction); + builder->fsEmitFunction(kFloat_GrSLType, + "luminance", + SK_ARRAY_COUNT(getLumArgs), getLumArgs, + getLumBody.c_str(), + &getFunction); // Emit the set luminance function. GrGLShaderVar setLumArgs[] = { @@ -1251,12 +1247,11 @@ public: "\t\toutColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) / (maxComp - outLum);\n" "\t}\n" "\treturn outColor;\n"); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec3f_GrSLType, - "set_luminance", - SK_ARRAY_COUNT(setLumArgs), setLumArgs, - setLumBody.c_str(), - setLumFunction); + builder->fsEmitFunction(kVec3f_GrSLType, + "set_luminance", + SK_ARRAY_COUNT(setLumArgs), setLumArgs, + setLumBody.c_str(), + setLumFunction); } // Adds a function that creates a color with the hue and luminosity of one input color and @@ -1269,12 +1264,11 @@ public: SkString getSatBody; getSatBody.printf("\treturn max(max(color.r, color.g), color.b) - " "min(min(color.r, color.g), color.b);\n"); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kFloat_GrSLType, - "saturation", - SK_ARRAY_COUNT(getSatArgs), getSatArgs, - getSatBody.c_str(), - &getFunction); + builder->fsEmitFunction(kFloat_GrSLType, + "saturation", + SK_ARRAY_COUNT(getSatArgs), getSatArgs, + getSatBody.c_str(), + &getFunction); // Emit a helper that sets the saturation given sorted input channels. This used // to use inout params for min, mid, and max components but that seems to cause @@ -1296,12 +1290,11 @@ public: "\t} else {\n" "\t\treturn vec3(0, 0, 0);\n" "\t}\n"; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec3f_GrSLType, - "set_saturation_helper", - SK_ARRAY_COUNT(helperArgs), helperArgs, - kHelperBody, - &helperFunction); + builder->fsEmitFunction(kVec3f_GrSLType, + "set_saturation_helper", + SK_ARRAY_COUNT(helperArgs), helperArgs, + kHelperBody, + &helperFunction); GrGLShaderVar setSatArgs[] = { GrGLShaderVar("hueLumColor", kVec3f_GrSLType), @@ -1328,12 +1321,11 @@ public: "\treturn hueLumColor;\n", getFunction.c_str(), helpFunc, helpFunc, helpFunc, helpFunc, helpFunc, helpFunc); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec3f_GrSLType, - "set_saturation", - SK_ARRAY_COUNT(setSatArgs), setSatArgs, - setSatBody.c_str(), - setSatFunction); + builder->fsEmitFunction(kVec3f_GrSLType, + "set_saturation", + SK_ARRAY_COUNT(setSatArgs), setSatArgs, + setSatBody.c_str(), + setSatFunction); } diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp index 1efa115106..fd81d8246a 100644 --- a/src/effects/SkArithmeticMode.cpp +++ b/src/effects/SkArithmeticMode.cpp @@ -354,10 +354,7 @@ void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder, SkString bgCoords; GrSLType bgCoordsType = fBackgroundEffectMatrix.emitCode(builder, key, &bgCoords, NULL, "BG"); builder->fsCodeAppend("\t\tvec4 bgColor = "); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[0], - bgCoords.c_str(), - bgCoordsType); + builder->fsAppendTextureLookup(samplers[0], bgCoords.c_str(), bgCoordsType); builder->fsCodeAppendf(";\n"); dstColor = "bgColor"; } else { @@ -365,7 +362,7 @@ void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder, } SkASSERT(NULL != dstColor); - fKUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fKUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrSLType, "k"); const char* kUni = builder->getUniformCStr(fKUni); diff --git a/src/effects/SkBicubicImageFilter.cpp b/src/effects/SkBicubicImageFilter.cpp index 56d9eba754..3b2dd4fe7d 100644 --- a/src/effects/SkBicubicImageFilter.cpp +++ b/src/effects/SkBicubicImageFilter.cpp @@ -226,9 +226,9 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, const TextureSamplerArray& samplers) { SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); - fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kMat44f_GrSLType, "Coefficients"); - fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "ImageIncrement"); const char* imgInc = builder->getUniformCStr(fImageIncrementUni); @@ -244,15 +244,14 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, GrGLShaderVar("c2", kVec4f_GrSLType), GrGLShaderVar("c3", kVec4f_GrSLType), }; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec4f_GrSLType, - "cubicBlend", - SK_ARRAY_COUNT(gCubicBlendArgs), - gCubicBlendArgs, - "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" - "\tvec4 c = coefficients * ts;\n" - "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;\n", - &cubicBlendName); + builder->fsEmitFunction(kVec4f_GrSLType, + "cubicBlend", + SK_ARRAY_COUNT(gCubicBlendArgs), + gCubicBlendArgs, + "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" + "\tvec4 c = coefficients * ts;\n" + "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;\n", + &cubicBlendName); builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5, 0.5);\n", coords.c_str(), imgInc); builder->fsCodeAppendf("\tvec2 f = fract(coord / %s);\n", imgInc); for (int y = 0; y < 4; ++y) { @@ -260,9 +259,7 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, SkString coord; coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1); builder->fsCodeAppendf("\tvec4 s%d%d = ", x, y); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[0], - coord.c_str()); + builder->fsAppendTextureLookup(samplers[0], coord.c_str()); builder->fsCodeAppend(";\n"); } builder->fsCodeAppendf("\tvec4 s%d = %s(%s, f.x, s0%d, s1%d, s2%d, s3%d);\n", y, cubicBlendName.c_str(), coeff, y, y, y, y); diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 7bb9673d10..fa4ad5e2bc 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -400,10 +400,10 @@ public: const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE { - fMatrixHandle = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fMatrixHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kMat44f_GrSLType, "ColorMatrix"); - fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrSLType, "ColorMatrixVector"); diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 4dfb754190..a0764ed223 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -409,7 +409,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder, const TextureSamplerArray& samplers) { sk_ignore_unused_variable(inputColor); - fScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "Scale"); const char* scaleUni = builder->getUniformCStr(fScaleUni); @@ -428,10 +428,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder, // leave room for 32-bit float GPU rounding errors. builder->fsCodeAppendf("\t\tvec4 %s = ", dColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[0], - dCoordsIn.c_str(), - dCoordsType); + builder->fsAppendTextureLookup(samplers[0], dCoordsIn.c_str(), dCoordsType); builder->fsCodeAppend(";\n"); // Unpremultiply the displacement @@ -484,10 +481,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder, "bool %s = (%s.x < 0.0) || (%s.y < 0.0) || (%s.x > 1.0) || (%s.y > 1.0);\t\t", outOfBounds, cCoords, cCoords, cCoords, cCoords); builder->fsCodeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[1], - cCoords, - cCoordsType); + builder->fsAppendTextureLookup(samplers[1], cCoords, cCoordsType); builder->fsCodeAppend(";\n"); } diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index f907a199b8..999b8f8bfa 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -1207,10 +1207,10 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); - fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "ImageIncrement"); - fSurfaceScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fSurfaceScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "SurfaceScale"); fLight->emitLightColorUniform(builder); @@ -1226,26 +1226,24 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, GrGLShaderVar("scale", kFloat_GrSLType), }; SkString sobelFuncName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kFloat_GrSLType, - "sobel", - SK_ARRAY_COUNT(gSobelArgs), - gSobelArgs, - "\treturn (-a + b - 2.0 * c + 2.0 * d -e + f) * scale;\n", - &sobelFuncName); + builder->fsEmitFunction(kFloat_GrSLType, + "sobel", + SK_ARRAY_COUNT(gSobelArgs), + gSobelArgs, + "\treturn (-a + b - 2.0 * c + 2.0 * d -e + f) * scale;\n", + &sobelFuncName); static const GrGLShaderVar gPointToNormalArgs[] = { GrGLShaderVar("x", kFloat_GrSLType), GrGLShaderVar("y", kFloat_GrSLType), GrGLShaderVar("scale", kFloat_GrSLType), }; SkString pointToNormalName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec3f_GrSLType, - "pointToNormal", - SK_ARRAY_COUNT(gPointToNormalArgs), - gPointToNormalArgs, - "\treturn normalize(vec3(-x * scale, y * scale, 1));\n", - &pointToNormalName); + builder->fsEmitFunction(kVec3f_GrSLType, + "pointToNormal", + SK_ARRAY_COUNT(gPointToNormalArgs), + gPointToNormalArgs, + "\treturn normalize(vec3(-x * scale, y * scale, 1));\n", + &pointToNormalName); static const GrGLShaderVar gInteriorNormalArgs[] = { GrGLShaderVar("m", kFloat_GrSLType, 9), @@ -1259,13 +1257,12 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, sobelFuncName.c_str(), sobelFuncName.c_str()); SkString interiorNormalName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec3f_GrSLType, - "interiorNormal", - SK_ARRAY_COUNT(gInteriorNormalArgs), - gInteriorNormalArgs, - interiorNormalBody.c_str(), - &interiorNormalName); + builder->fsEmitFunction(kVec3f_GrSLType, + "interiorNormal", + SK_ARRAY_COUNT(gInteriorNormalArgs), + gInteriorNormalArgs, + interiorNormalBody.c_str(), + &interiorNormalName); builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords.c_str()); builder->fsCodeAppend("\t\tfloat m[9];\n"); @@ -1279,9 +1276,7 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, SkString texCoords; texCoords.appendf("coord + vec2(%d, %d) * %s", dx, dy, imgInc); builder->fsCodeAppendf("\t\tm[%d] = ", index++); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[0], - texCoords.c_str()); + builder->fsAppendTextureLookup(samplers[0], texCoords.c_str()); builder->fsCodeAppend(".a;\n"); } } @@ -1337,7 +1332,7 @@ GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactor void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkString* funcName) { const char* kd; - fKDUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fKDUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "KD", &kd); @@ -1350,13 +1345,12 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri SkString lightBody; lightBody.appendf("\tfloat colorScale = %s * dot(normal, surfaceToLight);\n", kd); lightBody.appendf("\treturn vec4(lightColor * clamp(colorScale, 0.0, 1.0), 1.0);\n"); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec4f_GrSLType, - "light", - SK_ARRAY_COUNT(gLightArgs), - gLightArgs, - lightBody.c_str(), - funcName); + builder->fsEmitFunction(kVec4f_GrSLType, + "light", + SK_ARRAY_COUNT(gLightArgs), + gLightArgs, + lightBody.c_str(), + funcName); } void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman, @@ -1419,9 +1413,9 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr const char* ks; const char* shininess; - fKSUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fKSUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "KS", &ks); - fShininessUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fShininessUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Shininess", &shininess); static const GrGLShaderVar gLightArgs[] = { @@ -1434,13 +1428,12 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr lightBody.appendf("\tfloat colorScale = %s * pow(dot(normal, halfDir), %s);\n", ks, shininess); lightBody.appendf("\tvec3 color = lightColor * clamp(colorScale, 0.0, 1.0);\n"); lightBody.appendf("\treturn vec4(color, max(max(color.r, color.g), color.b));\n"); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec4f_GrSLType, - "light", - SK_ARRAY_COUNT(gLightArgs), - gLightArgs, - lightBody.c_str(), - funcName); + builder->fsEmitFunction(kVec4f_GrSLType, + "light", + SK_ARRAY_COUNT(gLightArgs), + gLightArgs, + lightBody.c_str(), + funcName); } void GrGLSpecularLightingEffect::setData(const GrGLUniformManager& uman, @@ -1453,7 +1446,7 @@ void GrGLSpecularLightingEffect::setData(const GrGLUniformManager& uman, /////////////////////////////////////////////////////////////////////////////// void GrGLLight::emitLightColorUniform(GrGLShaderBuilder* builder) { - fColorUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fColorUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec3f_GrSLType, "LightColor"); } @@ -1479,7 +1472,7 @@ void GrGLDistantLight::setData(const GrGLUniformManager& uman, void GrGLDistantLight::emitSurfaceToLight(GrGLShaderBuilder* builder, const char* z) { const char* dir; - fDirectionUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, kVec3f_GrSLType, + fDirectionUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec3f_GrSLType, "LightDirection", &dir); builder->fsCodeAppend(dir); } @@ -1496,7 +1489,7 @@ void GrGLPointLight::setData(const GrGLUniformManager& uman, void GrGLPointLight::emitSurfaceToLight(GrGLShaderBuilder* builder, const char* z) { const char* loc; - fLocationUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, kVec3f_GrSLType, + fLocationUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec3f_GrSLType, "LightLocation", &loc); builder->fsCodeAppendf("normalize(%s - vec3(%s.xy, %s))", loc, builder->fragmentPosition(), z); } @@ -1518,7 +1511,7 @@ void GrGLSpotLight::setData(const GrGLUniformManager& uman, void GrGLSpotLight::emitSurfaceToLight(GrGLShaderBuilder* builder, const char* z) { const char* location; - fLocationUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fLocationUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec3f_GrSLType, "LightLocation", &location); builder->fsCodeAppendf("normalize(%s - vec3(%s.xy, %s))", location, builder->fragmentPosition(), z); @@ -1534,15 +1527,15 @@ void GrGLSpotLight::emitLightColor(GrGLShaderBuilder* builder, const char* cosOuter; const char* coneScale; const char* s; - fExponentUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fExponentUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Exponent", &exponent); - fCosInnerConeAngleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fCosInnerConeAngleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "CosInnerConeAngle", &cosInner); - fCosOuterConeAngleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fCosOuterConeAngleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "CosOuterConeAngle", &cosOuter); - fConeScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fConeScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "ConeScale", &coneScale); - fSUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fSUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec3f_GrSLType, "S", &s); static const GrGLShaderVar gLightColorArgs[] = { @@ -1559,13 +1552,12 @@ void GrGLSpotLight::emitLightColor(GrGLShaderBuilder* builder, color, cosOuter, coneScale); lightColorBody.appendf("\t}\n"); lightColorBody.appendf("\treturn %s;\n", color); - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, - kVec3f_GrSLType, - "lightColor", - SK_ARRAY_COUNT(gLightColorArgs), - gLightColorArgs, - lightColorBody.c_str(), - &fLightColorFunc); + builder->fsEmitFunction(kVec3f_GrSLType, + "lightColor", + SK_ARRAY_COUNT(gLightColorArgs), + gLightColorArgs, + lightColorBody.c_str(), + &fLightColorFunc); builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); } diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index f6b70fc524..24aef28583 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -130,16 +130,16 @@ void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder, SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); fOffsetVar = builder->addUniform( - GrGLShaderBuilder::kFragment_ShaderType | - GrGLShaderBuilder::kVertex_ShaderType, + GrGLShaderBuilder::kFragment_Visibility | + GrGLShaderBuilder::kVertex_Visibility, kVec2f_GrSLType, "uOffset"); fZoomVar = builder->addUniform( - GrGLShaderBuilder::kFragment_ShaderType | - GrGLShaderBuilder::kVertex_ShaderType, + GrGLShaderBuilder::kFragment_Visibility | + GrGLShaderBuilder::kVertex_Visibility, kVec2f_GrSLType, "uZoom"); fInsetVar = builder->addUniform( - GrGLShaderBuilder::kFragment_ShaderType | - GrGLShaderBuilder::kVertex_ShaderType, + GrGLShaderBuilder::kFragment_Visibility | + GrGLShaderBuilder::kVertex_Visibility, kVec2f_GrSLType, "uInset"); builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords.c_str()); @@ -165,7 +165,7 @@ void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder, builder->fsCodeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n"); builder->fsCodeAppend("\t\tvec4 output_color = "); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "mix_coord"); + builder->fsAppendTextureLookup(samplers[0], "mix_coord"); builder->fsCodeAppend(";\n"); builder->fsCodeAppendf("\t\t%s = output_color;", outputColor); diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 00bb6ec4bb..03b28969b3 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -376,7 +376,7 @@ static void appendTextureLookup(GrGLShaderBuilder* builder, builder->fsCodeAppendf("clamp(%s, 0.0, 1.0) != %s ? vec4(0, 0, 0, 0) : ", coord, coord); break; } - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, sampler, coord); + builder->fsAppendTextureLookup(sampler, coord); } void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder, @@ -387,15 +387,15 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder, const TextureSamplerArray& samplers) { SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); - fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "ImageIncrement"); - fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType, + fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Kernel", fKernelSize.width() * fKernelSize.height()); - fTargetUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fTargetUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "Target"); - fGainUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fGainUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Gain"); - fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Bias"); const char* target = builder->getUniformCStr(fTargetUni); diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 6d15d4e2db..331bbd7edd 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -326,7 +326,7 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder, const TextureSamplerArray& samplers) { SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); - fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "ImageIncrement"); const char* func; @@ -349,7 +349,7 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder, builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc); builder->fsCodeAppendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width()); builder->fsCodeAppendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "coord"); + builder->fsAppendTextureLookup(samplers[0], "coord"); builder->fsCodeAppend(");\n"); builder->fsCodeAppendf("\t\t\tcoord += %s;\n", imgInc); builder->fsCodeAppend("\t\t}\n"); diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 720fcf27ed..b34afe7110 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -752,16 +752,16 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, SkString vCoords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &vCoords); - fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "seed"); const char* seedUni = builder->getUniformCStr(fSeedUni); - fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kMat33f_GrSLType, "invMatrix"); const char* invMatrixUni = builder->getUniformCStr(fInvMatrixUni); - fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "baseFrequency"); const char* baseFrequencyUni = builder->getUniformCStr(fBaseFrequencyUni); - fAlphaUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fAlphaUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "alpha"); const char* alphaUni = builder->getUniformCStr(fAlphaUni); @@ -771,10 +771,10 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, }; SkString mod289_3_funcName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kVec3f_GrSLType, - "mod289", SK_ARRAY_COUNT(gVec3Args), gVec3Args, - "const vec2 C = vec2(1.0 / 289.0, 289.0);\n" - "return x - floor(x * C.xxx) * C.yyy;", &mod289_3_funcName); + builder->fsEmitFunction(kVec3f_GrSLType, + "mod289", SK_ARRAY_COUNT(gVec3Args), gVec3Args, + "const vec2 C = vec2(1.0 / 289.0, 289.0);\n" + "return x - floor(x * C.xxx) * C.yyy;", &mod289_3_funcName); // Add vec4 modulo 289 function static const GrGLShaderVar gVec4Args[] = { @@ -782,26 +782,26 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, }; SkString mod289_4_funcName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kVec4f_GrSLType, - "mod289", SK_ARRAY_COUNT(gVec4Args), gVec4Args, - "const vec2 C = vec2(1.0 / 289.0, 289.0);\n" - "return x - floor(x * C.xxxx) * C.yyyy;", &mod289_4_funcName); + builder->fsEmitFunction(kVec4f_GrSLType, + "mod289", SK_ARRAY_COUNT(gVec4Args), gVec4Args, + "const vec2 C = vec2(1.0 / 289.0, 289.0);\n" + "return x - floor(x * C.xxxx) * C.yyyy;", &mod289_4_funcName); // Add vec4 permute function SkString permuteCode; permuteCode.appendf("const vec2 C = vec2(34.0, 1.0);\n" "return %s(((x * C.xxxx) + C.yyyy) * x);", mod289_4_funcName.c_str()); SkString permuteFuncName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kVec4f_GrSLType, - "permute", SK_ARRAY_COUNT(gVec4Args), gVec4Args, - permuteCode.c_str(), &permuteFuncName); + builder->fsEmitFunction(kVec4f_GrSLType, + "permute", SK_ARRAY_COUNT(gVec4Args), gVec4Args, + permuteCode.c_str(), &permuteFuncName); // Add vec4 taylorInvSqrt function SkString taylorInvSqrtFuncName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kVec4f_GrSLType, - "taylorInvSqrt", SK_ARRAY_COUNT(gVec4Args), gVec4Args, - "const vec2 C = vec2(-0.85373472095314, 1.79284291400159);\n" - "return x * C.xxxx + C.yyyy;", &taylorInvSqrtFuncName); + builder->fsEmitFunction(kVec4f_GrSLType, + "taylorInvSqrt", SK_ARRAY_COUNT(gVec4Args), gVec4Args, + "const vec2 C = vec2(-0.85373472095314, 1.79284291400159);\n" + "return x * C.xxxx + C.yyyy;", &taylorInvSqrtFuncName); // Add vec3 noise function static const GrGLShaderVar gNoiseVec3Args[] = { @@ -886,9 +886,9 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, taylorInvSqrtFuncName.c_str()); SkString noiseFuncName; - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_GrSLType, - "snoise", SK_ARRAY_COUNT(gNoiseVec3Args), gNoiseVec3Args, - noiseCode.c_str(), &noiseFuncName); + builder->fsEmitFunction(kFloat_GrSLType, + "snoise", SK_ARRAY_COUNT(gNoiseVec3Args), gNoiseVec3Args, + noiseCode.c_str(), &noiseFuncName); const char* noiseVecIni = "noiseVecIni"; const char* factors = "factors"; @@ -968,19 +968,19 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder, SkString vCoords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &vCoords); - fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kMat33f_GrSLType, "invMatrix"); const char* invMatrixUni = builder->getUniformCStr(fInvMatrixUni); - fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "baseFrequency"); const char* baseFrequencyUni = builder->getUniformCStr(fBaseFrequencyUni); - fAlphaUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fAlphaUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "alpha"); const char* alphaUni = builder->getUniformCStr(fAlphaUni); const char* stitchDataUni = NULL; if (fStitchTiles) { - fStitchDataUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fStitchDataUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "stitchData"); stitchDataUni = builder->getUniformCStr(fStitchDataUni); } @@ -1137,13 +1137,13 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder, SkString noiseFuncName; if (fStitchTiles) { - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_GrSLType, - "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseStitchArgs), - gPerlinNoiseStitchArgs, noiseCode.c_str(), &noiseFuncName); + builder->fsEmitFunction(kFloat_GrSLType, + "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseStitchArgs), + gPerlinNoiseStitchArgs, noiseCode.c_str(), &noiseFuncName); } else { - builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, kFloat_GrSLType, - "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseArgs), - gPerlinNoiseArgs, noiseCode.c_str(), &noiseFuncName); + builder->fsEmitFunction(kFloat_GrSLType, + "perlinnoise", SK_ARRAY_COUNT(gPerlinNoiseArgs), + gPerlinNoiseArgs, noiseCode.c_str(), &noiseFuncName); } // There are rounding errors if the floor operation is not performed here diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index cbcc6bc439..bb72b82628 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -312,19 +312,19 @@ void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder, } builder->fsCodeAppendf("\t\t%s.a = ", outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.a, 0.125)"); + builder->fsAppendTextureLookup(samplers[0], "vec2(coord.a, 0.125)"); builder->fsCodeAppend(";\n"); builder->fsCodeAppendf("\t\t%s.r = ", outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.r, 0.375)"); + builder->fsAppendTextureLookup(samplers[0], "vec2(coord.r, 0.375)"); builder->fsCodeAppend(";\n"); builder->fsCodeAppendf("\t\t%s.g = ", outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.g, 0.625)"); + builder->fsAppendTextureLookup(samplers[0], "vec2(coord.g, 0.625)"); builder->fsCodeAppend(";\n"); builder->fsCodeAppendf("\t\t%s.b = ", outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.b, 0.875)"); + builder->fsAppendTextureLookup(samplers[0], "vec2(coord.b, 0.875)"); builder->fsCodeAppend(";\n"); builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor); diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 329e6c76ce..ca6386acb0 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -832,7 +832,7 @@ GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory) GrGLGradientEffect::~GrGLGradientEffect() { } void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) { - fFSYUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fFSYUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "GradientYCoordFS"); } @@ -877,10 +877,7 @@ void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder, gradientTValue, builder->getUniformVariable(fFSYUni).c_str()); builder->fsCodeAppendf("\t%s = ", outputColor); - builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, - inputColor, - sampler, - "coord"); + builder->fsAppendTextureLookupAndModulate(inputColor, sampler, "coord"); builder->fsCodeAppend(";\n"); } diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 6926c2d2ec..5e0c4b892b 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -499,9 +499,9 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, // 2 copies of uniform array, 1 for each of vertex & fragment shader, // to work around Xoom bug. Doesn't seem to cause performance decrease // in test apps, but need to keep an eye on it. - fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_ShaderType, + fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility, kFloat_GrSLType, "Conical2VSParams", 6); - fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType, + fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Conical2FSParams", 6); // For radial gradients without perspective we can pass the linear diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 4c8575844c..a3f82ec038 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.cpp +++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp @@ -541,9 +541,9 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder, // 2 copies of uniform array, 1 for each of vertex & fragment shader, // to work around Xoom bug. Doesn't seem to cause performance decrease // in test apps, but need to keep an eye on it. - fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_ShaderType, + fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility, kFloat_GrSLType, "Radial2VSParams", 6); - fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType, + fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Radial2FSParams", 6); // For radial gradients without perspective we can pass the linear diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 8f58feff79..d50484712c 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -33,10 +33,7 @@ public: SkString coords; GrSLType coordsType = fEffectMatrix.emitCode(builder, key, &coords); builder->fsCodeAppendf("\t\t%s = ", outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, - samplers[0], - coords.c_str(), - coordsType); + builder->fsAppendTextureLookup(samplers[0], coords.c_str(), coordsType); builder->fsCodeAppend(";\n"); if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { SkASSERT(fSwapRedAndBlue); diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp index d3d18409ea..dd25d40e78 100644 --- a/src/gpu/effects/GrConvolutionEffect.cpp +++ b/src/gpu/effects/GrConvolutionEffect.cpp @@ -64,13 +64,13 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder, const TextureSamplerArray& samplers) { SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); - fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "ImageIncrement"); if (this->useBounds()) { - fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec2f_GrSLType, "Bounds"); } - fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType, + fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility, kFloat_GrSLType, "Kernel", this->width()); builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); @@ -88,7 +88,7 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder, index.appendS32(i); kernel.appendArrayAccess(index.c_str(), &kernelIndex); builder->fsCodeAppendf("\t\t%s += ", outputColor); - builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "coord"); + builder->fsAppendTextureLookup(samplers[0], "coord"); if (this->useBounds()) { const char* bounds = builder->getUniformCStr(fBoundsUni); const char* component = this->direction() == Gr1DKernelEffect::kY_Direction ? "y" : "x"; diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index 6a85e4780e..7a1692b325 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -48,11 +48,10 @@ public: fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoordName); } builder->fsCodeAppendf("\t%s = ", outputColor); - builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, - inputColor, - samplers[0], - fsCoordName.c_str(), - fsCoordSLType); + builder->fsAppendTextureLookupAndModulate(inputColor, + samplers[0], + fsCoordName.c_str(), + fsCoordSLType); builder->fsCodeAppend(";\n"); } diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp index 6f400cf3c1..c7eda889aa 100644 --- a/src/gpu/effects/GrTextureDomainEffect.cpp +++ b/src/gpu/effects/GrTextureDomainEffect.cpp @@ -53,7 +53,7 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, SkString coords; fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); const char* domain; - fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrSLType, "TexDom", &domain); if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) { @@ -61,10 +61,7 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, coords.c_str(), domain, domain); builder->fsCodeAppendf("\t%s = ", outputColor); - builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, - inputColor, - samplers[0], - "clampCoord"); + builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], "clampCoord"); builder->fsCodeAppend(";\n"); } else { SkASSERT(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode()); @@ -78,10 +75,7 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, // result=white;" code fails to compile. builder->fsCodeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\n"); builder->fsCodeAppend("\tvec4 inside = "); - builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, - inputColor, - samplers[0], - coords.c_str()); + builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], coords.c_str()); builder->fsCodeAppend(";\n"); builder->fsCodeAppendf("\tfloat x = abs(2.0*(%s.x - %s.x)/(%s.z - %s.x) - 1.0);\n", @@ -95,10 +89,7 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, builder->fsCodeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", coords.c_str(), domain); builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", coords.c_str(), domain); builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ", outputColor); - builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType, - inputColor, - samplers[0], - coords.c_str()); + builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], coords.c_str()); builder->fsCodeAppend(";\n"); } } diff --git a/src/gpu/gl/GrGLEffectMatrix.cpp b/src/gpu/gl/GrGLEffectMatrix.cpp index 58fcfeaa4a..19f99c0673 100644 --- a/src/gpu/gl/GrGLEffectMatrix.cpp +++ b/src/gpu/gl/GrGLEffectMatrix.cpp @@ -81,7 +81,7 @@ GrSLType GrGLEffectMatrix::emitCode(GrGLShaderBuilder* builder, uniName = suffixedUniName.c_str(); } if (kVoid_GrSLType != fUniType) { - fUni = builder->addUniform(GrGLShaderBuilder::kVertex_ShaderType, + fUni = builder->addUniform(GrGLShaderBuilder::kVertex_Visibility, fUniType, uniName, &uniName); diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index cae44bfd0c..a1c4fd5d76 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -231,7 +231,7 @@ GrSLConstantVec GrGLProgram::genInputColor(GrGLShaderBuilder* builder, SkString* } case GrGLProgramDesc::kUniform_ColorInput: { const char* name; - fUniformHandles.fColorUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fUniformHandles.fColorUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrSLType, "Color", &name); *inColor = name; return kNone_GrSLConstantVec; @@ -261,7 +261,7 @@ GrSLConstantVec GrGLProgram::genInputCoverage(GrGLShaderBuilder* builder, SkStri case GrGLProgramDesc::kUniform_ColorInput: { const char* name; fUniformHandles.fCoverageUni = - builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrSLType, "Coverage", &name); *inCoverage = name; return kNone_GrSLConstantVec; @@ -399,7 +399,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { SkString shader; - builder.getShader(GrGLShaderBuilder::kVertex_ShaderType, &shader); + builder.vsGetShader(&shader); if (c_PrintShaders) { GrPrintf(shader.c_str()); GrPrintf("\n"); @@ -412,7 +412,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { fGShaderID = 0; #if GR_GL_EXPERIMENTAL_GS if (fDesc.getHeader().fExperimentalGS) { - builder.getShader(GrGLShaderBuilder::kGeometry_ShaderType, &shader); + builder.gsGetShader(&shader); if (c_PrintShaders) { GrPrintf(shader.c_str()); GrPrintf("\n"); @@ -423,7 +423,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { } #endif - builder.getShader(GrGLShaderBuilder::kFragment_ShaderType, &shader); + builder.fsGetShader(&shader); if (c_PrintShaders) { GrPrintf(shader.c_str()); GrPrintf("\n"); @@ -456,7 +456,7 @@ bool GrGLProgram::genProgram(const GrEffectStage* colorStages[], } const char* viewMName; - fUniformHandles.fViewMatrixUni = builder.addUniform(GrGLShaderBuilder::kVertex_ShaderType, + fUniformHandles.fViewMatrixUni = builder.addUniform(GrGLShaderBuilder::kVertex_Visibility, kMat33f_GrSLType, "ViewM", &viewMName); @@ -514,7 +514,7 @@ bool GrGLProgram::genProgram(const GrEffectStage* colorStages[], // Insert the color filter. This will soon be replaced by a color effect. if (SkXfermode::kDst_Mode != header.fColorFilterXfermode) { const char* colorFilterColorUniName = NULL; - fUniformHandles.fColorFilterUni = builder.addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fUniformHandles.fColorFilterUni = builder.addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrSLType, "FilterColor", &colorFilterColorUniName); diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index 9ac4645ee0..2554142583 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -138,11 +138,11 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, } fDstCopySampler.init(this, configMask, "rgba", 0); - fDstCopyTopLeftUniform = this->addUniform(kFragment_ShaderType, + fDstCopyTopLeftUniform = this->addUniform(kFragment_Visibility, kVec2f_GrSLType, "DstCopyUpperLeft", &dstCopyTopLeftName); - fDstCopyScaleUniform = this->addUniform(kFragment_ShaderType, + fDstCopyScaleUniform = this->addUniform(kFragment_Visibility, kVec2f_GrSLType, "DstCopyCoordScale", &dstCopyCoordScaleName); @@ -154,7 +154,7 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, this->fsCodeAppend("\t_dstTexCoord.y = 1.0 - _dstTexCoord.y;\n"); } this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); - this->appendTextureLookup(kFragment_ShaderType, fDstCopySampler, "_dstTexCoord"); + this->fsAppendTextureLookup(fDstCopySampler, "_dstTexCoord"); this->fsCodeAppend(";\n\n"); } } @@ -253,42 +253,6 @@ const char* GrGLShaderBuilder::dstColor() { } } -void GrGLShaderBuilder::codeAppendf(ShaderType type, const char format[], va_list args) { - SkString* string = NULL; - switch (type) { - case kVertex_ShaderType: - string = &fVSCode; - break; - case kGeometry_ShaderType: - string = &fGSCode; - break; - case kFragment_ShaderType: - string = &fFSCode; - break; - default: - GrCrash("Invalid shader type"); - } - string->appendf(format, args); -} - -void GrGLShaderBuilder::codeAppend(ShaderType type, const char* str) { - SkString* string = NULL; - switch (type) { - case kVertex_ShaderType: - string = &fVSCode; - break; - case kGeometry_ShaderType: - string = &fGSCode; - break; - case kFragment_ShaderType: - string = &fFSCode; - break; - default: - GrCrash("Invalid shader type"); - } - string->append(str); -} - void GrGLShaderBuilder::appendTextureLookup(SkString* out, const GrGLShaderBuilder::TextureSampler& sampler, const char* coordName, @@ -302,21 +266,17 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out, append_swizzle(out, sampler, *fCtxInfo.caps()); } -void GrGLShaderBuilder::appendTextureLookup(ShaderType type, - const GrGLShaderBuilder::TextureSampler& sampler, - const char* coordName, - GrSLType varyingType) { - SkASSERT(kFragment_ShaderType == type); +void GrGLShaderBuilder::fsAppendTextureLookup(const GrGLShaderBuilder::TextureSampler& sampler, + const char* coordName, + GrSLType varyingType) { this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType); } -void GrGLShaderBuilder::appendTextureLookupAndModulate( - ShaderType type, +void GrGLShaderBuilder::fsAppendTextureLookupAndModulate( const char* modulation, const GrGLShaderBuilder::TextureSampler& sampler, const char* coordName, GrSLType varyingType) { - SkASSERT(kFragment_ShaderType == type); SkString lookup; this->appendTextureLookup(&lookup, sampler, coordName, varyingType); GrGLSLModulatef<4>(&fFSCode, modulation, lookup.c_str()); @@ -383,7 +343,7 @@ GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi int count, const char** outName) { SkASSERT(name && strlen(name)); - SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_ShaderType | kFragment_ShaderType); + SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFragment_Visibility); SkASSERT(0 == (~kVisibilityMask & visibility)); SkASSERT(0 != visibility); @@ -403,7 +363,7 @@ GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi // If it is visible in both the VS and FS, the precision must match. // We declare a default FS precision, but not a default VS. So set the var // to use the default FS precision. - if ((kVertex_ShaderType | kFragment_ShaderType) == visibility) { + if ((kVertex_Visibility | kFragment_Visibility) == visibility) { // the fragment and vertex precisions must match uni.fVariable.setPrecision(kDefaultFragmentPrecision); } @@ -508,7 +468,7 @@ const char* GrGLShaderBuilder::fragmentPosition() { SkASSERT(!fRTHeightUniform.isValid()); const char* rtHeightName; - fRTHeightUniform = this->addUniform(kFragment_ShaderType, + fRTHeightUniform = this->addUniform(kFragment_Visibility, kFloat_GrSLType, "RTHeight", &rtHeightName); @@ -523,14 +483,12 @@ const char* GrGLShaderBuilder::fragmentPosition() { } -void GrGLShaderBuilder::emitFunction(ShaderType shader, - GrSLType returnType, - const char* name, - int argCnt, - const GrGLShaderVar* args, - const char* body, - SkString* outName) { - SkASSERT(kFragment_ShaderType == shader); +void GrGLShaderBuilder::fsEmitFunction(GrSLType returnType, + const char* name, + int argCnt, + const GrGLShaderVar* args, + const char* body, + SkString* outName) { fFSFunctions.append(GrGLSLTypeString(returnType)); this->nameVariable(outName, '\0', name); fFSFunctions.appendf(" %s", outName->c_str()); @@ -579,59 +537,57 @@ void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const { } } -void GrGLShaderBuilder::appendUniformDecls(ShaderType stype, SkString* out) const { +void GrGLShaderBuilder::appendUniformDecls(ShaderVisibility visibility, + SkString* out) const { for (int i = 0; i < fUniforms.count(); ++i) { - if (fUniforms[i].fVisibility & stype) { + if (fUniforms[i].fVisibility & visibility) { fUniforms[i].fVariable.appendDecl(fCtxInfo, out); out->append(";\n"); } } } -void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const { - const char* version = GrGetGLSLVersionDecl(fCtxInfo); - - switch (type) { - case kVertex_ShaderType: - *shaderStr = version; - this->appendUniformDecls(kVertex_ShaderType, shaderStr); - this->appendDecls(fVSAttrs, shaderStr); - this->appendDecls(fVSOutputs, shaderStr); - shaderStr->append("void main() {\n"); - shaderStr->append(fVSCode); - shaderStr->append("}\n"); - break; - case kGeometry_ShaderType: - if (fUsesGS) { - *shaderStr = version; - shaderStr->append(fGSHeader); - this->appendDecls(fGSInputs, shaderStr); - this->appendDecls(fGSOutputs, shaderStr); - shaderStr->append("void main() {\n"); - shaderStr->append(fGSCode); - shaderStr->append("}\n"); - } else { - shaderStr->reset(); - } - break; - case kFragment_ShaderType: - *shaderStr = version; - shaderStr->append(fFSExtensions); - append_default_precision_qualifier(kDefaultFragmentPrecision, - fCtxInfo.binding(), - shaderStr); - this->appendUniformDecls(kFragment_ShaderType, shaderStr); - this->appendDecls(fFSInputs, shaderStr); - // We shouldn't have declared outputs on 1.10 - SkASSERT(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOutputs.empty()); - this->appendDecls(fFSOutputs, shaderStr); - shaderStr->append(fFSFunctions); - shaderStr->append("void main() {\n"); - shaderStr->append(fFSCode); - shaderStr->append("}\n"); - break; - } - } +void GrGLShaderBuilder::vsGetShader(SkString* shaderStr) const { + *shaderStr = GrGetGLSLVersionDecl(fCtxInfo); + this->appendUniformDecls(kVertex_Visibility, shaderStr); + this->appendDecls(fVSAttrs, shaderStr); + this->appendDecls(fVSOutputs, shaderStr); + shaderStr->append("void main() {\n"); + shaderStr->append(fVSCode); + shaderStr->append("}\n"); +} + +void GrGLShaderBuilder::gsGetShader(SkString* shaderStr) const { + if (!fUsesGS) { + shaderStr->reset(); + return; + } + + *shaderStr = GrGetGLSLVersionDecl(fCtxInfo); + shaderStr->append(fGSHeader); + this->appendDecls(fGSInputs, shaderStr); + this->appendDecls(fGSOutputs, shaderStr); + shaderStr->append("void main() {\n"); + shaderStr->append(fGSCode); + shaderStr->append("}\n"); +} + +void GrGLShaderBuilder::fsGetShader(SkString* shaderStr) const { + *shaderStr = GrGetGLSLVersionDecl(fCtxInfo); + shaderStr->append(fFSExtensions); + append_default_precision_qualifier(kDefaultFragmentPrecision, + fCtxInfo.binding(), + shaderStr); + this->appendUniformDecls(kFragment_Visibility, shaderStr); + this->appendDecls(fFSInputs, shaderStr); + // We shouldn't have declared outputs on 1.10 + SkASSERT(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOutputs.empty()); + this->appendDecls(fFSOutputs, shaderStr); + shaderStr->append(fFSFunctions); + shaderStr->append("void main() {\n"); + shaderStr->append(fFSCode); + shaderStr->append("}\n"); +} void GrGLShaderBuilder::finished(GrGLuint programID) { fUniformManager.getUniformLocations(programID, fUniforms); diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h index a4fd82689d..ad0d87ef31 100644 --- a/src/gpu/gl/GrGLShaderBuilder.h +++ b/src/gpu/gl/GrGLShaderBuilder.h @@ -71,7 +71,7 @@ public: SkASSERT(NULL != builder); SkString name; name.printf("Sampler%d", idx); - fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, + fSamplerUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, kSampler2D_GrSLType, name.c_str()); SkASSERT(fSamplerUniform.isValid()); @@ -97,10 +97,10 @@ public: typedef SkTArray<TextureSampler> TextureSamplerArray; - enum ShaderType { - kVertex_ShaderType = 0x1, - kGeometry_ShaderType = 0x2, - kFragment_ShaderType = 0x4, + enum ShaderVisibility { + kVertex_Visibility = 0x1, + kGeometry_Visibility = 0x2, + kFragment_Visibility = 0x4, }; GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, const GrGLProgramDesc&); @@ -127,27 +127,27 @@ public: void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { va_list args; va_start(args, format); - this->codeAppendf(kVertex_ShaderType, format, args); + fVSCode.appendf(format, args); va_end(args); } void gsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { va_list args; va_start(args, format); - this->codeAppendf(kGeometry_ShaderType, format, args); + fGSCode.appendf(format, args); va_end(args); } void fsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { va_list args; va_start(args, format); - this->codeAppendf(kFragment_ShaderType, format, args); + fFSCode.appendf(format, args); va_end(args); } - void vsCodeAppend(const char* str) { this->codeAppend(kVertex_ShaderType, str); } - void gsCodeAppend(const char* str) { this->codeAppend(kGeometry_ShaderType, str); } - void fsCodeAppend(const char* str) { this->codeAppend(kFragment_ShaderType, str); } + void vsCodeAppend(const char* str) { fVSCode.append(str); } + void gsCodeAppend(const char* str) { fGSCode.append(str); } + void fsCodeAppend(const char* str) { fFSCode.append(str); } /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle @@ -157,33 +157,28 @@ public: const char* coordName, GrSLType coordType = kVec2f_GrSLType) const; - /** Version of above that appends the result to the shader code rather than an SkString. - Currently the shader type must be kFragment */ - void appendTextureLookup(ShaderType, - const TextureSampler&, - const char* coordName, - GrSLType coordType = kVec2f_GrSLType); + /** Version of above that appends the result to the fragment shader code instead.*/ + void fsAppendTextureLookup(const TextureSampler&, + const char* coordName, + GrSLType coordType = kVec2f_GrSLType); /** Does the work of appendTextureLookup and modulates the result by modulation. The result is always a vec4. modulation and the swizzle specified by TextureSampler must both be vec4 or float. If modulation is "" or NULL it this function acts as though appendTextureLookup were called. */ - void appendTextureLookupAndModulate(ShaderType, - const char* modulation, - const TextureSampler&, - const char* coordName, - GrSLType coordType = kVec2f_GrSLType); - - /** Emits a helper function outside of main(). Currently ShaderType must be - kFragment_ShaderType. */ - void emitFunction(ShaderType shader, - GrSLType returnType, - const char* name, - int argCnt, - const GrGLShaderVar* args, - const char* body, - SkString* outName); + void fsAppendTextureLookupAndModulate(const char* modulation, + const TextureSampler&, + const char* coordName, + GrSLType coordType = kVec2f_GrSLType); + + /** Emits a helper function outside of main() in the fragment shader. */ + void fsEmitFunction(GrSLType returnType, + const char* name, + int argCnt, + const GrGLShaderVar* args, + const char* body, + SkString* outName); /** Generates a EffectKey for the shader code based on the texture access parameters and the capabilities of the GL context. This is useful for keying the shader programs that may @@ -209,8 +204,8 @@ public: static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps); /** Add a uniform variable to the current program, that has visibility in one or more shaders. - visibility is a bitfield of ShaderType values indicating from which shaders the uniform - should be accessible. At least one bit must be set. Geometry shader uniforms are not + visibility is a bitfield of ShaderVisibility values indicating from which shaders the + uniform should be accessible. At least one bit must be set. Geometry shader uniforms are not supported at this time. The actual uniform name will be mangled. If outName is not NULL then it will refer to the final uniform name after return. Use the addUniformArray variant to add an array of uniforms. @@ -280,7 +275,9 @@ public: */ /** Called after building is complete to get the final shader string. */ - void getShader(ShaderType, SkString*) const; + void vsGetShader(SkString*) const; + void gsGetShader(SkString*) const; + void fsGetShader(SkString*) const; /** * Adds code for effects. effectStages contains the effects to add. effectKeys[i] is the key @@ -330,13 +327,10 @@ public: const GrGLContextInfo& ctxInfo() const { return fCtxInfo; } private: - void codeAppendf(ShaderType type, const char format[], va_list args); - void codeAppend(ShaderType type, const char* str); - typedef GrTAllocator<GrGLShaderVar> VarArray; void appendDecls(const VarArray&, SkString*) const; - void appendUniformDecls(ShaderType, SkString*) const; + void appendUniformDecls(ShaderVisibility, SkString*) const; typedef GrGLUniformManager::BuilderUniform BuilderUniform; GrGLUniformManager::BuilderUniformArray fUniforms; @@ -414,8 +408,8 @@ private: }; bool enablePrivateFeature(GLSLPrivateFeature); - // If we ever have VS/GS features we can expand this to take a bitmask of ShaderType and track - // the enables separately for each shader. + // If we ever have VS/GS features we can expand this to take a bitmask of ShaderVisibility and + // track the enables separately for each shader. void addFSFeature(uint32_t featureBit, const char* extensionName); // Generates a name for a variable. The generated string will be name prefixed by the prefix diff --git a/src/gpu/gl/GrGLUniformManager.cpp b/src/gpu/gl/GrGLUniformManager.cpp index 55390d5c61..79895f1e2e 100644 --- a/src/gpu/gl/GrGLUniformManager.cpp +++ b/src/gpu/gl/GrGLUniformManager.cpp @@ -259,10 +259,10 @@ void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUn // TODO: Move the Xoom uniform array in both FS and VS bug workaround here. GR_GL_CALL_RET(fContext.interface(), location, GetUniformLocation(programID, uniforms[i].fVariable.c_str())); - if (GrGLShaderBuilder::kVertex_ShaderType & uniforms[i].fVisibility) { + if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) { fUniforms[i].fVSLocation = location; } - if (GrGLShaderBuilder::kFragment_ShaderType & uniforms[i].fVisibility) { + if (GrGLShaderBuilder::kFragment_Visibility & uniforms[i].fVisibility) { fUniforms[i].fFSLocation = location; } } |