Remove unneeded GrGLSLTransformedCoordsArray type
Rename GrGLSLFragmentBuilder::ensureFSCoords2D to ensureCoords2D and make it take an arbitrary GrShaderVar.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2324663004
Review-Url: https://codereview.chromium.org/2324663004
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 03a4515..3559694 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -99,8 +99,8 @@
"outer_threshold");
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
- SkString maskCoords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 1);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
+ SkString maskCoords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[1]);
fragBuilder->codeAppendf("vec2 coord = %s;", coords2D.c_str());
fragBuilder->codeAppendf("vec2 mask_coord = %s;", maskCoords2D.c_str());
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index df4103c..e74ca4f 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -544,15 +544,15 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fCoords[0].c_str(),
- args.fCoords[0].getType());
+ fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[0].getType());
fragBuilder->codeAppend(";\n");
// Unpremultiply the displacement
fragBuilder->codeAppendf(
"\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
dColor, dColor, nearZero, dColor, dColor);
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 1);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[1]);
fragBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
cCoords, coords2D.c_str(), scaleUni, dColor);
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 5e5aca9..0c82b16 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1803,7 +1803,7 @@
GrGLSLShaderVar("scale", kFloat_GrSLType),
};
SkString sobelFuncName;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->emitFunction(kFloat_GrSLType,
"sobel",
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 59be8fb..eee9ce2 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -135,7 +135,7 @@
"Bounds");
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
uniformHandler->getUniformCStr(fOffsetVar),
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index cdc236b..ebce1b3 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -218,7 +218,7 @@
const char* range = uniformHandler->getUniformCStr(fRangeUni);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* func;
switch (me.type()) {
case GrMorphologyEffect::kErode_MorphologyType:
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 7e49117..cacec1e 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -603,7 +603,7 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
- SkString vCoords = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString vCoords = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fBaseFrequencyUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
kVec2f_GrSLType, kDefault_GrSLPrecision,
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 872c6e8..98b621e 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -437,7 +437,7 @@
void GrLinearGradient::GLSLLinearProcessor::emitCode(EmitArgs& args) {
const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
this->emitUniforms(args.fUniformHandler, ge);
- SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString t = args.fFragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
t.append(".x");
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 78ecffa..1fbd171 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -333,7 +333,7 @@
const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>();
this->emitUniforms(args.fUniformHandler, ge);
SkString t("length(");
- t.append(args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0));
+ t.append(args.fFragBuilder->ensureCoords2D(args.fTransformedCoords[0]));
t.append(")");
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 505cfd2..bdb0e1c 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -212,7 +212,7 @@
void GrSweepGradient::GLSLSweepProcessor::emitCode(EmitArgs& args) {
const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
this->emitUniforms(args.fUniformHandler, ge);
- SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = args.fFragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
SkString t;
// 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
// On Intel GPU there is an issue where it reads the second arguement to atan "- %s.x" as an int
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index f11ca65..e89193f 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -243,19 +243,21 @@
p2.appendf("%s.z", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
// We interpolate the linear component in coords[1].
- SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
+ SkASSERT(args.fTransformedCoords[0].getType() == args.fTransformedCoords[1].getType());
const char* coords2D;
SkString bVar;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- if (kVec3f_GrSLType == args.fCoords[0].getType()) {
+ if (kVec3f_GrSLType == args.fTransformedCoords[0].getType()) {
fragBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n",
- args.fCoords[0].c_str(), args.fCoords[0].c_str(),
- args.fCoords[1].c_str(), args.fCoords[1].c_str());
+ args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[1].c_str(),
+ args.fTransformedCoords[1].c_str());
coords2D = "interpolants.xy";
bVar = "interpolants.z";
} else {
- coords2D = args.fCoords[0].c_str();
- bVar.printf("%s.x", args.fCoords[1].c_str());
+ coords2D = args.fTransformedCoords[0].c_str();
+ bVar.printf("%s.x", args.fTransformedCoords[1].c_str());
}
// output will default to transparent black (we simply won't write anything
@@ -523,7 +525,7 @@
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
// t = p.x * focal.x +/- sqrt(p.x^2 + (1 - focal.x^2) * p.y^2)
@@ -731,7 +733,7 @@
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
// t = p.x * focalX + length(p)
@@ -994,7 +996,7 @@
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
// p = coords2D
@@ -1237,7 +1239,7 @@
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
// output will default to transparent black (we simply won't write anything
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index 5237ba1..5a873d4 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -10,7 +10,6 @@
#include "gl/GrGLGpu.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProcessorTypes.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLVarying.h"
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 54c536a..86726c9 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -75,7 +75,7 @@
GrGLSLShaderVar("c3", kVec4f_GrSLType),
};
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->emitFunction(kVec4f_GrSLType,
"cubicBlend",
SK_ARRAY_COUNT(gCubicBlendArgs),
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index aeb0393..4eb7a11 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -31,8 +31,8 @@
fragBuilder->codeAppendf("%s;", tmpDecl.c_str());
fragBuilder->codeAppendf("%s = ", tmpVar.c_str());
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fCoords[0].c_str(),
- args.fCoords[0].getType());
+ fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[0].getType());
fragBuilder->codeAppend(";");
if (GrConfigConversionEffect::kNone_PMConversion == pmConversion) {
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 2266c47..59f7ab1 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -54,7 +54,7 @@
"Kernel", arrayCount);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 8f03190..a07b671 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -65,7 +65,7 @@
const char* bias = uniformHandler->getUniformCStr(fBiasUni);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
fragBuilder->codeAppend("vec4 c;");
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index b819cf3..6eb15e0 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -24,8 +24,8 @@
fragBuilder->codeAppendf("%s = ", args.fOutputColor);
fragBuilder->appendTextureLookupAndModulate(args.fInputColor,
args.fTexSamplers[0],
- args.fCoords[0].c_str(),
- args.fCoords[0].getType(),
+ args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[0].getType(),
&colorSpaceHelper);
fragBuilder->codeAppend(";");
}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 814d193..e06c8de 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -191,7 +191,7 @@
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fGLDomain.sampleTexture(fragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 7f95930..5b04f21 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -108,17 +108,20 @@
kMat44f_GrSLType, kDefault_GrSLPrecision,
"ColorSpaceMatrix", &colorSpaceMatrix);
fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor);
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fCoords[0].c_str(),
- args.fCoords[0].getType());
+ fragBuilder->appendTextureLookup(args.fTexSamplers[0],
+ args.fTransformedCoords[0].c_str(),
+ args.fTransformedCoords[0].getType());
fragBuilder->codeAppend(".r,");
- fragBuilder->appendTextureLookup(args.fTexSamplers[1], args.fCoords[1].c_str(),
- args.fCoords[1].getType());
+ fragBuilder->appendTextureLookup(args.fTexSamplers[1],
+ args.fTransformedCoords[1].c_str(),
+ args.fTransformedCoords[1].getType());
if (effect.fNV12) {
fragBuilder->codeAppendf(".rg,");
} else {
fragBuilder->codeAppend(".r,");
- fragBuilder->appendTextureLookup(args.fTexSamplers[2], args.fCoords[2].c_str(),
- args.fCoords[2].getType());
+ fragBuilder->appendTextureLookup(args.fTexSamplers[2],
+ args.fTransformedCoords[2].c_str(),
+ args.fTransformedCoords[2].getType());
fragBuilder->codeAppendf(".g,");
}
fragBuilder->codeAppendf("1.0) * %s;", colorSpaceMatrix);
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index 46945bd..9a58db7 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -82,11 +82,11 @@
firstTextureAt += args.fFp.childProcessor(i).numTextures();
firstBufferAt += args.fFp.childProcessor(i).numBuffers();
}
- GrGLSLTransformedCoordsArray childCoords;
+ SkTArray<GrShaderVar> childCoords;
const SamplerHandle* childTexSamplers = nullptr;
const SamplerHandle* childBufferSamplers = nullptr;
if (childProc.numTransforms() > 0) {
- childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCoordAt]);
+ childCoords.push_back_n(childProc.numTransforms(), &args.fTransformedCoords[firstCoordAt]);
}
if (childProc.numTextures() > 0) {
childTexSamplers = &args.fTexSamplers[firstTextureAt];
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h
index c6eb016..f4a93eb 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.h
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h
@@ -9,7 +9,7 @@
#define GrGLSLFragmentProcessor_DEFINED
#include "GrFragmentProcessor.h"
-#include "glsl/GrGLSLProcessorTypes.h"
+#include "GrShaderVar.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLSampler.h"
@@ -37,21 +37,27 @@
shader will be in its own block ({}) and so locally scoped names will not collide across
stages.
- @param builder Interface used to emit code in the shaders.
- @param processor The processor that generated this program stage.
- @param key The key that was computed by GenKey() from the generating GrProcessor.
- @param outputColor A predefined vec4 in the FS in which the stage should place its output
- color (or coverage).
- @param inputColor A vec4 that holds the input color to the stage in the FS. This may be
- nullptr in which case the implied input is solid white (all ones).
- TODO: Better system for communicating optimization info (e.g. input
- color is solid white, trans black, known to be opaque, etc.) that allows
- the processor to communicate back similar known info about its output.
- @param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These
- can be passed to the builder to emit texture reads in the generated
- code.
+ @param fragBuilder Interface used to emit code in the shaders.
+ @param fp The processor that generated this program stage.
+ @param key The key that was computed by GenKey() from the generating
+ GrProcessor.
+ @param outputColor A predefined vec4 in the FS in which the stage should place its
+ output color (or coverage).
+ @param inputColor A vec4 that holds the input color to the stage in the FS. This may
+ be nullptr in which case the implied input is solid white (all
+ ones). TODO: Better system for communicating optimization info
+ (e.g. input color is solid white, trans black, known to be opaque,
+ etc.) that allows the processor to communicate back similar known
+ info about its output.
+ @param transformedCoords Fragment shader variables containing the coords computed using
+ each of the GrFragmentProcessor's Coord Transforms.
+ @param texSamplers Contains one entry for each GrTextureAccess of the GrProcessor.
+ These can be passed to the builder to emit texture reads in the
+ generated code.
+ @param bufferSamplers Contains one entry for each GrBufferAccess of the GrProcessor.
+ These can be passed to the builder to emit buffer reads in the
+ generated code.
*/
-
struct EmitArgs {
EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder,
GrGLSLUniformHandler* uniformHandler,
@@ -59,7 +65,7 @@
const GrFragmentProcessor& fp,
const char* outputColor,
const char* inputColor,
- const GrGLSLTransformedCoordsArray& coords,
+ const SkTArray<GrShaderVar>& transformedCoords,
const SamplerHandle* texSamplers,
const SamplerHandle* bufferSamplers,
bool gpImplementsDistanceVector)
@@ -69,17 +75,17 @@
, fFp(fp)
, fOutputColor(outputColor)
, fInputColor(inputColor)
- , fCoords(coords)
+ , fTransformedCoords(transformedCoords)
, fTexSamplers(texSamplers)
, fBufferSamplers(bufferSamplers)
- , fGpImplementsDistanceVector(gpImplementsDistanceVector){}
+ , fGpImplementsDistanceVector(gpImplementsDistanceVector) {}
GrGLSLFPFragmentBuilder* fFragBuilder;
GrGLSLUniformHandler* fUniformHandler;
const GrGLSLCaps* fGLSLCaps;
const GrFragmentProcessor& fFp;
const char* fOutputColor;
const char* fInputColor;
- const GrGLSLTransformedCoordsArray& fCoords;
+ const SkTArray<GrShaderVar>& fTransformedCoords;
const SamplerHandle* fTexSamplers;
const SamplerHandle* fBufferSamplers;
bool fGpImplementsDistanceVector;
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 7763f86..d35730f 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -125,19 +125,16 @@
}
}
-SkString GrGLSLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
- int index) {
- if (kVec3f_GrSLType != coords[index].getType()) {
- SkASSERT(kVec2f_GrSLType == coords[index].getType());
- return coords[index].getName();
+SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords) {
+ if (kVec3f_GrSLType != coords.getType()) {
+ SkASSERT(kVec2f_GrSLType == coords.getType());
+ return coords.getName();
}
- SkString coords2D("coords2D");
- if (0 != index) {
- coords2D.appendf("_%i", index);
- }
- this->codeAppendf("\tvec2 %s = %s.xy / %s.z;",
- coords2D.c_str(), coords[index].c_str(), coords[index].c_str());
+ SkString coords2D;
+ coords2D.printf("%s_ensure2D", coords.c_str());
+ this->codeAppendf("\tvec2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
+ coords.c_str());
return coords2D;
}
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
index 55ef9db..ecb6d45 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
@@ -11,7 +11,6 @@
#include "GrGLSLShaderBuilder.h"
#include "GrProcessor.h"
-#include "glsl/GrGLSLProcessorTypes.h"
class GrRenderTarget;
class GrGLSLVarying;
@@ -43,10 +42,11 @@
/**
* This returns a variable name to access the 2D, perspective correct version of the coords in
- * the fragment shader. If the coordinates at index are 3-dimensional, it immediately emits a
- * perspective divide into the fragment shader (xy / z) to convert them to 2D.
+ * the fragment shader. The passed in coordinates must either be of type kVec2f or kVec3f. If
+ * the coordinates are 3-dimensional, it a perspective divide into is emitted into the
+ * fragment shader (xy / z) to convert them to 2D.
*/
- virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords, int index) = 0;
+ virtual SkString ensureCoords2D(const GrShaderVar&) = 0;
/** Returns a variable name that represents the position of the fragment in the FS. The position
@@ -167,8 +167,7 @@
// Shared GrGLSLFragmentBuilder interface.
bool enableFeature(GLSLFeature) override;
- virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
- int index) override;
+ virtual SkString ensureCoords2D(const GrShaderVar&) override;
const char* fragmentPosition() override;
const char* distanceVectorName() const override;
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index f7dba82..ce4d8b6 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -9,7 +9,6 @@
#include "GrCoordTransform.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProcessorTypes.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
index a940996..64531aa 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
@@ -9,7 +9,6 @@
#define GrGLSLPrimitiveProcessor_DEFINED
#include "GrPrimitiveProcessor.h"
-#include "glsl/GrGLSLProcessorTypes.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLSampler.h"
@@ -31,7 +30,7 @@
typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords;
typedef SkSTArray<8, ProcCoords> TransformsIn;
- typedef SkSTArray<8, GrGLSLTransformedCoordsArray> TransformsOut;
+ typedef SkSTArray<8, SkTArray<GrShaderVar>> TransformsOut;
struct EmitArgs {
EmitArgs(GrGLSLVertexBuilder* vertBuilder,
diff --git a/src/gpu/glsl/GrGLSLProcessorTypes.h b/src/gpu/glsl/GrGLSLProcessorTypes.h
deleted file mode 100644
index 6410e5e..0000000
--- a/src/gpu/glsl/GrGLSLProcessorTypes.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLSLProcessorTypes_DEFINED
-#define GrGLSLProcessorTypes_DEFINED
-
-#include "GrShaderVar.h"
-
-/**
- * These are meant to only be used by GrGLSL*Processors so they can add transformed coordinates
- * to their shader code.
- */
-typedef GrShaderVar GrGLSLTransformedCoords;
-typedef SkTArray<GrShaderVar> GrGLSLTransformedCoordsArray;
-
-#endif