diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 26 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 33 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 34 | ||||
-rw-r--r-- | src/gpu/GrStencilAndCoverTextContext.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrStencilAndCoverTextContext.h | 1 | ||||
-rw-r--r-- | src/gpu/batches/GrDrawPathBatch.cpp | 20 | ||||
-rw-r--r-- | src/gpu/batches/GrDrawPathBatch.h | 29 | ||||
-rw-r--r-- | src/gpu/batches/GrStencilAndCoverPathRenderer.cpp | 5 |
8 files changed, 51 insertions, 105 deletions
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index f8859df2ee..8978c6b542 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -136,22 +136,6 @@ void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint, fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, blob, x, y, filter, clipBounds); } -void GrDrawContext::drawPathsFromRange(const GrPipelineBuilder* pipelineBuilder, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - GrColor color, - GrPathRange* range, - GrPathRangeDraw* draw, - int /*GrPathRendering::FillType*/ fill, - const SkRect& bounds) { - RETURN_IF_ABANDONED - SkDEBUGCODE(this->validate();) - - this->getDrawTarget()->drawPathsFromRange(*pipelineBuilder, viewMatrix, localMatrix, color, - range, draw, (GrPathRendering::FillType) fill, - bounds); -} - void GrDrawContext::discard() { RETURN_IF_ABANDONED SkDEBUGCODE(this->validate();) @@ -638,6 +622,16 @@ void GrDrawContext::drawBatch(const GrClip& clip, this->getDrawTarget()->drawBatch(pipelineBuilder, batch); } +void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, + GrDrawPathBatchBase* batch) { + RETURN_IF_ABANDONED + SkDEBUGCODE(this->validate();) + + AutoCheckFlush acf(fDrawingManager); + + this->getDrawTarget()->drawPathBatch(pipelineBuilder, batch); +} + void GrDrawContext::drawPath(const GrClip& clip, const GrPaint& paint, const SkMatrix& viewMatrix, diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 4f91a3cf96..59488c4d03 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -316,40 +316,13 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, batch->unref(); } -void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, - const SkMatrix& viewMatrix, - GrColor color, - const GrPath* path, - GrPathRendering::FillType fill) { - SkASSERT(path); - SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); - - GrDrawPathBatchBase* batch = GrDrawPathBatch::Create(viewMatrix, color, path); - this->drawPathBatch(pipelineBuilder, batch, fill); - batch->unref(); -} - -void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - GrColor color, - GrPathRange* range, - GrPathRangeDraw* draw, - GrPathRendering::FillType fill, - const SkRect& bounds) { - GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(viewMatrix, localMatrix, color, - range, draw, bounds); - this->drawPathBatch(pipelineBuilder, batch, fill); - batch->unref(); -} - void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, - GrDrawPathBatchBase* batch, - GrPathRendering::FillType fill) { + GrDrawPathBatchBase* batch) { // This looks like drawBatch() but there is an added wrinkle that stencil settings get inserted // after setting up clipping but before onDrawBatch(). TODO: Figure out a better model for // handling stencil settings WRT interactions between pipeline(builder), clipmaskmanager, and // batches. + SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); GrPipelineBuilder::AutoRestoreStencil ars; GrAppliedClip clip; @@ -367,7 +340,7 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrStencilSettings stencilSettings; GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); - this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); + this->getPathStencilSettingsForFilltype(batch->fillType(), sb, &stencilSettings); batch->setStencilSettings(stencilSettings); GrPipeline::CreateArgs args; diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index dc38b5d6d8..c80ac34b94 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -39,7 +39,6 @@ class GrClip; class GrCaps; class GrPath; class GrDrawPathBatchBase; -class GrPathRangeDraw; class GrDrawTarget final : public SkRefCnt { public: @@ -112,34 +111,13 @@ public: GrPathRendering::FillType); /** - * Draws a path. Fill must not be a hairline. It will respect the HW - * antialias flag on the GrPipelineBuilder (if possible in the 3D API). + * Draws a path batch. Fill must not be a hairline. It will respect the HW antialias flag on + * the GrPipelineBuilder (if possible in the 3D API). This needs to be separate from drawBatch + * because we install path stencil settings late. * - * TODO: Remove this function and construct the batch outside GrDrawTarget. + * TODO: Figure out a better model that allows us to roll this method into drawBatch. */ - void drawPath(const GrPipelineBuilder&, const SkMatrix& viewMatrix, GrColor color, - const GrPath*, GrPathRendering::FillType); - - /** - * Draws the aggregate path from combining multiple. Note that this will not - * always be equivalent to back-to-back calls to drawPath(). It will respect - * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API). - * - * TODO: Remove this function and construct the batch outside GrDrawTarget. - * - * @param draw The transforms and indices for the draw. - * This object must only be drawn once. The draw - * may modify its contents. - * @param fill Fill type for drawing all the paths - */ - void drawPathsFromRange(const GrPipelineBuilder&, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - GrColor color, - GrPathRange* range, - GrPathRangeDraw* draw, - GrPathRendering::FillType fill, - const SkRect& bounds); + void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatchBase* batch); /** * Helper function for drawing rects. @@ -288,8 +266,6 @@ private: GrXferProcessor::DstTexture*, const SkRect& batchBounds); - void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatchBase* batch, - GrPathRendering::FillType fill); // Check to see if this set of draw commands has been sent out void getPathStencilSettingsForFilltype(GrPathRendering::FillType, const GrStencilAttachment*, diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp index 4ae5ec43df..77960dbe7a 100644 --- a/src/gpu/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/GrStencilAndCoverTextContext.cpp @@ -523,8 +523,12 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, SkRect bounds = SkRect::MakeIWH(pipelineBuilder->getRenderTarget()->width(), pipelineBuilder->getRenderTarget()->height()); - dc->drawPathsFromRange(pipelineBuilder, drawMatrix, localMatrix, color, glyphs, fDraw, - GrPathRendering::kWinding_FillType, bounds); + SkAutoTUnref<GrDrawPathBatchBase> batch( + GrDrawPathRangeBatch::Create(drawMatrix, localMatrix, color, + GrPathRendering::kWinding_FillType, glyphs, fDraw, + bounds)); + + dc->drawPathBatch(*pipelineBuilder, batch); } if (fFallbackTextBlob) { diff --git a/src/gpu/GrStencilAndCoverTextContext.h b/src/gpu/GrStencilAndCoverTextContext.h index c223521c7c..7716c78405 100644 --- a/src/gpu/GrStencilAndCoverTextContext.h +++ b/src/gpu/GrStencilAndCoverTextContext.h @@ -18,6 +18,7 @@ class GrTextStrike; class GrPath; class SkSurfaceProps; +class GrPathRangeDraw; /* * This class implements text rendering using stencil and cover path rendering diff --git a/src/gpu/batches/GrDrawPathBatch.cpp b/src/gpu/batches/GrDrawPathBatch.cpp index 5209f907de..c2007ce933 100644 --- a/src/gpu/batches/GrDrawPathBatch.cpp +++ b/src/gpu/batches/GrDrawPathBatch.cpp @@ -42,23 +42,11 @@ SkString GrDrawPathRangeBatch::dumpInfo() const { return string; } -bool GrDrawPathRangeBatch::isWinding() const { - static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Face; - bool isWinding = kInvert_StencilOp != this->stencilSettings().passOp(pathFace); - if (isWinding) { - // Double check that it is in fact winding. - SkASSERT(kIncClamp_StencilOp == this->stencilSettings().passOp(pathFace)); - SkASSERT(kIncClamp_StencilOp == this->stencilSettings().failOp(pathFace)); - SkASSERT(0x1 != this->stencilSettings().writeMask(pathFace)); - SkASSERT(!this->stencilSettings().isTwoSided()); - } - return isWinding; -} - GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix, - GrColor color, GrPathRange* range, GrPathRangeDraw* draw, + GrColor color, GrPathRendering::FillType fill, + GrPathRange* range, GrPathRangeDraw* draw, const SkRect& bounds) - : INHERITED(ClassID(), viewMatrix, color) + : INHERITED(ClassID(), viewMatrix, color, fill) , fPathRange(range) , fLocalMatrix(localMatrix) { SkDEBUGCODE(draw->fUsedInBatch = true;) @@ -90,7 +78,7 @@ bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { // work). Note that it's also possible for overlapping paths to cancel each other's winding // numbers, and we only partially account for this by not allowing even/odd paths to be // combined. (Glyphs in the same font tend to wind the same direction so it works out OK.) - if (!this->isWinding() || + if (GrPathRendering::kWinding_FillType != this->fillType() || this->stencilSettings() != that->stencilSettings() || this->overrides().willColorBlendWithDst()) { return false; diff --git a/src/gpu/batches/GrDrawPathBatch.h b/src/gpu/batches/GrDrawPathBatch.h index 4067c808dc..fdd3448a73 100644 --- a/src/gpu/batches/GrDrawPathBatch.h +++ b/src/gpu/batches/GrDrawPathBatch.h @@ -27,13 +27,17 @@ public: overrides->fUsePLSDstRead = false; } + GrPathRendering::FillType fillType() const { return fFillType; } + void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings = stencil; } protected: - GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor initialColor) + GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor initialColor, + GrPathRendering::FillType fill) : INHERITED(classID) , fViewMatrix(viewMatrix) - , fColor(initialColor) {} + , fColor(initialColor) + , fFillType(fill) {} const GrStencilSettings& stencilSettings() const { return fStencilSettings; } const GrXPOverridesForBatch& overrides() const { return fOverrides; } @@ -48,6 +52,7 @@ private: SkMatrix fViewMatrix; GrColor fColor; + GrPathRendering::FillType fFillType; GrStencilSettings fStencilSettings; GrXPOverridesForBatch fOverrides; @@ -60,8 +65,8 @@ public: // This can't return a more abstract type because we install the stencil settings late :( static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color, - const GrPath* path) { - return new GrDrawPathBatch(viewMatrix, color, path); + GrPathRendering::FillType fill, const GrPath* path) { + return new GrDrawPathBatch(viewMatrix, color, fill, path); } const char* name() const override { return "DrawPath"; } @@ -69,8 +74,9 @@ public: SkString dumpInfo() const override; private: - GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* path) - : INHERITED(ClassID(), viewMatrix, color) + GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, GrPathRendering::FillType fill, + const GrPath* path) + : INHERITED(ClassID(), viewMatrix, color, fill) , fPath(path) { fBounds = path->getBounds(); viewMatrix.mapRect(&fBounds); @@ -148,9 +154,11 @@ public: // This can't return a more abstract type because we install the stencil settings late :( static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatrix& localMatrix, - GrColor color, GrPathRange* range, GrPathRangeDraw* draw, + GrColor color, GrPathRendering::FillType fill, + GrPathRange* range, GrPathRangeDraw* draw, const SkRect& bounds) { - return new GrDrawPathRangeBatch(viewMatrix, localMatrix, color, range, draw, bounds); + return new GrDrawPathRangeBatch(viewMatrix, localMatrix, color, fill, range, draw, + bounds); } ~GrDrawPathRangeBatch() override; @@ -160,10 +168,9 @@ public: SkString dumpInfo() const override; private: - inline bool isWinding() const; - GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix, GrColor color, - GrPathRange* range, GrPathRangeDraw* draw, const SkRect& bounds); + GrPathRendering::FillType fill, GrPathRange* range, + GrPathRangeDraw* draw, const SkRect& bounds); bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp index cf5db3fc63..848c82104d 100644 --- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp @@ -10,6 +10,7 @@ #include "GrStencilAndCoverPathRenderer.h" #include "GrCaps.h" #include "GrContext.h" +#include "GrDrawPathBatch.h" #include "GrGpu.h" #include "GrPath.h" #include "GrRenderTarget.h" @@ -131,7 +132,9 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { 0xffff); pipelineBuilder->setStencil(kStencilPass); - args.fTarget->drawPath(*pipelineBuilder, viewMatrix, args.fColor, p, p->getFillType()); + SkAutoTUnref<GrDrawPathBatchBase> batch( + GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType(), p)); + args.fTarget->drawPathBatch(*pipelineBuilder, batch); } pipelineBuilder->stencil()->setDisabled(); |