From cf3edc9c972ce1696d1fe21dcddbabbca2999361 Mon Sep 17 00:00:00 2001 From: "senorblanco@chromium.org" Date: Tue, 29 Mar 2011 17:42:30 +0000 Subject: Two optimizations for the tesselated path renderer: 1) If the path contains a single convex subpath, and we're not using inverted fill modes, skip the tesselation and draw the interpolated path as a triangle fan directly. 2) Use GrDrawTarget.set*SourceToArray(), rather than creating a new AutoReleaseGeometry, saving a copy of the vertex and index data. Review URL: http://codereview.appspot.com/4280076/ git-svn-id: http://skia.googlecode.com/svn/trunk@1014 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gpu/src/GrTesselatedPathRenderer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'gpu/src') diff --git a/gpu/src/GrTesselatedPathRenderer.cpp b/gpu/src/GrTesselatedPathRenderer.cpp index 95e8abe4ed..8ed2c2249e 100644 --- a/gpu/src/GrTesselatedPathRenderer.cpp +++ b/gpu/src/GrTesselatedPathRenderer.cpp @@ -205,6 +205,13 @@ FINISHED: size_t count = vert - base; + if (subpathCnt == 1 && !inverted && path->convexHint() == kConvex_ConvexHint) { + target->setVertexSourceToArray(layout, base, count); + target->drawNonIndexed(kTriangleFan_PrimitiveType, 0, count); + delete[] base; + return; + } + // FIXME: This copy could be removed if we had (templated?) versions of // generate_*_point above that wrote directly into doubles. double* inVertices = new double[count * 3]; @@ -243,15 +250,9 @@ FINISHED: internal_gluTessEndPolygon(tess); internal_gluDeleteTess(tess); - // FIXME: If we could figure out the maxIndices before running the - // tesselator, we could allocate the geometry upfront, rather than making - // yet another copy. - GrDrawTarget::AutoReleaseGeometry geom(target, layout, vertices.count(), indices.count()); - - memcpy(geom.vertices(), vertices.begin(), vertices.count() * sizeof(GrPoint)); - memcpy(geom.indices(), indices.begin(), indices.count() * sizeof(short)); - if (indices.count() > 0) { + target->setVertexSourceToArray(layout, vertices.begin(), vertices.count()); + target->setIndexSourceToArray(indices.begin(), indices.count()); target->drawIndexed(kTriangles_PrimitiveType, 0, 0, -- cgit v1.2.3