aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/src
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-29 17:42:30 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-29 17:42:30 +0000
commitcf3edc9c972ce1696d1fe21dcddbabbca2999361 (patch)
treed2fb2abc733ad3b840aad0aed49e82d2af31658a /gpu/src
parent9d18b7873ce9b44f130a41e0cbd0a3df76ab9adf (diff)
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
Diffstat (limited to 'gpu/src')
-rw-r--r--gpu/src/GrTesselatedPathRenderer.cpp17
1 files changed, 9 insertions, 8 deletions
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,