Remove unneeded GrGLSLTransformedCoordsArray type
authorbsalomon <bsalomon@google.com>
Mon, 12 Sep 2016 16:30:36 +0000 (09:30 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 12 Sep 2016 16:30:36 +0000 (09:30 -0700)
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

28 files changed:
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
gm/dcshader.cpp
gyp/gpu.gypi
src/effects/GrAlphaThresholdFragmentProcessor.cpp
src/effects/SkDisplacementMapEffect.cpp
src/effects/SkLightingImageFilter.cpp
src/effects/SkMagnifierImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/SkPerlinNoiseShader.cpp
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
src/gpu/GrPathProcessor.cpp
src/gpu/effects/GrBicubicEffect.cpp
src/gpu/effects/GrConfigConversionEffect.cpp
src/gpu/effects/GrConvolutionEffect.cpp
src/gpu/effects/GrMatrixConvolutionEffect.cpp
src/gpu/effects/GrSimpleTextureEffect.cpp
src/gpu/effects/GrTextureDomain.cpp
src/gpu/effects/GrYUVEffect.cpp
src/gpu/glsl/GrGLSLFragmentProcessor.cpp
src/gpu/glsl/GrGLSLFragmentProcessor.h
src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
src/gpu/glsl/GrGLSLGeometryProcessor.cpp
src/gpu/glsl/GrGLSLPrimitiveProcessor.h
src/gpu/glsl/GrGLSLProcessorTypes.h [deleted file]

index cfea4087311711189f50bfacbe844436726a1ccd..2c2f65e58fe8d81d76badd4477fb5c089f85a742 100644 (file)
@@ -739,7 +739,7 @@ void GrGLPerlinNoise2::emitCode(EmitArgs& args) {
 
     GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
     GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
-    SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
+    SkString vCoords = fsBuilder->ensureCoords2D(args.fTransformedCoords[0]);
 
     fBaseFrequencyUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
                                                    kVec2f_GrSLType, kDefault_GrSLPrecision,
@@ -1145,7 +1145,7 @@ sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTe
 void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
     GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
     GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
-    SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
+    SkString vCoords = fsBuilder->ensureCoords2D(args.fTransformedCoords[0]);
 
     fBaseFrequencyUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
                                                    kVec2f_GrSLType, kDefault_GrSLPrecision,
index 25d114fd1493cee67c2baf411d5d249a8de1423e..e53f5ae8a34f088af434d11f9ae761a5fce13e21 100644 (file)
@@ -65,8 +65,8 @@ public:
         class DCGLFP : public GrGLSLFragmentProcessor {
             void emitCode(EmitArgs& args) override {
                 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
-                fragBuilder->codeAppendf("vec2 c = %s;",
-                                         fragBuilder->ensureFSCoords2D(args.fCoords, 0).c_str());
+                SkString coords2d = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
+                fragBuilder->codeAppendf("vec2 c = %s;", coords2d.c_str());
                 fragBuilder->codeAppend("vec2 r = mod(c, vec2(20.0));");
                 fragBuilder->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5,"
                                                       "0.5*cos((c.x + c.y) / 15.0) + 0.5,"
index 90e35c40cf2f1beb4f1043d529d06e834a9732ac..75b5984bd45773f99fc988500c259eda7487766d 100644 (file)
       '<(skia_src_path)/gpu/glsl/GrGLSLGeometryShaderBuilder.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLPrimitiveProcessor.cpp',
       '<(skia_src_path)/gpu/glsl/GrGLSLPrimitiveProcessor.h',
-      '<(skia_src_path)/gpu/glsl/GrGLSLProcessorTypes.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramBuilder.cpp',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramBuilder.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramDataManager.cpp',
index 03a451519151c3593a4b9e58d4d9631c020716a7..3559694f0560ab597adf1fd1fe3075fbc306b5c8 100644 (file)
@@ -99,8 +99,8 @@ void GrGLAlphaThresholdFragmentProcessor::emitCode(EmitArgs& args) {
                                                     "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());
index df4103cf064feab1bfb55152517652f801f4d79d..e74ca4fe3fbe1a3475cb0975f11965c4688bab92 100644 (file)
@@ -544,15 +544,15 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
 
     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);
 
index 5e5aca96af133fde57e62c5628eaf836eb5c6992..0c82b1655e7755584050ae489e325e9f1a6aaf08 100644 (file)
@@ -1803,7 +1803,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
         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",
index 59be8fb86ee42dad5cadcb0f4181a532582104b6..eee9ce2d0cfe5f597b677358f085bbedac1031c3 100644 (file)
@@ -135,7 +135,7 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
                                             "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),
index cdc236b63a09d306075dd3a9585b38b9b38ef0b9..ebce1b3c5d0144b3bd782062b86eaeb9de475643 100644 (file)
@@ -218,7 +218,7 @@ void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
     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:
index 7e4911730ebdbe5581cac802a63a8c9c1b02e9ed..cacec1e2b4eb947eeb1ba32548668d3c509150a4 100644 (file)
@@ -603,7 +603,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
 
     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,
index 872c6e81d100263c74a705a71b7aaa944feb229f..98b621ec8eb5b8b517ed4542f86239f0eebed54c 100644 (file)
@@ -437,7 +437,7 @@ sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d)
 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,
index 78ecffae1a003b66196918dfcd3a4cc0be7f65c9..1fbd1716abad9917f07aaffa2946159b85c65c54 100644 (file)
@@ -333,7 +333,7 @@ void GrRadialGradient::GLSLRadialProcessor::emitCode(EmitArgs& args) {
     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,
index 505cfd2c95d4d722e038afe9a51232f982e8aa29..bdb0e1ce25d86cb4ed2f6ead60b813691bd45eed 100644 (file)
@@ -212,7 +212,7 @@ sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
 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
index f11ca65d0c0611a4bcb6d1cf11e18a8959453f0c..e89193ff550974069c2f79fecdd4615f3346b5b1 100644 (file)
@@ -243,19 +243,21 @@ void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args)
     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 @@ void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode
 
     // 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 @@ void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(E
 
     // 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 @@ void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode
 
     // 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 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCo
 
     // 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
index 5237ba1cfd43594a2194b5ce4852c77c75314c50..5a873d420d08e1e5bb6cc2066e4c31554a119cb9 100644 (file)
@@ -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"
 
index 54c536a2a27ca99ec52e04fa92f603274f17c1a7..86726c90584fa5f073ca065226b80dec211e98f4 100644 (file)
@@ -75,7 +75,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
         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),
index aeb0393daf7a693830fa0e0d3118f2b5932a383f..4eb7a11c76c234ad890521202768e446849effec 100644 (file)
@@ -31,8 +31,8 @@ public:
         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) {
index 2266c47eeb60355d73c18205b8375cbd8f6f847e..59f7ab19e36c56b76106be9b19b225c68fc54653 100644 (file)
@@ -54,7 +54,7 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
                                                  "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);
 
index 8f031904caa14c2643165d41559274eb710e3bba..a07b67128bac85d1a156e01cdae720c3541f01c2 100644 (file)
@@ -65,7 +65,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
     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;");
index b819cf3b81364664865c33dc5a46bf8f23d8ed8c..6eb15e0c315a9d30e43fbd5126b31b70fd29d4bd 100644 (file)
@@ -24,8 +24,8 @@ public:
         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(";");
     }
index 814d193fde27244c4d6af391a347acd8807d551b..e06c8de801f904cf2061b0e3dde97e5a51045439 100644 (file)
@@ -191,7 +191,7 @@ void GrGLTextureDomainEffect::emitCode(EmitArgs& args) {
     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,
index 7f959306f4a836ffa3ccdf59b0f896cdb638f54d..5b04f212355d27ddc55a4259287ce2341dd5cdd0 100644 (file)
@@ -108,17 +108,20 @@ public:
                                                           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);
index 46945bdc6baa5e0e4f89abd2e83cab8116c5738f..9a58db77bd6cd1430f58bd8f7097b00fbbe36e6a 100644 (file)
@@ -82,11 +82,11 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
         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];
index c6eb016a32bc6d19b138127ef344c1e4df9d7544..f4a93ebe71c35b41b49a62466e22d204ca45ab58 100644 (file)
@@ -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 @@ public:
         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 @@ public:
                  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 @@ public:
             , 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;
index 7763f86e42957b664c027a2931a0f8d3da44e807..d35730f633012d764302d9994412e113ec793082 100644 (file)
@@ -125,19 +125,16 @@ bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
     }
 }
 
-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;
 }
 
index 55ef9db207ff4af643ba8a7414d12d5acf72ba95..ecb6d455ddefcb8be3ebc9a4534ecda2d64ce347 100644 (file)
@@ -11,7 +11,6 @@
 #include "GrGLSLShaderBuilder.h"
 
 #include "GrProcessor.h"
-#include "glsl/GrGLSLProcessorTypes.h"
 
 class GrRenderTarget;
 class GrGLSLVarying;
@@ -43,10 +42,11 @@ public:
 
     /**
      * 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 @@ public:
 
     // 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;
 
index f7dba820a0542ea8bd43603445f80d81f5d83b14..ce4d8b66eab89351c82073aaf4cf54934a715cf4 100644 (file)
@@ -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"
index a94099656b9286468ba51fb950d5af2b29f24c7d..64531aaedcb704bf137eab87097975ba2ea15e54 100644 (file)
@@ -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 @@ public:
 
     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 (file)
index 6410e5e..0000000
+++ /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