| OLD | NEW |
| 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 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
| 11 #include "SkErrorInternals.h" | 11 #include "SkErrorInternals.h" |
| 12 #include "SkMath.h" | 12 #include "SkMath.h" |
| 13 #include "SkPath.h" | 13 #include "SkPath.h" |
| 14 #include "SkPathRef.h" | 14 #include "SkPathRef.h" |
| 15 #include "SkRRect.h" | 15 #include "SkRRect.h" |
| 16 #include "SkThread.h" | 16 #include "SkThread.h" |
| 17 | 17 |
| 18 SK_DEFINE_INST_COUNT(SkPath); | 18 SK_DEFINE_INST_COUNT(SkPath); |
| 19 | 19 |
| 20 #define SK_IGNORE_QUAD_RR_CORNERS_OPT 1 | |
| 21 | |
| 22 // This value is just made-up for now. When count is 4, calling memset was much | 20 // This value is just made-up for now. When count is 4, calling memset was much |
| 23 // slower than just writing the loop. This seems odd, and hopefully in the | 21 // slower than just writing the loop. This seems odd, and hopefully in the |
| 24 // future this we appear to have been a fluke... | 22 // future this we appear to have been a fluke... |
| 25 #define MIN_COUNT_FOR_MEMSET_TO_BE_FAST 16 | 23 #define MIN_COUNT_FOR_MEMSET_TO_BE_FAST 16 |
| 26 | 24 |
| 27 //////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////// |
| 28 | 26 |
| 29 /** | 27 /** |
| 30 * Path.bounds is defined to be the bounds of all the control points. | 28 * Path.bounds is defined to be the bounds of all the control points. |
| 31 * If we called bounds.join(r) we would skip r if r was empty, which breaks | 29 * If we called bounds.join(r) we would skip r if r was empty, which breaks |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 matrix.postTranslate(oval.centerX(), oval.centerY()); | 957 matrix.postTranslate(oval.centerX(), oval.centerY()); |
| 960 | 958 |
| 961 return SkBuildQuadArc(start, stop, | 959 return SkBuildQuadArc(start, stop, |
| 962 sweepAngle > 0 ? kCW_SkRotationDirection : | 960 sweepAngle > 0 ? kCW_SkRotationDirection : |
| 963 kCCW_SkRotationDirection, | 961 kCCW_SkRotationDirection, |
| 964 &matrix, pts); | 962 &matrix, pts); |
| 965 } | 963 } |
| 966 | 964 |
| 967 static void add_corner_arc(SkPath* path, const SkRect& rect, | 965 static void add_corner_arc(SkPath* path, const SkRect& rect, |
| 968 SkScalar rx, SkScalar ry, int startAngle, | 966 SkScalar rx, SkScalar ry, int startAngle, |
| 969 SkPath::Direction dir, bool addArcTo, | 967 SkPath::Direction dir, bool forceMoveTo) { |
| 970 bool forceMoveTo = false) { | |
| 971 // These two asserts are not sufficient, since really we want to know | 968 // These two asserts are not sufficient, since really we want to know |
| 972 // that the pair of radii (e.g. left and right, or top and bottom) sum | 969 // that the pair of radii (e.g. left and right, or top and bottom) sum |
| 973 // to <= dimension, but we don't have that data here, so we just have | 970 // to <= dimension, but we don't have that data here, so we just have |
| 974 // these conservative asserts. | 971 // these conservative asserts. |
| 975 SkASSERT(0 <= rx && rx <= rect.width()); | 972 SkASSERT(0 <= rx && rx <= rect.width()); |
| 976 SkASSERT(0 <= ry && ry <= rect.height()); | 973 SkASSERT(0 <= ry && ry <= rect.height()); |
| 977 | 974 |
| 978 SkRect r; | 975 SkRect r; |
| 979 r.set(-rx, -ry, rx, ry); | 976 r.set(-rx, -ry, rx, ry); |
| 980 | 977 |
| 981 switch (startAngle) { | 978 switch (startAngle) { |
| 982 case 0: | 979 case 0: |
| 983 r.offset(rect.fRight - r.fRight, rect.fBottom - r.fBottom); | 980 r.offset(rect.fRight - r.fRight, rect.fBottom - r.fBottom); |
| 984 break; | 981 break; |
| 985 case 90: | 982 case 90: |
| 986 r.offset(rect.fLeft - r.fLeft, rect.fBottom - r.fBottom); | 983 r.offset(rect.fLeft - r.fLeft, rect.fBottom - r.fBottom); |
| 987 break; | 984 break; |
| 988 case 180: r.offset(rect.fLeft - r.fLeft, rect.fTop - r.fTop); break; | 985 case 180: r.offset(rect.fLeft - r.fLeft, rect.fTop - r.fTop); break; |
| 989 case 270: r.offset(rect.fRight - r.fRight, rect.fTop - r.fTop); break; | 986 case 270: r.offset(rect.fRight - r.fRight, rect.fTop - r.fTop); break; |
| 990 default: SkDEBUGFAIL("unexpected startAngle in add_corner_arc"); | 987 default: SkDEBUGFAIL("unexpected startAngle in add_corner_arc"); |
| 991 } | 988 } |
| 992 | 989 |
| 993 SkScalar start = SkIntToScalar(startAngle); | 990 SkScalar start = SkIntToScalar(startAngle); |
| 994 SkScalar sweep = SkIntToScalar(90); | 991 SkScalar sweep = SkIntToScalar(90); |
| 995 if (SkPath::kCCW_Direction == dir) { | 992 if (SkPath::kCCW_Direction == dir) { |
| 996 start += sweep; | 993 start += sweep; |
| 997 sweep = -sweep; | 994 sweep = -sweep; |
| 998 } | 995 } |
| 999 | 996 |
| 1000 if (addArcTo) { | 997 path->arcTo(r, start, sweep, forceMoveTo); |
| 1001 path->arcTo(r, start, sweep, forceMoveTo); | |
| 1002 } else { | |
| 1003 SkPoint pts[kSkBuildQuadArcStorage]; | |
| 1004 int count = build_arc_points(r, start, sweep, pts); | |
| 1005 for (int i = 1; i < count; i += 2) { | |
| 1006 path->quadTo(pts[i], pts[i+1]); | |
| 1007 } | |
| 1008 } | |
| 1009 } | 998 } |
| 1010 | 999 |
| 1011 void SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[], | 1000 void SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[], |
| 1012 Direction dir) { | 1001 Direction dir) { |
| 1013 SkRRect rrect; | 1002 SkRRect rrect; |
| 1014 rrect.setRectRadii(rect, (const SkVector*) radii); | 1003 rrect.setRectRadii(rect, (const SkVector*) radii); |
| 1015 this->addRRect(rrect, dir); | 1004 this->addRRect(rrect, dir); |
| 1016 } | 1005 } |
| 1017 | 1006 |
| 1018 void SkPath::addRRect(const SkRRect& rrect, Direction dir) { | 1007 void SkPath::addRRect(const SkRRect& rrect, Direction dir) { |
| 1019 assert_known_direction(dir); | 1008 assert_known_direction(dir); |
| 1020 | 1009 |
| 1021 if (rrect.isEmpty()) { | 1010 if (rrect.isEmpty()) { |
| 1022 return; | 1011 return; |
| 1023 } | 1012 } |
| 1024 | 1013 |
| 1025 const SkRect& bounds = rrect.getBounds(); | 1014 const SkRect& bounds = rrect.getBounds(); |
| 1026 | 1015 |
| 1027 if (rrect.isRect()) { | 1016 if (rrect.isRect()) { |
| 1028 this->addRect(bounds, dir); | 1017 this->addRect(bounds, dir); |
| 1029 } else if (rrect.isOval()) { | 1018 } else if (rrect.isOval()) { |
| 1030 this->addOval(bounds, dir); | 1019 this->addOval(bounds, dir); |
| 1031 } else if (rrect.isSimple()) { | 1020 } else if (rrect.isSimple()) { |
| 1032 const SkVector& rad = rrect.getSimpleRadii(); | 1021 const SkVector& rad = rrect.getSimpleRadii(); |
| 1033 this->addRoundRect(bounds, rad.x(), rad.y(), dir); | 1022 this->addRoundRect(bounds, rad.x(), rad.y(), dir); |
| 1034 } else { | 1023 } else { |
| 1035 SkAutoPathBoundsUpdate apbu(this, bounds); | 1024 SkAutoPathBoundsUpdate apbu(this, bounds); |
| 1036 | 1025 |
| 1037 if (kCW_Direction == dir) { | 1026 if (kCW_Direction == dir) { |
| 1038 add_corner_arc(this, bounds, rrect.fRadii[0].fX, rrect.fRadii[0].fY,
180, dir, true, true); | 1027 add_corner_arc(this, bounds, rrect.fRadii[0].fX, rrect.fRadii[0].fY,
180, dir, true); |
| 1039 add_corner_arc(this, bounds, rrect.fRadii[1].fX, rrect.fRadii[1].fY,
270, dir, true); | 1028 add_corner_arc(this, bounds, rrect.fRadii[1].fX, rrect.fRadii[1].fY,
270, dir, false); |
| 1040 add_corner_arc(this, bounds, rrect.fRadii[2].fX, rrect.fRadii[2].fY,
0, dir, true); | 1029 add_corner_arc(this, bounds, rrect.fRadii[2].fX, rrect.fRadii[2].fY,
0, dir, false); |
| 1041 add_corner_arc(this, bounds, rrect.fRadii[3].fX, rrect.fRadii[3].fY,
90, dir, true); | 1030 add_corner_arc(this, bounds, rrect.fRadii[3].fX, rrect.fRadii[3].fY,
90, dir, false); |
| 1042 } else { | 1031 } else { |
| 1043 add_corner_arc(this, bounds, rrect.fRadii[0].fX, rrect.fRadii[0].fY,
180, dir, true, true); | 1032 add_corner_arc(this, bounds, rrect.fRadii[0].fX, rrect.fRadii[0].fY,
180, dir, true); |
| 1044 add_corner_arc(this, bounds, rrect.fRadii[3].fX, rrect.fRadii[3].fY,
90, dir, true); | 1033 add_corner_arc(this, bounds, rrect.fRadii[3].fX, rrect.fRadii[3].fY,
90, dir, false); |
| 1045 add_corner_arc(this, bounds, rrect.fRadii[2].fX, rrect.fRadii[2].fY,
0, dir, true); | 1034 add_corner_arc(this, bounds, rrect.fRadii[2].fX, rrect.fRadii[2].fY,
0, dir, false); |
| 1046 add_corner_arc(this, bounds, rrect.fRadii[1].fX, rrect.fRadii[1].fY,
270, dir, true); | 1035 add_corner_arc(this, bounds, rrect.fRadii[1].fX, rrect.fRadii[1].fY,
270, dir, false); |
| 1047 } | 1036 } |
| 1048 this->close(); | 1037 this->close(); |
| 1049 } | 1038 } |
| 1050 } | 1039 } |
| 1051 | 1040 |
| 1052 bool SkPath::hasOnlyMoveTos() const { | 1041 bool SkPath::hasOnlyMoveTos() const { |
| 1053 int count = fPathRef->countVerbs(); | 1042 int count = fPathRef->countVerbs(); |
| 1054 const uint8_t* verbs = const_cast<const SkPathRef*>(fPathRef.get())->verbsMe
mBegin(); | 1043 const uint8_t* verbs = const_cast<const SkPathRef*>(fPathRef.get())->verbsMe
mBegin(); |
| 1055 for (int i = 0; i < count; ++i) { | 1044 for (int i = 0; i < count; ++i) { |
| 1056 if (*verbs == kLine_Verb || | 1045 if (*verbs == kLine_Verb || |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 } else if (skip_vert) { | 1095 } else if (skip_vert) { |
| 1107 ry = halfH; | 1096 ry = halfH; |
| 1108 } | 1097 } |
| 1109 | 1098 |
| 1110 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1099 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1111 SkScalar sx = SkScalarMul(rx, CUBIC_ARC_FACTOR); | 1100 SkScalar sx = SkScalarMul(rx, CUBIC_ARC_FACTOR); |
| 1112 SkScalar sy = SkScalarMul(ry, CUBIC_ARC_FACTOR); | 1101 SkScalar sy = SkScalarMul(ry, CUBIC_ARC_FACTOR); |
| 1113 | 1102 |
| 1114 this->incReserve(17); | 1103 this->incReserve(17); |
| 1115 #else | 1104 #else |
| 1116 this->incReserve(13); | 1105 // Please see SkBuildQuadArc for more information but, we need to pull |
| 1106 // the off-curve quadratic points in a little bit to make the round |
| 1107 // rects convex. |
| 1108 static const SkScalar kOffCurveEpsilon = 0.0001f; |
| 1109 |
| 1110 SkScalar midPtX = rx * SK_ScalarRoot2Over2; |
| 1111 SkScalar midPtY = ry * SK_ScalarRoot2Over2; |
| 1112 |
| 1113 SkScalar offPtX = rx * SK_ScalarTanPIOver8 - kOffCurveEpsilon; |
| 1114 SkScalar offPtY = ry * SK_ScalarTanPIOver8 - kOffCurveEpsilon; |
| 1115 |
| 1116 this->incReserve(21); |
| 1117 #endif | 1117 #endif |
| 1118 this->moveTo(rect.fRight - rx, rect.fTop); | 1118 this->moveTo(rect.fRight - rx, rect.fTop); // top-right |
| 1119 if (dir == kCCW_Direction) { | 1119 if (dir == kCCW_Direction) { |
| 1120 if (!skip_hori) { | 1120 if (!skip_hori) { |
| 1121 this->lineTo(rect.fLeft + rx, rect.fTop); // top | 1121 this->lineTo(rect.fLeft + rx, rect.fTop); // top |
| 1122 } | 1122 } |
| 1123 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1123 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1124 this->cubicTo(rect.fLeft + rx - sx, rect.fTop, | 1124 this->cubicTo(rect.fLeft + rx - sx, rect.fTop, |
| 1125 rect.fLeft, rect.fTop + ry - sy, | 1125 rect.fLeft, rect.fTop + ry - sy, |
| 1126 rect.fLeft, rect.fTop + ry); // top-left | 1126 rect.fLeft, rect.fTop + ry); // top-left |
| 1127 #else | 1127 #else |
| 1128 add_corner_arc(this, rect, rx, ry, 180, dir, false); // top-left | 1128 this->quadTo(rect.fLeft + rx - offPtX, rect.fTop + kOffCurveEpsilon, |
| 1129 rect.fLeft + rx - midPtX, rect.fTop + ry - midPtY); |
| 1130 this->quadTo(rect.fLeft + kOffCurveEpsilon, rect.fTop + ry - offPtY, |
| 1131 rect.fLeft, rect.fTop + ry); |
| 1129 #endif | 1132 #endif |
| 1130 if (!skip_vert) { | 1133 if (!skip_vert) { |
| 1131 this->lineTo(rect.fLeft, rect.fBottom - ry); // left | 1134 this->lineTo(rect.fLeft, rect.fBottom - ry); // left |
| 1132 } | 1135 } |
| 1133 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1136 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1134 this->cubicTo(rect.fLeft, rect.fBottom - ry + sy, | 1137 this->cubicTo(rect.fLeft, rect.fBottom - ry + sy, |
| 1135 rect.fLeft + rx - sx, rect.fBottom, | 1138 rect.fLeft + rx - sx, rect.fBottom, |
| 1136 rect.fLeft + rx, rect.fBottom); // bot-left | 1139 rect.fLeft + rx, rect.fBottom); // bot-left |
| 1137 #else | 1140 #else |
| 1138 add_corner_arc(this, rect, rx, ry, 90, dir, false); // bot-left | 1141 this->quadTo(rect.fLeft + kOffCurveEpsilon, rect.fBottom - ry + offPtY, |
| 1142 rect.fLeft + rx - midPtX, rect.fBottom - ry + midPtY); |
| 1143 this->quadTo(rect.fLeft + rx - offPtX, rect.fBottom - kOffCurveEpsilon, |
| 1144 rect.fLeft + rx, rect.fBottom); |
| 1139 #endif | 1145 #endif |
| 1140 if (!skip_hori) { | 1146 if (!skip_hori) { |
| 1141 this->lineTo(rect.fRight - rx, rect.fBottom); // bottom | 1147 this->lineTo(rect.fRight - rx, rect.fBottom); // bottom |
| 1142 } | 1148 } |
| 1143 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1149 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1144 this->cubicTo(rect.fRight - rx + sx, rect.fBottom, | 1150 this->cubicTo(rect.fRight - rx + sx, rect.fBottom, |
| 1145 rect.fRight, rect.fBottom - ry + sy, | 1151 rect.fRight, rect.fBottom - ry + sy, |
| 1146 rect.fRight, rect.fBottom - ry); // bot-right | 1152 rect.fRight, rect.fBottom - ry); // bot-right |
| 1147 #else | 1153 #else |
| 1148 add_corner_arc(this, rect, rx, ry, 0, dir, false); // bot-right | 1154 this->quadTo(rect.fRight - rx + offPtX, rect.fBottom - kOffCurveEpsilon, |
| 1155 rect.fRight - rx + midPtX, rect.fBottom - ry + midPtY); |
| 1156 this->quadTo(rect.fRight - kOffCurveEpsilon, rect.fBottom - ry + offPtY, |
| 1157 rect.fRight, rect.fBottom - ry); |
| 1149 #endif | 1158 #endif |
| 1150 if (!skip_vert) { | 1159 if (!skip_vert) { |
| 1151 this->lineTo(rect.fRight, rect.fTop + ry); // right | 1160 this->lineTo(rect.fRight, rect.fTop + ry); // right |
| 1152 } | 1161 } |
| 1153 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1162 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1154 this->cubicTo(rect.fRight, rect.fTop + ry - sy, | 1163 this->cubicTo(rect.fRight, rect.fTop + ry - sy, |
| 1155 rect.fRight - rx + sx, rect.fTop, | 1164 rect.fRight - rx + sx, rect.fTop, |
| 1156 rect.fRight - rx, rect.fTop); // top-right | 1165 rect.fRight - rx, rect.fTop); // top-right |
| 1157 #else | 1166 #else |
| 1158 add_corner_arc(this, rect, rx, ry, 270, dir, false); // top-right | 1167 this->quadTo(rect.fRight - kOffCurveEpsilon, rect.fTop + ry - offPtY, |
| 1168 rect.fRight - rx + midPtX, rect.fTop + ry - midPtY); |
| 1169 this->quadTo(rect.fRight - rx + offPtX, rect.fTop + kOffCurveEpsilon, |
| 1170 rect.fRight - rx, rect.fTop); |
| 1159 #endif | 1171 #endif |
| 1160 } else { | 1172 } else { |
| 1161 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1173 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1162 this->cubicTo(rect.fRight - rx + sx, rect.fTop, | 1174 this->cubicTo(rect.fRight - rx + sx, rect.fTop, |
| 1163 rect.fRight, rect.fTop + ry - sy, | 1175 rect.fRight, rect.fTop + ry - sy, |
| 1164 rect.fRight, rect.fTop + ry); // top-right | 1176 rect.fRight, rect.fTop + ry); // top-right |
| 1165 #else | 1177 #else |
| 1166 add_corner_arc(this, rect, rx, ry, 270, dir, false); // top-right | 1178 this->quadTo(rect.fRight - rx + offPtX, rect.fTop + kOffCurveEpsilon, |
| 1179 rect.fRight - rx + midPtX, rect.fTop + ry - midPtY); |
| 1180 this->quadTo(rect.fRight - kOffCurveEpsilon, rect.fTop + ry - offPtY, |
| 1181 rect.fRight, rect.fTop + ry); |
| 1167 #endif | 1182 #endif |
| 1168 if (!skip_vert) { | 1183 if (!skip_vert) { |
| 1169 this->lineTo(rect.fRight, rect.fBottom - ry); // right | 1184 this->lineTo(rect.fRight, rect.fBottom - ry); // right |
| 1170 } | 1185 } |
| 1171 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1186 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1172 this->cubicTo(rect.fRight, rect.fBottom - ry + sy, | 1187 this->cubicTo(rect.fRight, rect.fBottom - ry + sy, |
| 1173 rect.fRight - rx + sx, rect.fBottom, | 1188 rect.fRight - rx + sx, rect.fBottom, |
| 1174 rect.fRight - rx, rect.fBottom); // bot-right | 1189 rect.fRight - rx, rect.fBottom); // bot-right |
| 1175 #else | 1190 #else |
| 1176 add_corner_arc(this, rect, rx, ry, 0, dir, false); // bot-right | 1191 this->quadTo(rect.fRight - kOffCurveEpsilon, rect.fBottom - ry + offPtY, |
| 1192 rect.fRight - rx + midPtX, rect.fBottom - ry + midPtY); |
| 1193 this->quadTo(rect.fRight - rx + offPtX, rect.fBottom - kOffCurveEpsilon, |
| 1194 rect.fRight - rx, rect.fBottom); |
| 1177 #endif | 1195 #endif |
| 1178 if (!skip_hori) { | 1196 if (!skip_hori) { |
| 1179 this->lineTo(rect.fLeft + rx, rect.fBottom); // bottom | 1197 this->lineTo(rect.fLeft + rx, rect.fBottom); // bottom |
| 1180 } | 1198 } |
| 1181 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1199 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1182 this->cubicTo(rect.fLeft + rx - sx, rect.fBottom, | 1200 this->cubicTo(rect.fLeft + rx - sx, rect.fBottom, |
| 1183 rect.fLeft, rect.fBottom - ry + sy, | 1201 rect.fLeft, rect.fBottom - ry + sy, |
| 1184 rect.fLeft, rect.fBottom - ry); // bot-left | 1202 rect.fLeft, rect.fBottom - ry); // bot-left |
| 1185 #else | 1203 #else |
| 1186 add_corner_arc(this, rect, rx, ry, 90, dir, false); // bot-left | 1204 this->quadTo(rect.fLeft + rx - offPtX, rect.fBottom - kOffCurveEpsilon, |
| 1205 rect.fLeft + rx - midPtX, rect.fBottom - ry + midPtY); |
| 1206 this->quadTo(rect.fLeft + kOffCurveEpsilon, rect.fBottom - ry + offPtY, |
| 1207 rect.fLeft, rect.fBottom - ry); |
| 1187 #endif | 1208 #endif |
| 1188 if (!skip_vert) { | 1209 if (!skip_vert) { |
| 1189 this->lineTo(rect.fLeft, rect.fTop + ry); // left | 1210 this->lineTo(rect.fLeft, rect.fTop + ry); // left |
| 1190 } | 1211 } |
| 1191 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT | 1212 #ifdef SK_IGNORE_QUAD_RR_CORNERS_OPT |
| 1192 this->cubicTo(rect.fLeft, rect.fTop + ry - sy, | 1213 this->cubicTo(rect.fLeft, rect.fTop + ry - sy, |
| 1193 rect.fLeft + rx - sx, rect.fTop, | 1214 rect.fLeft + rx - sx, rect.fTop, |
| 1194 rect.fLeft + rx, rect.fTop); // top-left | 1215 rect.fLeft + rx, rect.fTop); // top-left |
| 1195 #else | 1216 #else |
| 1196 add_corner_arc(this, rect, rx, ry, 180, dir, false); // top-left | 1217 this->quadTo(rect.fLeft + kOffCurveEpsilon, rect.fTop + ry - offPtY, |
| 1218 rect.fLeft + rx - midPtX, rect.fTop + ry - midPtY); |
| 1219 this->quadTo(rect.fLeft + rx - offPtX, rect.fTop + kOffCurveEpsilon, |
| 1220 rect.fLeft + rx, rect.fTop); |
| 1197 #endif | 1221 #endif |
| 1198 if (!skip_hori) { | 1222 if (!skip_hori) { |
| 1199 this->lineTo(rect.fRight - rx, rect.fTop); // top | 1223 this->lineTo(rect.fRight - rx, rect.fTop); // top |
| 1200 } | 1224 } |
| 1201 } | 1225 } |
| 1202 this->close(); | 1226 this->close(); |
| 1203 } | 1227 } |
| 1204 | 1228 |
| 1205 void SkPath::addOval(const SkRect& oval, Direction dir) { | 1229 void SkPath::addOval(const SkRect& oval, Direction dir) { |
| 1206 assert_known_direction(dir); | 1230 assert_known_direction(dir); |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2978 switch (this->getFillType()) { | 3002 switch (this->getFillType()) { |
| 2979 case SkPath::kEvenOdd_FillType: | 3003 case SkPath::kEvenOdd_FillType: |
| 2980 case SkPath::kInverseEvenOdd_FillType: | 3004 case SkPath::kInverseEvenOdd_FillType: |
| 2981 w &= 1; | 3005 w &= 1; |
| 2982 break; | 3006 break; |
| 2983 default: | 3007 default: |
| 2984 break; | 3008 break; |
| 2985 } | 3009 } |
| 2986 return SkToBool(w); | 3010 return SkToBool(w); |
| 2987 } | 3011 } |
| OLD | NEW |