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: tests/GrShapeTest.cpp

Issue 2064113004: Some simplifications of GrShape reductions/canonicalizations (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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') | no next file » | 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 2016 Google Inc. 2 * Copyright 2016 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 <initializer_list> 8 #include <initializer_list>
9 #include <functional> 9 #include <functional>
10 #include "Test.h" 10 #include "Test.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // occurred to fAppliedPE. 196 // occurred to fAppliedPE.
197 GrShape(postPathEffect, GrStyle(postPEStrokeRec, nullptr)).asPath(&p ostPathEffect); 197 GrShape(postPathEffect, GrStyle(postPEStrokeRec, nullptr)).asPath(&p ostPathEffect);
198 198
199 SkPath testPath; 199 SkPath testPath;
200 fAppliedPE.asPath(&testPath); 200 fAppliedPE.asPath(&testPath);
201 REPORTER_ASSERT(r, testPath == postPathEffect); 201 REPORTER_ASSERT(r, testPath == postPathEffect);
202 REPORTER_ASSERT(r, postPEStrokeRec.hasEqualEffect(fAppliedPE.style() .strokeRec())); 202 REPORTER_ASSERT(r, postPEStrokeRec.hasEqualEffect(fAppliedPE.style() .strokeRec()));
203 } 203 }
204 SkStrokeRec::InitStyle fillOrHairline; 204 SkStrokeRec::InitStyle fillOrHairline;
205 if (fBase.style().applyToPath(&postAllStyle, &fillOrHairline, preStyle, scale)) { 205 if (fBase.style().applyToPath(&postAllStyle, &fillOrHairline, preStyle, scale)) {
206 // run postPathEffect through GrShape to get any reductions that wou ld have occurred
207 // to fAppliedFull.
208 GrShape(postAllStyle, GrStyle(fillOrHairline)).asPath(&postAllStyle) ;
209
210 SkPath testPath; 206 SkPath testPath;
211 fAppliedFull.asPath(&testPath); 207 fAppliedFull.asPath(&testPath);
212 REPORTER_ASSERT(r, testPath == postAllStyle); 208 if (fBase.style().hasPathEffect()) {
209 // Because GrShape always does two-stage application when there is a path effect
210 // there may be a reduction/canonicalization step between the pa th effect and
211 // strokerec not reflected in postAllStyle since it applied both the path effect
212 // and strokerec without analyzing the intermediate path.
213 REPORTER_ASSERT(r, paths_fill_same(postAllStyle, testPath));
214 } else {
215 // Make sure that postAllStyle sees any reductions/canonicalizat ions that GrShape
216 // would apply.
217 GrShape(postAllStyle, GrStyle(fillOrHairline)).asPath(&postAllSt yle);
218 REPORTER_ASSERT(r, testPath == postAllStyle);
219 }
220
213 if (fillOrHairline == SkStrokeRec::kFill_InitStyle) { 221 if (fillOrHairline == SkStrokeRec::kFill_InitStyle) {
214 REPORTER_ASSERT(r, fAppliedFull.style().isSimpleFill()); 222 REPORTER_ASSERT(r, fAppliedFull.style().isSimpleFill());
215 } else { 223 } else {
216 REPORTER_ASSERT(r, fAppliedFull.style().isSimpleHairline()); 224 REPORTER_ASSERT(r, fAppliedFull.style().isSimpleHairline());
217 } 225 }
218 } 226 }
219 } 227 }
220 228
221 GrShape fBase; 229 GrShape fBase;
222 GrShape fAppliedPE; 230 GrShape fAppliedPE;
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape() .asLine(nullptr)); 1459 REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape() .asLine(nullptr));
1452 } 1460 }
1453 1461
1454 // Test a volatile empty path. 1462 // Test a volatile empty path.
1455 test_volatile_path(reporter, SkPath(), true); 1463 test_volatile_path(reporter, SkPath(), true);
1456 1464
1457 test_empty_shape(reporter); 1465 test_empty_shape(reporter);
1458 } 1466 }
1459 1467
1460 #endif 1468 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrShape.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698