Move bounds to GrBatch

BUG=skia:

Review URL: https://codereview.chromium.org/1121463002
This commit is contained in:
joshualitt 2015-05-01 13:43:30 -07:00 committed by Commit bot
parent a499f905e9
commit 99c7c07e0f
18 changed files with 136 additions and 95 deletions

View File

@ -46,7 +46,7 @@ public:
private:
BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& geo,
const SkScalar klmEqs[9], SkScalar sign)
: INHERITED(gp) {
: INHERITED(gp, geo.fBounds) {
for (int i = 0; i < 9; i++) {
fKlmEqs[i] = klmEqs[i];
}
@ -243,7 +243,7 @@ protected:
SkAutoTUnref<GrBatch> batch(
BezierCubicOrConicTestBatch::Create(gp, geometry, klmEqs, klmSigns[c]));
tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
tt.target()->drawBatch(&pipelineBuilder, batch);
}
++col;
if (numCols == col) {
@ -387,7 +387,7 @@ protected:
SkAutoTUnref<GrBatch> batch(
BezierCubicOrConicTestBatch::Create(gp, geometry, klmEqs, 1.f));
tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
tt.target()->drawBatch(&pipelineBuilder, batch);
}
++col;
if (numCols == col) {
@ -457,7 +457,7 @@ public:
private:
BezierQuadTestBatch(const GrGeometryProcessor* gp, const Geometry& geo,
const GrPathUtils::QuadUVMatrix& devToUV)
: INHERITED(gp)
: INHERITED(gp, geo.fBounds)
, fGeometry(geo)
, fDevToUV(devToUV) {
}
@ -641,7 +641,7 @@ protected:
SkAutoTUnref<GrBatch> batch(BezierQuadTestBatch::Create(gp, geometry, DevToUV));
tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
tt.target()->drawBatch(&pipelineBuilder, batch);
}
++col;
if (numCols == col) {

View File

@ -42,7 +42,7 @@ public:
private:
ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo)
: INHERITED(gp)
: INHERITED(gp, geo.fBounds)
, fGeometry(geo) {
}
@ -211,7 +211,7 @@ protected:
SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
tt.target()->drawBatch(&pipelineBuilder, batch);
x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
}
@ -260,7 +260,7 @@ protected:
SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
tt.target()->drawBatch(&pipelineBuilder, batch);
x += SkScalarCeilToScalar(rect.width() + 10.f);
}

View File

@ -847,6 +847,10 @@ private:
AAConvexPathBatch(const Geometry& geometry) {
this->initClassID<AAConvexPathBatch>();
fGeoData.push_back(geometry);
// compute bounds
fBounds = geometry.fPath.getBounds();
geometry.fViewMatrix.mapRect(&fBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -862,6 +866,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -891,19 +896,13 @@ bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
return true;
}
// We outset our vertices one pixel and add one more pixel for precision.
// TODO create tighter bounds when we start reordering.
SkRect devRect = path.getBounds();
vm.mapRect(&devRect);
devRect.outset(2, 2);
AAConvexPathBatch::Geometry geometry;
geometry.fColor = color;
geometry.fViewMatrix = vm;
geometry.fPath = path;
SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry));
target->drawBatch(pipelineBuilder, batch, &devRect);
target->drawBatch(pipelineBuilder, batch);
return true;

View File

@ -312,6 +312,10 @@ private:
fAtlas = atlas;
fPathCache = pathCache;
fPathList = pathList;
// Compute bounds
fBounds = geometry.fPath.getBounds();
viewMatrix.mapRect(&fBounds);
}
bool addPathToAtlas(GrBatchTarget* batchTarget,
@ -548,6 +552,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -607,10 +612,7 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color, viewMatrix,
fAtlas, &fPathCache, &fPathList));
SkRect bounds = path.getBounds();
viewMatrix.mapRect(&bounds);
target->drawBatch(pipelineBuilder, batch, &bounds);
target->drawBatch(pipelineBuilder, batch);
return true;
}

View File

@ -699,7 +699,6 @@ public:
uint8_t fCoverage;
SkMatrix fViewMatrix;
SkPath fPath;
SkDEBUGCODE(SkRect fDevBounds;)
SkIRect fDevClipBounds;
};
@ -734,7 +733,6 @@ public:
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
fBatch.fCoverage = fGeoData[0].fCoverage;
SkDEBUGCODE(fBatch.fDevBounds = fGeoData[0].fDevBounds;)
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override;
@ -753,6 +751,10 @@ private:
SkASSERT(linesIndexBuffer && quadsIndexBuffer);
this->initClassID<AAHairlineBatch>();
fGeoData.push_back(geometry);
// compute bounds
fBounds = geometry.fPath.getBounds();
geometry.fViewMatrix.mapRect(&fBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -785,6 +787,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -1047,23 +1050,16 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
pipelineBuilder->clip().getConservativeBounds(pipelineBuilder->getRenderTarget(),
&devClipBounds);
// This outset was determined experimentally by running skps and gms. It probably could be a
// bit tighter
SkRect devRect = path.getBounds();
viewMatrix.mapRect(&devRect);
devRect.outset(2, 2);
AAHairlineBatch::Geometry geometry;
geometry.fColor = color;
geometry.fCoverage = newCoverage;
geometry.fViewMatrix = viewMatrix;
geometry.fPath = path;
SkDEBUGCODE(geometry.fDevBounds = devRect;)
geometry.fDevClipBounds = devClipBounds;
SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuffer,
fQuadsIndexBuffer));
target->drawBatch(pipelineBuilder, batch, &devRect);
target->drawBatch(pipelineBuilder, batch);
return true;
}

View File

@ -186,6 +186,8 @@ private:
: fIndexBuffer(indexBuffer) {
this->initClassID<AAFillRectBatch>();
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevRect);
}
GrColor color() const { return fBatch.fColor; }
@ -216,6 +218,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -476,7 +479,7 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
geometry.fColor = color;
SkAutoTUnref<GrBatch> batch(AAFillRectBatch::Create(geometry, fAAFillRectIndexBuffer));
target->drawBatch(pipelineBuilder, batch, &devRect);
target->drawBatch(pipelineBuilder, batch);
}
void GrAARectRenderer::strokeAARect(GrDrawTarget* target,
@ -501,14 +504,6 @@ void GrAARectRenderer::strokeAARect(GrDrawTarget* target,
const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
// Temporarily #if'ed out. We don't want to pass in the devRect but
// right now it is computed in GrContext::apply_aa_to_rect and we don't
// want to throw away the work
#if 0
SkRect devRect;
combinedMatrix.mapRect(&devRect, rect);
#endif
SkScalar spare;
{
SkScalar w = devRect.width() - dx;
@ -693,6 +688,11 @@ private:
this->initClassID<AAStrokeRectBatch>();
fBatch.fViewMatrix = viewMatrix;
fGeoData.push_back(geometry);
// If we have miterstroke then we inset devOutside and outset devOutsideAssist, so we need
// the join for proper bounds
fBounds = geometry.fDevOutside;
fBounds.join(geometry.fDevOutsideAssist);
}
GrColor color() const { return fBatch.fColor; }
@ -727,6 +727,7 @@ private:
fBatch.fColor = GrColor_ILLEGAL;
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}

View File

@ -1721,6 +1721,7 @@ public:
void init() {
fBatch.fColor = fGeoData[0].fColor;
fBatch.fViewMatrix = fGeoData[0].fBlob->fViewMatrix;
this->setBounds(fGeoData[0].fBlob->fRuns[fGeoData[0].fRun].fVertexBounds);
}
private:
@ -1924,6 +1925,8 @@ private:
fGeoData[i].fBlob->ref();
}
fInstanceCount = total;
this->joinBounds(that->bounds());
return true;
}
@ -2092,7 +2095,7 @@ inline void GrAtlasTextContext::flushRun(GrDrawTarget* target, GrPipelineBuilder
geometry.fTransY = transY;
batch->init();
target->drawBatch(pipelineBuilder, batch, &cacheBlob->fRuns[run].fVertexBounds);
target->drawBatch(pipelineBuilder, batch);
}
}

View File

@ -38,7 +38,6 @@ struct GrInitInvariantOutput;
* If there are any possible optimizations which might require knowing more about the full state of
* the draw, ie whether or not the GrBatch is allowed to tweak alpha for coverage, then this
* information will be communicated to the GrBatch prior to geometry generation.
* TODO Batch should own the draw bounds
*/
class GrBatch : public SkRefCnt {
@ -62,13 +61,15 @@ public:
return false;
}
return onCombineIfPossible(that);
return this->onCombineIfPossible(that);
}
virtual bool onCombineIfPossible(GrBatch*) = 0;
virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0;
const SkRect& bounds() const { return fBounds; }
// TODO this goes away when batches are everywhere
void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; }
int numberOfDraws() const { return fNumberOfDraws; }
@ -104,6 +105,16 @@ protected:
uint32_t fClassID;
// NOTE, compute some bounds, even if extremely conservative. Do *NOT* setLargest on the bounds
// rect because we outset it for dst copy textures
void setBounds(const SkRect& newBounds) { fBounds = newBounds; }
void joinBounds(const SkRect& otherBounds) {
return fBounds.joinPossiblyEmptyRect(otherBounds);
}
SkRect fBounds;
private:
static uint32_t GenClassID() {
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The

View File

@ -529,6 +529,12 @@ private:
fBatch.fHairline = geometry.fStrokeWidth == 0;
fGeoData.push_back(geometry);
// setup bounds
fBounds = geometry.fRect;
SkScalar rad = SkScalarHalf(geometry.fStrokeWidth);
fBounds.outset(rad, rad);
geometry.fViewMatrix.mapRect(&fBounds);
}
/* create a triangle strip that strokes the specified rect. There are 8
@ -679,16 +685,12 @@ void GrContext::drawRect(GrRenderTarget* rt,
SkAutoTUnref<GrBatch> batch(StrokeRectBatch::Create(geometry));
SkRect bounds = rect;
SkScalar rad = SkScalarHalf(width);
bounds.outset(rad, rad);
viewMatrix.mapRect(&bounds);
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
// hairline rects. We jam all the vertices to pixel centers to avoid this, but not when MSAA
// is enabled because it can cause ugly artifacts.
pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag,
0 == width && !rt->isMultisampled());
target->drawBatch(&pipelineBuilder, batch, &bounds);
target->drawBatch(&pipelineBuilder, batch);
} else {
// filled BW rect
target->drawSimpleRect(&pipelineBuilder, color, viewMatrix, rect);
@ -758,10 +760,11 @@ public:
const SkMatrix& viewMatrix,
const SkPoint* positions, int vertexCount,
const uint16_t* indices, int indexCount,
const GrColor* colors, const SkPoint* localCoords) {
const GrColor* colors, const SkPoint* localCoords,
const SkRect& bounds) {
return SkNEW_ARGS(DrawVerticesBatch, (geometry, primitiveType, viewMatrix, positions,
vertexCount, indices, indexCount, colors,
localCoords));
localCoords, bounds));
}
const char* name() const override { return "DrawVerticesBatch"; }
@ -895,7 +898,7 @@ private:
const SkMatrix& viewMatrix,
const SkPoint* positions, int vertexCount,
const uint16_t* indices, int indexCount,
const GrColor* colors, const SkPoint* localCoords) {
const GrColor* colors, const SkPoint* localCoords, const SkRect& bounds) {
this->initClassID<DrawVerticesBatch>();
SkASSERT(positions);
@ -926,6 +929,8 @@ private:
fBatch.fVertexCount = vertexCount;
fBatch.fIndexCount = indexCount;
fBatch.fPrimitiveType = primitiveType;
this->setBounds(bounds);
}
GrPrimitiveType primitiveType() const { return fBatch.fPrimitiveType; }
@ -980,6 +985,8 @@ private:
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
fBatch.fVertexCount += that->vertexCount();
fBatch.fIndexCount += that->indexCount();
this->joinBounds(that->bounds());
return true;
}
@ -1032,13 +1039,12 @@ void GrContext::drawVertices(GrRenderTarget* rt,
DrawVerticesBatch::Geometry geometry;
geometry.fColor = paint.getColor();
SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveType, viewMatrix,
positions, vertexCount, indices,
indexCount,colors, texCoords));
indexCount, colors, texCoords,
bounds));
// TODO figure out bounds
target->drawBatch(&pipelineBuilder, batch, &bounds);
target->drawBatch(&pipelineBuilder, batch);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -217,12 +217,12 @@ public:
GrColor fColor;
SkPath fPath;
SkScalar fTolerance;
SkDEBUGCODE(SkRect fDevBounds;)
};
static GrBatch* Create(const Geometry& geometry, uint8_t coverage, const SkMatrix& viewMatrix,
bool isHairline) {
return SkNEW_ARGS(DefaultPathBatch, (geometry, coverage, viewMatrix, isHairline));
bool isHairline, const SkRect& devBounds) {
return SkNEW_ARGS(DefaultPathBatch, (geometry, coverage, viewMatrix, isHairline,
devBounds));
}
const char* name() const override { return "DefaultPathBatch"; }
@ -393,12 +393,14 @@ public:
private:
DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix& viewMatrix,
bool isHairline) {
bool isHairline, const SkRect& devBounds) {
this->initClassID<DefaultPathBatch>();
fBatch.fCoverage = coverage;
fBatch.fIsHairline = isHairline;
fBatch.fViewMatrix = viewMatrix;
fGeoData.push_back(geometry);
this->setBounds(devBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -421,6 +423,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -704,12 +707,11 @@ bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
geometry.fColor = color;
geometry.fPath = path;
geometry.fTolerance = srcSpaceTol;
SkDEBUGCODE(geometry.fDevBounds = devBounds;)
SkAutoTUnref<GrBatch> batch(DefaultPathBatch::Create(geometry, newCoverage, viewMatrix,
isHairline));
isHairline, devBounds));
target->drawBatch(pipelineBuilder, batch, &devBounds);
target->drawBatch(pipelineBuilder, batch);
}
}
return true;

View File

@ -163,8 +163,7 @@ void GrDrawTarget::flush() {
}
void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
GrBatch* batch,
const SkRect* devBounds) {
GrBatch* batch) {
SkASSERT(pipelineBuilder);
// TODO some kind of checkdraw, but not at this level
@ -172,11 +171,17 @@ void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
GrScissorState scissorState;
GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
GrPipelineBuilder::AutoRestoreStencil ars;
if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBounds)) {
if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, &batch->bounds())) {
return;
}
GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batch, devBounds, this);
// Batch bounds are tight, so for dev copies
// TODO move this into setupDstReadIfNecessary when paths are in batch
SkRect bounds = batch->bounds();
bounds.outset(0.5f, 0.5f);
GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batch, &bounds,
this);
if (pipelineInfo.mustSkipDraw()) {
return;
}

View File

@ -68,8 +68,7 @@ public:
*/
const GrDrawTargetCaps* caps() const { return fCaps.get(); }
// TODO devbounds should live on the batch
void drawBatch(GrPipelineBuilder*, GrBatch*, const SkRect* devBounds = NULL);
void drawBatch(GrPipelineBuilder*, GrBatch*);
/**
* Draws path into the stencil buffer. The fill must be either even/odd or

View File

@ -212,6 +212,9 @@ private:
RectBatch(const Geometry& geometry) {
this->initClassID<RectBatch>();
fGeoData.push_back(geometry);
fBounds = geometry.fRect;
geometry.fViewMatrix.mapRect(&fBounds);
}
GrColor color() const { return fBatch.fColor; }
@ -248,6 +251,7 @@ private:
fBatch.fColor = GrColor_ILLEGAL;
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -291,10 +295,7 @@ void GrInOrderDrawBuffer::onDrawRect(GrPipelineBuilder* pipelineBuilder,
}
SkAutoTUnref<GrBatch> batch(RectBatch::Create(geometry));
SkRect bounds = rect;
viewMatrix.mapRect(&bounds);
this->drawBatch(pipelineBuilder, batch, &bounds);
this->drawBatch(pipelineBuilder, batch);
}
void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,

View File

@ -836,6 +836,8 @@ private:
CircleBatch(const Geometry& geometry) {
this->initClassID<CircleBatch>();
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -856,6 +858,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -942,7 +945,7 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
SkRect bounds;
SkAutoTUnref<GrBatch> batch(create_circle_batch(color, viewMatrix, useCoverageAA, circle,
stroke, &bounds));
target->drawBatch(pipelineBuilder, batch, &bounds);
target->drawBatch(pipelineBuilder, batch);
}
///////////////////////////////////////////////////////////////////////////////
@ -1103,6 +1106,8 @@ private:
EllipseBatch(const Geometry& geometry) {
this->initClassID<EllipseBatch>();
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -1123,6 +1128,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -1250,7 +1256,7 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
return false;
}
target->drawBatch(pipelineBuilder, batch, &bounds);
target->drawBatch(pipelineBuilder, batch);
return true;
}
@ -1271,8 +1277,8 @@ public:
SkRect fBounds;
};
static GrBatch* Create(const Geometry& geometry) {
return SkNEW_ARGS(DIEllipseBatch, (geometry));
static GrBatch* Create(const Geometry& geometry, const SkRect& bounds) {
return SkNEW_ARGS(DIEllipseBatch, (geometry, bounds));
}
const char* name() const override { return "DIEllipseBatch"; }
@ -1402,9 +1408,11 @@ public:
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
private:
DIEllipseBatch(const Geometry& geometry) {
DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) {
this->initClassID<DIEllipseBatch>();
fGeoData.push_back(geometry);
this->setBounds(bounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -1425,6 +1433,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -1525,7 +1534,7 @@ static GrBatch* create_diellipse_batch(GrColor color,
geometry.fBounds = *bounds;
viewMatrix.mapRect(bounds);
return DIEllipseBatch::Create(geometry);
return DIEllipseBatch::Create(geometry, *bounds);
}
bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
@ -1541,7 +1550,7 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
if (!batch) {
return false;
}
target->drawBatch(pipelineBuilder, batch, &bounds);
target->drawBatch(pipelineBuilder, batch);
return true;
}
@ -1803,6 +1812,8 @@ private:
: fIndexBuffer(indexBuffer) {
this->initClassID<RRectCircleRendererBatch>();
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -1823,6 +1834,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -2022,6 +2034,8 @@ private:
: fIndexBuffer(indexBuffer) {
this->initClassID<RRectEllipseRendererBatch>();
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -2042,6 +2056,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}
@ -2279,7 +2294,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
return false;
}
target->drawBatch(pipelineBuilder, batch, &bounds);
target->drawBatch(pipelineBuilder, batch);
return true;
}

View File

@ -82,13 +82,6 @@ public:
Cmd* recordDrawBatch(GrInOrderDrawBuffer*,
GrBatch*,
const GrDrawTarget::PipelineInfo&);
void recordDrawRect(GrInOrderDrawBuffer*,
GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix);
Cmd* recordStencilPath(GrInOrderDrawBuffer*,
const GrPipelineBuilder&,
const GrPathProcessor*,
@ -120,11 +113,6 @@ public:
const SkIRect& srcRect,
const SkIPoint& dstPoint);
protected:
void willReserveVertexAndIndexSpace(int vertexCount,
size_t vertexStride,
int indexCount);
private:
friend class GrInOrderDrawBuffer;

View File

@ -1485,6 +1485,9 @@ private:
, fViewMatrix(viewMatrix)
, fClipBounds(clipBounds) {
this->initClassID<TessellatingPathBatch>();
fBounds = path.getBounds();
viewMatrix.mapRect(&fBounds);
}
GrColor fColor;

View File

@ -68,8 +68,10 @@ public:
}
protected:
GrTestBatch(const GrGeometryProcessor* gp) {
GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) {
fGeometryProcessor.reset(SkRef(gp));
this->setBounds(bounds);
}
const GrGeometryProcessor* geometryProcessor() const { return fGeometryProcessor; }

View File

@ -256,7 +256,6 @@ public:
SkScalar fIntervals[2];
SkScalar fParallelScale;
SkScalar fPerpendicularScale;
SkDEBUGCODE(SkRect fDevBounds;)
};
static GrBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode,
@ -367,9 +366,6 @@ public:
SkScalar startAdj = 0;
SkMatrix& combinedMatrix = args.fSrcRotInv;
combinedMatrix.postConcat(args.fViewMatrix);
bool lineDone = false;
// Too simplify the algorithm, we always push back rects for start and end rect.
@ -646,6 +642,17 @@ private:
fBatch.fAAMode = aaMode;
fBatch.fCap = cap;
fBatch.fFullDash = fullDash;
// compute bounds
SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth;
SkScalar xBloat = SkPaint::kButt_Cap == cap ? 0 : halfStrokeWidth;
fBounds.set(geometry.fPtsRot[0], geometry.fPtsRot[1]);
fBounds.outset(xBloat, halfStrokeWidth);
// Note, we actually create the combined matrix here, and save the work
SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv;
combinedMatrix.postConcat(geometry.fViewMatrix);
combinedMatrix.mapRect(&fBounds);
}
bool onCombineIfPossible(GrBatch* t) override {
@ -674,6 +681,7 @@ private:
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
this->joinBounds(that->bounds());
return true;
}