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
This commit is contained in:
parent
9d18b7873c
commit
cf3edc9c97
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user