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

Side by Side Diff: include/core/SkPath.h

Issue 16950021: add rect-output parameter to isRect, allowing us to return the correct bounds even if a rectagular … (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkPath.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkPath_DEFINED 10 #ifndef SkPath_DEFINED
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 230
231 /** 231 /**
232 * Returns true if the path specifies a single line (i.e. it contains just 232 * Returns true if the path specifies a single line (i.e. it contains just
233 * a moveTo and a lineTo). If so, and line[] is not null, it sets the 2 233 * a moveTo and a lineTo). If so, and line[] is not null, it sets the 2
234 * points in line[] to the end-points of the line. If the path is not a 234 * points in line[] to the end-points of the line. If the path is not a
235 * line, returns false and ignores line[]. 235 * line, returns false and ignores line[].
236 */ 236 */
237 bool isLine(SkPoint line[2]) const; 237 bool isLine(SkPoint line[2]) const;
238 238
239 enum Direction {
240 /** Direction either has not been or could not be computed */
241 kUnknown_Direction,
242 /** clockwise direction for adding closed contours */
243 kCW_Direction,
244 /** counter-clockwise direction for adding closed contours */
245 kCCW_Direction,
246 };
247
239 /** Returns true if the path specifies a rectangle. If so, and if rect is 248 /** Returns true if the path specifies a rectangle. If so, and if rect is
240 not null, set rect to the bounds of the path. If the path does not 249 not null, set rect to the bounds of the path. If the path does not
241 specify a rectangle, return false and ignore rect. 250 specify a rectangle, return false and ignore rect.
242 251
243 @param rect If not null, returns the bounds of the path if it specifies 252 @param rect If not null, returns the bounds of the path if it specifies
244 a rectangle 253 a rectangle
245 @return true if the path specifies a rectangle 254 @return true if the path specifies a rectangle
246 */ 255 */
247 bool isRect(SkRect* rect) const; 256 bool isRect(SkRect* rect) const {
257 return this->isRect(rect, NULL, NULL);
258 }
259
260 /**
261 * Returns true if the path specifies a rectangle.
262 *
263 * If this returns false, then all output parameters are ignored, and left
264 * unchanged. If this returns true, then each of the output parameters
265 * are checked for NULL. If they are not, they return their value.
266 *
267 * @param rect If not null, set to the bounds of the rectangle
268 * @param isClosed If not null, set to true if the path is closed
269 * @param direction If not null, set to the rectangle's direction
270 * @return true if the path specifies a rectangle
271 */
272 bool isRect(SkRect* rect, bool* isClosed, Direction* direction) const;
Stephen Chennney 2013/06/21 17:19:05 Is isClosed implied by a true return value? On oth
reed1 2013/06/21 17:24:03 move line line line line that path is not closed,
273
274 /** Returns true if the path specifies a pair of nested rectangles. If so, a nd if
275 rect is not null, set rect[0] to the outer rectangle and rect[1] to the inn er
276 rectangle. If so, and dirs is not null, set dirs[0] to the direction of
277 the outer rectangle and dirs[1] to the direction of the inner rectangle. If
278 the path does not specify a pair of nested rectangles, return
279 false and ignore rect and dirs.
280
281 @param rect If not null, returns the path as a pair of nested rectangles
282 @param dirs If not null, returns the direction of the rects
283 @return true if the path describes a pair of nested rectangles
284 */
285 bool isNestedRects(SkRect rect[2], Direction dirs[2] = NULL) const;
248 286
249 /** Return the number of points in the path 287 /** Return the number of points in the path
250 */ 288 */
251 int countPoints() const; 289 int countPoints() const;
252 290
253 /** Return the point at the specified index. If the index is out of range 291 /** Return the point at the specified index. If the index is out of range
254 (i.e. is not 0 <= index < countPoints()) then the returned coordinates 292 (i.e. is not 0 <= index < countPoints()) then the returned coordinates
255 will be (0,0) 293 will be (0,0)
256 */ 294 */
257 SkPoint getPoint(int index) const; 295 SkPoint getPoint(int index) const;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 */ 531 */
494 void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) { 532 void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
495 this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius); 533 this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
496 } 534 }
497 535
498 /** Close the current contour. If the current point is not equal to the 536 /** Close the current contour. If the current point is not equal to the
499 first point of the contour, a line segment is automatically added. 537 first point of the contour, a line segment is automatically added.
500 */ 538 */
501 void close(); 539 void close();
502 540
503 enum Direction {
504 /** Direction either has not been or could not be computed */
505 kUnknown_Direction,
506 /** clockwise direction for adding closed contours */
507 kCW_Direction,
508 /** counter-clockwise direction for adding closed contours */
509 kCCW_Direction,
510 };
511
512 /** 541 /**
513 * Return the opposite of the specified direction. kUnknown is its own 542 * Return the opposite of the specified direction. kUnknown is its own
514 * opposite. 543 * opposite.
515 */ 544 */
516 static Direction OppositeDirection(Direction dir) { 545 static Direction OppositeDirection(Direction dir) {
517 static const Direction gOppositeDir[] = { 546 static const Direction gOppositeDir[] = {
518 kUnknown_Direction, kCCW_Direction, kCW_Direction 547 kUnknown_Direction, kCCW_Direction, kCW_Direction
519 }; 548 };
520 return gOppositeDir[dir]; 549 return gOppositeDir[dir];
521 } 550 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 * cheapComputDirection() and if that computed direction matches the 595 * cheapComputDirection() and if that computed direction matches the
567 * specified direction. If dir is kUnknown, returns true if the direction 596 * specified direction. If dir is kUnknown, returns true if the direction
568 * cannot be computed. 597 * cannot be computed.
569 */ 598 */
570 bool cheapIsDirection(Direction dir) const { 599 bool cheapIsDirection(Direction dir) const {
571 Direction computedDir = kUnknown_Direction; 600 Direction computedDir = kUnknown_Direction;
572 (void)this->cheapComputeDirection(&computedDir); 601 (void)this->cheapComputeDirection(&computedDir);
573 return computedDir == dir; 602 return computedDir == dir;
574 } 603 }
575 604
576 /** Returns true if the path specifies a rectangle. If so, and if isClosed i s
577 not null, set isClosed to true if the path is closed. Also, if returning true
578 and direction is not null, return the rect direction. If the path does n ot
579 specify a rectangle, return false and ignore isClosed and direction.
580
581 @param isClosed If not null, set to true if the path is closed
582 @param direction If not null, set to the rectangle's direction
583 @return true if the path specifies a rectangle
584 */
585 bool isRect(bool* isClosed, Direction* direction) const;
586
587 /** Returns true if the path specifies a pair of nested rectangles. If so, a nd if
588 rect is not null, set rect[0] to the outer rectangle and rect[1] to the inner
589 rectangle. If so, and dirs is not null, set dirs[0] to the direction of
590 the outer rectangle and dirs[1] to the direction of the inner rectangle. If
591 the path does not specify a pair of nested rectangles, return
592 false and ignore rect and dirs.
593
594 @param rect If not null, returns the path as a pair of nested rectangles
595 @param dirs If not null, returns the direction of the rects
596 @return true if the path describes a pair of nested rectangles
597 */
598 bool isNestedRects(SkRect rect[2], Direction dirs[2] = NULL) const;
599
600 /** 605 /**
601 * Add a closed rectangle contour to the path 606 * Add a closed rectangle contour to the path
602 * @param rect The rectangle to add as a closed contour to the path 607 * @param rect The rectangle to add as a closed contour to the path
603 * @param dir The direction to wind the rectangle's contour. Cannot be 608 * @param dir The direction to wind the rectangle's contour. Cannot be
604 * kUnknown_Direction. 609 * kUnknown_Direction.
605 */ 610 */
606 void addRect(const SkRect& rect, Direction dir = kCW_Direction); 611 void addRect(const SkRect& rect, Direction dir = kCW_Direction);
607 612
608 /** 613 /**
609 * Add a closed rectangle contour to the path 614 * Add a closed rectangle contour to the path
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts, 1022 bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts,
1018 bool* isClosed, Direction* direction) const; 1023 bool* isClosed, Direction* direction) const;
1019 1024
1020 friend class SkAutoPathBoundsUpdate; 1025 friend class SkAutoPathBoundsUpdate;
1021 friend class SkAutoDisableOvalCheck; 1026 friend class SkAutoDisableOvalCheck;
1022 friend class SkAutoDisableDirectionCheck; 1027 friend class SkAutoDisableDirectionCheck;
1023 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo 1028 friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
1024 }; 1029 };
1025 1030
1026 #endif 1031 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698