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

Side by Side Diff: src/core/SkPath.cpp

Issue 834503002: Update stroke path to use rect returned from isRect (to fix trailing moveTo bug) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment Created 5 years, 11 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 | « include/core/SkPath.h ('k') | src/core/SkStroke.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 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 } 527 }
528 528
529 SkPath::PathAsRect SkPath::asRect(Direction* direction) const { 529 SkPath::PathAsRect SkPath::asRect(Direction* direction) const {
530 SK_COMPILE_ASSERT(0 == kNone_PathAsRect, path_as_rect_mismatch); 530 SK_COMPILE_ASSERT(0 == kNone_PathAsRect, path_as_rect_mismatch);
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, bool* isClosed, Direction* direction) 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 const SkPoint* first = pts; 541 const SkPoint* first = pts;
542 bool isClosed; 542 if (!this->isRectContour(false, &currVerb, &pts, isClosed, direction)) {
543 if (!this->isRectContour(false, &currVerb, &pts, &isClosed, NULL)) {
544 return false; 543 return false;
545 } 544 }
546 if (rect) { 545 if (rect) {
547 if (isClosed) { 546 int32_t num = SkToS32(pts - first);
548 rect->set(first, SkToS32(pts - first)); 547 if (num) {
548 rect->set(first, num);
549 } else { 549 } else {
550 // 'pts' isn't updated for open rects 550 // 'pts' isn't updated for open rects
551 *rect = this->getBounds(); 551 *rect = this->getBounds();
552 } 552 }
553 } 553 }
554 return true; 554 return true;
555 } 555 }
556 556
557 bool SkPath::isRect(bool* isClosed, Direction* direction) const {
558 SkDEBUGCODE(this->validate();)
559 int currVerb = 0;
560 const SkPoint* pts = fPathRef->points();
561 return isRectContour(false, &currVerb, &pts, isClosed, direction);
562 }
563
564 bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const { 557 bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const {
565 SkDEBUGCODE(this->validate();) 558 SkDEBUGCODE(this->validate();)
566 int currVerb = 0; 559 int currVerb = 0;
567 const SkPoint* pts = fPathRef->points(); 560 const SkPoint* pts = fPathRef->points();
568 const SkPoint* first = pts; 561 const SkPoint* first = pts;
569 Direction testDirs[2]; 562 Direction testDirs[2];
570 if (!isRectContour(true, &currVerb, &pts, NULL, &testDirs[0])) { 563 if (!isRectContour(true, &currVerb, &pts, NULL, &testDirs[0])) {
571 return false; 564 return false;
572 } 565 }
573 const SkPoint* last = pts; 566 const SkPoint* last = pts;
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 switch (this->getFillType()) { 2940 switch (this->getFillType()) {
2948 case SkPath::kEvenOdd_FillType: 2941 case SkPath::kEvenOdd_FillType:
2949 case SkPath::kInverseEvenOdd_FillType: 2942 case SkPath::kInverseEvenOdd_FillType:
2950 w &= 1; 2943 w &= 1;
2951 break; 2944 break;
2952 default: 2945 default:
2953 break; 2946 break;
2954 } 2947 }
2955 return SkToBool(w); 2948 return SkToBool(w);
2956 } 2949 }
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkStroke.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698