Fail path rendering gracefully when vb/ib space alloc fails

Review URL: http://codereview.appspot.com/4839050/



git-svn-id: http://skia.googlecode.com/svn/trunk@2052 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2011-08-05 16:27:32 +00:00
parent 3bbee32664
commit 82866fd5a7

View File

@ -233,6 +233,9 @@ bool GrDefaultPathRenderer::requiresStencilPass(const GrDrawTarget* target,
void GrDefaultPathRenderer::pathWillClear() {
fSubpathVertCount.realloc(0);
fTarget->resetVertexSource();
if (fUseIndexedDraw) {
fTarget->resetIndexSource();
}
fPreviousSrcTol = -GR_Scalar1;
fPreviousStages = -1;
}
@ -268,9 +271,6 @@ bool GrDefaultPathRenderer::createGeom(GrScalar srcSpaceTol,
return false;
}
fPreviousSrcTol = srcSpaceTol;
fPreviousStages = stages;
GrVertexLayout layout = 0;
for (int s = 0; s < GrDrawTarget::kNumStages; ++s) {
if ((1 << s) & stages) {
@ -298,14 +298,21 @@ bool GrDefaultPathRenderer::createGeom(GrScalar srcSpaceTol,
}
GrPoint* base;
fTarget->reserveVertexSpace(layout, maxPts, (void**)&base);
if (!fTarget->reserveVertexSpace(layout, maxPts, (void**)&base)) {
return false;
}
GrAssert(NULL != base);
GrPoint* vert = base;
uint16_t* idxBase = NULL;
uint16_t* idx = NULL;
uint16_t subpathIdxStart = 0;
if (fUseIndexedDraw) {
fTarget->reserveIndexSpace(maxIdxs, (void**)&idxBase);
if (!fTarget->reserveIndexSpace(maxIdxs, (void**)&idxBase)) {
fTarget->resetVertexSource();
return false;
}
GrAssert(NULL != idxBase);
idx = idxBase;
}
@ -393,6 +400,11 @@ FINISHED:
}
}
}
// set these at the end so if we failed on first drawPath inside a
// setPath/clearPath block we won't assume geom was created on a subsequent
// drawPath in the same block.
fPreviousSrcTol = srcSpaceTol;
fPreviousStages = stages;
return true;
}