diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrDefaultGeoProcFactory.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrPrimitiveProcessor.h | 5 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCCPRPathProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrBezierEffect.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 12 | ||||
-rw-r--r-- | src/gpu/effects/GrShadowGeoProc.cpp | 3 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLGeometryProcessor.cpp | 11 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLGeometryProcessor.h | 27 | ||||
-rw-r--r-- | src/gpu/instanced/InstanceProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/ops/GrAAConvexPathRenderer.cpp | 3 | ||||
-rw-r--r-- | src/gpu/ops/GrDashOp.cpp | 6 | ||||
-rw-r--r-- | src/gpu/ops/GrMSAAPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/ops/GrOvalOpFactory.cpp | 9 | ||||
-rw-r--r-- | src/gpu/ops/GrTextureOp.cpp | 3 |
15 files changed, 46 insertions, 60 deletions
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index 70f64ab10c..56758769b7 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -144,8 +144,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - gp.inLocalCoords()->fName, + gp.inLocalCoords()->asShaderVar(), gp.localMatrix(), args.fFPCoordTransformHandler); } else { @@ -153,8 +152,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - gp.inPosition()->fName, + gp.inPosition()->asShaderVar(), gp.localMatrix(), args.fFPCoordTransformHandler); } diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index 375b5129ba..f480110df5 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -45,7 +45,10 @@ public: kPerVertex, kPerInstance }; - + GrShaderVar asShaderVar() const { + return GrShaderVar(fName, GrVertexAttribTypeToSLType(fType), + GrShaderVar::kIn_TypeModifier); + } const char* fName; GrVertexAttribType fType; int fOffsetInRecord; diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp index 612035af4a..be9f67a4b9 100644 --- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp +++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp @@ -172,7 +172,7 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { proc.getInstanceAttrib(InstanceAttribs::kViewMatrix).fName, proc.getInstanceAttrib(InstanceAttribs::kViewTranslate).fName); - this->emitTransforms(v, varyingHandler, uniHandler, gpArgs->fPositionVar, "pathcoord", + this->emitTransforms(v, varyingHandler, uniHandler, GrShaderVar("pathcoord", kFloat2_GrSLType), args.fFPCoordTransformHandler); // Fragment shader. diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index ffd7b0657f..5bc04c82ea 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -97,8 +97,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - gp.inPosition()->fName, + gp.inPosition()->asShaderVar(), gp.localMatrix(), args.fFPCoordTransformHandler); @@ -350,8 +349,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - gp.inPosition()->fName, + gp.inPosition()->asShaderVar(), gp.localMatrix(), args.fFPCoordTransformHandler); @@ -578,11 +576,9 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - gp.inPosition()->fName, + gp.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); - GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0); GrShaderVar gF("gF", kFloat2_GrSLType, 0); GrShaderVar func("func", kFloat_GrSLType, 0); diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index d5f930fec4..df71f70a1c 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -58,8 +58,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - btgp.inPosition()->fName, + btgp.inPosition()->asShaderVar(), btgp.localMatrix(), args.fFPCoordTransformHandler); diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index aafabdeb60..fda2f9d5c2 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -72,8 +72,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - dfTexEffect.inPosition()->fName, + dfTexEffect.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); // add varyings @@ -365,8 +364,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - dfTexEffect.inPosition()->fName, + dfTexEffect.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); } else { // Setup position @@ -376,8 +374,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - dfTexEffect.inPosition()->fName, + dfTexEffect.inPosition()->asShaderVar(), dfTexEffect.matrix(), args.fFPCoordTransformHandler); } @@ -633,8 +630,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - dfTexEffect.inPosition()->fName, + dfTexEffect.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); // set up varyings diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp index ba337d73b0..507101d87b 100644 --- a/src/gpu/effects/GrShadowGeoProc.cpp +++ b/src/gpu/effects/GrShadowGeoProc.cpp @@ -39,8 +39,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - rsgp.inPosition()->fName, + rsgp.inPosition()->asShaderVar(), args.fFPCoordTransformHandler); fragBuilder->codeAppend("half d = length(shadowParams.xy);"); 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 diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp index 43dfbef1fc..f99a0dbc48 100644 --- a/src/gpu/instanced/InstanceProcessor.cpp +++ b/src/gpu/instanced/InstanceProcessor.cpp @@ -406,7 +406,7 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { GrGLSLTypeString(args.fShaderCaps, positionType), backend->outShapeCoords()); gpArgs->fPositionVar.set(positionType, "deviceCoords"); - this->emitTransforms(v, varyingHandler, uniHandler, gpArgs->fPositionVar, localCoords, + this->emitTransforms(v, varyingHandler, uniHandler, GrShaderVar(localCoords, kHalf2_GrSLType), args.fFPCoordTransformHandler); } diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 3c84b32df7..b706d68858 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -582,8 +582,7 @@ public: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - qe.fInPosition->fName, + qe.fInPosition->asShaderVar(), qe.fLocalMatrix, args.fFPCoordTransformHandler); diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index e87a335af0..34c1a2bc8b 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -910,8 +910,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - dce.inPosition()->fName, + dce.inPosition()->asShaderVar(), dce.localMatrix(), args.fFPCoordTransformHandler); @@ -1114,8 +1113,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - de.inPosition()->fName, + de.inPosition()->asShaderVar(), de.localMatrix(), args.fFPCoordTransformHandler); diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index 50741bc537..8097b7c73c 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -149,8 +149,8 @@ public: qp.viewMatrix(), &fViewMatrixUniform); // emit transforms - this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar, - qp.inPosition()->fName, SkMatrix::I(), + this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, + qp.inPosition()->asShaderVar(), SkMatrix::I(), args.fFPCoordTransformHandler); GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index a3256602af..3c4898f848 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -144,8 +144,7 @@ private: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - cgp.fInPosition->fName, + cgp.fInPosition->asShaderVar(), cgp.fLocalMatrix, args.fFPCoordTransformHandler); @@ -293,8 +292,7 @@ private: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - egp.fInPosition->fName, + egp.fInPosition->asShaderVar(), egp.fLocalMatrix, args.fFPCoordTransformHandler); @@ -437,8 +435,7 @@ private: this->emitTransforms(vertBuilder, varyingHandler, uniformHandler, - gpArgs->fPositionVar, - diegp.fInPosition->fName, + diegp.fInPosition->asShaderVar(), args.fFPCoordTransformHandler); // for outer curve diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index f9600e5d44..79a22d83e4 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -107,8 +107,7 @@ public: this->emitTransforms(args.fVertBuilder, args.fVaryingHandler, args.fUniformHandler, - gpArgs->fPositionVar, - textureGP.fTextureCoords.fName, + textureGP.fTextureCoords.asShaderVar(), args.fFPCoordTransformHandler); if (args.fShaderCaps->preferFlatInterpolation()) { args.fVaryingHandler->addFlatPassThroughAttribute(&textureGP.fColors, |