Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: src/gpu/batches/GrAAConvexPathRenderer.cpp

Issue 1483103003: Make onPrepareDraws const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/batches/GrAAConvexPathRenderer.cpp
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index aee18b720a6a2ef03825f089ee4236dacd2ab92a..90f2e1df82a5e2f32184a05894e1dd6946771cc7 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -777,7 +777,7 @@ private:
fBatch.fCanTweakAlphaForCoverage = opt.canTweakAlphaForCoverage();
}
- void prepareLinesOnlyDraws(Target* target) {
+ void prepareLinesOnlyDraws(Target* target) const {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
// Setup GrGeometryProcessor
@@ -805,7 +805,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;
@@ -841,7 +841,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);
@@ -865,15 +865,21 @@ 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);
robertphillips 2015/11/30 19:52:40 Should we set the volatile bit on the new path ?
+ tmpPathPtr->transform(*viewMatrix);
viewMatrix = &SkMatrix::I();
+ pathPtr = tmpPathPtr;
}
int vertexCount;
@@ -885,7 +891,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;
}

Powered by Google App Engine
This is Rietveld 408576698