diff options
author | Brian Salomon <bsalomon@google.com> | 2017-12-06 14:47:42 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-07 19:20:19 +0000 |
commit | 04460ccee50e03b89420cdaa85882a9da083fa38 (patch) | |
tree | 9c5b83a5822ac6e59cac1555f6043a0d396b6ad3 /src/gpu/glsl | |
parent | e951e4a1dca5c6706b11e402838d9e14de430a05 (diff) |
Make GrGLSLPrimitiveProcessor::emitTransforms take local coords as GrShaderVar.
Also remove unused position variable parameter.
Change-Id: I37f98a03ac1ca750810de13b08e3ffa11e41828c
Reviewed-on: https://skia-review.googlesource.com/81320
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/glsl')
-rw-r--r-- | src/gpu/glsl/GrGLSLGeometryProcessor.cpp | 11 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLGeometryProcessor.h | 27 |
2 files changed, 20 insertions, 18 deletions
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp index 8ee9bbdd21..01322eddea 100644 --- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp +++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp @@ -43,10 +43,12 @@ void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) { void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb, GrGLSLVaryingHandler* varyingHandler, GrGLSLUniformHandler* uniformHandler, - const GrShaderVar& posVar, - const char* localCoords, + const GrShaderVar& localCoordsVar, const SkMatrix& localMatrix, FPCoordTransformHandler* handler) { + SkASSERT(GrSLTypeIsFloatType(localCoordsVar.getType())); + SkASSERT(2 == GrSLTypeVecLength(localCoordsVar.getType())); + int i = 0; while (const GrCoordTransform* coordTransform = handler->nextCoordTransform()) { SkString strUniName; @@ -75,9 +77,10 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb, handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType); if (kFloat2_GrSLType == varyingType) { - vb->codeAppendf("%s = (%s * float3(%s, 1)).xy;", v.vsOut(), uniName, localCoords); + vb->codeAppendf("%s = (%s * float3(%s, 1)).xy;", v.vsOut(), uniName, + localCoordsVar.c_str()); } else { - vb->codeAppendf("%s = %s * float3(%s, 1);", v.vsOut(), uniName, localCoords); + vb->codeAppendf("%s = %s * float3(%s, 1);", v.vsOut(), uniName, localCoordsVar.c_str()); } ++i; } diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.h b/src/gpu/glsl/GrGLSLGeometryProcessor.h index 17a67797d0..de1e4fd02a 100644 --- a/src/gpu/glsl/GrGLSLGeometryProcessor.h +++ b/src/gpu/glsl/GrGLSLGeometryProcessor.h @@ -28,26 +28,25 @@ protected: const GrGLSLProgramDataManager& pdman, FPCoordTransformIter*); - // Emit a uniform matrix for each coord transform. - void emitTransforms(GrGLSLVertexBuilder* vb, - GrGLSLVaryingHandler* varyingHandler, - GrGLSLUniformHandler* uniformHandler, - const GrShaderVar& posVar, - const char* localCoords, - FPCoordTransformHandler* handler) { - this->emitTransforms(vb, varyingHandler, uniformHandler, - posVar, localCoords, SkMatrix::I(), handler); - } - - // Emit pre-transformed coords as a varying per coord-transform. + // Emit transformed local coords from the vertex shader as a uniform matrix and varying per + // coord-transform. void emitTransforms(GrGLSLVertexBuilder*, GrGLSLVaryingHandler*, GrGLSLUniformHandler*, - const GrShaderVar& posVar, - const char* localCoords, + const GrShaderVar& localCoordsVar, const SkMatrix& localMatrix, FPCoordTransformHandler*); + // Version of above that assumes identity for the local matrix. + void emitTransforms(GrGLSLVertexBuilder* vb, + GrGLSLVaryingHandler* varyingHandler, + GrGLSLUniformHandler* uniformHandler, + const GrShaderVar& localCoordsVar, + FPCoordTransformHandler* handler) { + this->emitTransforms(vb, varyingHandler, uniformHandler, localCoordsVar, SkMatrix::I(), + handler); + } + struct GrGPArgs { // Used to specify the output variable used by the GP to store its device position. It can // either be a float2 or a float3 (in order to handle perspective). The subclass sets this |