diff options
author | 2013-10-02 13:04:56 +0000 | |
---|---|---|
committer | 2013-10-02 13:04:56 +0000 | |
commit | 77af6805e5faea1e2a5c0220098aec9082f3a6e5 (patch) | |
tree | da604c305177b007bb8a669ab753290143431ca8 /src/effects/gradients/SkTwoPointConicalGradient.cpp | |
parent | 693a837082404d212fd9b2c3d2ab65dd269211c9 (diff) |
Make GPU coord transforms automatic
Adds a GrCoordTransform class and updates the framework to handle
coord transforms similar to how it handles textures with
GrTextureAccess. Renames GrGLEffectMatrix to GrGLCoordTransform and
slightly repurposes it to be used by the framework instead of effects.
R=bsalomon@google.com, robertphillips@google.com
Review URL: https://codereview.chromium.org/24853002
git-svn-id: http://skia.googlecode.com/svn/trunk@11569 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/gradients/SkTwoPointConicalGradient.cpp')
-rw-r--r-- | src/effects/gradients/SkTwoPointConicalGradient.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 6315565149..0a5e29b856 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -347,6 +347,7 @@ public: EffectKey, const char* outputColor, const char* inputColor, + const TransformedCoordsArray&, const TextureSamplerArray&) SK_OVERRIDE; virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE; @@ -488,12 +489,8 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, EffectKey key, const char* outputColor, const char* inputColor, + const TransformedCoordsArray& coords, const TextureSamplerArray& samplers) { - SkString fsCoords; - SkString vsCoordsVarying; - GrSLType coordsVaryingType; - this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingType); - this->emitUniforms(builder, key); // 2 copies of uniform array, 1 for each of vertex & fragment shader, // to work around Xoom bug. Doesn't seem to cause performance decrease @@ -506,7 +503,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, // For radial gradients without perspective we can pass the linear // part of the quadratic as a varying. GrGLShaderBuilder::VertexBuilder* vertexBuilder = - (kVec2f_GrSLType == coordsVaryingType) ? builder->getVertexBuilder() : NULL; + (kVec2f_GrSLType == coords[0].type()) ? builder->getVertexBuilder() : NULL; if (NULL != vertexBuilder) { vertexBuilder->addVarying(kFloat_GrSLType, "Conical2BCoeff", &fVSVaryingName, &fFSVaryingName); @@ -527,13 +524,13 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, // r2Var = -2 * (r2Parm[2] * varCoord.x - r2Param[3] * r2Param[5]) vertexBuilder->vsCodeAppendf("\t%s = -2.0 * (%s * %s.x + %s * %s);\n", fVSVaryingName, p2.c_str(), - vsCoordsVarying.c_str(), p3.c_str(), p5.c_str()); + coords[0].getVSName().c_str(), p3.c_str(), p5.c_str()); } } // FS { - + SkString coords2D = builder->ensureFSCoords2D(coords, 0); SkString cName("c"); SkString ac4Name("ac4"); SkString dName("d"); @@ -563,7 +560,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, } else { bVar = "b"; builder->fsCodeAppendf("\tfloat %s = -2.0 * (%s * %s.x + %s * %s);\n", - bVar.c_str(), p2.c_str(), fsCoords.c_str(), + bVar.c_str(), p2.c_str(), coords2D.c_str(), p3.c_str(), p5.c_str()); } @@ -573,7 +570,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, // c = (x^2)+(y^2) - params[4] builder->fsCodeAppendf("\tfloat %s = dot(%s, %s) - %s;\n", cName.c_str(), - fsCoords.c_str(), fsCoords.c_str(), + coords2D.c_str(), coords2D.c_str(), p4.c_str()); // Non-degenerate case (quadratic) |