diff options
author | 2016-09-12 09:30:36 -0700 | |
---|---|---|
committer | 2016-09-12 09:30:36 -0700 | |
commit | 1a1aa9303484106a955e5549bf8ae24950f54e7a (patch) | |
tree | 512123db32ff1045b74f8ac2ef95d60bc4573a62 /src/gpu | |
parent | a316395e66095aa1bf495525e34c991688467a45 (diff) |
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
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrPathProcessor.cpp | 1 | ||||
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrConvolutionEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrSimpleTextureEffect.cpp | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrYUVEffect.cpp | 15 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentProcessor.cpp | 4 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentProcessor.h | 44 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp | 19 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentShaderBuilder.h | 11 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLGeometryProcessor.cpp | 1 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLPrimitiveProcessor.h | 3 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLProcessorTypes.h | 20 |
15 files changed, 58 insertions, 76 deletions
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp index 5237ba1cfd..5a873d420d 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 54c536a2a2..86726c9058 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -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), diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index aeb0393daf..4eb7a11c76 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -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) { diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp index 2266c47eeb..59f7ab19e3 100644 --- a/src/gpu/effects/GrConvolutionEffect.cpp +++ b/src/gpu/effects/GrConvolutionEffect.cpp @@ -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); diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index 8f031904ca..a07b67128b 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -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;"); diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index b819cf3b81..6eb15e0c31 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -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(";"); } diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 814d193fde..e06c8de801 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -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, diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp index 7f959306f4..5b04f21235 100644 --- a/src/gpu/effects/GrYUVEffect.cpp +++ b/src/gpu/effects/GrYUVEffect.cpp @@ -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); diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp index 46945bdc6b..9a58db77bd 100644 --- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp +++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp @@ -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]; diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h index c6eb016a32..f4a93ebe71 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 @@ 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; diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp index 7763f86e42..d35730f633 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp @@ -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; } diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h index 55ef9db207..ecb6d455dd 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 @@ 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; diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp index f7dba820a0..ce4d8b66ea 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 a94099656b..64531aaedc 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 @@ 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 index 6410e5eee1..0000000000 --- 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 |