diff options
author | 2015-11-30 12:30:13 -0800 | |
---|---|---|
committer | 2015-11-30 12:30:13 -0800 | |
commit | 144c3c8b7ff3ebc389b41211f3388fb24a7ff0c2 (patch) | |
tree | 9339d400b3d47a8d0307f19419e3dacd62a6cf12 /src/gpu/batches/GrAAConvexPathRenderer.cpp | |
parent | 0cf5ecb67a2af5ec3ea20c5a189ff165ccb678c9 (diff) |
Make onPrepareDraws const
BUG=skia:
Review URL: https://codereview.chromium.org/1483103003
Diffstat (limited to 'src/gpu/batches/GrAAConvexPathRenderer.cpp')
-rw-r--r-- | src/gpu/batches/GrAAConvexPathRenderer.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp index 79296e3c3e..c5b7c579b7 100644 --- a/src/gpu/batches/GrAAConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp @@ -778,7 +778,7 @@ private: fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage(); } - void prepareLinesOnlyDraws(Target* target) { + void prepareLinesOnlyDraws(Target* target) const { bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); // Setup GrGeometryProcessor @@ -806,7 +806,7 @@ private: for (int i = 0; i < instanceCount; i++) { tess.rewind(); - Geometry& args = fGeoData[i]; + const Geometry& args = fGeoData[i]; if (!tess.tessellate(args.fViewMatrix, args.fPath)) { continue; @@ -842,7 +842,7 @@ private: } } - void onPrepareDraws(Target* target) override { + void onPrepareDraws(Target* target) const override { #ifndef SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS if (this->linesOnly()) { this->prepareLinesOnlyDraws(target); @@ -866,15 +866,22 @@ private: // TODO generate all segments for all paths and use one vertex buffer for (int i = 0; i < instanceCount; i++) { - Geometry& args = fGeoData[i]; + const Geometry& args = fGeoData[i]; // 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. const SkMatrix* viewMatrix = &args.fViewMatrix; + + // We avoid initializing the path unless we have to + const SkPath* pathPtr = &args.fPath; + SkTLazy<SkPath> tmpPath; if (viewMatrix->hasPerspective()) { - args.fPath.transform(*viewMatrix); + SkPath* tmpPathPtr = tmpPath.init(*pathPtr); + tmpPathPtr->setIsVolatile(true); + tmpPathPtr->transform(*viewMatrix); viewMatrix = &SkMatrix::I(); + pathPtr = tmpPathPtr; } int vertexCount; @@ -886,7 +893,7 @@ private: SkSTArray<kPreallocSegmentCnt, Segment, true> segments; SkPoint fanPt; - if (!get_segments(args.fPath, *viewMatrix, &segments, &fanPt, &vertexCount, + if (!get_segments(*pathPtr, *viewMatrix, &segments, &fanPt, &vertexCount, &indexCount)) { continue; } |