| Index: src/gpu/effects/GrBezierEffect.cpp
|
| diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
|
| index 8d1b0dbd7aed78465f1f5d6400f7e377abd83c5a..a09d6ce4149236a34fd95670708f60b1bd4d2b5d 100644
|
| --- a/src/gpu/effects/GrBezierEffect.cpp
|
| +++ b/src/gpu/effects/GrBezierEffect.cpp
|
| @@ -12,6 +12,13 @@
|
| #include "gl/GrGLGeometryProcessor.h"
|
| #include "gl/builders/GrGLProgramBuilder.h"
|
|
|
| +struct ConicBatchTracker {
|
| + GrGPInput fInputColorType;
|
| + GrColor fColor;
|
| + uint8_t fCoverageScale;
|
| + bool fUsesLocalCoords;
|
| +};
|
| +
|
| class GrGLConicEffect : public GrGLGeometryProcessor {
|
| public:
|
| GrGLConicEffect(const GrGeometryProcessor&,
|
| @@ -30,16 +37,16 @@
|
| const GrConicEffect& ce = primProc.cast<GrConicEffect>();
|
| this->setUniformViewMatrix(pdman, ce.viewMatrix());
|
|
|
| - if (ce.color() != fColor) {
|
| + const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
| + if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
| GrGLfloat c[4];
|
| - GrColorToRGBAFloat(ce.color(), c);
|
| + GrColorToRGBAFloat(local.fColor, c);
|
| pdman.set4fv(fColorUniform, 1, c);
|
| - fColor = ce.color();
|
| - }
|
| -
|
| - if (ce.coverageScale() != 0xff && ce.coverageScale() != fCoverageScale) {
|
| - pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(ce.coverageScale()));
|
| - fCoverageScale = ce.coverageScale();
|
| + fColor = local.fColor;
|
| + }
|
| + if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageScale) {
|
| + pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCoverageScale));
|
| + fCoverageScale = local.fCoverageScale;
|
| }
|
| }
|
|
|
| @@ -71,6 +78,7 @@
|
| GrGLGPBuilder* pb = args.fPB;
|
| GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
| const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
|
| + const ConicBatchTracker& local = args.fBT.cast<ConicBatchTracker>();
|
|
|
| // emit attributes
|
| vsBuilder->emitAttributes(gp);
|
| @@ -80,9 +88,8 @@
|
| vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
|
|
|
| // Setup pass through color
|
| - if (!gp.colorIgnored()) {
|
| - this->setupUniformColor(args.fPB, args.fOutputColor, &fColorUniform);
|
| - }
|
| + this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
|
| + &fColorUniform);
|
|
|
| // Setup position
|
| this->setupPosition(pb, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
| @@ -148,8 +155,7 @@
|
| SkFAIL("Shouldn't get here");
|
| }
|
|
|
| - // TODO should we really be doing this?
|
| - if (gp.coverageScale() != 0xff) {
|
| + if (0xff != local.fCoverageScale) {
|
| const char* coverageScale;
|
| fCoverageScaleUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
| kFloat_GrSLType,
|
| @@ -167,10 +173,11 @@
|
| const GrGLSLCaps&,
|
| GrProcessorKeyBuilder* b) {
|
| const GrConicEffect& ce = gp.cast<GrConicEffect>();
|
| + const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
| uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
| - key |= GrColor_ILLEGAL != ce.color() ? 0x4 : 0x0;
|
| - key |= 0xff != ce.coverageScale() ? 0x8 : 0x0;
|
| - key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
| + key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
|
| + key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
|
| + key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
| key |= ComputePosKey(ce.viewMatrix()) << 5;
|
| b->add32(key);
|
| }
|
| @@ -191,18 +198,23 @@
|
| }
|
|
|
| GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
|
| - GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix,
|
| - bool usesLocalCoords)
|
| + GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix)
|
| : fColor(color)
|
| , fViewMatrix(viewMatrix)
|
| , fLocalMatrix(viewMatrix)
|
| - , fUsesLocalCoords(usesLocalCoords)
|
| , fCoverageScale(coverage)
|
| , fEdgeType(edgeType) {
|
| this->initClassID<GrConicEffect>();
|
| fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
| fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs",
|
| - kVec4f_GrVertexAttribType));
|
| + kVec4f_GrVertexAttribType));
|
| +}
|
| +
|
| +void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
| + ConicBatchTracker* local = bt->cast<ConicBatchTracker>();
|
| + local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
| + local->fCoverageScale = fCoverageScale;
|
| + local->fUsesLocalCoords = init.fUsesLocalCoords;
|
| }
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
| @@ -219,7 +231,7 @@
|
| random->nextULessThan(kGrProcessorEdgeTypeCnt));
|
| gp = GrConicEffect::Create(GrRandomColor(random), GrTest::TestMatrix(random),
|
| edgeType, caps,
|
| - GrTest::TestMatrix(random), random->nextBool());
|
| + GrTest::TestMatrix(random));
|
| } while (NULL == gp);
|
| return gp;
|
| }
|
| @@ -227,6 +239,13 @@
|
| //////////////////////////////////////////////////////////////////////////////
|
| // Quad
|
| //////////////////////////////////////////////////////////////////////////////
|
| +
|
| +struct QuadBatchTracker {
|
| + GrGPInput fInputColorType;
|
| + GrColor fColor;
|
| + uint8_t fCoverageScale;
|
| + bool fUsesLocalCoords;
|
| +};
|
|
|
| class GrGLQuadEffect : public GrGLGeometryProcessor {
|
| public:
|
| @@ -246,16 +265,16 @@
|
| const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
|
| this->setUniformViewMatrix(pdman, qe.viewMatrix());
|
|
|
| - if (qe.color() != fColor) {
|
| + const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
| + if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
| GrGLfloat c[4];
|
| - GrColorToRGBAFloat(qe.color(), c);
|
| + GrColorToRGBAFloat(local.fColor, c);
|
| pdman.set4fv(fColorUniform, 1, c);
|
| - fColor = qe.color();
|
| - }
|
| -
|
| - if (qe.coverageScale() != 0xff && qe.coverageScale() != fCoverageScale) {
|
| - pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(qe.coverageScale()));
|
| - fCoverageScale = qe.coverageScale();
|
| + fColor = local.fColor;
|
| + }
|
| + if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageScale) {
|
| + pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCoverageScale));
|
| + fCoverageScale = local.fCoverageScale;
|
| }
|
| }
|
|
|
| @@ -287,6 +306,7 @@
|
| GrGLGPBuilder* pb = args.fPB;
|
| GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
| const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
|
| + const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>();
|
|
|
| // emit attributes
|
| vsBuilder->emitAttributes(gp);
|
| @@ -296,9 +316,8 @@
|
| vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
|
|
|
| // Setup pass through color
|
| - if (!gp.colorIgnored()) {
|
| - this->setupUniformColor(args.fPB, args.fOutputColor, &fColorUniform);
|
| - }
|
| + this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
|
| + &fColorUniform);
|
|
|
| // Setup position
|
| this->setupPosition(pb, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
| @@ -350,7 +369,7 @@
|
| SkFAIL("Shouldn't get here");
|
| }
|
|
|
| - if (0xff != gp.coverageScale()) {
|
| + if (0xff != local.fCoverageScale) {
|
| const char* coverageScale;
|
| fCoverageScaleUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
| kFloat_GrSLType,
|
| @@ -368,10 +387,11 @@
|
| const GrGLSLCaps&,
|
| GrProcessorKeyBuilder* b) {
|
| const GrQuadEffect& ce = gp.cast<GrQuadEffect>();
|
| + const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
| uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
| - key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x0;
|
| - key |= ce.coverageScale() != 0xff ? 0x8 : 0x0;
|
| - key |= ce.usesLocalCoords() && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
| + key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
|
| + key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
|
| + key |= local.fUsesLocalCoords && ce.localMatrix().hasPerspective() ? 0x10 : 0x0;
|
| key |= ComputePosKey(ce.viewMatrix()) << 5;
|
| b->add32(key);
|
| }
|
| @@ -392,18 +412,23 @@
|
| }
|
|
|
| GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
|
| - GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix,
|
| - bool usesLocalCoords)
|
| + GrPrimitiveEdgeType edgeType, const SkMatrix& localMatrix)
|
| : fColor(color)
|
| , fViewMatrix(viewMatrix)
|
| , fLocalMatrix(localMatrix)
|
| - , fUsesLocalCoords(usesLocalCoords)
|
| , fCoverageScale(coverage)
|
| , fEdgeType(edgeType) {
|
| this->initClassID<GrQuadEffect>();
|
| fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
| fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge",
|
| kVec4f_GrVertexAttribType));
|
| +}
|
| +
|
| +void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
| + QuadBatchTracker* local = bt->cast<QuadBatchTracker>();
|
| + local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
| + local->fCoverageScale = fCoverageScale;
|
| + local->fUsesLocalCoords = init.fUsesLocalCoords;
|
| }
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
| @@ -421,8 +446,7 @@
|
| gp = GrQuadEffect::Create(GrRandomColor(random),
|
| GrTest::TestMatrix(random),
|
| edgeType, caps,
|
| - GrTest::TestMatrix(random),
|
| - random->nextBool());
|
| + GrTest::TestMatrix(random));
|
| } while (NULL == gp);
|
| return gp;
|
| }
|
| @@ -430,6 +454,12 @@
|
| //////////////////////////////////////////////////////////////////////////////
|
| // Cubic
|
| //////////////////////////////////////////////////////////////////////////////
|
| +
|
| +struct CubicBatchTracker {
|
| + GrGPInput fInputColorType;
|
| + GrColor fColor;
|
| + bool fUsesLocalCoords;
|
| +};
|
|
|
| class GrGLCubicEffect : public GrGLGeometryProcessor {
|
| public:
|
| @@ -449,11 +479,12 @@
|
| const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
|
| this->setUniformViewMatrix(pdman, ce.viewMatrix());
|
|
|
| - if (ce.color() != fColor) {
|
| + const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
|
| + if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
|
| GrGLfloat c[4];
|
| - GrColorToRGBAFloat(ce.color(), c);
|
| + GrColorToRGBAFloat(local.fColor, c);
|
| pdman.set4fv(fColorUniform, 1, c);
|
| - fColor = ce.color();
|
| + fColor = local.fColor;
|
| }
|
| }
|
|
|
| @@ -475,6 +506,7 @@
|
| void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
| GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
| const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
|
| + const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>();
|
|
|
| // emit attributes
|
| vsBuilder->emitAttributes(gp);
|
| @@ -484,9 +516,8 @@
|
| vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
|
|
|
| // Setup pass through color
|
| - if (!gp.colorIgnored()) {
|
| - this->setupUniformColor(args.fPB, args.fOutputColor, &fColorUniform);
|
| - }
|
| + this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputColor, NULL,
|
| + &fColorUniform);
|
|
|
| // Setup position
|
| this->setupPosition(args.fPB, gpArgs, gp.inPosition()->fName, gp.viewMatrix());
|
| @@ -587,8 +618,9 @@
|
| const GrGLSLCaps&,
|
| GrProcessorKeyBuilder* b) {
|
| const GrCubicEffect& ce = gp.cast<GrCubicEffect>();
|
| + const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
|
| uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
| - key |= ce.color() != GrColor_ILLEGAL ? 0x4 : 0x8;
|
| + key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8;
|
| key |= ComputePosKey(ce.viewMatrix()) << 5;
|
| b->add32(key);
|
| }
|
| @@ -617,6 +649,12 @@
|
| fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
|
| fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs",
|
| kVec4f_GrVertexAttribType));
|
| +}
|
| +
|
| +void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
|
| + CubicBatchTracker* local = bt->cast<CubicBatchTracker>();
|
| + local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
|
| + local->fUsesLocalCoords = init.fUsesLocalCoords;
|
| }
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|