| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 fAppliedPE.asPath(&b); | 256 fAppliedPE.asPath(&b); |
| 257 REPORTER_ASSERT(reporter, a == b); | 257 REPORTER_ASSERT(reporter, a == b); |
| 258 if (expectations.fStrokeApplies) { | 258 if (expectations.fStrokeApplies) { |
| 259 REPORTER_ASSERT(reporter, fBaseKey != fAppliedFullKey); | 259 REPORTER_ASSERT(reporter, fBaseKey != fAppliedFullKey); |
| 260 } else { | 260 } else { |
| 261 REPORTER_ASSERT(reporter, fBaseKey == fAppliedFullKey); | 261 REPORTER_ASSERT(reporter, fBaseKey == fAppliedFullKey); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 void check_equivalence(skiatest::Reporter* r, const GrShape& a, const GrShape& b
, | 266 static bool can_interchange_winding_and_even_odd_fill(const GrShape& shape) { |
| 267 const Key& keyA, const Key& keyB) { | 267 SkPath path; |
| 268 shape.asPath(&path); |
| 269 if (shape.style().hasNonDashPathEffect()) { |
| 270 return false; |
| 271 } |
| 272 const SkStrokeRec::Style strokeRecStyle = shape.style().strokeRec().getStyle
(); |
| 273 return strokeRecStyle == SkStrokeRec::kStroke_Style || |
| 274 strokeRecStyle == SkStrokeRec::kHairline_Style || |
| 275 (shape.style().isSimpleFill() && path.isConvex()); |
| 276 } |
| 277 |
| 278 static void check_equivalence(skiatest::Reporter* r, const GrShape& a, const GrS
hape& b, |
| 279 const Key& keyA, const Key& keyB) { |
| 268 // GrShape only respects the input winding direction and start point for rre
ct shapes | 280 // GrShape only respects the input winding direction and start point for rre
ct shapes |
| 269 // when there is a path effect. Thus, if there are two GrShapes representing
the same rrect | 281 // when there is a path effect. Thus, if there are two GrShapes representing
the same rrect |
| 270 // but one has a path effect in its style and the other doesn't then asPath(
) and the unstyled | 282 // but one has a path effect in its style and the other doesn't then asPath(
) and the unstyled |
| 271 // key will differ. GrShape will have canonicalized the direction and start
point for the shape | 283 // key will differ. GrShape will have canonicalized the direction and start
point for the shape |
| 272 // without the path effect. If *both* have path effects then they should hav
e both preserved | 284 // without the path effect. If *both* have path effects then they should hav
e both preserved |
| 273 // the direction and starting point. | 285 // the direction and starting point. |
| 274 | 286 |
| 275 // The asRRect() output params are all initialized just to silence compiler
warnings about | 287 // The asRRect() output params are all initialized just to silence compiler
warnings about |
| 276 // uninitialized variables. | 288 // uninitialized variables. |
| 277 SkRRect rrectA = SkRRect::MakeEmpty(), rrectB = SkRRect::MakeEmpty(); | 289 SkRRect rrectA = SkRRect::MakeEmpty(), rrectB = SkRRect::MakeEmpty(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 295 if (pathA.isInverseFillType() != pathB.isInverseFillType()) { | 307 if (pathA.isInverseFillType() != pathB.isInverseFillType()) { |
| 296 const GrShape* s1 = pathA.isInverseFillType() ? &a : &b; | 308 const GrShape* s1 = pathA.isInverseFillType() ? &a : &b; |
| 297 const GrShape* s2 = pathA.isInverseFillType() ? &b : &a; | 309 const GrShape* s2 = pathA.isInverseFillType() ? &b : &a; |
| 298 bool canDropInverse1 = s1->style().isDashed(); | 310 bool canDropInverse1 = s1->style().isDashed(); |
| 299 bool canDropInverse2 = s2->style().isDashed(); | 311 bool canDropInverse2 = s2->style().isDashed(); |
| 300 ignoreInversenessDifference = (canDropInverse1 != canDropInverse2); | 312 ignoreInversenessDifference = (canDropInverse1 != canDropInverse2); |
| 301 } | 313 } |
| 302 bool ignoreWindingVsEvenOdd = false; | 314 bool ignoreWindingVsEvenOdd = false; |
| 303 if (SkPath::ConvertToNonInverseFillType(pathA.getFillType()) != | 315 if (SkPath::ConvertToNonInverseFillType(pathA.getFillType()) != |
| 304 SkPath::ConvertToNonInverseFillType(pathB.getFillType())) { | 316 SkPath::ConvertToNonInverseFillType(pathB.getFillType())) { |
| 305 const SkStrokeRec::Style strokeRecStyleA = a.style().strokeRec().getSty
le(); | 317 bool aCanChange = can_interchange_winding_and_even_odd_fill(a); |
| 306 const SkStrokeRec::Style strokeRecStyleB = b.style().strokeRec().getSty
le(); | 318 bool bCanChange = can_interchange_winding_and_even_odd_fill(b); |
| 307 bool aCanChange = !a.style().hasNonDashPathEffect() && | |
| 308 (strokeRecStyleA == SkStrokeRec::kStroke_Style || | |
| 309 strokeRecStyleA == SkStrokeRec::kHairline_Style || | |
| 310 (a.style().isSimpleFill() && pathA.isConvex())); | |
| 311 bool bCanChange = !b.style().hasNonDashPathEffect() && | |
| 312 (strokeRecStyleB == SkStrokeRec::kStroke_Style || | |
| 313 strokeRecStyleB == SkStrokeRec::kHairline_Style || | |
| 314 (b.style().isSimpleFill() && pathB.isConvex())); | |
| 315 if (aCanChange != bCanChange) { | 319 if (aCanChange != bCanChange) { |
| 316 ignoreWindingVsEvenOdd = true; | 320 ignoreWindingVsEvenOdd = true; |
| 317 } | 321 } |
| 318 } | 322 } |
| 319 if (allowSameRRectButDiffStartAndDir) { | 323 if (allowSameRRectButDiffStartAndDir) { |
| 320 REPORTER_ASSERT(r, rrectA == rrectB); | 324 REPORTER_ASSERT(r, rrectA == rrectB); |
| 321 REPORTER_ASSERT(r, paths_fill_same(pathA, pathB)); | 325 REPORTER_ASSERT(r, paths_fill_same(pathA, pathB)); |
| 322 REPORTER_ASSERT(r, ignoreInversenessDifference || invertedA == invertedB
); | 326 REPORTER_ASSERT(r, ignoreInversenessDifference || invertedA == invertedB
); |
| 323 } else { | 327 } else { |
| 324 SkPath pA = pathA; | 328 SkPath pA = pathA; |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape()
.asLine(nullptr)); | 1499 REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape()
.asLine(nullptr)); |
| 1496 } | 1500 } |
| 1497 | 1501 |
| 1498 // Test a volatile empty path. | 1502 // Test a volatile empty path. |
| 1499 test_volatile_path(reporter, SkPath(), true); | 1503 test_volatile_path(reporter, SkPath(), true); |
| 1500 | 1504 |
| 1501 test_empty_shape(reporter); | 1505 test_empty_shape(reporter); |
| 1502 } | 1506 } |
| 1503 | 1507 |
| 1504 #endif | 1508 #endif |
| OLD | NEW |