diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h index f051ebd994..e0a9b0eedb 100644 --- a/include/gpu/GrDrawContext.h +++ b/include/gpu/GrDrawContext.h @@ -70,7 +70,8 @@ public: GrColor color, GrPathRange* range, GrPathRangeDraw* draw, - int /*GrPathRendering::FillType*/ fill); + int /*GrPathRendering::FillType*/ fill, + const SkRect& bounds); /** * Provides a perfomance hint that the render target's contents are allowed diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 1137c57bc4..51d057e8f5 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -143,12 +143,14 @@ void GrDrawContext::drawPathsFromRange(const GrPipelineBuilder* pipelineBuilder, GrColor color, GrPathRange* range, GrPathRangeDraw* draw, - int /*GrPathRendering::FillType*/ fill) { + 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); + range, draw, (GrPathRendering::FillType) fill, + bounds); } void GrDrawContext::discard() { diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 01d4f63bc5..fb6ccaa1b5 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -322,9 +322,10 @@ void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, GrColor color, GrPathRange* range, GrPathRangeDraw* draw, - GrPathRendering::FillType fill) { + GrPathRendering::FillType fill, + const SkRect& bounds) { GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(viewMatrix, localMatrix, color, - range, draw); + range, draw, bounds); this->drawPathBatch(pipelineBuilder, batch, fill); batch->unref(); } diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index cf3137fe7c..591bbc7361 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -133,7 +133,8 @@ public: GrColor color, GrPathRange* range, GrPathRangeDraw* draw, - GrPathRendering::FillType fill); + GrPathRendering::FillType fill, + const SkRect& bounds); /** * Helper function for drawing rects. diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp index 2c8773860e..bab0b32ce6 100644 --- a/src/gpu/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/GrStencilAndCoverTextContext.cpp @@ -516,8 +516,16 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, localMatrix.setTranslateX(x); localMatrix.setTranslateY(y); + // Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy + // the entire dst. Realistically this is a moot point, because any context that supports + // NV_path_rendering will also support NV_blend_equation_advanced. + // For clipping we'll just skip any optimizations based on the bounds. This does, however, + // hurt batching. + SkRect bounds = SkRect::MakeIWH(pipelineBuilder->getRenderTarget()->width(), + pipelineBuilder->getRenderTarget()->height()); + dc->drawPathsFromRange(pipelineBuilder, drawMatrix, localMatrix, color, glyphs, fDraw, - GrPathRendering::kWinding_FillType); + GrPathRendering::kWinding_FillType, bounds); } if (fFallbackTextBlob) { diff --git a/src/gpu/batches/GrDrawPathBatch.cpp b/src/gpu/batches/GrDrawPathBatch.cpp index faf2d961fd..a829378e54 100644 --- a/src/gpu/batches/GrDrawPathBatch.cpp +++ b/src/gpu/batches/GrDrawPathBatch.cpp @@ -56,18 +56,15 @@ bool GrDrawPathRangeBatch::isWinding() const { } GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix, - GrColor color, GrPathRange* range, GrPathRangeDraw* draw) + GrColor color, GrPathRange* range, GrPathRangeDraw* draw, + const SkRect& bounds) : INHERITED(ClassID(), viewMatrix, color) , fPathRange(range) , fLocalMatrix(localMatrix) { SkDEBUGCODE(draw->fUsedInBatch = true;) fDraws.addToHead(SkRef(draw)); fTotalPathCount = draw->count(); - // Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy - // the entire dst. Realistically this is a moot point, because any context that supports - // NV_path_rendering will also support NV_blend_equation_advanced. - // For clipping we'll just skip any optimizations based on the bounds. - fBounds.setLargest(); + fBounds = bounds; } bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { diff --git a/src/gpu/batches/GrDrawPathBatch.h b/src/gpu/batches/GrDrawPathBatch.h index 39c729fa28..2c166c14c9 100644 --- a/src/gpu/batches/GrDrawPathBatch.h +++ b/src/gpu/batches/GrDrawPathBatch.h @@ -148,8 +148,9 @@ 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) { - return new GrDrawPathRangeBatch(viewMatrix, localMatrix, color, range, draw); + GrColor color, GrPathRange* range, GrPathRangeDraw* draw, + const SkRect& bounds) { + return new GrDrawPathRangeBatch(viewMatrix, localMatrix, color, range, draw, bounds); } ~GrDrawPathRangeBatch() override; @@ -162,7 +163,7 @@ private: inline bool isWinding() const; GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix, GrColor color, - GrPathRange* range, GrPathRangeDraw* draw); + GrPathRange* range, GrPathRangeDraw* draw, const SkRect& bounds); bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override;