| Index: src/gpu/effects/GrBezierEffect.cpp
|
| diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
|
| index 6ad1537f6253e046f5aa612dfef7701716b36bfe..73b888f86f1028c78ed02973448db9106e91fa9b 100644
|
| --- a/src/gpu/effects/GrBezierEffect.cpp
|
| +++ b/src/gpu/effects/GrBezierEffect.cpp
|
| @@ -12,6 +12,11 @@
|
| #include "gl/GrGLGeometryProcessor.h"
|
| #include "gl/builders/GrGLProgramBuilder.h"
|
|
|
| +struct ConicBatchTracker {
|
| + GPInput fInputColorType;
|
| + GrColor fColor;
|
| +};
|
| +
|
| class GrGLConicEffect : public GrGLGeometryProcessor {
|
| public:
|
| GrGLConicEffect(const GrGeometryProcessor&,
|
| @@ -24,12 +29,16 @@ public:
|
| const GrGLCaps&,
|
| GrProcessorKeyBuilder*);
|
|
|
| - virtual void setData(const GrGLProgramDataManager&,
|
| + virtual void setData(const GrGLProgramDataManager& pdman,
|
| const GrGeometryProcessor&,
|
| - const GrBatchTracker&) SK_OVERRIDE {}
|
| + const GrBatchTracker& bt) SK_OVERRIDE {
|
| + const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
| + this->setUniformColorIfRequired(pdman, local.fInputColorType, local.fColor, fColorUniform);
|
| + }
|
|
|
| private:
|
| GrPrimitiveEdgeType fEdgeType;
|
| + UniformHandle fColorUniform;
|
|
|
| typedef GrGLGeometryProcessor INHERITED;
|
| };
|
| @@ -43,11 +52,15 @@ GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor,
|
| void GrGLConicEffect::emitCode(const EmitArgs& args) {
|
| GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
| const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
|
| + const ConicBatchTracker& local = args.fBT.cast<ConicBatchTracker>();
|
|
|
| GrGLVertToFrag v(kVec4f_GrSLType);
|
| args.fPB->addVarying("ConicCoeffs", &v);
|
| vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
|
|
|
| + // Setup pass through color
|
| + this->setupColor(args.fPB, local.fInputColorType, args.fOutputColor, NULL, &fColorUniform);
|
| +
|
| // setup coord outputs
|
| vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPosition()->fName);
|
| vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()->fName);
|
| @@ -117,11 +130,13 @@ void GrGLConicEffect::emitCode(const EmitArgs& args) {
|
| }
|
|
|
| void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor,
|
| - const GrBatchTracker&,
|
| + const GrBatchTracker& bt,
|
| const GrGLCaps&,
|
| GrProcessorKeyBuilder* b) {
|
| const GrConicEffect& ce = processor.cast<GrConicEffect>();
|
| + const ConicBatchTracker& local = bt.cast<ConicBatchTracker>();
|
| uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
| + key |= kUniform_GPInput == local.fInputColorType ? 0x4 : 0x8;
|
| b->add32(key);
|
| }
|
|
|
| @@ -152,6 +167,20 @@ bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const {
|
| return (ce.fEdgeType == fEdgeType);
|
| }
|
|
|
| +void GrConicEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& init) const {
|
| + ConicBatchTracker* local = bt->cast<ConicBatchTracker>();
|
| +
|
| + local->fColor = init.fColor;
|
| + local->fInputColorType = GetColorInputType(init, false);
|
| +}
|
| +
|
| +bool GrConicEffect::onCanBatch(const GrBatchTracker& l, const GrBatchTracker& r) const {
|
| + const ConicBatchTracker& left = l.cast<ConicBatchTracker>();
|
| + const ConicBatchTracker& right = r.cast<ConicBatchTracker>();
|
| + return CanCombineOutput(left.fInputColorType, left.fColor,
|
| + right.fInputColorType, right.fColor);
|
| +}
|
| +
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
|
| @@ -173,6 +202,11 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
|
| // Quad
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| +struct QuadBatchTracker {
|
| + GPInput fInputColorType;
|
| + GrColor fColor;
|
| +};
|
| +
|
| class GrGLQuadEffect : public GrGLGeometryProcessor {
|
| public:
|
| GrGLQuadEffect(const GrGeometryProcessor&,
|
| @@ -185,12 +219,17 @@ public:
|
| const GrGLCaps&,
|
| GrProcessorKeyBuilder*);
|
|
|
| - virtual void setData(const GrGLProgramDataManager&,
|
| + virtual void setData(const GrGLProgramDataManager& pdman,
|
| const GrGeometryProcessor&,
|
| - const GrBatchTracker&) SK_OVERRIDE {}
|
| + const GrBatchTracker& bt) SK_OVERRIDE {
|
| + const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
| + this->setUniformColorIfRequired(pdman, local.fInputColorType, local.fColor, fColorUniform);
|
| + }
|
|
|
| private:
|
| GrPrimitiveEdgeType fEdgeType;
|
| + UniformHandle fColorUniform;
|
| +
|
|
|
| typedef GrGLGeometryProcessor INHERITED;
|
| };
|
| @@ -204,11 +243,15 @@ GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor,
|
| void GrGLQuadEffect::emitCode(const EmitArgs& args) {
|
| GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
| const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
|
| + const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>();
|
|
|
| GrGLVertToFrag v(kVec4f_GrSLType);
|
| args.fPB->addVarying("HairQuadEdge", &v);
|
| vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
|
|
|
| + // Setup pass through color
|
| + this->setupColor(args.fPB, local.fInputColorType, args.fOutputColor, NULL, &fColorUniform);
|
| +
|
| // setup coord outputs
|
| vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPosition()->fName);
|
| vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()->fName);
|
| @@ -264,11 +307,13 @@ void GrGLQuadEffect::emitCode(const EmitArgs& args) {
|
| }
|
|
|
| void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor,
|
| - const GrBatchTracker&,
|
| + const GrBatchTracker& bt,
|
| const GrGLCaps&,
|
| GrProcessorKeyBuilder* b) {
|
| const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
|
| + const QuadBatchTracker& local = bt.cast<QuadBatchTracker>();
|
| uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
| + key |= kUniform_GPInput == local.fInputColorType ? 0x4 : 0x8;
|
| b->add32(key);
|
| }
|
|
|
| @@ -299,6 +344,20 @@ bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const {
|
| return (ce.fEdgeType == fEdgeType);
|
| }
|
|
|
| +void GrQuadEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& init) const {
|
| + QuadBatchTracker* local = bt->cast<QuadBatchTracker>();
|
| +
|
| + local->fColor = init.fColor;
|
| + local->fInputColorType = GetColorInputType(init, false);
|
| +}
|
| +
|
| +bool GrQuadEffect::onCanBatch(const GrBatchTracker& l, const GrBatchTracker& r) const {
|
| + const QuadBatchTracker& left = l.cast<QuadBatchTracker>();
|
| + const QuadBatchTracker& right = r.cast<QuadBatchTracker>();
|
| + return CanCombineOutput(left.fInputColorType, left.fColor,
|
| + right.fInputColorType, right.fColor);
|
| +}
|
| +
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
|
| @@ -320,6 +379,11 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
|
| // Cubic
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| +struct CubicBatchTracker {
|
| + GPInput fInputColorType;
|
| + GrColor fColor;
|
| +};
|
| +
|
| class GrGLCubicEffect : public GrGLGeometryProcessor {
|
| public:
|
| GrGLCubicEffect(const GrGeometryProcessor&,
|
| @@ -332,12 +396,16 @@ public:
|
| const GrGLCaps&,
|
| GrProcessorKeyBuilder*);
|
|
|
| - virtual void setData(const GrGLProgramDataManager&,
|
| + virtual void setData(const GrGLProgramDataManager& pdman,
|
| const GrGeometryProcessor&,
|
| - const GrBatchTracker&) SK_OVERRIDE {}
|
| + const GrBatchTracker& bt) SK_OVERRIDE {
|
| + const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
|
| + this->setUniformColorIfRequired(pdman, local.fInputColorType, local.fColor, fColorUniform);
|
| + }
|
|
|
| private:
|
| GrPrimitiveEdgeType fEdgeType;
|
| + UniformHandle fColorUniform;
|
|
|
| typedef GrGLGeometryProcessor INHERITED;
|
| };
|
| @@ -351,11 +419,15 @@ GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor,
|
| void GrGLCubicEffect::emitCode(const EmitArgs& args) {
|
| GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
| const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
|
| + const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>();
|
|
|
| GrGLVertToFrag v(kVec4f_GrSLType);
|
| args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
|
| vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
|
|
|
| + // Setup pass through color
|
| + this->setupColor(args.fPB, local.fInputColorType, args.fOutputColor, NULL, &fColorUniform);
|
| +
|
| // setup coord outputs
|
| vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPosition()->fName);
|
| vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()->fName);
|
| @@ -452,11 +524,13 @@ void GrGLCubicEffect::emitCode(const EmitArgs& args) {
|
| }
|
|
|
| void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor,
|
| - const GrBatchTracker&,
|
| + const GrBatchTracker& bt,
|
| const GrGLCaps&,
|
| GrProcessorKeyBuilder* b) {
|
| const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
|
| + const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
|
| uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
| + key |= kUniform_GPInput == local.fInputColorType ? 0x4 : 0x8;
|
| b->add32(key);
|
| }
|
|
|
| @@ -487,6 +561,20 @@ bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const {
|
| return (ce.fEdgeType == fEdgeType);
|
| }
|
|
|
| +void GrCubicEffect::initBatchTracker(GrBatchTracker* bt, const InitBT& init) const {
|
| + CubicBatchTracker* local = bt->cast<CubicBatchTracker>();
|
| +
|
| + local->fColor = init.fColor;
|
| + local->fInputColorType = GetColorInputType(init, false);
|
| +}
|
| +
|
| +bool GrCubicEffect::onCanBatch(const GrBatchTracker& l, const GrBatchTracker& r) const {
|
| + const CubicBatchTracker& left = l.cast<CubicBatchTracker>();
|
| + const CubicBatchTracker& right = r.cast<CubicBatchTracker>();
|
| + return CanCombineOutput(left.fInputColorType, left.fColor,
|
| + right.fInputColorType, right.fColor);
|
| +}
|
| +
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
|
|
|