diff options
Diffstat (limited to 'src/gpu')
24 files changed, 229 insertions, 177 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 52994758c0..58a393140a 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -761,19 +761,18 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSegmentMasks(); - fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage; + fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); } void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp index 3c7648aae3..c11c641f57 100755 --- a/src/gpu/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp @@ -157,16 +157,15 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fBatch.fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fBatch.fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fBatch.fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fColorIgnored = !init.readsColor(); + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } struct FlushInfo { diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index da60a6cabd..14770b8531 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -700,17 +700,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); fBatch.fCoverage = fGeoData[0].fCoverage; } diff --git a/src/gpu/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/GrAALinearizingConvexPathRenderer.cpp index 786378ba84..f9174cedeb 100644 --- a/src/gpu/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/GrAALinearizingConvexPathRenderer.cpp @@ -136,19 +136,18 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSegmentMasks(); - fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage; + fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); } void draw(GrBatchTarget* batchTarget, const GrPipeline* pipeline, int vertexCount, diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 1c5b6d8616..b0a0e51a68 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -76,18 +76,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { - fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; + if (!init.readsColor()) { + fBatch.fColor = GrColor_ILLEGAL; } + init.getOverrideColorIfSet(&fBatch.fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; - fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; - fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage; + fBatch.fColorIgnored = !init.readsColor(); + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); + fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { @@ -424,19 +422,18 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); fBatch.fMiterStroke = fGeoData[0].fMiterStroke; - fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage; + fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index c25ddd25e2..e0d452997b 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -1498,16 +1498,15 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fBatch.fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fBatch.fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fBatch.fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fColorIgnored = !init.readsColor(); + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } struct FlushInfo { diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index a72c88052c..39efd248ea 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -24,16 +24,16 @@ public: GrColor color, const SkMatrix& viewMatrix, const SkMatrix& localMatrix, - bool usesLocalCoords, - bool coverageIgnored, + bool localCoordsWillBeRead, + bool coverageWillBeIgnored, uint8_t coverage) { return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, color, viewMatrix, localMatrix, coverage, - usesLocalCoords, - coverageIgnored)); + localCoordsWillBeRead, + coverageWillBeIgnored)); } const char* name() const override { return "DefaultGeometryProcessor"; } @@ -47,9 +47,9 @@ public: bool hasVertexColor() const { return SkToBool(fInColor); } const SkMatrix& viewMatrix() const { return fViewMatrix; } const SkMatrix& localMatrix() const { return fLocalMatrix; } - bool usesLocalCoords() const { return fUsesLocalCoords; } + bool localCoordsWillBeRead() const { return fLocalCoordsWillBeRead; } uint8_t coverage() const { return fCoverage; } - bool coverageIgnored() const { return fCoverageIgnored; } + bool coverageWillBeIgnored() const { return fCoverageWillBeIgnored; } bool hasVertexCoverage() const { return SkToBool(fInCoverage); } class GLProcessor : public GrGLGeometryProcessor { @@ -90,7 +90,7 @@ public: } // Setup coverage as pass through - if (!gp.coverageIgnored()) { + if (!gp.coverageWillBeIgnored()) { if (gp.hasVertexCoverage()) { fs->codeAppendf("float alpha = 1.0;"); args.fPB->addPassThroughAttribute(gp.inCoverage(), "alpha"); @@ -116,11 +116,12 @@ public: const DefaultGeoProc& def = gp.cast<DefaultGeoProc>(); uint32_t key = def.fFlags; key |= def.colorIgnored() << 8; - key |= def.coverageIgnored() << 9; + key |= def.coverageWillBeIgnored() << 9; key |= def.hasVertexColor() << 10; key |= def.hasVertexCoverage() << 11; key |= def.coverage() == 0xff ? 0x1 << 12 : 0; - key |= def.usesLocalCoords() && def.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0; + key |= def.localCoordsWillBeRead() && def.localMatrix().hasPerspective() ? 0x1 << 24 : + 0x0; key |= ComputePosKey(def.viewMatrix()) << 25; b->add32(key); } @@ -144,7 +145,8 @@ public: fColor = dgp.color(); } - if (!dgp.coverageIgnored() && dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) { + if (!dgp.coverageWillBeIgnored() && + dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) { pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverage())); fCoverage = dgp.coverage(); } @@ -185,8 +187,8 @@ private: const SkMatrix& viewMatrix, const SkMatrix& localMatrix, uint8_t coverage, - bool usesLocalCoords, - bool coverageIgnored) + bool localCoordsWillBeRead, + bool coverageWillBeIgnored) : fInPosition(NULL) , fInColor(NULL) , fInLocalCoords(NULL) @@ -196,8 +198,8 @@ private: , fLocalMatrix(localMatrix) , fCoverage(coverage) , fFlags(gpTypeFlags) - , fUsesLocalCoords(usesLocalCoords) - , fCoverageIgnored(coverageIgnored) { + , fLocalCoordsWillBeRead(localCoordsWillBeRead) + , fCoverageWillBeIgnored(coverageWillBeIgnored) { this->initClassID<DefaultGeoProc>(); bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType); bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType); @@ -214,7 +216,7 @@ private: } if (hasCoverage) { fInCoverage = &this->addVertexAttrib(Attribute("inCoverage", - kFloat_GrVertexAttribType)); + kFloat_GrVertexAttribType)); } } @@ -227,8 +229,8 @@ private: SkMatrix fLocalMatrix; uint8_t fCoverage; uint32_t fFlags; - bool fUsesLocalCoords; - bool fCoverageIgnored; + bool fLocalCoordsWillBeRead; + bool fCoverageWillBeIgnored; GR_DECLARE_GEOMETRY_PROCESSOR_TEST; @@ -263,8 +265,8 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(SkRandom* random, const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags, GrColor color, - bool usesLocalCoords, - bool coverageIgnored, + bool localCoordsWillBeRead, + bool coverageWillBeIgnored, const SkMatrix& viewMatrix, const SkMatrix& localMatrix, uint8_t coverage) { @@ -272,7 +274,7 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags, color, viewMatrix, localMatrix, - usesLocalCoords, - coverageIgnored, + localCoordsWillBeRead, + coverageWillBeIgnored, coverage); } diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h index 3722a320ce..00fd0bce6b 100644 --- a/src/gpu/GrDefaultGeoProcFactory.h +++ b/src/gpu/GrDefaultGeoProcFactory.h @@ -74,17 +74,17 @@ public: }; /* - * The following functions are used to create default GPs. If you just need to create - * attributes seperately from creating the default GP, use the SetAttribs function followed - * by the Create function. Otherwise use CreateAndSetAttribs to do both at once. + * The following functions are used to create default GPs. If you just need to create + * attributes separately from creating the default GP, use the SetAttribs function followed + * by the Create function. Otherwise use CreateAndSetAttribs to do both at once. * * You must unref the return from Create. */ // TODO clean this up static const GrGeometryProcessor* Create(uint32_t gpTypeFlags, GrColor, - bool usesLocalCoords, - bool coverageIgnored, + bool localCoordsWillBeRead, + bool coverageWillBeIgnored, const SkMatrix& viewMatrix = SkMatrix::I(), const SkMatrix& localMatrix = SkMatrix::I(), uint8_t coverage = 0xff); diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp index f039cee198..2431696d06 100644 --- a/src/gpu/GrDefaultPathRenderer.cpp +++ b/src/gpu/GrDefaultPathRenderer.cpp @@ -237,17 +237,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index f7d7e7bb09..b957b9124e 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -275,17 +275,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { @@ -614,17 +613,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { diff --git a/src/gpu/GrImmediateDrawTarget.cpp b/src/gpu/GrImmediateDrawTarget.cpp index 59a105a73e..2b72bae9b8 100644 --- a/src/gpu/GrImmediateDrawTarget.cpp +++ b/src/gpu/GrImmediateDrawTarget.cpp @@ -33,7 +33,7 @@ void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, return; } - batch->initBatchTracker(pipeline->getInitBatchTracker()); + batch->initBatchTracker(pipeline->infoForPrimitiveProcessor()); fBatchTarget.resetNumberOfDraws(); diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 2a2b5b6912..0b4dab1c2c 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -157,8 +157,8 @@ GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* prim return NULL; } - state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker, - state->getPipeline()->getInitBatchTracker()); + state->fPrimitiveProcessor->initBatchTracker( + &state->fBatchTracker, state->getPipeline()->infoForPrimitiveProcessor()); if (fPrevState && fPrevState->fPrimitiveProcessor.get() && fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, @@ -186,7 +186,7 @@ GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch, return NULL; } - batch->initBatchTracker(state->getPipeline()->getInitBatchTracker()); + batch->initBatchTracker(state->getPipeline()->infoForPrimitiveProcessor()); if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && fPrevState->getPipeline()->isEqual(*state->getPipeline())) { diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index a429caba11..57e53b69d6 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -661,18 +661,17 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; fBatch.fStroke = fGeoData[0].fStroke; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { @@ -876,18 +875,17 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsCoverage()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; fBatch.fStroke = fGeoData[0].fStroke; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { @@ -1140,18 +1138,17 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; fBatch.fMode = fGeoData[0].fMode; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { @@ -1489,18 +1486,17 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; fBatch.fStroke = fGeoData[0].fStroke; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { @@ -1662,18 +1658,17 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; fBatch.fStroke = fGeoData[0].fStroke; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp index b47fa6a973..d10c4662e9 100644 --- a/src/gpu/GrPathProcessor.cpp +++ b/src/gpu/GrPathProcessor.cpp @@ -32,17 +32,18 @@ void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) con void GrPathProcessor::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const { PathBatchTracker* local = bt->cast<PathBatchTracker>(); - if (init.fColorIgnored) { + if (!init.readsColor()) { local->fInputColorType = kIgnored_GrGPInput; local->fColor = GrColor_ILLEGAL; } else { local->fInputColorType = kUniform_GrGPInput; - local->fColor = GrColor_ILLEGAL == init.fOverrideColor ? this->color() : - init.fOverrideColor; + if (!init.getOverrideColorIfSet(&local->fColor)) { + local->fColor = this->color(); + } } - local->fInputCoverageType = init.fCoverageIgnored ? kIgnored_GrGPInput : kAllOnes_GrGPInput; - local->fUsesLocalCoords = init.fUsesLocalCoords; + local->fInputCoverageType = init.readsCoverage() ? kAllOnes_GrGPInput : kIgnored_GrGPInput; + local->fUsesLocalCoords = init.readsLocalCoords(); } bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m, diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 4feddb00ab..8c40438a27 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -30,7 +30,7 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder, overrideColor = colorPOI.inputColorToEffectiveStage(); } - GrXferProcessor::OptFlags optFlags; + GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; if (xferProcessor) { fXferProcessor.reset(xferProcessor.get()); @@ -41,6 +41,11 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder, caps); } + // No need to have an override color if it isn't even going to be used. + if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) { + overrideColor = GrColor_ILLEGAL; + } + // When path rendering the stencil settings are not always set on the GrPipelineBuilder // so we must check the draw type. In cases where we will skip drawing we simply return a // null GrPipeline. @@ -98,13 +103,25 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder, pipelineBuilder.fCoverageStages[i].processor()->usesLocalCoords(); } - // let the GP init the batch tracker - fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag); - fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideColor; - fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag); - fInitBT.fUsesLocalCoords = usesLocalCoords; - fInitBT.fCanTweakAlphaForCoverage = - SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag); + // Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline. + fInfoForPrimitiveProcessor.fFlags = 0; + if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipelineInfoFlag; + } + if (GrColor_ILLEGAL != overrideColor) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_GrPipelineInfoFlag; + fInfoForPrimitiveProcessor.fOverrideColor = overrideColor; + } + if (!SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag)) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsCoverage_GrPipelineInfoFlag; + } + if (usesLocalCoords) { + fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsLocalCoords_GrPipelineInfoFlag; + } + if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) { + fInfoForPrimitiveProcessor.fFlags |= + GrPipelineInfo::kCanTweakAlphaForCoverage_GrPipelineInfoFlag; + } } void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelineBuilder, diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index e91baeb35e..bf8ca8a725 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -97,7 +97,9 @@ public: bool readsFragPosition() const { return fReadsFragPosition; } - const GrPipelineInfo& getInitBatchTracker() const { return fInitBT; } + const GrPipelineInfo& infoForPrimitiveProcessor() const { + return fInfoForPrimitiveProcessor; + } private: /** @@ -135,7 +137,7 @@ private: ProgramXferProcessor fXferProcessor; FragmentStageArray fFragmentStages; bool fReadsFragPosition; - GrPipelineInfo fInitBT; + GrPipelineInfo fInfoForPrimitiveProcessor; // This function is equivalent to the offset into fFragmentStages where coverage stages begin. int fNumColorStages; diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index 4147b74963..e5635a823b 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -72,16 +72,65 @@ class GrGLPrimitiveProcessor; struct GrInitInvariantOutput; /* - * This struct allows the GrPipeline to communicate information about the pipeline. Most of this - * is overrides, but some of it is general information. Logically it should live in GrPipeline.h, - * but this is problematic due to circular dependencies. + * This class allows the GrPipeline to communicate information about the pipeline to a + * GrPrimitiveProcessor that will be used in conjunction with the GrPipeline. */ -struct GrPipelineInfo { - bool fColorIgnored; - bool fCoverageIgnored; - GrColor fOverrideColor; - bool fUsesLocalCoords; - bool fCanTweakAlphaForCoverage; +class GrPipelineInfo { +public: + /** Does the pipeline require the GrPrimitiveProcessor's color? */ + bool readsColor() const { return SkToBool(kReadsColor_GrPipelineInfoFlag & fFlags); } + + /** Does the pipeline require the GrPrimitiveProcessor's coverage? */ + bool readsCoverage() const { return SkToBool(kReadsCoverage_GrPipelineInfoFlag & fFlags); } + + /** Does the pipeline require access to (implicit or explicit) local coordinates? */ + bool readsLocalCoords() const { + return SkToBool(kReadsLocalCoords_GrPipelineInfoFlag & fFlags); + } + + /** Does the pipeline allow the GrPrimitiveProcessor to combine color and coverage into one + color output ? */ + bool canTweakAlphaForCoverage() const { + return SkToBool(kCanTweakAlphaForCoverage_GrPipelineInfoFlag & fFlags); + } + + /** Does the pipeline require the GrPrimitiveProcessor to specify a specific color (and if + so get the color)? */ + bool getOverrideColorIfSet(GrColor* overrideColor) const { + if (SkToBool(kUseOverrideColor_GrPipelineInfoFlag & fFlags)) { + SkASSERT(SkToBool(kReadsColor_GrPipelineInfoFlag & fFlags)); + if (overrideColor) { + *overrideColor = fOverrideColor; + } + return true; + } + return false; + } + +private: + enum { + // If this is not set the primitive processor need not produce a color output + kReadsColor_GrPipelineInfoFlag = 0x1, + + // If this is not set the primitive processor need not produce a coverage output + kReadsCoverage_GrPipelineInfoFlag = 0x2, + + // If this is not set the primitive processor need not produce local coordinates + kReadsLocalCoords_GrPipelineInfoFlag = 0x4, + + // If this flag is set then the primitive processor may produce color*coverage as + // its color output (and not output a separate coverage). + kCanTweakAlphaForCoverage_GrPipelineInfoFlag = 0x8, + + // If this flag is set the GrPrimitiveProcessor must produce fOverrideColor as its + // output color. If not set fOverrideColor is to be ignored. + kUseOverrideColor_GrPipelineInfoFlag = 0x10, + }; + + uint32_t fFlags; + GrColor fOverrideColor; + + friend class GrPipeline; // To initialize this }; /* diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp index bf085bdfdf..222aaef8a9 100644 --- a/src/gpu/GrRectBatch.cpp +++ b/src/gpu/GrRectBatch.cpp @@ -70,17 +70,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp index a41a88eed6..de5dcab8ab 100644 --- a/src/gpu/GrTessellatingPathRenderer.cpp +++ b/src/gpu/GrTessellatingPathRenderer.cpp @@ -1375,11 +1375,10 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fColor); fPipelineInfo = init; } @@ -1412,8 +1411,8 @@ public: LOG("got %d pts, %d contours\n", maxPts, contourCnt); uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; SkAutoTUnref<const GrGeometryProcessor> gp( - GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.fUsesLocalCoords, - fPipelineInfo.fCoverageIgnored, fViewMatrix, + GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.readsLocalCoords(), + !fPipelineInfo.readsCoverage(), fViewMatrix, SkMatrix::I())); batchTarget->initDraw(gp, pipeline); diff --git a/src/gpu/GrTestBatch.h b/src/gpu/GrTestBatch.h index aa0c63773e..5e0f107d27 100644 --- a/src/gpu/GrTestBatch.h +++ b/src/gpu/GrTestBatch.h @@ -34,17 +34,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { this->geoData(0)->fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - this->geoData(0)->fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&this->geoData(0)->fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = this->geoData(0)->fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp index 67dc84156f..e80e06a4a6 100644 --- a/src/gpu/effects/GrConstColorProcessor.cpp +++ b/src/gpu/effects/GrConstColorProcessor.cpp @@ -66,7 +66,8 @@ private: void GrConstColorProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { if (kIgnore_InputMode == fMode) { - inout->setToOther(kRGBA_GrColorComponentFlags, fColor, GrInvariantOutput::kWill_ReadInput); + inout->setToOther(kRGBA_GrColorComponentFlags, fColor, + GrInvariantOutput::kWillNot_ReadInput); } else { GrColor r = GrColorUnpackR(fColor); bool colorIsSingleChannel = r == GrColorUnpackG(fColor) && r == GrColorUnpackB(fColor) && diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index da3b5a25a9..94d50f684e 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -755,7 +755,7 @@ GrXferProcessor::OptFlags CustomXP::onGetOptimizations(const GrProcOptInfo& colo = blend(f*Sa, Da) */ - OptFlags flags = kNone_Opt; + OptFlags flags = kNone_OptFlags; if (colorPOI.allStagesMultiplyInput()) { flags |= kCanTweakAlphaForCoverage_OptFlag; } diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index 8ebb31f9fe..063bfd1352 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -274,17 +274,16 @@ public: void initBatchTracker(const GrPipelineInfo& init) override { // Handle any color overrides - if (init.fColorIgnored) { + if (!init.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; - } else if (GrColor_ILLEGAL != init.fOverrideColor) { - fGeoData[0].fColor = init.fOverrideColor; } + init.getOverrideColorIfSet(&fGeoData[0].fColor); // setup batch properties - fBatch.fColorIgnored = init.fColorIgnored; + fBatch.fColorIgnored = !init.readsColor(); fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = init.fUsesLocalCoords; - fBatch.fCoverageIgnored = init.fCoverageIgnored; + fBatch.fUsesLocalCoords = init.readsLocalCoords(); + fBatch.fCoverageIgnored = !init.readsCoverage(); } struct DashDraw { diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index df44a1b555..6fc3c93e00 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -428,7 +428,7 @@ PorterDuffXferProcessor::onGetOptimizations(const GrProcOptInfo& colorPOI, bool doesStencilWrite, GrColor* overrideColor, const GrCaps& caps) { - GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_Opt; + GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags; if (!fBlendFormula.modifiesDst()) { if (!doesStencilWrite) { optFlags |= GrXferProcessor::kSkipDraw_OptFlag; @@ -471,7 +471,7 @@ public: private: GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo&, const GrProcOptInfo&, bool, GrColor*, const GrCaps&) override { - return kNone_Opt; + return kNone_OptFlags; } void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override; |