Chromium Code Reviews| 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 "GrShape.h" | 8 #include "GrShape.h" |
| 9 | 9 |
| 10 GrShape& GrShape::operator=(const GrShape& that) { | 10 GrShape& GrShape::operator=(const GrShape& that) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 } | 325 } |
| 326 if (this->style().isSimpleFill()) { | 326 if (this->style().isSimpleFill()) { |
| 327 // Filled paths are treated as though all their contours were closed . | 327 // Filled paths are treated as though all their contours were closed . |
| 328 // Since SkPath doesn't track individual contours, this will only cl ose the last. :( | 328 // Since SkPath doesn't track individual contours, this will only cl ose the last. :( |
| 329 // There is no point in closing lines, though, since they loose thei r line-ness. | 329 // There is no point in closing lines, though, since they loose thei r line-ness. |
| 330 if (!fPath.get()->isLine(nullptr)) { | 330 if (!fPath.get()->isLine(nullptr)) { |
| 331 fPath.get()->close(); | 331 fPath.get()->close(); |
| 332 fPath.get()->setIsVolatile(true); | 332 fPath.get()->setIsVolatile(true); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 if (fPath.get()->isConvex()) { | 335 if (!this->style().hasNonDashPathEffect()) { |
| 336 // There is no distinction between even/odd and non-zero winding cou nt for convex | 336 if (this->style().strokeRec().getStyle() == SkStrokeRec::kStroke_Sty le || |
| 337 // paths. | 337 this->style().strokeRec().getStyle() == SkStrokeRec::kHairline_S tyle) { |
| 338 if (fPath.get()->isInverseFillType()) { | 338 // Stroke styles don't differentiate between winding and even/od d. |
| 339 fPath.get()->setFillType(SkPath::kInverseEvenOdd_FillType); | 339 // Moreover, dashing ignores inverseness (skbug.com/5421) |
|
robertphillips
2016/06/23 18:47:54
why fStyle here and not style() ?
| |
| 340 } else { | 340 bool inverse = !this->fStyle.isDashed() && fPath.get()->isInvers eFillType(); |
| 341 fPath.get()->setFillType(SkPath::kEvenOdd_FillType); | 341 if (inverse) { |
| 342 } | 342 fPath.get()->setFillType(kDefaultPathInverseFillType); |
| 343 } | 343 } else { |
| 344 if (this->style().isDashed()) { | 344 fPath.get()->setFillType(kDefaultPathFillType); |
| 345 // Dashing ignores inverseness (skbug.com/5421) | 345 } |
| 346 switch (fPath.get()->getFillType()) { | 346 } else if (fPath.get()->isConvex()) { |
| 347 case SkPath::kWinding_FillType: | 347 // There is no distinction between even/odd and non-zero winding count for convex |
| 348 case SkPath::kEvenOdd_FillType: | 348 // paths. |
| 349 break; | 349 if (fPath.get()->isInverseFillType()) { |
| 350 case SkPath::kInverseWinding_FillType: | 350 fPath.get()->setFillType(kDefaultPathInverseFillType); |
| 351 fPath.get()->setFillType(SkPath::kWinding_FillType); | 351 } else { |
| 352 break; | 352 fPath.get()->setFillType(kDefaultPathFillType); |
| 353 case SkPath::kInverseEvenOdd_FillType: | 353 } |
| 354 fPath.get()->setFillType(SkPath::kEvenOdd_FillType); | |
| 355 break; | |
| 356 } | 354 } |
| 357 } | 355 } |
| 358 } | 356 } |
| 359 } | 357 } |
| 360 | 358 |
| 361 void GrShape::attemptToSimplifyRRect() { | 359 void GrShape::attemptToSimplifyRRect() { |
| 362 SkASSERT(Type::kRRect == fType); | 360 SkASSERT(Type::kRRect == fType); |
| 363 SkASSERT(!fInheritedKey.count()); | 361 SkASSERT(!fInheritedKey.count()); |
| 364 if (fRRect.isEmpty()) { | 362 if (fRRect.isEmpty()) { |
| 365 fType = Type::kEmpty; | 363 fType = Type::kEmpty; |
| 366 return; | 364 return; |
| 367 } | 365 } |
| 368 if (!this->style().hasPathEffect()) { | 366 if (!this->style().hasPathEffect()) { |
| 369 fRRectDir = kDefaultRRectDir; | 367 fRRectDir = kDefaultRRectDir; |
| 370 fRRectStart = kDefaultRRectStart; | 368 fRRectStart = kDefaultRRectStart; |
| 371 } else if (fStyle.isDashed()) { | 369 } else if (fStyle.isDashed()) { |
| 372 // Dashing ignores the inverseness (currently). skbug.com/5421 | 370 // Dashing ignores the inverseness (currently). skbug.com/5421 |
| 373 fRRectIsInverted = false; | 371 fRRectIsInverted = false; |
| 374 } | 372 } |
| 375 } | 373 } |
| OLD | NEW |