Add support for non-mappable vert buffers to tessellating path renderer.

Use malloc-ed memory and the updateData() call instead.

BUG=skia:4215

Review URL: https://codereview.chromium.org/1288683004
This commit is contained in:
senorblanco 2015-08-18 11:46:28 -07:00 committed by Commit bot
parent 3011711d5d
commit f39c9b2ccf

View File

@ -1417,7 +1417,8 @@ private:
int tessellate(GrUniqueKey* key, int tessellate(GrUniqueKey* key,
GrResourceProvider* resourceProvider, GrResourceProvider* resourceProvider,
SkAutoTUnref<GrVertexBuffer>& vertexBuffer) { SkAutoTUnref<GrVertexBuffer>& vertexBuffer,
bool canMapVB) {
SkPath path; SkPath path;
GrStrokeInfo stroke(fStroke); GrStrokeInfo stroke(fStroke);
if (stroke.isDashed()) { if (stroke.isDashed()) {
@ -1490,13 +1491,23 @@ private:
SkDebugf("Could not allocate vertices\n"); SkDebugf("Could not allocate vertices\n");
return 0; return 0;
} }
SkPoint* verts = static_cast<SkPoint*>(vertexBuffer->map()); SkPoint* verts;
LOG("emitting %d verts\n", count); if (canMapVB) {
verts = static_cast<SkPoint*>(vertexBuffer->map());
} else {
verts = SkNEW_ARRAY(SkPoint, count);
}
SkPoint* end = polys_to_triangles(polys, fillType, verts); SkPoint* end = polys_to_triangles(polys, fillType, verts);
vertexBuffer->unmap();
int actualCount = static_cast<int>(end - verts); int actualCount = static_cast<int>(end - verts);
LOG("actual count: %d\n", actualCount); LOG("actual count: %d\n", actualCount);
SkASSERT(actualCount <= count); SkASSERT(actualCount <= count);
if (canMapVB) {
vertexBuffer->unmap();
} else {
vertexBuffer->updateData(verts, actualCount * sizeof(SkPoint));
SkDELETE_ARRAY(verts);
}
if (!fPath.isVolatile()) { if (!fPath.isVolatile()) {
TessInfo info; TessInfo info;
@ -1533,7 +1544,8 @@ private:
SkScalar tol = GrPathUtils::scaleToleranceToSrc( SkScalar tol = GrPathUtils::scaleToleranceToSrc(
screenSpaceTol, fViewMatrix, fPath.getBounds()); screenSpaceTol, fViewMatrix, fPath.getBounds());
if (!cache_match(vertexBuffer.get(), tol, &actualCount)) { if (!cache_match(vertexBuffer.get(), tol, &actualCount)) {
actualCount = tessellate(&key, rp, vertexBuffer); bool canMapVB = GrCaps::kNone_MapFlags != target->caps().mapBufferFlags();
actualCount = tessellate(&key, rp, vertexBuffer, canMapVB);
} }
if (actualCount == 0) { if (actualCount == 0) {