OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkBuffer.h" | 8 #include "SkBuffer.h" |
9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 SK_COMPILE_ASSERT(1 == kFill_PathAsRect, path_as_rect_mismatch); | 531 SK_COMPILE_ASSERT(1 == kFill_PathAsRect, path_as_rect_mismatch); |
532 SK_COMPILE_ASSERT(2 == kStroke_PathAsRect, path_as_rect_mismatch); | 532 SK_COMPILE_ASSERT(2 == kStroke_PathAsRect, path_as_rect_mismatch); |
533 bool isClosed = false; | 533 bool isClosed = false; |
534 return (PathAsRect) (isRect(&isClosed, direction) + isClosed); | 534 return (PathAsRect) (isRect(&isClosed, direction) + isClosed); |
535 } | 535 } |
536 | 536 |
537 bool SkPath::isRect(SkRect* rect) const { | 537 bool SkPath::isRect(SkRect* rect) const { |
538 SkDEBUGCODE(this->validate();) | 538 SkDEBUGCODE(this->validate();) |
539 int currVerb = 0; | 539 int currVerb = 0; |
540 const SkPoint* pts = fPathRef->points(); | 540 const SkPoint* pts = fPathRef->points(); |
541 bool result = isRectContour(false, &currVerb, &pts, NULL, NULL); | 541 const SkPoint* first = pts; |
542 if (result && rect) { | 542 bool isClosed; |
543 *rect = getBounds(); | 543 if (!this->isRectContour(false, &currVerb, &pts, &isClosed, NULL)) { |
| 544 return false; |
544 } | 545 } |
545 return result; | 546 if (rect) { |
| 547 if (isClosed) { |
| 548 rect->set(first, SkToS32(pts - first)); |
| 549 } else { |
| 550 // 'pts' isn't updated for open rects |
| 551 *rect = this->getBounds(); |
| 552 } |
| 553 } |
| 554 return true; |
546 } | 555 } |
547 | 556 |
548 bool SkPath::isRect(bool* isClosed, Direction* direction) const { | 557 bool SkPath::isRect(bool* isClosed, Direction* direction) const { |
549 SkDEBUGCODE(this->validate();) | 558 SkDEBUGCODE(this->validate();) |
550 int currVerb = 0; | 559 int currVerb = 0; |
551 const SkPoint* pts = fPathRef->points(); | 560 const SkPoint* pts = fPathRef->points(); |
552 return isRectContour(false, &currVerb, &pts, isClosed, direction); | 561 return isRectContour(false, &currVerb, &pts, isClosed, direction); |
553 } | 562 } |
554 | 563 |
555 bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const { | 564 bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const { |
(...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 switch (this->getFillType()) { | 2947 switch (this->getFillType()) { |
2939 case SkPath::kEvenOdd_FillType: | 2948 case SkPath::kEvenOdd_FillType: |
2940 case SkPath::kInverseEvenOdd_FillType: | 2949 case SkPath::kInverseEvenOdd_FillType: |
2941 w &= 1; | 2950 w &= 1; |
2942 break; | 2951 break; |
2943 default: | 2952 default: |
2944 break; | 2953 break; |
2945 } | 2954 } |
2946 return SkToBool(w); | 2955 return SkToBool(w); |
2947 } | 2956 } |
OLD | NEW |