diff options
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 |