Make stencil and cover path rendering have more reasonable bounds.

BUG=skia:

Review URL: https://codereview.chromium.org/1471883002
This commit is contained in:
bsalomon 2015-11-23 14:25:19 -08:00 committed by Commit bot
parent 50aa15b88a
commit bf07455533
7 changed files with 27 additions and 16 deletions

View File

@ -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

View File

@ -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() {

View File

@ -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();
}

View File

@ -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.

View File

@ -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) {

View File

@ -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) {

View File

@ -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;