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
diff --git a/gpu/src/GrTesselatedPathRenderer.cpp b/gpu/src/GrTesselatedPathRenderer.cpp
index 95e8abe..8ed2c22 100644
--- a/gpu/src/GrTesselatedPathRenderer.cpp
+++ b/gpu/src/GrTesselatedPathRenderer.cpp
@@ -205,6 +205,13 @@
 
     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 @@
     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,