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

Side by Side Diff: tests/PathTest.cpp

Issue 1176953002: move SkPath direction-as-computed into SkPathPriv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« src/core/SkPathPriv.h ('K') | « src/pathops/SkOpBuilder.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkParse.h" 10 #include "SkParse.h"
11 #include "SkParsePath.h" 11 #include "SkParsePath.h"
12 #include "SkPath.h" 12 #include "SkPathPriv.h"
13 #include "SkPathEffect.h" 13 #include "SkPathEffect.h"
14 #include "SkRRect.h" 14 #include "SkRRect.h"
15 #include "SkRandom.h" 15 #include "SkRandom.h"
16 #include "SkReader32.h" 16 #include "SkReader32.h"
17 #include "SkSize.h" 17 #include "SkSize.h"
18 #include "SkStream.h" 18 #include "SkStream.h"
19 #include "SkSurface.h" 19 #include "SkSurface.h"
20 #include "SkTypes.h" 20 #include "SkTypes.h"
21 #include "SkWriter32.h" 21 #include "SkWriter32.h"
22 #include "Test.h" 22 #include "Test.h"
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 800
801 rec.setStrokeStyle(0, false); 801 rec.setStrokeStyle(0, false);
802 REPORTER_ASSERT(reporter, SkStrokeRec::kHairline_Style == rec.getStyle()); 802 REPORTER_ASSERT(reporter, SkStrokeRec::kHairline_Style == rec.getStyle());
803 803
804 rec.setStrokeStyle(0, true); 804 rec.setStrokeStyle(0, true);
805 REPORTER_ASSERT(reporter, SkStrokeRec::kFill_Style == rec.getStyle()); 805 REPORTER_ASSERT(reporter, SkStrokeRec::kFill_Style == rec.getStyle());
806 } 806 }
807 807
808 // Set this for paths that don't have a consistent direction such as a bowtie. 808 // Set this for paths that don't have a consistent direction such as a bowtie.
809 // (cheapComputeDirection is not expected to catch these.) 809 // (cheapComputeDirection is not expected to catch these.)
810 static const SkPath::Direction kDontCheckDir = static_cast<SkPath::Direction>(-1 ); 810 const SkPathPriv::FirstDirection kDontCheckDir = static_cast<SkPathPriv::FirstDi rection>(-1);
811 811
812 static void check_direction(skiatest::Reporter* reporter, const SkPath& path, 812 static void check_direction(skiatest::Reporter* reporter, const SkPath& path,
813 SkPath::Direction expected) { 813 SkPathPriv::FirstDirection expected) {
814 if (expected == kDontCheckDir) { 814 if (expected == kDontCheckDir) {
815 return; 815 return;
816 } 816 }
817 SkPath copy(path); // we make a copy so that we don't cache the result on th e passed in path. 817 SkPath copy(path); // we make a copy so that we don't cache the result on th e passed in path.
818 818
819 SkPath::Direction dir; 819 SkPathPriv::FirstDirection dir;
820 if (copy.cheapComputeDirection(&dir)) { 820 if (SkPathPriv::CheapComputeFirstDirection(copy, &dir)) {
821 REPORTER_ASSERT(reporter, dir == expected); 821 REPORTER_ASSERT(reporter, dir == expected);
822 } else { 822 } else {
823 REPORTER_ASSERT(reporter, SkPath::kUnknown_Direction == expected); 823 REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expecte d);
824 } 824 }
825 } 825 }
826 826
827 static void test_direction(skiatest::Reporter* reporter) { 827 static void test_direction(skiatest::Reporter* reporter) {
828 size_t i; 828 size_t i;
829 SkPath path; 829 SkPath path;
830 REPORTER_ASSERT(reporter, !path.cheapComputeDirection(NULL)); 830 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, NULL ));
831 REPORTER_ASSERT(reporter, !path.cheapIsDirection(SkPath::kCW_Direction)); 831 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPri v::kCW_FirstDirection));
832 REPORTER_ASSERT(reporter, !path.cheapIsDirection(SkPath::kCCW_Direction)); 832 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPri v::kCCW_FirstDirection));
833 REPORTER_ASSERT(reporter, path.cheapIsDirection(SkPath::kUnknown_Direction)) ; 833 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv ::kUnknown_FirstDirection));
834 834
835 static const char* gDegen[] = { 835 static const char* gDegen[] = {
836 "M 10 10", 836 "M 10 10",
837 "M 10 10 M 20 20", 837 "M 10 10 M 20 20",
838 "M 10 10 L 20 20", 838 "M 10 10 L 20 20",
839 "M 10 10 L 10 10 L 10 10", 839 "M 10 10 L 10 10 L 10 10",
840 "M 10 10 Q 10 10 10 10", 840 "M 10 10 Q 10 10 10 10",
841 "M 10 10 C 10 10 10 10 10 10", 841 "M 10 10 C 10 10 10 10 10 10",
842 }; 842 };
843 for (i = 0; i < SK_ARRAY_COUNT(gDegen); ++i) { 843 for (i = 0; i < SK_ARRAY_COUNT(gDegen); ++i) {
844 path.reset(); 844 path.reset();
845 bool valid = SkParsePath::FromSVGString(gDegen[i], &path); 845 bool valid = SkParsePath::FromSVGString(gDegen[i], &path);
846 REPORTER_ASSERT(reporter, valid); 846 REPORTER_ASSERT(reporter, valid);
847 REPORTER_ASSERT(reporter, !path.cheapComputeDirection(NULL)); 847 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, NULL));
848 } 848 }
849 849
850 static const char* gCW[] = { 850 static const char* gCW[] = {
851 "M 10 10 L 10 10 Q 20 10 20 20", 851 "M 10 10 L 10 10 Q 20 10 20 20",
852 "M 10 10 C 20 10 20 20 20 20", 852 "M 10 10 C 20 10 20 20 20 20",
853 "M 20 10 Q 20 20 30 20 L 10 20", // test double-back at y-max 853 "M 20 10 Q 20 20 30 20 L 10 20", // test double-back at y-max
854 // rect with top two corners replaced by cubics with identical middle 854 // rect with top two corners replaced by cubics with identical middle
855 // control points 855 // control points
856 "M 10 10 C 10 0 10 0 20 0 L 40 0 C 50 0 50 0 50 10", 856 "M 10 10 C 10 0 10 0 20 0 L 40 0 C 50 0 50 0 50 10",
857 "M 20 10 L 0 10 Q 10 10 20 0", // left, degenerate serif 857 "M 20 10 L 0 10 Q 10 10 20 0", // left, degenerate serif
858 }; 858 };
859 for (i = 0; i < SK_ARRAY_COUNT(gCW); ++i) { 859 for (i = 0; i < SK_ARRAY_COUNT(gCW); ++i) {
860 path.reset(); 860 path.reset();
861 bool valid = SkParsePath::FromSVGString(gCW[i], &path); 861 bool valid = SkParsePath::FromSVGString(gCW[i], &path);
862 REPORTER_ASSERT(reporter, valid); 862 REPORTER_ASSERT(reporter, valid);
863 check_direction(reporter, path, SkPath::kCW_Direction); 863 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
864 } 864 }
865 865
866 static const char* gCCW[] = { 866 static const char* gCCW[] = {
867 "M 10 10 L 10 10 Q 20 10 20 -20", 867 "M 10 10 L 10 10 Q 20 10 20 -20",
868 "M 10 10 C 20 10 20 -20 20 -20", 868 "M 10 10 C 20 10 20 -20 20 -20",
869 "M 20 10 Q 20 20 10 20 L 30 20", // test double-back at y-max 869 "M 20 10 Q 20 20 10 20 L 30 20", // test double-back at y-max
870 // rect with top two corners replaced by cubics with identical middle 870 // rect with top two corners replaced by cubics with identical middle
871 // control points 871 // control points
872 "M 50 10 C 50 0 50 0 40 0 L 20 0 C 10 0 10 0 10 10", 872 "M 50 10 C 50 0 50 0 40 0 L 20 0 C 10 0 10 0 10 10",
873 "M 10 10 L 30 10 Q 20 10 10 0", // right, degenerate serif 873 "M 10 10 L 30 10 Q 20 10 10 0", // right, degenerate serif
874 }; 874 };
875 for (i = 0; i < SK_ARRAY_COUNT(gCCW); ++i) { 875 for (i = 0; i < SK_ARRAY_COUNT(gCCW); ++i) {
876 path.reset(); 876 path.reset();
877 bool valid = SkParsePath::FromSVGString(gCCW[i], &path); 877 bool valid = SkParsePath::FromSVGString(gCCW[i], &path);
878 REPORTER_ASSERT(reporter, valid); 878 REPORTER_ASSERT(reporter, valid);
879 check_direction(reporter, path, SkPath::kCCW_Direction); 879 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
880 } 880 }
881 881
882 // Test two donuts, each wound a different direction. Only the outer contour 882 // Test two donuts, each wound a different direction. Only the outer contour
883 // determines the cheap direction 883 // determines the cheap direction
884 path.reset(); 884 path.reset();
885 path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCW_Direction); 885 path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCW_Direction);
886 path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCCW_Direction); 886 path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCCW_Direction);
887 check_direction(reporter, path, SkPath::kCW_Direction); 887 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
888 888
889 path.reset(); 889 path.reset();
890 path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCW_Direction); 890 path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCW_Direction);
891 path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction); 891 path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction);
892 check_direction(reporter, path, SkPath::kCCW_Direction); 892 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
893 893
894 // triangle with one point really far from the origin. 894 // triangle with one point really far from the origin.
895 path.reset(); 895 path.reset();
896 // the first point is roughly 1.05e10, 1.05e10 896 // the first point is roughly 1.05e10, 1.05e10
897 path.moveTo(SkBits2Float(0x501c7652), SkBits2Float(0x501c7652)); 897 path.moveTo(SkBits2Float(0x501c7652), SkBits2Float(0x501c7652));
898 path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); 898 path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1);
899 path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1); 899 path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1);
900 check_direction(reporter, path, SkPath::kCCW_Direction); 900 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
901 901
902 path.reset(); 902 path.reset();
903 path.conicTo(20, 0, 20, 20, 0.5f); 903 path.conicTo(20, 0, 20, 20, 0.5f);
904 path.close(); 904 path.close();
905 check_direction(reporter, path, SkPath::kCW_Direction); 905 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
906 906
907 path.reset(); 907 path.reset();
908 path.lineTo(1, 1e7f); 908 path.lineTo(1, 1e7f);
909 path.lineTo(1e7f, 2e7f); 909 path.lineTo(1e7f, 2e7f);
910 path.close(); 910 path.close();
911 REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity()); 911 REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity());
912 check_direction(reporter, path, SkPath::kCCW_Direction); 912 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
913 } 913 }
914 914
915 static void add_rect(SkPath* path, const SkRect& r) { 915 static void add_rect(SkPath* path, const SkRect& r) {
916 path->moveTo(r.fLeft, r.fTop); 916 path->moveTo(r.fLeft, r.fTop);
917 path->lineTo(r.fRight, r.fTop); 917 path->lineTo(r.fRight, r.fTop);
918 path->lineTo(r.fRight, r.fBottom); 918 path->lineTo(r.fRight, r.fBottom);
919 path->lineTo(r.fLeft, r.fBottom); 919 path->lineTo(r.fLeft, r.fBottom);
920 path->close(); 920 path->close();
921 } 921 }
922 922
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1078
1079 static void test_path_crbug389050(skiatest::Reporter* reporter) { 1079 static void test_path_crbug389050(skiatest::Reporter* reporter) {
1080 SkPath tinyConvexPolygon; 1080 SkPath tinyConvexPolygon;
1081 tinyConvexPolygon.moveTo(600.131559f, 800.112512f); 1081 tinyConvexPolygon.moveTo(600.131559f, 800.112512f);
1082 tinyConvexPolygon.lineTo(600.161735f, 800.118627f); 1082 tinyConvexPolygon.lineTo(600.161735f, 800.118627f);
1083 tinyConvexPolygon.lineTo(600.148962f, 800.142338f); 1083 tinyConvexPolygon.lineTo(600.148962f, 800.142338f);
1084 tinyConvexPolygon.lineTo(600.134891f, 800.137724f); 1084 tinyConvexPolygon.lineTo(600.134891f, 800.137724f);
1085 tinyConvexPolygon.close(); 1085 tinyConvexPolygon.close();
1086 tinyConvexPolygon.getConvexity(); 1086 tinyConvexPolygon.getConvexity();
1087 check_convexity(reporter, tinyConvexPolygon, SkPath::kConvex_Convexity); 1087 check_convexity(reporter, tinyConvexPolygon, SkPath::kConvex_Convexity);
1088 check_direction(reporter, tinyConvexPolygon, SkPath::kCW_Direction); 1088 check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection) ;
1089 1089
1090 SkPath platTriangle; 1090 SkPath platTriangle;
1091 platTriangle.moveTo(0, 0); 1091 platTriangle.moveTo(0, 0);
1092 platTriangle.lineTo(200, 0); 1092 platTriangle.lineTo(200, 0);
1093 platTriangle.lineTo(100, 0.04f); 1093 platTriangle.lineTo(100, 0.04f);
1094 platTriangle.close(); 1094 platTriangle.close();
1095 platTriangle.getConvexity(); 1095 platTriangle.getConvexity();
1096 check_direction(reporter, platTriangle, SkPath::kCW_Direction); 1096 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1097 1097
1098 platTriangle.reset(); 1098 platTriangle.reset();
1099 platTriangle.moveTo(0, 0); 1099 platTriangle.moveTo(0, 0);
1100 platTriangle.lineTo(200, 0); 1100 platTriangle.lineTo(200, 0);
1101 platTriangle.lineTo(100, 0.03f); 1101 platTriangle.lineTo(100, 0.03f);
1102 platTriangle.close(); 1102 platTriangle.close();
1103 platTriangle.getConvexity(); 1103 platTriangle.getConvexity();
1104 check_direction(reporter, platTriangle, SkPath::kCW_Direction); 1104 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1105 } 1105 }
1106 1106
1107 static void test_convexity2(skiatest::Reporter* reporter) { 1107 static void test_convexity2(skiatest::Reporter* reporter) {
1108 SkPath pt; 1108 SkPath pt;
1109 pt.moveTo(0, 0); 1109 pt.moveTo(0, 0);
1110 pt.close(); 1110 pt.close();
1111 check_convexity(reporter, pt, SkPath::kConvex_Convexity); 1111 check_convexity(reporter, pt, SkPath::kConvex_Convexity);
1112 check_direction(reporter, pt, SkPath::kUnknown_Direction); 1112 check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection);
1113 1113
1114 SkPath line; 1114 SkPath line;
1115 line.moveTo(12*SK_Scalar1, 20*SK_Scalar1); 1115 line.moveTo(12*SK_Scalar1, 20*SK_Scalar1);
1116 line.lineTo(-12*SK_Scalar1, -20*SK_Scalar1); 1116 line.lineTo(-12*SK_Scalar1, -20*SK_Scalar1);
1117 line.close(); 1117 line.close();
1118 check_convexity(reporter, line, SkPath::kConvex_Convexity); 1118 check_convexity(reporter, line, SkPath::kConvex_Convexity);
1119 check_direction(reporter, line, SkPath::kUnknown_Direction); 1119 check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection);
1120 1120
1121 SkPath triLeft; 1121 SkPath triLeft;
1122 triLeft.moveTo(0, 0); 1122 triLeft.moveTo(0, 0);
1123 triLeft.lineTo(SK_Scalar1, 0); 1123 triLeft.lineTo(SK_Scalar1, 0);
1124 triLeft.lineTo(SK_Scalar1, SK_Scalar1); 1124 triLeft.lineTo(SK_Scalar1, SK_Scalar1);
1125 triLeft.close(); 1125 triLeft.close();
1126 check_convexity(reporter, triLeft, SkPath::kConvex_Convexity); 1126 check_convexity(reporter, triLeft, SkPath::kConvex_Convexity);
1127 check_direction(reporter, triLeft, SkPath::kCW_Direction); 1127 check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection);
1128 1128
1129 SkPath triRight; 1129 SkPath triRight;
1130 triRight.moveTo(0, 0); 1130 triRight.moveTo(0, 0);
1131 triRight.lineTo(-SK_Scalar1, 0); 1131 triRight.lineTo(-SK_Scalar1, 0);
1132 triRight.lineTo(SK_Scalar1, SK_Scalar1); 1132 triRight.lineTo(SK_Scalar1, SK_Scalar1);
1133 triRight.close(); 1133 triRight.close();
1134 check_convexity(reporter, triRight, SkPath::kConvex_Convexity); 1134 check_convexity(reporter, triRight, SkPath::kConvex_Convexity);
1135 check_direction(reporter, triRight, SkPath::kCCW_Direction); 1135 check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection);
1136 1136
1137 SkPath square; 1137 SkPath square;
1138 square.moveTo(0, 0); 1138 square.moveTo(0, 0);
1139 square.lineTo(SK_Scalar1, 0); 1139 square.lineTo(SK_Scalar1, 0);
1140 square.lineTo(SK_Scalar1, SK_Scalar1); 1140 square.lineTo(SK_Scalar1, SK_Scalar1);
1141 square.lineTo(0, SK_Scalar1); 1141 square.lineTo(0, SK_Scalar1);
1142 square.close(); 1142 square.close();
1143 check_convexity(reporter, square, SkPath::kConvex_Convexity); 1143 check_convexity(reporter, square, SkPath::kConvex_Convexity);
1144 check_direction(reporter, square, SkPath::kCW_Direction); 1144 check_direction(reporter, square, SkPathPriv::kCW_FirstDirection);
1145 1145
1146 SkPath redundantSquare; 1146 SkPath redundantSquare;
1147 redundantSquare.moveTo(0, 0); 1147 redundantSquare.moveTo(0, 0);
1148 redundantSquare.lineTo(0, 0); 1148 redundantSquare.lineTo(0, 0);
1149 redundantSquare.lineTo(0, 0); 1149 redundantSquare.lineTo(0, 0);
1150 redundantSquare.lineTo(SK_Scalar1, 0); 1150 redundantSquare.lineTo(SK_Scalar1, 0);
1151 redundantSquare.lineTo(SK_Scalar1, 0); 1151 redundantSquare.lineTo(SK_Scalar1, 0);
1152 redundantSquare.lineTo(SK_Scalar1, 0); 1152 redundantSquare.lineTo(SK_Scalar1, 0);
1153 redundantSquare.lineTo(SK_Scalar1, SK_Scalar1); 1153 redundantSquare.lineTo(SK_Scalar1, SK_Scalar1);
1154 redundantSquare.lineTo(SK_Scalar1, SK_Scalar1); 1154 redundantSquare.lineTo(SK_Scalar1, SK_Scalar1);
1155 redundantSquare.lineTo(SK_Scalar1, SK_Scalar1); 1155 redundantSquare.lineTo(SK_Scalar1, SK_Scalar1);
1156 redundantSquare.lineTo(0, SK_Scalar1); 1156 redundantSquare.lineTo(0, SK_Scalar1);
1157 redundantSquare.lineTo(0, SK_Scalar1); 1157 redundantSquare.lineTo(0, SK_Scalar1);
1158 redundantSquare.lineTo(0, SK_Scalar1); 1158 redundantSquare.lineTo(0, SK_Scalar1);
1159 redundantSquare.close(); 1159 redundantSquare.close();
1160 check_convexity(reporter, redundantSquare, SkPath::kConvex_Convexity); 1160 check_convexity(reporter, redundantSquare, SkPath::kConvex_Convexity);
1161 check_direction(reporter, redundantSquare, SkPath::kCW_Direction); 1161 check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection);
1162 1162
1163 SkPath bowTie; 1163 SkPath bowTie;
1164 bowTie.moveTo(0, 0); 1164 bowTie.moveTo(0, 0);
1165 bowTie.lineTo(0, 0); 1165 bowTie.lineTo(0, 0);
1166 bowTie.lineTo(0, 0); 1166 bowTie.lineTo(0, 0);
1167 bowTie.lineTo(SK_Scalar1, SK_Scalar1); 1167 bowTie.lineTo(SK_Scalar1, SK_Scalar1);
1168 bowTie.lineTo(SK_Scalar1, SK_Scalar1); 1168 bowTie.lineTo(SK_Scalar1, SK_Scalar1);
1169 bowTie.lineTo(SK_Scalar1, SK_Scalar1); 1169 bowTie.lineTo(SK_Scalar1, SK_Scalar1);
1170 bowTie.lineTo(SK_Scalar1, 0); 1170 bowTie.lineTo(SK_Scalar1, 0);
1171 bowTie.lineTo(SK_Scalar1, 0); 1171 bowTie.lineTo(SK_Scalar1, 0);
(...skipping 18 matching lines...) Expand all
1190 check_direction(reporter, spiral, kDontCheckDir); 1190 check_direction(reporter, spiral, kDontCheckDir);
1191 1191
1192 SkPath dent; 1192 SkPath dent;
1193 dent.moveTo(0, 0); 1193 dent.moveTo(0, 0);
1194 dent.lineTo(100*SK_Scalar1, 100*SK_Scalar1); 1194 dent.lineTo(100*SK_Scalar1, 100*SK_Scalar1);
1195 dent.lineTo(0, 100*SK_Scalar1); 1195 dent.lineTo(0, 100*SK_Scalar1);
1196 dent.lineTo(-50*SK_Scalar1, 200*SK_Scalar1); 1196 dent.lineTo(-50*SK_Scalar1, 200*SK_Scalar1);
1197 dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1); 1197 dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1);
1198 dent.close(); 1198 dent.close();
1199 check_convexity(reporter, dent, SkPath::kConcave_Convexity); 1199 check_convexity(reporter, dent, SkPath::kConcave_Convexity);
1200 check_direction(reporter, dent, SkPath::kCW_Direction); 1200 check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection);
1201 1201
1202 // http://skbug.com/2235 1202 // http://skbug.com/2235
1203 SkPath strokedSin; 1203 SkPath strokedSin;
1204 for (int i = 0; i < 2000; i++) { 1204 for (int i = 0; i < 2000; i++) {
1205 SkScalar x = SkIntToScalar(i) / 2; 1205 SkScalar x = SkIntToScalar(i) / 2;
1206 SkScalar y = 500 - (x + SkScalarSin(x / 100) * 40) / 3; 1206 SkScalar y = 500 - (x + SkScalarSin(x / 100) * 40) / 3;
1207 if (0 == i) { 1207 if (0 == i) {
1208 strokedSin.moveTo(x, y); 1208 strokedSin.moveTo(x, y);
1209 } else { 1209 } else {
1210 strokedSin.lineTo(x, y); 1210 strokedSin.lineTo(x, y);
1211 } 1211 }
1212 } 1212 }
1213 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 1213 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
1214 stroke.setStrokeStyle(2 * SK_Scalar1); 1214 stroke.setStrokeStyle(2 * SK_Scalar1);
1215 stroke.applyToPath(&strokedSin, strokedSin); 1215 stroke.applyToPath(&strokedSin, strokedSin);
1216 check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity); 1216 check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity);
1217 check_direction(reporter, strokedSin, kDontCheckDir); 1217 check_direction(reporter, strokedSin, kDontCheckDir);
1218 1218
1219 // http://crbug.com/412640 1219 // http://crbug.com/412640
1220 SkPath degenerateConcave; 1220 SkPath degenerateConcave;
1221 degenerateConcave.moveTo(148.67912f, 191.875f); 1221 degenerateConcave.moveTo(148.67912f, 191.875f);
1222 degenerateConcave.lineTo(470.37695f, 7.5f); 1222 degenerateConcave.lineTo(470.37695f, 7.5f);
1223 degenerateConcave.lineTo(148.67912f, 191.875f); 1223 degenerateConcave.lineTo(148.67912f, 191.875f);
1224 degenerateConcave.lineTo(41.446522f, 376.25f); 1224 degenerateConcave.lineTo(41.446522f, 376.25f);
1225 degenerateConcave.lineTo(-55.971577f, 460.0f); 1225 degenerateConcave.lineTo(-55.971577f, 460.0f);
1226 degenerateConcave.lineTo(41.446522f, 376.25f); 1226 degenerateConcave.lineTo(41.446522f, 376.25f);
1227 check_convexity(reporter, degenerateConcave, SkPath::kConcave_Convexity); 1227 check_convexity(reporter, degenerateConcave, SkPath::kConcave_Convexity);
1228 check_direction(reporter, degenerateConcave, SkPath::kUnknown_Direction); 1228 check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirec tion);
1229 1229
1230 // http://crbug.com/433683 1230 // http://crbug.com/433683
1231 SkPath badFirstVector; 1231 SkPath badFirstVector;
1232 badFirstVector.moveTo(501.087708f, 319.610352f); 1232 badFirstVector.moveTo(501.087708f, 319.610352f);
1233 badFirstVector.lineTo(501.087708f, 319.610352f); 1233 badFirstVector.lineTo(501.087708f, 319.610352f);
1234 badFirstVector.cubicTo(501.087677f, 319.610321f, 449.271606f, 258.078674f, 3 95.084564f, 198.711182f); 1234 badFirstVector.cubicTo(501.087677f, 319.610321f, 449.271606f, 258.078674f, 3 95.084564f, 198.711182f);
1235 badFirstVector.cubicTo(358.967072f, 159.140717f, 321.910553f, 120.650436f, 2 98.442322f, 101.955399f); 1235 badFirstVector.cubicTo(358.967072f, 159.140717f, 321.910553f, 120.650436f, 2 98.442322f, 101.955399f);
1236 badFirstVector.lineTo(301.557678f, 98.044601f); 1236 badFirstVector.lineTo(301.557678f, 98.044601f);
1237 badFirstVector.cubicTo(325.283844f, 116.945084f, 362.615204f, 155.720825f, 3 98.777557f, 195.340454f); 1237 badFirstVector.cubicTo(325.283844f, 116.945084f, 362.615204f, 155.720825f, 3 98.777557f, 195.340454f);
1238 badFirstVector.cubicTo(453.031860f, 254.781662f, 504.912262f, 316.389618f, 5 04.912292f, 316.389648f); 1238 badFirstVector.cubicTo(453.031860f, 254.781662f, 504.912262f, 316.389618f, 5 04.912292f, 316.389648f);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 1281
1282 check_convexity(reporter, path, SkPath::kConvex_Convexity); 1282 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1283 path.addCircle(0, 0, SkIntToScalar(10)); 1283 path.addCircle(0, 0, SkIntToScalar(10));
1284 check_convexity(reporter, path, SkPath::kConvex_Convexity); 1284 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1285 path.addCircle(0, 0, SkIntToScalar(10)); // 2nd circle 1285 path.addCircle(0, 0, SkIntToScalar(10)); // 2nd circle
1286 check_convexity(reporter, path, SkPath::kConcave_Convexity); 1286 check_convexity(reporter, path, SkPath::kConcave_Convexity);
1287 1287
1288 path.reset(); 1288 path.reset();
1289 path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPath::kCCW_Direct ion); 1289 path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPath::kCCW_Direct ion);
1290 check_convexity(reporter, path, SkPath::kConvex_Convexity); 1290 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1291 REPORTER_ASSERT(reporter, path.cheapIsDirection(SkPath::kCCW_Direction)); 1291 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv ::kCCW_FirstDirection));
1292 1292
1293 path.reset(); 1293 path.reset();
1294 path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPath::kCW_Directi on); 1294 path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPath::kCW_Directi on);
1295 check_convexity(reporter, path, SkPath::kConvex_Convexity); 1295 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1296 REPORTER_ASSERT(reporter, path.cheapIsDirection(SkPath::kCW_Direction)); 1296 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv ::kCW_FirstDirection));
1297 1297
1298 static const struct { 1298 static const struct {
1299 const char* fPathStr; 1299 const char* fPathStr;
1300 SkPath::Convexity fExpectedConvexity; 1300 SkPath::Convexity fExpectedConvexity;
1301 SkPath::Direction fExpectedDirection; 1301 SkPathPriv::FirstDirection fExpectedDirection;
1302 } gRec[] = { 1302 } gRec[] = {
1303 { "", SkPath::kConvex_Convexity, SkPath::kUnknown_Direction }, 1303 { "", SkPath::kConvex_Convexity, SkPathPriv::kUnknown_FirstDirection },
1304 { "0 0", SkPath::kConvex_Convexity, SkPath::kUnknown_Direction }, 1304 { "0 0", SkPath::kConvex_Convexity, SkPathPriv::kUnknown_FirstDirection },
1305 { "0 0 10 10", SkPath::kConvex_Convexity, SkPath::kUnknown_Direction }, 1305 { "0 0 10 10", SkPath::kConvex_Convexity, SkPathPriv::kUnknown_FirstDire ction },
1306 { "0 0 10 10 20 20 0 0 10 10", SkPath::kConcave_Convexity, SkPath::kUnkn own_Direction }, 1306 { "0 0 10 10 20 20 0 0 10 10", SkPath::kConcave_Convexity, SkPathPriv::k Unknown_FirstDirection },
1307 { "0 0 10 10 10 20", SkPath::kConvex_Convexity, SkPath::kCW_Direction }, 1307 { "0 0 10 10 10 20", SkPath::kConvex_Convexity, SkPathPriv::kCW_FirstDir ection },
1308 { "0 0 10 10 10 0", SkPath::kConvex_Convexity, SkPath::kCCW_Direction }, 1308 { "0 0 10 10 10 0", SkPath::kConvex_Convexity, SkPathPriv::kCCW_FirstDir ection },
1309 { "0 0 10 10 10 0 0 10", SkPath::kConcave_Convexity, kDontCheckDir }, 1309 { "0 0 10 10 10 0 0 10", SkPath::kConcave_Convexity, kDontCheckDir },
1310 { "0 0 10 0 0 10 -10 -10", SkPath::kConcave_Convexity, SkPath::kCW_Direc tion }, 1310 { "0 0 10 0 0 10 -10 -10", SkPath::kConcave_Convexity, SkPathPriv::kCW_F irstDirection },
1311 }; 1311 };
1312 1312
1313 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 1313 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
1314 SkPath path; 1314 SkPath path;
1315 setFromString(&path, gRec[i].fPathStr); 1315 setFromString(&path, gRec[i].fPathStr);
1316 check_convexity(reporter, path, gRec[i].fExpectedConvexity); 1316 check_convexity(reporter, path, gRec[i].fExpectedConvexity);
1317 check_direction(reporter, path, gRec[i].fExpectedDirection); 1317 check_direction(reporter, path, gRec[i].fExpectedDirection);
1318 // check after setting the initial convex and direction 1318 // check after setting the initial convex and direction
1319 if (kDontCheckDir != gRec[i].fExpectedDirection) { 1319 if (kDontCheckDir != gRec[i].fExpectedDirection) {
1320 SkPath copy(path); 1320 SkPath copy(path);
1321 SkPath::Direction dir; 1321 SkPathPriv::FirstDirection dir;
1322 bool foundDir = copy.cheapComputeDirection(&dir); 1322 bool foundDir = SkPathPriv::CheapComputeFirstDirection(copy, &dir);
1323 REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPath::kUn known_Direction) 1323 REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPathPriv: :kUnknown_FirstDirection)
1324 ^ foundDir); 1324 ^ foundDir);
1325 REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir); 1325 REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir);
1326 check_convexity(reporter, copy, gRec[i].fExpectedConvexity); 1326 check_convexity(reporter, copy, gRec[i].fExpectedConvexity);
1327 } 1327 }
1328 REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexit y()); 1328 REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexit y());
1329 check_direction(reporter, path, gRec[i].fExpectedDirection); 1329 check_direction(reporter, path, gRec[i].fExpectedDirection);
1330 } 1330 }
1331 1331
1332 static const SkPoint nonFinitePts[] = { 1332 static const SkPoint nonFinitePts[] = {
1333 { SK_ScalarInfinity, 0 }, 1333 { SK_ScalarInfinity, 0 },
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex].fPo ints[index].fY); 1774 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex].fPo ints[index].fY);
1775 } 1775 }
1776 if (tests[testIndex].fClose) { 1776 if (tests[testIndex].fClose) {
1777 path.close(); 1777 path.close();
1778 } 1778 }
1779 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(NULL)) ; 1779 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(NULL)) ;
1780 1780
1781 if (tests[testIndex].fIsRect) { 1781 if (tests[testIndex].fIsRect) {
1782 SkRect computed, expected; 1782 SkRect computed, expected;
1783 bool isClosed; 1783 bool isClosed;
1784 SkPath::Direction direction, cheapDirection; 1784 SkPath::Direction direction;
1785 SkPathPriv::FirstDirection cheapDirection;
1785 expected.set(tests[testIndex].fPoints, tests[testIndex].fPointCount) ; 1786 expected.set(tests[testIndex].fPoints, tests[testIndex].fPointCount) ;
1786 REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection )); 1787 REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(pat h, &cheapDirection));
1787 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &directi on)); 1788 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &directi on));
1788 REPORTER_ASSERT(reporter, expected == computed); 1789 REPORTER_ASSERT(reporter, expected == computed);
1789 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose); 1790 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose);
1790 REPORTER_ASSERT(reporter, direction == cheapDirection); 1791 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(direction) == cheapDirection);
1791 } else { 1792 } else {
1792 SkRect computed; 1793 SkRect computed;
1793 computed.set(123, 456, 789, 1011); 1794 computed.set(123, 456, 789, 1011);
1794 bool isClosed = (bool)-1; 1795 bool isClosed = (bool)-1;
1795 SkPath::Direction direction = (SkPath::Direction) - 1; 1796 SkPath::Direction direction = (SkPath::Direction) - 1;
1796 REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direct ion)); 1797 REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direct ion));
1797 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456); 1798 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
1798 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011); 1799 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
1799 REPORTER_ASSERT(reporter, isClosed == (bool) -1); 1800 REPORTER_ASSERT(reporter, isClosed == (bool) -1);
1800 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1); 1801 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 SkPoint f7[] = {{0, 0}, {1, 0}, {1, 1}, {0, 2}}; // end overshoots 1885 SkPoint f7[] = {{0, 0}, {1, 0}, {1, 1}, {0, 2}}; // end overshoots
1885 SkPoint f8[] = {{0, 0}, {1, 0}, {1, 1}, {1, 0}}; // 'L' 1886 SkPoint f8[] = {{0, 0}, {1, 0}, {1, 1}, {1, 0}}; // 'L'
1886 1887
1887 // success, no close is OK 1888 // success, no close is OK
1888 SkPoint c1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // close doesn't match 1889 SkPoint c1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // close doesn't match
1889 SkPoint c2[] = {{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 1}}; // ditto 1890 SkPoint c2[] = {{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 1}}; // ditto
1890 1891
1891 struct IsNestedRectTest { 1892 struct IsNestedRectTest {
1892 SkPoint *fPoints; 1893 SkPoint *fPoints;
1893 int fPointCount; 1894 int fPointCount;
1894 SkPath::Direction fDirection; 1895 SkPathPriv::FirstDirection fDirection;
1895 bool fClose; 1896 bool fClose;
1896 bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2); 1897 bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2);
1897 } tests[] = { 1898 } tests[] = {
1898 { r1, SK_ARRAY_COUNT(r1), SkPath::kCW_Direction , true, true }, 1899 { r1, SK_ARRAY_COUNT(r1), SkPathPriv::kCW_FirstDirection , true, true },
1899 { r2, SK_ARRAY_COUNT(r2), SkPath::kCW_Direction , true, true }, 1900 { r2, SK_ARRAY_COUNT(r2), SkPathPriv::kCW_FirstDirection , true, true },
1900 { r3, SK_ARRAY_COUNT(r3), SkPath::kCW_Direction , true, true }, 1901 { r3, SK_ARRAY_COUNT(r3), SkPathPriv::kCW_FirstDirection , true, true },
1901 { r4, SK_ARRAY_COUNT(r4), SkPath::kCW_Direction , true, true }, 1902 { r4, SK_ARRAY_COUNT(r4), SkPathPriv::kCW_FirstDirection , true, true },
1902 { r5, SK_ARRAY_COUNT(r5), SkPath::kCCW_Direction, true, true }, 1903 { r5, SK_ARRAY_COUNT(r5), SkPathPriv::kCCW_FirstDirection, true, true },
1903 { r6, SK_ARRAY_COUNT(r6), SkPath::kCCW_Direction, true, true }, 1904 { r6, SK_ARRAY_COUNT(r6), SkPathPriv::kCCW_FirstDirection, true, true },
1904 { r7, SK_ARRAY_COUNT(r7), SkPath::kCCW_Direction, true, true }, 1905 { r7, SK_ARRAY_COUNT(r7), SkPathPriv::kCCW_FirstDirection, true, true },
1905 { r8, SK_ARRAY_COUNT(r8), SkPath::kCCW_Direction, true, true }, 1906 { r8, SK_ARRAY_COUNT(r8), SkPathPriv::kCCW_FirstDirection, true, true },
1906 { r9, SK_ARRAY_COUNT(r9), SkPath::kCCW_Direction, true, true }, 1907 { r9, SK_ARRAY_COUNT(r9), SkPathPriv::kCCW_FirstDirection, true, true },
1907 { ra, SK_ARRAY_COUNT(ra), SkPath::kCCW_Direction, true, true }, 1908 { ra, SK_ARRAY_COUNT(ra), SkPathPriv::kCCW_FirstDirection, true, true },
1908 { rb, SK_ARRAY_COUNT(rb), SkPath::kCW_Direction, true, true }, 1909 { rb, SK_ARRAY_COUNT(rb), SkPathPriv::kCW_FirstDirection, true, true },
1909 { rc, SK_ARRAY_COUNT(rc), SkPath::kCW_Direction, true, true }, 1910 { rc, SK_ARRAY_COUNT(rc), SkPathPriv::kCW_FirstDirection, true, true },
1910 { rd, SK_ARRAY_COUNT(rd), SkPath::kCCW_Direction, true, true }, 1911 { rd, SK_ARRAY_COUNT(rd), SkPathPriv::kCCW_FirstDirection, true, true },
1911 { re, SK_ARRAY_COUNT(re), SkPath::kCW_Direction, true, true }, 1912 { re, SK_ARRAY_COUNT(re), SkPathPriv::kCW_FirstDirection, true, true },
1912 1913
1913 { f1, SK_ARRAY_COUNT(f1), SkPath::kUnknown_Direction, true, false }, 1914 { f1, SK_ARRAY_COUNT(f1), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1914 { f2, SK_ARRAY_COUNT(f2), SkPath::kUnknown_Direction, true, false }, 1915 { f2, SK_ARRAY_COUNT(f2), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1915 { f3, SK_ARRAY_COUNT(f3), SkPath::kUnknown_Direction, true, false }, 1916 { f3, SK_ARRAY_COUNT(f3), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1916 { f4, SK_ARRAY_COUNT(f4), SkPath::kUnknown_Direction, true, false }, 1917 { f4, SK_ARRAY_COUNT(f4), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1917 { f5, SK_ARRAY_COUNT(f5), SkPath::kUnknown_Direction, true, false }, 1918 { f5, SK_ARRAY_COUNT(f5), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1918 { f6, SK_ARRAY_COUNT(f6), SkPath::kUnknown_Direction, true, false }, 1919 { f6, SK_ARRAY_COUNT(f6), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1919 { f7, SK_ARRAY_COUNT(f7), SkPath::kUnknown_Direction, true, false }, 1920 { f7, SK_ARRAY_COUNT(f7), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1920 { f8, SK_ARRAY_COUNT(f8), SkPath::kUnknown_Direction, true, false }, 1921 { f8, SK_ARRAY_COUNT(f8), SkPathPriv::kUnknown_FirstDirection, true, fal se },
1921 1922
1922 { c1, SK_ARRAY_COUNT(c1), SkPath::kCW_Direction, false, true }, 1923 { c1, SK_ARRAY_COUNT(c1), SkPathPriv::kCW_FirstDirection, false, true },
1923 { c2, SK_ARRAY_COUNT(c2), SkPath::kCW_Direction, false, true }, 1924 { c2, SK_ARRAY_COUNT(c2), SkPathPriv::kCW_FirstDirection, false, true },
1924 }; 1925 };
1925 1926
1926 const size_t testCount = SK_ARRAY_COUNT(tests); 1927 const size_t testCount = SK_ARRAY_COUNT(tests);
1927 int index; 1928 int index;
1928 for (int rectFirst = 0; rectFirst <= 1; ++rectFirst) { 1929 for (int rectFirst = 0; rectFirst <= 1; ++rectFirst) {
1929 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { 1930 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) {
1930 SkPath path; 1931 SkPath path;
1931 if (rectFirst) { 1932 if (rectFirst) {
1932 path.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); 1933 path.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
1933 } 1934 }
1934 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints [0].fY); 1935 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints [0].fY);
1935 for (index = 1; index < tests[testIndex].fPointCount; ++index) { 1936 for (index = 1; index < tests[testIndex].fPointCount; ++index) {
1936 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex] .fPoints[index].fY); 1937 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex] .fPoints[index].fY);
1937 } 1938 }
1938 if (tests[testIndex].fClose) { 1939 if (tests[testIndex].fClose) {
1939 path.close(); 1940 path.close();
1940 } 1941 }
1941 if (!rectFirst) { 1942 if (!rectFirst) {
1942 path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); 1943 path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
1943 } 1944 }
1944 REPORTER_ASSERT(reporter, 1945 REPORTER_ASSERT(reporter,
1945 tests[testIndex].fIsNestedRect == path.isNestedFillRects(NUL L)); 1946 tests[testIndex].fIsNestedRect == path.isNestedFillRects(NUL L));
1946 if (tests[testIndex].fIsNestedRect) { 1947 if (tests[testIndex].fIsNestedRect) {
1947 SkRect expected[2], computed[2]; 1948 SkRect expected[2], computed[2];
1948 SkPath::Direction expectedDirs[2], computedDirs[2]; 1949 SkPathPriv::FirstDirection expectedDirs[2];
1950 SkPath::Direction computedDirs[2];
1949 SkRect testBounds; 1951 SkRect testBounds;
1950 testBounds.set(tests[testIndex].fPoints, tests[testIndex].fPoint Count); 1952 testBounds.set(tests[testIndex].fPoints, tests[testIndex].fPoint Count);
1951 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); 1953 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2);
1952 expected[1] = testBounds; 1954 expected[1] = testBounds;
1953 if (rectFirst) { 1955 if (rectFirst) {
1954 expectedDirs[0] = SkPath::kCW_Direction; 1956 expectedDirs[0] = SkPathPriv::kCW_FirstDirection;
1955 } else { 1957 } else {
1956 expectedDirs[0] = SkPath::kCCW_Direction; 1958 expectedDirs[0] = SkPathPriv::kCCW_FirstDirection;
1957 } 1959 }
1958 expectedDirs[1] = tests[testIndex].fDirection; 1960 expectedDirs[1] = tests[testIndex].fDirection;
1959 REPORTER_ASSERT(reporter, path.isNestedFillRects(computed, compu tedDirs)); 1961 REPORTER_ASSERT(reporter, path.isNestedFillRects(computed, compu tedDirs));
1960 REPORTER_ASSERT(reporter, expected[0] == computed[0]); 1962 REPORTER_ASSERT(reporter, expected[0] == computed[0]);
1961 REPORTER_ASSERT(reporter, expected[1] == computed[1]); 1963 REPORTER_ASSERT(reporter, expected[1] == computed[1]);
1962 REPORTER_ASSERT(reporter, expectedDirs[0] == computedDirs[0]); 1964 REPORTER_ASSERT(reporter, expectedDirs[0] == SkPathPriv::AsFirst Direction(computedDirs[0]));
1963 REPORTER_ASSERT(reporter, expectedDirs[1] == computedDirs[1]); 1965 REPORTER_ASSERT(reporter, expectedDirs[1] == SkPathPriv::AsFirst Direction(computedDirs[1]));
1964 } 1966 }
1965 } 1967 }
1966 1968
1967 // fail, close then line 1969 // fail, close then line
1968 SkPath path1; 1970 SkPath path1;
1969 if (rectFirst) { 1971 if (rectFirst) {
1970 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); 1972 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
1971 } 1973 }
1972 path1.moveTo(r1[0].fX, r1[0].fY); 1974 path1.moveTo(r1[0].fX, r1[0].fY);
1973 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { 1975 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 p.reset(); 2228 p.reset();
2227 p.addCircle(0, 0, 1, SkPath::kCW_Direction); 2229 p.addCircle(0, 0, 1, SkPath::kCW_Direction);
2228 2230
2229 { 2231 {
2230 SkMatrix matrix; 2232 SkMatrix matrix;
2231 matrix.reset(); 2233 matrix.reset();
2232 SkPath p1; 2234 SkPath p1;
2233 p1.moveTo(SkPoint::Make(0, 0)); 2235 p1.moveTo(SkPoint::Make(0, 0));
2234 2236
2235 p.transform(matrix, &p1); 2237 p.transform(matrix, &p1);
2236 REPORTER_ASSERT(reporter, p1.cheapIsDirection(SkPath::kCW_Direction)); 2238 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPr iv::kCW_FirstDirection));
2237 } 2239 }
2238 2240
2239 2241
2240 { 2242 {
2241 SkMatrix matrix; 2243 SkMatrix matrix;
2242 matrix.reset(); 2244 matrix.reset();
2243 matrix.setScaleX(-1); 2245 matrix.setScaleX(-1);
2244 SkPath p1; 2246 SkPath p1;
2245 p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path) 2247 p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path)
2246 2248
2247 p.transform(matrix, &p1); 2249 p.transform(matrix, &p1);
2248 REPORTER_ASSERT(reporter, p1.cheapIsDirection(SkPath::kCCW_Direction)); 2250 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPr iv::kCCW_FirstDirection));
2249 } 2251 }
2250 2252
2251 { 2253 {
2252 SkMatrix matrix; 2254 SkMatrix matrix;
2253 matrix.setAll(1, 1, 0, 1, 1, 0, 0, 0, 1); 2255 matrix.setAll(1, 1, 0, 1, 1, 0, 0, 0, 1);
2254 SkPath p1; 2256 SkPath p1;
2255 p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path) 2257 p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path)
2256 2258
2257 p.transform(matrix, &p1); 2259 p.transform(matrix, &p1);
2258 REPORTER_ASSERT(reporter, p1.cheapIsDirection(SkPath::kUnknown_Direction )); 2260 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPr iv::kUnknown_FirstDirection));
2259 } 2261 }
2260 } 2262 }
2261 2263
2262 static void test_zero_length_paths(skiatest::Reporter* reporter) { 2264 static void test_zero_length_paths(skiatest::Reporter* reporter) {
2263 SkPath p; 2265 SkPath p;
2264 uint8_t verbs[32]; 2266 uint8_t verbs[32];
2265 2267
2266 struct SUPPRESS_VISIBILITY_WARNING zeroPathTestData { 2268 struct SUPPRESS_VISIBILITY_WARNING zeroPathTestData {
2267 const char* testPath; 2269 const char* testPath;
2268 const size_t numResultPts; 2270 const size_t numResultPts;
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 } 2764 }
2763 } 2765 }
2764 REPORTER_ASSERT(reporter, numIterPts == numPoints); 2766 REPORTER_ASSERT(reporter, numIterPts == numPoints);
2765 REPORTER_ASSERT(reporter, numIterVerbs == numVerbs); 2767 REPORTER_ASSERT(reporter, numIterVerbs == numVerbs);
2766 } 2768 }
2767 } 2769 }
2768 2770
2769 static void check_for_circle(skiatest::Reporter* reporter, 2771 static void check_for_circle(skiatest::Reporter* reporter,
2770 const SkPath& path, 2772 const SkPath& path,
2771 bool expectedCircle, 2773 bool expectedCircle,
2772 SkPath::Direction expectedDir) { 2774 SkPathPriv::FirstDirection expectedDir) {
2773 SkRect rect = SkRect::MakeEmpty(); 2775 SkRect rect = SkRect::MakeEmpty();
2774 REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle); 2776 REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle);
2775 REPORTER_ASSERT(reporter, path.cheapIsDirection(expectedDir)); 2777 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, expectedDi r));
2776 2778
2777 if (expectedCircle) { 2779 if (expectedCircle) {
2778 REPORTER_ASSERT(reporter, rect.height() == rect.width()); 2780 REPORTER_ASSERT(reporter, rect.height() == rect.width());
2779 } 2781 }
2780 } 2782 }
2781 2783
2782 static void test_circle_skew(skiatest::Reporter* reporter, 2784 static void test_circle_skew(skiatest::Reporter* reporter,
2783 const SkPath& path, 2785 const SkPath& path,
2784 SkPath::Direction dir) { 2786 SkPathPriv::FirstDirection dir) {
2785 SkPath tmp; 2787 SkPath tmp;
2786 2788
2787 SkMatrix m; 2789 SkMatrix m;
2788 m.setSkew(SkIntToScalar(3), SkIntToScalar(5)); 2790 m.setSkew(SkIntToScalar(3), SkIntToScalar(5));
2789 path.transform(m, &tmp); 2791 path.transform(m, &tmp);
2790 // this matrix reverses the direction. 2792 // this matrix reverses the direction.
2791 if (SkPath::kCCW_Direction == dir) { 2793 if (SkPathPriv::kCCW_FirstDirection == dir) {
2792 dir = SkPath::kCW_Direction; 2794 dir = SkPathPriv::kCW_FirstDirection;
2793 } else { 2795 } else {
2794 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); 2796 REPORTER_ASSERT(reporter, SkPathPriv::kCW_FirstDirection == dir);
2795 dir = SkPath::kCCW_Direction; 2797 dir = SkPathPriv::kCCW_FirstDirection;
2796 } 2798 }
2797 check_for_circle(reporter, tmp, false, dir); 2799 check_for_circle(reporter, tmp, false, dir);
2798 } 2800 }
2799 2801
2800 static void test_circle_translate(skiatest::Reporter* reporter, 2802 static void test_circle_translate(skiatest::Reporter* reporter,
2801 const SkPath& path, 2803 const SkPath& path,
2802 SkPath::Direction dir) { 2804 SkPathPriv::FirstDirection dir) {
2803 SkPath tmp; 2805 SkPath tmp;
2804 2806
2805 // translate at small offset 2807 // translate at small offset
2806 SkMatrix m; 2808 SkMatrix m;
2807 m.setTranslate(SkIntToScalar(15), SkIntToScalar(15)); 2809 m.setTranslate(SkIntToScalar(15), SkIntToScalar(15));
2808 path.transform(m, &tmp); 2810 path.transform(m, &tmp);
2809 check_for_circle(reporter, tmp, true, dir); 2811 check_for_circle(reporter, tmp, true, dir);
2810 2812
2811 tmp.reset(); 2813 tmp.reset();
2812 m.reset(); 2814 m.reset();
2813 2815
2814 // translate at a relatively big offset 2816 // translate at a relatively big offset
2815 m.setTranslate(SkIntToScalar(1000), SkIntToScalar(1000)); 2817 m.setTranslate(SkIntToScalar(1000), SkIntToScalar(1000));
2816 path.transform(m, &tmp); 2818 path.transform(m, &tmp);
2817 check_for_circle(reporter, tmp, true, dir); 2819 check_for_circle(reporter, tmp, true, dir);
2818 } 2820 }
2819 2821
2820 static void test_circle_rotate(skiatest::Reporter* reporter, 2822 static void test_circle_rotate(skiatest::Reporter* reporter,
2821 const SkPath& path, 2823 const SkPath& path,
2822 SkPath::Direction dir) { 2824 SkPathPriv::FirstDirection dir) {
2823 for (int angle = 0; angle < 360; ++angle) { 2825 for (int angle = 0; angle < 360; ++angle) {
2824 SkPath tmp; 2826 SkPath tmp;
2825 SkMatrix m; 2827 SkMatrix m;
2826 m.setRotate(SkIntToScalar(angle)); 2828 m.setRotate(SkIntToScalar(angle));
2827 path.transform(m, &tmp); 2829 path.transform(m, &tmp);
2828 2830
2829 // TODO: a rotated circle whose rotated angle is not a multiple of 90 2831 // TODO: a rotated circle whose rotated angle is not a multiple of 90
2830 // degrees is not an oval anymore, this can be improved. we made this 2832 // degrees is not an oval anymore, this can be improved. we made this
2831 // for the simplicity of our implementation. 2833 // for the simplicity of our implementation.
2832 if (angle % 90 == 0) { 2834 if (angle % 90 == 0) {
2833 check_for_circle(reporter, tmp, true, dir); 2835 check_for_circle(reporter, tmp, true, dir);
2834 } else { 2836 } else {
2835 check_for_circle(reporter, tmp, false, dir); 2837 check_for_circle(reporter, tmp, false, dir);
2836 } 2838 }
2837 } 2839 }
2838 } 2840 }
2839 2841
2840 static void test_circle_mirror_x(skiatest::Reporter* reporter, 2842 static void test_circle_mirror_x(skiatest::Reporter* reporter,
2841 const SkPath& path, 2843 const SkPath& path,
2842 SkPath::Direction dir) { 2844 SkPathPriv::FirstDirection dir) {
2843 SkPath tmp; 2845 SkPath tmp;
2844 SkMatrix m; 2846 SkMatrix m;
2845 m.reset(); 2847 m.reset();
2846 m.setScaleX(-SK_Scalar1); 2848 m.setScaleX(-SK_Scalar1);
2847 path.transform(m, &tmp); 2849 path.transform(m, &tmp);
2848 2850
2849 if (SkPath::kCW_Direction == dir) { 2851 if (SkPathPriv::kCW_FirstDirection == dir) {
2850 dir = SkPath::kCCW_Direction; 2852 dir = SkPathPriv::kCCW_FirstDirection;
2851 } else { 2853 } else {
2852 REPORTER_ASSERT(reporter, SkPath::kCCW_Direction == dir); 2854 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
2853 dir = SkPath::kCW_Direction; 2855 dir = SkPathPriv::kCW_FirstDirection;
2854 } 2856 }
2855 2857
2856 check_for_circle(reporter, tmp, true, dir); 2858 check_for_circle(reporter, tmp, true, dir);
2857 } 2859 }
2858 2860
2859 static void test_circle_mirror_y(skiatest::Reporter* reporter, 2861 static void test_circle_mirror_y(skiatest::Reporter* reporter,
2860 const SkPath& path, 2862 const SkPath& path,
2861 SkPath::Direction dir) { 2863 SkPathPriv::FirstDirection dir) {
2862 SkPath tmp; 2864 SkPath tmp;
2863 SkMatrix m; 2865 SkMatrix m;
2864 m.reset(); 2866 m.reset();
2865 m.setScaleY(-SK_Scalar1); 2867 m.setScaleY(-SK_Scalar1);
2866 path.transform(m, &tmp); 2868 path.transform(m, &tmp);
2867 2869
2868 if (SkPath::kCW_Direction == dir) { 2870 if (SkPathPriv::kCW_FirstDirection == dir) {
2869 dir = SkPath::kCCW_Direction; 2871 dir = SkPathPriv::kCCW_FirstDirection;
2870 } else { 2872 } else {
2871 REPORTER_ASSERT(reporter, SkPath::kCCW_Direction == dir); 2873 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
2872 dir = SkPath::kCW_Direction; 2874 dir = SkPathPriv::kCW_FirstDirection;
2873 } 2875 }
2874 2876
2875 check_for_circle(reporter, tmp, true, dir); 2877 check_for_circle(reporter, tmp, true, dir);
2876 } 2878 }
2877 2879
2878 static void test_circle_mirror_xy(skiatest::Reporter* reporter, 2880 static void test_circle_mirror_xy(skiatest::Reporter* reporter,
2879 const SkPath& path, 2881 const SkPath& path,
2880 SkPath::Direction dir) { 2882 SkPathPriv::FirstDirection dir) {
2881 SkPath tmp; 2883 SkPath tmp;
2882 SkMatrix m; 2884 SkMatrix m;
2883 m.reset(); 2885 m.reset();
2884 m.setScaleX(-SK_Scalar1); 2886 m.setScaleX(-SK_Scalar1);
2885 m.setScaleY(-SK_Scalar1); 2887 m.setScaleY(-SK_Scalar1);
2886 path.transform(m, &tmp); 2888 path.transform(m, &tmp);
2887 2889
2888 check_for_circle(reporter, tmp, true, dir); 2890 check_for_circle(reporter, tmp, true, dir);
2889 } 2891 }
2890 2892
2891 static void test_circle_with_direction(skiatest::Reporter* reporter, 2893 static void test_circle_with_direction(skiatest::Reporter* reporter,
2892 SkPath::Direction dir) { 2894 SkPath::Direction inDir) {
2895 const SkPathPriv::FirstDirection dir = SkPathPriv::AsFirstDirection(inDir);
2893 SkPath path; 2896 SkPath path;
2894 2897
2895 // circle at origin 2898 // circle at origin
2896 path.addCircle(0, 0, SkIntToScalar(20), dir); 2899 path.addCircle(0, 0, SkIntToScalar(20), inDir);
2900
2897 check_for_circle(reporter, path, true, dir); 2901 check_for_circle(reporter, path, true, dir);
2898 test_circle_rotate(reporter, path, dir); 2902 test_circle_rotate(reporter, path, dir);
2899 test_circle_translate(reporter, path, dir); 2903 test_circle_translate(reporter, path, dir);
2900 test_circle_skew(reporter, path, dir); 2904 test_circle_skew(reporter, path, dir);
2901 2905
2902 // circle at an offset at (10, 10) 2906 // circle at an offset at (10, 10)
2903 path.reset(); 2907 path.reset();
2904 path.addCircle(SkIntToScalar(10), SkIntToScalar(10), 2908 path.addCircle(SkIntToScalar(10), SkIntToScalar(10),
2905 SkIntToScalar(20), dir); 2909 SkIntToScalar(20), inDir);
2910
2906 check_for_circle(reporter, path, true, dir); 2911 check_for_circle(reporter, path, true, dir);
2907 test_circle_rotate(reporter, path, dir); 2912 test_circle_rotate(reporter, path, dir);
2908 test_circle_translate(reporter, path, dir); 2913 test_circle_translate(reporter, path, dir);
2909 test_circle_skew(reporter, path, dir); 2914 test_circle_skew(reporter, path, dir);
2910 test_circle_mirror_x(reporter, path, dir); 2915 test_circle_mirror_x(reporter, path, dir);
2911 test_circle_mirror_y(reporter, path, dir); 2916 test_circle_mirror_y(reporter, path, dir);
2912 test_circle_mirror_xy(reporter, path, dir); 2917 test_circle_mirror_xy(reporter, path, dir);
2913 } 2918 }
2914 2919
2915 static void test_circle_with_add_paths(skiatest::Reporter* reporter) { 2920 static void test_circle_with_add_paths(skiatest::Reporter* reporter) {
2916 SkPath path; 2921 SkPath path;
2917 SkPath circle; 2922 SkPath circle;
2918 SkPath rect; 2923 SkPath rect;
2919 SkPath empty; 2924 SkPath empty;
2920 2925
2921 static const SkPath::Direction kCircleDir = SkPath::kCW_Direction; 2926 const SkPath::Direction kCircleDir = SkPath::kCW_Direction;
2922 static const SkPath::Direction kCircleDirOpposite = SkPath::kCCW_Direction; 2927 const SkPath::Direction kCircleDirOpposite = SkPath::kCCW_Direction;
2923 2928
2924 circle.addCircle(0, 0, SkIntToScalar(10), kCircleDir); 2929 circle.addCircle(0, 0, SkIntToScalar(10), kCircleDir);
2925 rect.addRect(SkIntToScalar(5), SkIntToScalar(5), 2930 rect.addRect(SkIntToScalar(5), SkIntToScalar(5),
2926 SkIntToScalar(20), SkIntToScalar(20), SkPath::kCW_Direction); 2931 SkIntToScalar(20), SkIntToScalar(20), SkPath::kCW_Direction);
2927 2932
2928 SkMatrix translate; 2933 SkMatrix translate;
2929 translate.setTranslate(SkIntToScalar(12), SkIntToScalar(12)); 2934 translate.setTranslate(SkIntToScalar(12), SkIntToScalar(12));
2930 2935
2931 // Although all the path concatenation related operations leave 2936 // Although all the path concatenation related operations leave
2932 // the path a circle, most mark it as a non-circle for simplicity 2937 // the path a circle, most mark it as a non-circle for simplicity
2933 2938
2934 // empty + circle (translate) 2939 // empty + circle (translate)
2935 path = empty; 2940 path = empty;
2936 path.addPath(circle, translate); 2941 path.addPath(circle, translate);
2937 check_for_circle(reporter, path, false, kCircleDir); 2942 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircle Dir));
2938 2943
2939 // circle + empty (translate) 2944 // circle + empty (translate)
2940 path = circle; 2945 path = circle;
2941 path.addPath(empty, translate); 2946 path.addPath(empty, translate);
2942 check_for_circle(reporter, path, true, kCircleDir); 2947 check_for_circle(reporter, path, true, SkPathPriv::AsFirstDirection(kCircleD ir));
2943 2948
2944 // test reverseAddPath 2949 // test reverseAddPath
2945 path = circle; 2950 path = circle;
2946 path.reverseAddPath(rect); 2951 path.reverseAddPath(rect);
2947 check_for_circle(reporter, path, false, kCircleDirOpposite); 2952 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircle DirOpposite));
2948 } 2953 }
2949 2954
2950 static void test_circle(skiatest::Reporter* reporter) { 2955 static void test_circle(skiatest::Reporter* reporter) {
2951 test_circle_with_direction(reporter, SkPath::kCW_Direction); 2956 test_circle_with_direction(reporter, SkPath::kCW_Direction);
2952 test_circle_with_direction(reporter, SkPath::kCCW_Direction); 2957 test_circle_with_direction(reporter, SkPath::kCCW_Direction);
2953 2958
2954 // multiple addCircle() 2959 // multiple addCircle()
2955 SkPath path; 2960 SkPath path;
2956 path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction); 2961 path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction);
2957 path.addCircle(0, 0, SkIntToScalar(20), SkPath::kCW_Direction); 2962 path.addCircle(0, 0, SkIntToScalar(20), SkPath::kCW_Direction);
2958 check_for_circle(reporter, path, false, SkPath::kCW_Direction); 2963 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
2959 2964
2960 // some extra lineTo() would make isOval() fail 2965 // some extra lineTo() would make isOval() fail
2961 path.reset(); 2966 path.reset();
2962 path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction); 2967 path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction);
2963 path.lineTo(0, 0); 2968 path.lineTo(0, 0);
2964 check_for_circle(reporter, path, false, SkPath::kCW_Direction); 2969 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
2965 2970
2966 // not back to the original point 2971 // not back to the original point
2967 path.reset(); 2972 path.reset();
2968 path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction); 2973 path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction);
2969 path.setLastPt(SkIntToScalar(5), SkIntToScalar(5)); 2974 path.setLastPt(SkIntToScalar(5), SkIntToScalar(5));
2970 check_for_circle(reporter, path, false, SkPath::kCW_Direction); 2975 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
2971 2976
2972 test_circle_with_add_paths(reporter); 2977 test_circle_with_add_paths(reporter);
2973 2978
2974 // test negative radius 2979 // test negative radius
2975 path.reset(); 2980 path.reset();
2976 path.addCircle(0, 0, -1, SkPath::kCW_Direction); 2981 path.addCircle(0, 0, -1, SkPath::kCW_Direction);
2977 REPORTER_ASSERT(reporter, path.isEmpty()); 2982 REPORTER_ASSERT(reporter, path.isEmpty());
2978 } 2983 }
2979 2984
2980 static void test_oval(skiatest::Reporter* reporter) { 2985 static void test_oval(skiatest::Reporter* reporter) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 REPORTER_ASSERT(reporter, p.isConvex()); 3047 REPORTER_ASSERT(reporter, p.isConvex());
3043 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType); 3048 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType);
3044 REPORTER_ASSERT(reporter, !p.isInverseFillType()); 3049 REPORTER_ASSERT(reporter, !p.isInverseFillType());
3045 REPORTER_ASSERT(reporter, p == empty); 3050 REPORTER_ASSERT(reporter, p == empty);
3046 REPORTER_ASSERT(reporter, !(p != empty)); 3051 REPORTER_ASSERT(reporter, !(p != empty));
3047 } 3052 }
3048 3053
3049 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path, 3054 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path,
3050 SkPath::Direction dir) { 3055 SkPath::Direction dir) {
3051 REPORTER_ASSERT(reporter, path->isConvex()); 3056 REPORTER_ASSERT(reporter, path->isConvex());
3052 REPORTER_ASSERT(reporter, path->cheapIsDirection(dir)); 3057 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPri v::AsFirstDirection(dir)));
3053 path->setConvexity(SkPath::kUnknown_Convexity); 3058 path->setConvexity(SkPath::kUnknown_Convexity);
3054 REPORTER_ASSERT(reporter, path->isConvex()); 3059 REPORTER_ASSERT(reporter, path->isConvex());
3055 path->reset(); 3060 path->reset();
3056 } 3061 }
3057 3062
3058 static void test_rrect_convexity_is_unknown(skiatest::Reporter* reporter, SkPath * path, 3063 static void test_rrect_convexity_is_unknown(skiatest::Reporter* reporter, SkPath * path,
3059 SkPath::Direction dir) { 3064 SkPath::Direction dir) {
3060 REPORTER_ASSERT(reporter, path->isConvex()); 3065 REPORTER_ASSERT(reporter, path->isConvex());
3061 REPORTER_ASSERT(reporter, path->cheapIsDirection(dir)); 3066 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPri v::AsFirstDirection(dir)));
3062 path->setConvexity(SkPath::kUnknown_Convexity); 3067 path->setConvexity(SkPath::kUnknown_Convexity);
3063 REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kUnknown_Convexity ); 3068 REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kUnknown_Convexity );
3064 path->reset(); 3069 path->reset();
3065 } 3070 }
3066 3071
3067 static void test_rrect(skiatest::Reporter* reporter) { 3072 static void test_rrect(skiatest::Reporter* reporter) {
3068 SkPath p; 3073 SkPath p;
3069 SkRRect rr; 3074 SkRRect rr;
3070 SkVector radii[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; 3075 SkVector radii[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
3071 SkRect r = {10, 20, 30, 40}; 3076 SkRect r = {10, 20, 30, 40};
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 p.addArc(oval, 1, 360); 3152 p.addArc(oval, 1, 360);
3148 REPORTER_ASSERT(reporter, p == cwOval); 3153 REPORTER_ASSERT(reporter, p == cwOval);
3149 p.reset(); 3154 p.reset();
3150 SkPath ccwOval; 3155 SkPath ccwOval;
3151 ccwOval.addOval(oval, SkPath::kCCW_Direction); 3156 ccwOval.addOval(oval, SkPath::kCCW_Direction);
3152 p.addArc(oval, 1, -360); 3157 p.addArc(oval, 1, -360);
3153 REPORTER_ASSERT(reporter, p == ccwOval); 3158 REPORTER_ASSERT(reporter, p == ccwOval);
3154 p.reset(); 3159 p.reset();
3155 p.addArc(oval, 1, 180); 3160 p.addArc(oval, 1, 180);
3156 REPORTER_ASSERT(reporter, p.isConvex()); 3161 REPORTER_ASSERT(reporter, p.isConvex());
3157 REPORTER_ASSERT(reporter, p.cheapIsDirection(SkPath::kCW_Direction)); 3162 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::k CW_FirstDirection));
3158 p.setConvexity(SkPath::kUnknown_Convexity); 3163 p.setConvexity(SkPath::kUnknown_Convexity);
3159 REPORTER_ASSERT(reporter, p.isConvex()); 3164 REPORTER_ASSERT(reporter, p.isConvex());
3160 } 3165 }
3161 3166
3162 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter, 3167 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3163 SkScalar x0, SkScalar y0) { 3168 SkScalar x0, SkScalar y0) {
3164 SkPoint pts[4]; 3169 SkPoint pts[4];
3165 SkPath::Verb v = iter->next(pts); 3170 SkPath::Verb v = iter->next(pts);
3166 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb); 3171 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb);
3167 REPORTER_ASSERT(reporter, pts[0].fX == x0); 3172 REPORTER_ASSERT(reporter, pts[0].fX == x0);
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 test_get_point(reporter); 3778 test_get_point(reporter);
3774 test_contains(reporter); 3779 test_contains(reporter);
3775 PathTest_Private::TestPathTo(reporter); 3780 PathTest_Private::TestPathTo(reporter);
3776 PathRefTest_Private::TestPathRef(reporter); 3781 PathRefTest_Private::TestPathRef(reporter);
3777 test_dump(reporter); 3782 test_dump(reporter);
3778 test_path_crbug389050(reporter); 3783 test_path_crbug389050(reporter);
3779 test_path_crbugskia2820(reporter); 3784 test_path_crbugskia2820(reporter);
3780 test_skbug_3469(reporter); 3785 test_skbug_3469(reporter);
3781 test_skbug_3239(reporter); 3786 test_skbug_3239(reporter);
3782 } 3787 }
OLDNEW
« src/core/SkPathPriv.h ('K') | « src/pathops/SkOpBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698