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

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

Issue 151353006: Adding new 'extend' mode to SkPath::addPath (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added test and fix for empty path case Created 6 years, 10 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 | « 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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 * this->moveTo(pts[0]); 695 * this->moveTo(pts[0]);
696 * for (int i = 1; i < count; ++i) { 696 * for (int i = 1; i < count; ++i) {
697 * this->lineTo(pts[i]); 697 * this->lineTo(pts[i]);
698 * } 698 * }
699 * if (close) { 699 * if (close) {
700 * this->close(); 700 * this->close();
701 * } 701 * }
702 */ 702 */
703 void addPoly(const SkPoint pts[], int count, bool close); 703 void addPoly(const SkPoint pts[], int count, bool close);
704 704
705 enum AddPathMode {
706 /** Source path contours are added as new contours.
707 */
708 kAppend_AddPathMode,
709 /** Path is added by extending the last contour of the destination path
710 with the first contour of the source path. If the last contour of
711 the destination path is closed, then it will not be extended.
712 Instead, the start of source path will be extended by a straight
713 line to the end point of the destination path.
714 */
715 kExtend_AddPathMode
716 };
717
705 /** Add a copy of src to the path, offset by (dx,dy) 718 /** Add a copy of src to the path, offset by (dx,dy)
706 @param src The path to add as a new contour 719 @param src The path to add as a new contour
707 @param dx The amount to translate the path in X as it is added 720 @param dx The amount to translate the path in X as it is added
708 @param dx The amount to translate the path in Y as it is added 721 @param dx The amount to translate the path in Y as it is added
709 */ 722 */
710 void addPath(const SkPath& src, SkScalar dx, SkScalar dy); 723 void addPath(const SkPath& src, SkScalar dx, SkScalar dy,
724 AddPathMode mode = kAppend_AddPathMode);
711 725
712 /** Add a copy of src to the path 726 /** Add a copy of src to the path
713 */ 727 */
714 void addPath(const SkPath& src) { 728 void addPath(const SkPath& src, AddPathMode mode = kAppend_AddPathMode) {
715 SkMatrix m; 729 SkMatrix m;
716 m.reset(); 730 m.reset();
717 this->addPath(src, m); 731 this->addPath(src, m, mode);
718 } 732 }
719 733
720 /** Add a copy of src to the path, transformed by matrix 734 /** Add a copy of src to the path, transformed by matrix
721 @param src The path to add as a new contour 735 @param src The path to add as a new contour
736 @param matrix Transform applied to src
737 @param mode Determines how path is added
722 */ 738 */
723 void addPath(const SkPath& src, const SkMatrix& matrix); 739 void addPath(const SkPath& src, const SkMatrix& matrix, AddPathMode mode = k Append_AddPathMode);
724 740
725 /** 741 /**
726 * Same as addPath(), but reverses the src input 742 * Same as addPath(), but reverses the src input
727 */ 743 */
728 void reverseAddPath(const SkPath& src); 744 void reverseAddPath(const SkPath& src);
729 745
730 /** Offset the path by (dx,dy), returning true on success 746 /** Offset the path by (dx,dy), returning true on success
731 747
732 @param dx The amount in the X direction to offset the entire path 748 @param dx The amount in the X direction to offset the entire path
733 @param dy The amount in the Y direction to offset the entire path 749 @param dy The amount in the Y direction to offset the entire path
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 } 1040 }
1025 1041
1026 friend class SkAutoPathBoundsUpdate; 1042 friend class SkAutoPathBoundsUpdate;
1027 friend class SkAutoDisableOvalCheck; 1043 friend class SkAutoDisableOvalCheck;
1028 friend class SkAutoDisableDirectionCheck; 1044 friend class SkAutoDisableDirectionCheck;
1029 friend class SkBench_AddPathTest; // perf test reversePathTo 1045 friend class SkBench_AddPathTest; // perf test reversePathTo
1030 friend class PathTest_Private; // unit test reversePathTo 1046 friend class PathTest_Private; // unit test reversePathTo
1031 }; 1047 };
1032 1048
1033 #endif 1049 #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