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

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

Issue 2342873002: Fix key computation for GrPaths (Closed)
Patch Set: more MSVS warnings 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
« no previous file with comments | « src/gpu/GrPath.cpp ('k') | tests/GpuDrawPathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 sk_sp<GrPath> path;
60 static_cast<GrPath*>(resourceProvider->findAndRefResourceByUniqueKey(key ))); 59 if (!isVolatile) {
60 path.reset(
61 static_cast<GrPath*>(resourceProvider->findAndRefResourceByUniqueKey (key)));
62 }
61 if (!path) { 63 if (!path) {
62 path.reset(resourceProvider->createPath(skPath, style)); 64 SkPath skPath;
65 shape.asPath(&skPath);
66 path.reset(resourceProvider->createPath(skPath, shape.style()));
63 if (!isVolatile) { 67 if (!isVolatile) {
64 resourceProvider->assignUniqueKeyToResource(key, path); 68 resourceProvider->assignUniqueKeyToResource(key, path.get());
65 } 69 }
66 } else { 70 } else {
67 SkASSERT(path->isEqualTo(skPath, style)); 71 #ifdef SK_DEBUG
72 SkPath skPath;
73 shape.asPath(&skPath);
74 SkASSERT(path->isEqualTo(skPath, shape.style()));
75 #endif
68 } 76 }
69 return path.release(); 77 return path.release();
70 } 78 }
71 79
72 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { 80 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
73 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 81 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
74 "GrStencilAndCoverPathRenderer::onStencilPath"); 82 "GrStencilAndCoverPathRenderer::onStencilPath");
75 SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled()); 83 SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled());
76 SkPath path;
77 args.fShape->asPath(&path);
78 84
79 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, GrStyle::SimpleF ill())); 85 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
80 args.fDrawContext->drawContextPriv().stencilPath(*args.fClip, args.fIsAA, *a rgs.fViewMatrix, p); 86 args.fDrawContext->drawContextPriv().stencilPath(*args.fClip, args.fIsAA, *a rgs.fViewMatrix, p);
81 } 87 }
82 88
83 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { 89 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
84 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 90 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
85 "GrStencilAndCoverPathRenderer::onDrawPath"); 91 "GrStencilAndCoverPathRenderer::onDrawPath");
86 SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMu ltisampled()); 92 SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMu ltisampled());
87 SkASSERT(!args.fShape->style().strokeRec().isHairlineStyle()); 93 SkASSERT(!args.fShape->style().strokeRec().isHairlineStyle());
88 94
89 const SkMatrix& viewMatrix = *args.fViewMatrix; 95 const SkMatrix& viewMatrix = *args.fViewMatrix;
90 96
91 SkPath path; 97 SkPath path;
92 args.fShape->asPath(&path); 98 args.fShape->asPath(&path);
93 99
94 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, args.fShape->sty le())); 100 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
95 101
96 if (path.isInverseFillType()) { 102 if (path.isInverseFillType()) {
97 SkMatrix invert = SkMatrix::I(); 103 SkMatrix invert = SkMatrix::I();
98 SkRect bounds = 104 SkRect bounds =
99 SkRect::MakeLTRB(0, 0, 105 SkRect::MakeLTRB(0, 0,
100 SkIntToScalar(args.fDrawContext->width()), 106 SkIntToScalar(args.fDrawContext->width()),
101 SkIntToScalar(args.fDrawContext->height())); 107 SkIntToScalar(args.fDrawContext->height()));
102 SkMatrix vmi; 108 SkMatrix vmi;
103 // mapRect through persp matrix may not be correct 109 // mapRect through persp matrix may not be correct
104 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { 110 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (args.fAntiAlias) { 168 if (args.fAntiAlias) {
163 SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); 169 SkASSERT(args.fDrawContext->isStencilBufferMultisampled());
164 pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag); 170 pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag);
165 } 171 }
166 172
167 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); 173 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
168 } 174 }
169 175
170 return true; 176 return true;
171 } 177 }
OLDNEW
« no previous file with comments | « src/gpu/GrPath.cpp ('k') | tests/GpuDrawPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698