aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-11-20 14:01:22 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-20 14:01:22 -0800
commit0eafe79f42e3c675f3c504aed4a41abf511df2b7 (patch)
tree564912e8c811c3eb1bff5fd18131e9015b4a9fd6 /src/gpu/effects
parenta7006d45217d128a94fa53cb4b827cca79bc7049 (diff)
Create GrGLSLVaryingHandler class for program building
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp19
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp9
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp17
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp29
4 files changed, 48 insertions, 26 deletions
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 7ce2b31a8c..13672da6ea 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -11,6 +11,7 @@
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUtil.h"
+#include "glsl/GrGLSLVarying.h"
class GrGLConicEffect : public GrGLSLGeometryProcessor {
public:
@@ -75,12 +76,13 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(gp);
+ varyingHandler->emitAttributes(gp);
GrGLSLVertToFrag v(kVec4f_GrSLType);
- args.fPB->addVarying("ConicCoeffs", &v);
+ varyingHandler->addVarying("ConicCoeffs", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -100,6 +102,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit transforms with position
this->emitTransforms(pb,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
gp.inPosition()->fName,
gp.localMatrix(),
@@ -301,12 +304,13 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(gp);
+ varyingHandler->emitAttributes(gp);
GrGLSLVertToFrag v(kVec4f_GrSLType);
- args.fPB->addVarying("HairQuadEdge", &v);
+ varyingHandler->addVarying("HairQuadEdge", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -326,6 +330,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit transforms with position
this->emitTransforms(pb,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
gp.inPosition()->fName,
gp.localMatrix(),
@@ -501,12 +506,13 @@ GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor)
void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(gp);
+ varyingHandler->emitAttributes(gp);
GrGLSLVertToFrag v(kVec4f_GrSLType);
- args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -526,6 +532,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit transforms with position
this->emitTransforms(args.fPB,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
gp.inPosition()->fName,
args.fTransformsIn,
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 28c6f0ffc4..594646256e 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -12,6 +12,7 @@
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor {
@@ -23,9 +24,10 @@ public:
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(cte);
+ varyingHandler->emitAttributes(cte);
// compute numbers to be hardcoded to convert texture coordinates from int to float
SkASSERT(cte.numTextures() == 1);
@@ -35,7 +37,7 @@ public:
SkScalar recipHeight = 1.0f / atlas->height();
GrGLSLVertToFrag v(kVec2f_GrSLType);
- pb->addVarying("TextureCoords", &v);
+ varyingHandler->addVarying("TextureCoords", &v);
vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(),
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
@@ -45,7 +47,7 @@ public:
// Setup pass through color
if (!cte.colorIgnored()) {
if (cte.hasVertexColor()) {
- pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
+ varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
} else {
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
}
@@ -57,6 +59,7 @@ public:
// emit transforms
this->emitTransforms(args.fPB,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
cte.inPosition()->fName,
cte.localMatrix(),
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 94cfd80b0c..c1e2011e08 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -25,6 +25,7 @@
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
///////////////////////////////////////////////////////////////////////////////
@@ -853,18 +854,19 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
const DashingCircleEffect& dce = args.fGP.cast<DashingCircleEffect>();
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(dce);
+ varyingHandler->emitAttributes(dce);
// XY are dashPos, Z is dashInterval
GrGLSLVertToFrag dashParams(kVec3f_GrSLType);
- args.fPB->addVarying("DashParam", &dashParams);
+ varyingHandler->addVarying("DashParam", &dashParams);
vertBuilder->codeAppendf("%s = %s;", dashParams.vsOut(), dce.inDashParams()->fName);
// x refers to circle radius - 0.5, y refers to cicle's center x coord
GrGLSLVertToFrag circleParams(kVec2f_GrSLType);
- args.fPB->addVarying("CircleParams", &circleParams);
+ varyingHandler->addVarying("CircleParams", &circleParams);
vertBuilder->codeAppendf("%s = %s;", circleParams.vsOut(), dce.inCircleParams()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -879,6 +881,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit transforms
this->emitTransforms(args.fPB,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
dce.inPosition()->fName,
dce.localMatrix(),
@@ -1064,19 +1067,20 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
+ GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
// emit attributes
- vertBuilder->emitAttributes(de);
+ varyingHandler->emitAttributes(de);
// XY refers to dashPos, Z is the dash interval length
GrGLSLVertToFrag inDashParams(kVec3f_GrSLType);
- args.fPB->addVarying("DashParams", &inDashParams, GrSLPrecision::kHigh_GrSLPrecision);
+ varyingHandler->addVarying("DashParams", &inDashParams, GrSLPrecision::kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", inDashParams.vsOut(), de.inDashParams()->fName);
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
// respectively.
GrGLSLVertToFrag inRectParams(kVec4f_GrSLType);
- args.fPB->addVarying("RectParams", &inRectParams, GrSLPrecision::kHigh_GrSLPrecision);
+ varyingHandler->addVarying("RectParams", &inRectParams, GrSLPrecision::kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->fName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -1091,6 +1095,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit transforms
this->emitTransforms(args.fPB,
vertBuilder,
+ varyingHandler,
gpArgs->fPositionVar,
de.inPosition()->fName,
de.localMatrix(),
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 1f3fedef76..cf77157e0d 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,