aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-14 18:42:34 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-14 18:42:34 +0000
commitf0c41e24d5322022c7678b60837274c1340fc109 (patch)
treeb58ee5102bf7d71728c3f8fe761a1e29ec33debc /src/gpu/GrContext.cpp
parent46de153d4e887d82b5309316ed2e26e5cdc291f0 (diff)
Initialize written paths and strokerecs lazily during GPU drawPath
Initialize SkPaths and SkStrokeRecs lazily during GPU drawPath calls. The constructors seem to appear in some profiler results on ARM (~1%). R=bsalomon@google.com, robertphillips@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/118143002 git-svn-id: http://skia.googlecode.com/svn/trunk@13069 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r--src/gpu/GrContext.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 127d9ec97b..bb0f4fa9fa 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1134,7 +1134,7 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok
}
void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path,
- const SkStrokeRec& stroke) {
+ const SkStrokeRec& origStroke) {
SkASSERT(!path.isEmpty());
// An Assumption here is that path renderer would use some form of tweaking
@@ -1151,18 +1151,18 @@ void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
GrPathRendererChain::kColor_DrawType;
const SkPath* pathPtr = &path;
- SkPath tmpPath;
- SkStrokeRec strokeRec(stroke);
+ SkTLazy<SkPath> tmpPath;
+ SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke);
// Try a 1st time without stroking the path and without allowing the SW renderer
- GrPathRenderer* pr = this->getPathRenderer(*pathPtr, strokeRec, target, false, type);
+ GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false, type);
if (NULL == pr) {
- if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(strokeRec, this->getMatrix(), NULL)) {
+ if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatrix(), NULL)) {
// It didn't work the 1st time, so try again with the stroked path
- if (strokeRec.applyToPath(&tmpPath, *pathPtr)) {
- pathPtr = &tmpPath;
- strokeRec.setFillStyle();
+ if (stroke->applyToPath(tmpPath.init(), *pathPtr)) {
+ pathPtr = tmpPath.get();
+ stroke.writable()->setFillStyle();
if (pathPtr->isEmpty()) {
return;
}
@@ -1170,7 +1170,7 @@ void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
}
// This time, allow SW renderer
- pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type);
+ pr = this->getPathRenderer(*pathPtr, *stroke, target, true, type);
}
if (NULL == pr) {
@@ -1180,7 +1180,7 @@ void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
return;
}
- pr->drawPath(*pathPtr, strokeRec, target, useCoverageAA);
+ pr->drawPath(*pathPtr, *stroke, target, useCoverageAA);
}
////////////////////////////////////////////////////////////////////////////////