diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-05 19:55:43 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-05 19:55:43 +0000 |
commit | c759af3444b6de633752496480e642d1ae8f90ea (patch) | |
tree | 3d622205bfcc15918fa010876f3c3efcbfb35f95 /src/gpu | |
parent | cc46a0ab52de39b66baaf71add92aac34c662f0a (diff) |
Avoid making a copy of the path in GrAAConvexPathRenderer
Review URL: http://codereview.appspot.com/5720074/
git-svn-id: http://skia.googlecode.com/svn/trunk@3321 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrAAConvexPathRenderer.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 7a11316c0e..18965b7ec5 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -202,10 +202,11 @@ void update_degenerate_test(DegenerateTestData* data, const GrPoint& pt) { } bool get_segments(const GrPath& path, - SegmentArray* segments, - SkPoint* fanPt, - int* vCount, - int* iCount) { + const GrMatrix& m, + SegmentArray* segments, + SkPoint* fanPt, + int* vCount, + int* iCount) { SkPath::Iter iter(path, true); // This renderer overemphasises very thin path regions. We use the distance // to the path from the sample to compute coverage. Every pixel intersected @@ -225,6 +226,7 @@ bool get_segments(const GrPath& path, break; case kLine_PathCmd: { update_degenerate_test(°enerateData, pts[1]); + m.mapPoints(pts + 1, 1); segments->push_back(); segments->back().fType = Segment::kLine; segments->back().fPts[0] = pts[1]; @@ -233,6 +235,7 @@ bool get_segments(const GrPath& path, case kQuadratic_PathCmd: update_degenerate_test(°enerateData, pts[1]); update_degenerate_test(°enerateData, pts[2]); + m.mapPoints(pts + 1, 2); segments->push_back(); segments->back().fType = Segment::kQuad; segments->back().fPts[0] = pts[1]; @@ -242,6 +245,9 @@ bool get_segments(const GrPath& path, update_degenerate_test(°enerateData, pts[1]); update_degenerate_test(°enerateData, pts[2]); update_degenerate_test(°enerateData, pts[3]); + // unlike quads and lines, the pts[0] will also be read (in + // convertCubicToQuads). + m.mapPoints(pts, 4); SkSTArray<15, SkPoint, true> quads; GrPathUtils::convertCubicToQuads(pts, SK_Scalar1, &quads); int count = quads.count(); @@ -431,8 +437,8 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, GrDrawState::StageMask stageMask, bool antiAlias) { - - if (origPath.isEmpty()) { + const SkPath* path = &origPath; + if (path->isEmpty()) { return true; } GrDrawState* drawState = target->drawState(); @@ -449,9 +455,6 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, } drawState->setViewMatrix(GrMatrix::I()); - SkPath path; - origPath.transform(vm, &path); - GrVertexLayout layout = 0; for (int s = 0; s < GrDrawState::kNumStages; ++s) { if ((1 << s) & stageMask) { @@ -460,6 +463,16 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, } layout |= GrDrawTarget::kEdge_VertexLayoutBit; + // We use the fact that SkPath::transform path does subdivision based on + // perspective. Otherwise, we apply the view matrix when copying to the + // segment representation. + SkPath tmpPath; + if (vm.hasPerspective()) { + origPath.transform(vm, &tmpPath); + path = &tmpPath; + vm.reset(); + } + QuadVertex *verts; uint16_t* idxs; @@ -470,7 +483,8 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, }; SkSTArray<kPreallocSegmentCnt, Segment, true> segments; SkPoint fanPt; - if (!get_segments(path, &segments, &fanPt, &vCount, &iCount)) { + + if (!get_segments(*path, vm, &segments, &fanPt, &vCount, &iCount)) { return false; } |