Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: src/gpu/effects/GrDistanceFieldGeoProc.cpp

Issue 1414373002: Move shader precision modifier check onto GLSLCaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrConvexPolyEffect.cpp ('k') | src/gpu/effects/GrTextureDomain.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrDistanceFieldGeoProc.cpp
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 4f8da160e7a11e907180b0e6b592c9e4e5c3d1e0..89aa31ee5d01f5f796f41da51c5d1ff5d0118af0 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -33,11 +33,11 @@ public:
const GrDistanceFieldA8TextGeoProc& dfTexEffect =
args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
GrGLGPBuilder* pb = args.fPB;
- GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+ GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
- GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+ GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
// emit attributes
vsBuilder->emitAttributes(dfTexEffect);
@@ -46,7 +46,7 @@ public:
// adjust based on gamma
const char* distanceAdjustUniName = nullptr;
// width, height, 1/(3*width)
- fDistanceAdjustUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ fDistanceAdjustUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType, kDefault_GrSLPrecision,
"DistanceAdjust", &distanceAdjustUniName);
#endif
@@ -65,14 +65,14 @@ public:
&fViewMatrixUniform);
// emit transforms
- this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
+ this->emitTransforms(pb, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
args.fTransformsIn, args.fTransformsOut);
// add varyings
GrGLVertToFrag recipScale(kFloat_GrSLType);
GrGLVertToFrag st(kVec2f_GrSLType);
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
- args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
+ pb->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName);
// compute numbers to be hardcoded to convert texture coordinates from int to float
@@ -83,15 +83,14 @@ public:
SkScalar recipHeight = 1.0f / atlas->height();
GrGLVertToFrag uv(kVec2f_GrSLType);
- args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
+ pb->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
dfTexEffect.inTextureCoords()->fName);
// Use highp to work around aliasing issues
- fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
- pb->ctxInfo().standard()));
+ fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
fsBuilder->codeAppend("\tfloat texColor = ");
@@ -284,17 +283,17 @@ public:
const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>();
GrGLGPBuilder* pb = args.fPB;
- GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+ GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
- GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+ GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
// emit attributes
vsBuilder->emitAttributes(dfTexEffect);
GrGLVertToFrag v(kVec2f_GrSLType);
- args.fPB->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
+ pb->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
// setup pass through color
if (!dfTexEffect.colorIgnored()) {
@@ -311,17 +310,16 @@ public:
&fViewMatrixUniform);
// emit transforms
- this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
+ this->emitTransforms(pb, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
args.fTransformsIn, args.fTransformsOut);
const char* textureSizeUniName = nullptr;
- fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "TextureSize", &textureSizeUniName);
+ fTextureSizeUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "TextureSize", &textureSizeUniName);
// Use highp to work around aliasing issues
- fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
- pb->ctxInfo().standard()));
+ fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
fsBuilder->codeAppendf("vec2 uv = %s;", v.fsIn());
fsBuilder->codeAppend("float texColor = ");
@@ -332,8 +330,7 @@ public:
fsBuilder->codeAppend("float distance = "
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
- fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
- pb->ctxInfo().standard()));
+ fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
fsBuilder->codeAppendf("vec2 st = uv*%s;", textureSizeUniName);
fsBuilder->codeAppend("float afwidth;");
if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) {
@@ -500,7 +497,7 @@ public:
args.fGP.cast<GrDistanceFieldLCDTextGeoProc>();
GrGLGPBuilder* pb = args.fPB;
- GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+ GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
// emit attributes
vsBuilder->emitAttributes(dfTexEffect);
@@ -515,14 +512,14 @@ public:
&fViewMatrixUniform);
// emit transforms
- this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
+ this->emitTransforms(pb, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
args.fTransformsIn, args.fTransformsOut);
// set up varyings
bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask);
GrGLVertToFrag recipScale(kFloat_GrSLType);
GrGLVertToFrag st(kVec2f_GrSLType);
- args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
+ pb->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName);
// compute numbers to be hardcoded to convert texture coordinates from int to float
@@ -533,25 +530,23 @@ public:
SkScalar recipHeight = 1.0f / atlas->height();
GrGLVertToFrag uv(kVec2f_GrSLType);
- args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
+ pb->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
dfTexEffect.inTextureCoords()->fName);
// add frag shader code
- GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+ GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
// create LCD offset adjusted by inverse of transform
// Use highp to work around aliasing issues
- fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
- pb->ctxInfo().standard()));
+ fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
- fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
- pb->ctxInfo().standard()));
+ fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
@@ -594,7 +589,7 @@ public:
// adjust width based on gamma
const char* distanceAdjustUniName = nullptr;
- fDistanceAdjustUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ fDistanceAdjustUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType, kDefault_GrSLPrecision,
"DistanceAdjust", &distanceAdjustUniName);
fsBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
« no previous file with comments | « src/gpu/effects/GrConvexPolyEffect.cpp ('k') | src/gpu/effects/GrTextureDomain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698