aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/batches/GrAAConvexPathRenderer.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-11-30 12:30:13 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-30 12:30:13 -0800
commit144c3c8b7ff3ebc389b41211f3388fb24a7ff0c2 (patch)
tree9339d400b3d47a8d0307f19419e3dacd62a6cf12 /src/gpu/batches/GrAAConvexPathRenderer.cpp
parent0cf5ecb67a2af5ec3ea20c5a189ff165ccb678c9 (diff)
Make onPrepareDraws const
Diffstat (limited to 'src/gpu/batches/GrAAConvexPathRenderer.cpp')
-rw-r--r--src/gpu/batches/GrAAConvexPathRenderer.cpp19
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;
}