aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-08-18 11:46:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-18 11:46:28 -0700
commitf39c9b2ccfc47338dda86aa897219e53574eea9f (patch)
tree56ebfc7ea537efca905a101db55d6c83949a201b /src/gpu
parent3011711d5d8d1b88ee2b5aaef230ebdc949fcaa5 (diff)
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
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrTessellatingPathRenderer.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp
index 6a70a90283..9fe5278b42 100644
--- a/src/gpu/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/GrTessellatingPathRenderer.cpp
@@ -1417,7 +1417,8 @@ private:
int tessellate(GrUniqueKey* key,
GrResourceProvider* resourceProvider,
- SkAutoTUnref<GrVertexBuffer>& vertexBuffer) {
+ SkAutoTUnref<GrVertexBuffer>& vertexBuffer,
+ bool canMapVB) {
SkPath path;
GrStrokeInfo stroke(fStroke);
if (stroke.isDashed()) {
@@ -1490,13 +1491,23 @@ private:
SkDebugf("Could not allocate vertices\n");
return 0;
}
- SkPoint* verts = static_cast<SkPoint*>(vertexBuffer->map());
- LOG("emitting %d verts\n", count);
+ SkPoint* verts;
+ if (canMapVB) {
+ verts = static_cast<SkPoint*>(vertexBuffer->map());
+ } else {
+ verts = SkNEW_ARRAY(SkPoint, count);
+ }
SkPoint* end = polys_to_triangles(polys, fillType, verts);
- vertexBuffer->unmap();
int actualCount = static_cast<int>(end - verts);
LOG("actual count: %d\n", actualCount);
SkASSERT(actualCount <= count);
+ if (canMapVB) {
+ vertexBuffer->unmap();
+ } else {
+ vertexBuffer->updateData(verts, actualCount * sizeof(SkPoint));
+ SkDELETE_ARRAY(verts);
+ }
+
if (!fPath.isVolatile()) {
TessInfo info;
@@ -1533,7 +1544,8 @@ private:
SkScalar tol = GrPathUtils::scaleToleranceToSrc(
screenSpaceTol, fViewMatrix, fPath.getBounds());
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) {