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

Side by Side Diff: tests/GpuDrawPathTest.cpp

Issue 2369513002: Don't compute path keys for volatile paths in GrShape. (Closed)
Patch Set: fix test 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/GrShape.cpp ('k') | tests/GrShapeTest.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 2013 Google Inc. 2 * Copyright 2013 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 #include "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 strokePaint.setStrokeWidth(10.f); 97 strokePaint.setStrokeWidth(10.f);
98 GrStyle styles[] = { 98 GrStyle styles[] = {
99 GrStyle::SimpleFill(), 99 GrStyle::SimpleFill(),
100 GrStyle::SimpleHairline(), 100 GrStyle::SimpleHairline(),
101 GrStyle(strokePaint) 101 GrStyle(strokePaint)
102 }; 102 };
103 103
104 for (const GrStyle& style : styles) { 104 for (const GrStyle& style : styles) {
105 // Keys should not ignore conic weights. 105 // Keys should not ignore conic weights.
106 SkPath path1, path2; 106 SkPath path1, path2;
107 path1.setIsVolatile(true);
108 path2.setIsVolatile(true);
109 SkPoint p0 = SkPoint::Make(100, 0); 107 SkPoint p0 = SkPoint::Make(100, 0);
110 SkPoint p1 = SkPoint::Make(100, 100); 108 SkPoint p1 = SkPoint::Make(100, 100);
111 109
112 path1.conicTo(p0, p1, .5f); 110 path1.conicTo(p0, p1, .5f);
113 path2.conicTo(p0, p1, .7f); 111 path2.conicTo(p0, p1, .7f);
114 112
113 GrUniqueKey key1, key2;
114 // We expect these small paths to be keyed based on their data.
115 bool isVolatile; 115 bool isVolatile;
116 GrUniqueKey key1, key2;
117 // Even though the paths are marked volatile, they should have keys base d on the path data
118 // because they have a small amount of data.
119 GrPath::ComputeKey(GrShape(path1, GrStyle::SimpleFill()), &key1, &isVola tile); 116 GrPath::ComputeKey(GrShape(path1, GrStyle::SimpleFill()), &key1, &isVola tile);
120 REPORTER_ASSERT(reporter, !isVolatile); 117 REPORTER_ASSERT(reporter, !isVolatile);
121 REPORTER_ASSERT(reporter, key1.isValid()); 118 REPORTER_ASSERT(reporter, key1.isValid());
122 GrPath::ComputeKey(GrShape(path2, GrStyle::SimpleFill()), &key2, &isVola tile); 119 GrPath::ComputeKey(GrShape(path2, GrStyle::SimpleFill()), &key2, &isVola tile);
123 REPORTER_ASSERT(reporter, !isVolatile); 120 REPORTER_ASSERT(reporter, !isVolatile);
124 REPORTER_ASSERT(reporter, key1.isValid()); 121 REPORTER_ASSERT(reporter, key1.isValid());
125 REPORTER_ASSERT(reporter, key1 != key2); 122 REPORTER_ASSERT(reporter, key1 != key2);
123 {
124 GrUniqueKey tempKey;
125 path1.setIsVolatile(true);
126 GrPath::ComputeKey(GrShape(path1, style), &key1, &isVolatile);
127 REPORTER_ASSERT(reporter, isVolatile);
128 REPORTER_ASSERT(reporter, !tempKey.isValid());
129 }
126 130
127 // Ensure that recreating the GrShape doesn't change the key. 131 // Ensure that recreating the GrShape doesn't change the key.
128 { 132 {
129 GrUniqueKey tempKey; 133 GrUniqueKey tempKey;
130 GrPath::ComputeKey(GrShape(path1, GrStyle::SimpleFill()), &tempKey, &isVolatile); 134 GrPath::ComputeKey(GrShape(path2, GrStyle::SimpleFill()), &tempKey, &isVolatile);
131 REPORTER_ASSERT(reporter, key1 == tempKey); 135 REPORTER_ASSERT(reporter, key2 == tempKey);
132 } 136 }
133 137
134 // Try a large path that is too big to be keyed off its data. 138 // Try a large path that is too big to be keyed off its data.
135 SkPath path3; 139 SkPath path3;
136 SkPath path4; 140 SkPath path4;
137 for (int i = 0; i < 1000; ++i) { 141 for (int i = 0; i < 1000; ++i) {
138 SkScalar s = SkIntToScalar(i); 142 SkScalar s = SkIntToScalar(i);
139 path3.conicTo(s, 3.f * s / 4, s + 1.f, s, 0.5f + s / 2000.f); 143 path3.conicTo(s, 3.f * s / 4, s + 1.f, s, 0.5f + s / 2000.f);
140 path4.conicTo(s, 3.f * s / 4, s + 1.f, s, 0.3f + s / 2000.f); 144 path4.conicTo(s, 3.f * s / 4, s + 1.f, s, 0.3f + s / 2000.f);
141 } 145 }
(...skipping 12 matching lines...) Expand all
154 GrUniqueKey tempKey; 158 GrUniqueKey tempKey;
155 path3.setIsVolatile(true); 159 path3.setIsVolatile(true);
156 GrPath::ComputeKey(GrShape(path3, style), &key1, &isVolatile); 160 GrPath::ComputeKey(GrShape(path3, style), &key1, &isVolatile);
157 REPORTER_ASSERT(reporter, isVolatile); 161 REPORTER_ASSERT(reporter, isVolatile);
158 REPORTER_ASSERT(reporter, !tempKey.isValid()); 162 REPORTER_ASSERT(reporter, !tempKey.isValid());
159 } 163 }
160 } 164 }
161 } 165 }
162 166
163 #endif 167 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrShape.cpp ('k') | tests/GrShapeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698