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

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

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder Created 5 years, 1 month 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/GrDashingEffect.cpp ('k') | src/gpu/gl/GrGLProgram.h » ('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 1f3fedef7677727ea29fc9c673f0e550bb40ab6f..cf77157e0d31bcca92999b76bcbd728a1fa21142 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -15,8 +15,9 @@
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLVertexShaderBuilder.h"
#include "glsl/GrGLSLUtil.h"
+#include "glsl/GrGLSLVarying.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
// Assuming a radius of a little less than the diagonal of the fragment
#define SK_DistanceFieldAAFactor "0.65"
@@ -40,9 +41,10 @@ public:
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(dfTexEffect);
+ varyingHandler->emitAttributes(dfTexEffect);
#ifdef SK_GAMMA_APPLY_TO_A8
// adjust based on gamma
@@ -56,7 +58,7 @@ public:
// Setup pass through color
if (!dfTexEffect.colorIgnored()) {
if (dfTexEffect.hasVertexColor()) {
- pb->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
+ varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
} else {
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
}
@@ -73,6 +75,7 @@ public:
// emit transforms
this->emitTransforms(pb,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
dfTexEffect.inPosition()->fName,
args.fTransformsIn,
@@ -82,7 +85,7 @@ public:
GrGLSLVertToFrag recipScale(kFloat_GrSLType);
GrGLSLVertToFrag st(kVec2f_GrSLType);
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
- pb->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName);
// compute numbers to be hardcoded to convert texture coordinates from int to float
@@ -93,7 +96,7 @@ public:
SkScalar recipHeight = 1.0f / atlas->height();
GrGLSLVertToFrag uv(kVec2f_GrSLType);
- pb->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
@@ -299,17 +302,18 @@ public:
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(dfTexEffect);
+ varyingHandler->emitAttributes(dfTexEffect);
GrGLSLVertToFrag v(kVec2f_GrSLType);
- pb->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
// setup pass through color
if (!dfTexEffect.colorIgnored()) {
if (dfTexEffect.hasVertexColor()) {
- pb->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
+ varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
} else {
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
}
@@ -327,6 +331,7 @@ public:
// emit transforms
this->emitTransforms(pb,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
dfTexEffect.inPosition()->fName,
args.fTransformsIn,
@@ -519,9 +524,10 @@ public:
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(dfTexEffect);
+ varyingHandler->emitAttributes(dfTexEffect);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -541,6 +547,7 @@ public:
// emit transforms
this->emitTransforms(pb,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
dfTexEffect.inPosition()->fName,
args.fTransformsIn,
@@ -550,7 +557,7 @@ public:
bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask);
GrGLSLVertToFrag recipScale(kFloat_GrSLType);
GrGLSLVertToFrag st(kVec2f_GrSLType);
- pb->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName);
// compute numbers to be hardcoded to convert texture coordinates from int to float
@@ -561,7 +568,7 @@ public:
SkScalar recipHeight = 1.0f / atlas->height();
GrGLSLVertToFrag uv(kVec2f_GrSLType);
- pb->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
« no previous file with comments | « src/gpu/effects/GrDashingEffect.cpp ('k') | src/gpu/gl/GrGLProgram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698