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

Side by Side Diff: src/gpu/batches/GrStencilAndCoverPathRenderer.cpp

Issue 2342873002: Fix key computation for GrPaths (Closed)
Patch Set: test multiple styles Created 4 years, 3 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrStencilAndCoverPathRenderer.h" 9 #include "GrStencilAndCoverPathRenderer.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (args.fHasUserStencilSettings) { 44 if (args.fHasUserStencilSettings) {
45 return false; 45 return false;
46 } 46 }
47 if (args.fAntiAlias) { 47 if (args.fAntiAlias) {
48 return args.fIsStencilBufferMSAA; 48 return args.fIsStencilBufferMSAA;
49 } else { 49 } else {
50 return true; // doesn't do per-path AA, relies on the target having MSAA 50 return true; // doesn't do per-path AA, relies on the target having MSAA
51 } 51 }
52 } 52 }
53 53
54 static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const SkPath& s kPath, 54 static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape& shape) {
55 const GrStyle& style) {
56 GrUniqueKey key; 55 GrUniqueKey key;
57 bool isVolatile; 56 bool isVolatile;
58 GrPath::ComputeKey(skPath, style, &key, &isVolatile); 57 GrPath::ComputeKey(shape, &key, &isVolatile);
59 SkAutoTUnref<GrPath> path( 58 SkAutoTUnref<GrPath> path(
60 static_cast<GrPath*>(resourceProvider->findAndRefResourceByUniqueKey(key ))); 59 static_cast<GrPath*>(resourceProvider->findAndRefResourceByUniqueKey(key )));
61 if (!path) { 60 if (!path) {
62 path.reset(resourceProvider->createPath(skPath, style)); 61 SkPath skPath;
62 shape.asPath(&skPath);
63 path.reset(resourceProvider->createPath(skPath, shape.style()));
63 if (!isVolatile) { 64 if (!isVolatile) {
64 resourceProvider->assignUniqueKeyToResource(key, path); 65 resourceProvider->assignUniqueKeyToResource(key, path);
65 } 66 }
66 } else { 67 } else {
67 SkASSERT(path->isEqualTo(skPath, style)); 68 #ifdef SK_DEBUG
69 SkPath skPath;
70 shape.asPath(&skPath);
71 SkASSERT(path->isEqualTo(skPath, shape.style()));
72 #endif
68 } 73 }
69 return path.release(); 74 return path.release();
70 } 75 }
71 76
72 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { 77 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
73 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 78 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
74 "GrStencilAndCoverPathRenderer::onStencilPath"); 79 "GrStencilAndCoverPathRenderer::onStencilPath");
75 SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled()); 80 SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled());
76 SkPath path;
77 args.fShape->asPath(&path);
78 81
79 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, GrStyle::SimpleF ill())); 82 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
80 args.fDrawContext->drawContextPriv().stencilPath(*args.fClip, args.fIsAA, *a rgs.fViewMatrix, p); 83 args.fDrawContext->drawContextPriv().stencilPath(*args.fClip, args.fIsAA, *a rgs.fViewMatrix, p);
81 } 84 }
82 85
83 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { 86 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
84 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 87 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
85 "GrStencilAndCoverPathRenderer::onDrawPath"); 88 "GrStencilAndCoverPathRenderer::onDrawPath");
86 SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMu ltisampled()); 89 SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMu ltisampled());
87 SkASSERT(!args.fShape->style().strokeRec().isHairlineStyle()); 90 SkASSERT(!args.fShape->style().strokeRec().isHairlineStyle());
88 91
89 const SkMatrix& viewMatrix = *args.fViewMatrix; 92 const SkMatrix& viewMatrix = *args.fViewMatrix;
90 93
91 SkPath path; 94 SkPath path;
92 args.fShape->asPath(&path); 95 args.fShape->asPath(&path);
93 96
94 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, args.fShape->sty le())); 97 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
95 98
96 if (path.isInverseFillType()) { 99 if (path.isInverseFillType()) {
97 SkMatrix invert = SkMatrix::I(); 100 SkMatrix invert = SkMatrix::I();
98 SkRect bounds = 101 SkRect bounds =
99 SkRect::MakeLTRB(0, 0, 102 SkRect::MakeLTRB(0, 0,
100 SkIntToScalar(args.fDrawContext->width()), 103 SkIntToScalar(args.fDrawContext->width()),
101 SkIntToScalar(args.fDrawContext->height())); 104 SkIntToScalar(args.fDrawContext->height()));
102 SkMatrix vmi; 105 SkMatrix vmi;
103 // mapRect through persp matrix may not be correct 106 // mapRect through persp matrix may not be correct
104 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { 107 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (args.fAntiAlias) { 165 if (args.fAntiAlias) {
163 SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); 166 SkASSERT(args.fDrawContext->isStencilBufferMultisampled());
164 pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag); 167 pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag);
165 } 168 }
166 169
167 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); 170 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
168 } 171 }
169 172
170 return true; 173 return true;
171 } 174 }
OLDNEW
« src/gpu/GrPath.cpp ('K') | « src/gpu/GrPath.cpp ('k') | tests/GpuDrawPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698