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

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

Issue 1023103004: remove SK_SUPPORT_LEGACY_ARCTO_QUADS code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/SkStrokerPriv.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBuffer.h" 8 #include "SkBuffer.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkGeometry.h" 10 #include "SkGeometry.h"
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 // not sure how much will be enough, so we use a loop 917 // not sure how much will be enough, so we use a loop
918 do { 918 do {
919 stopRad -= deltaRad; 919 stopRad -= deltaRad;
920 stopV->fY = SkScalarSinCos(stopRad, &stopV->fX); 920 stopV->fY = SkScalarSinCos(stopRad, &stopV->fX);
921 } while (*startV == *stopV); 921 } while (*startV == *stopV);
922 } 922 }
923 } 923 }
924 *dir = sweepAngle > 0 ? kCW_SkRotationDirection : kCCW_SkRotationDirection; 924 *dir = sweepAngle > 0 ? kCW_SkRotationDirection : kCCW_SkRotationDirection;
925 } 925 }
926 926
927 #ifdef SK_SUPPORT_LEGACY_ARCTO_QUADS
928 static int build_arc_points(const SkRect& oval, const SkVector& start, const SkV ector& stop,
929 SkRotationDirection dir, SkPoint pts[kSkBuildQuadArc Storage]) {
930 SkMatrix matrix;
931
932 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height()));
933 matrix.postTranslate(oval.centerX(), oval.centerY());
934
935 return SkBuildQuadArc(start, stop, dir, &matrix, pts);
936 }
937 #else
938 /** 927 /**
939 * If this returns 0, then the caller should just line-to the singlePt, else it should 928 * If this returns 0, then the caller should just line-to the singlePt, else it should
940 * ignore singlePt and append the specified number of conics. 929 * ignore singlePt and append the specified number of conics.
941 */ 930 */
942 static int build_arc_conics(const SkRect& oval, const SkVector& start, const SkV ector& stop, 931 static int build_arc_conics(const SkRect& oval, const SkVector& start, const SkV ector& stop,
943 SkRotationDirection dir, SkConic conics[SkConic::kMa xConicsForArc], 932 SkRotationDirection dir, SkConic conics[SkConic::kMa xConicsForArc],
944 SkPoint* singlePt) { 933 SkPoint* singlePt) {
945 SkMatrix matrix; 934 SkMatrix matrix;
946 935
947 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height())); 936 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height()));
948 matrix.postTranslate(oval.centerX(), oval.centerY()); 937 matrix.postTranslate(oval.centerX(), oval.centerY());
949 938
950 int count = SkConic::BuildUnitArc(start, stop, dir, &matrix, conics); 939 int count = SkConic::BuildUnitArc(start, stop, dir, &matrix, conics);
951 if (0 == count) { 940 if (0 == count) {
952 matrix.mapXY(start.x(), start.y(), singlePt); 941 matrix.mapXY(start.x(), start.y(), singlePt);
953 } 942 }
954 return count; 943 return count;
955 } 944 }
956 #endif
957 945
958 void SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[], 946 void SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[],
959 Direction dir) { 947 Direction dir) {
960 SkRRect rrect; 948 SkRRect rrect;
961 rrect.setRectRadii(rect, (const SkVector*) radii); 949 rrect.setRectRadii(rect, (const SkVector*) radii);
962 this->addRRect(rrect, dir); 950 this->addRRect(rrect, dir);
963 } 951 }
964 952
965 void SkPath::addRRect(const SkRRect& rrect, Direction dir) { 953 void SkPath::addRRect(const SkRRect& rrect, Direction dir) {
966 assert_known_direction(dir); 954 assert_known_direction(dir);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 SkPoint lonePt; 1111 SkPoint lonePt;
1124 if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) { 1112 if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) {
1125 forceMoveTo ? this->moveTo(lonePt) : this->lineTo(lonePt); 1113 forceMoveTo ? this->moveTo(lonePt) : this->lineTo(lonePt);
1126 return; 1114 return;
1127 } 1115 }
1128 1116
1129 SkVector startV, stopV; 1117 SkVector startV, stopV;
1130 SkRotationDirection dir; 1118 SkRotationDirection dir;
1131 angles_to_unit_vectors(startAngle, sweepAngle, &startV, &stopV, &dir); 1119 angles_to_unit_vectors(startAngle, sweepAngle, &startV, &stopV, &dir);
1132 1120
1133 #ifdef SK_SUPPORT_LEGACY_ARCTO_QUADS
1134 SkPoint pts[kSkBuildQuadArcStorage];
1135 int count = build_arc_points(oval, startV, stopV, dir, pts);
1136 SkASSERT((count & 1) == 1);
1137
1138 this->incReserve(count);
1139 forceMoveTo ? this->moveTo(pts[0]) : this->lineTo(pts[0]);
1140 for (int i = 1; i < count; i += 2) {
1141 this->quadTo(pts[i], pts[i+1]);
1142 }
1143 #else
1144 SkPoint singlePt; 1121 SkPoint singlePt;
1145 SkConic conics[SkConic::kMaxConicsForArc]; 1122 SkConic conics[SkConic::kMaxConicsForArc];
1146 int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt); 1123 int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt);
1147 if (count) { 1124 if (count) {
1148 this->incReserve(count * 2 + 1); 1125 this->incReserve(count * 2 + 1);
1149 const SkPoint& pt = conics[0].fPts[0]; 1126 const SkPoint& pt = conics[0].fPts[0];
1150 forceMoveTo ? this->moveTo(pt) : this->lineTo(pt); 1127 forceMoveTo ? this->moveTo(pt) : this->lineTo(pt);
1151 for (int i = 0; i < count; ++i) { 1128 for (int i = 0; i < count; ++i) {
1152 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW); 1129 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW);
1153 } 1130 }
1154 } else { 1131 } else {
1155 forceMoveTo ? this->moveTo(singlePt) : this->lineTo(singlePt); 1132 forceMoveTo ? this->moveTo(singlePt) : this->lineTo(singlePt);
1156 } 1133 }
1157 #endif
1158 } 1134 }
1159 1135
1160 void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle ) { 1136 void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle ) {
1161 if (oval.isEmpty() || 0 == sweepAngle) { 1137 if (oval.isEmpty() || 0 == sweepAngle) {
1162 return; 1138 return;
1163 } 1139 }
1164 1140
1165 const SkScalar kFullCircleAngle = SkIntToScalar(360); 1141 const SkScalar kFullCircleAngle = SkIntToScalar(360);
1166 1142
1167 if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) { 1143 if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) {
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 switch (this->getFillType()) { 2764 switch (this->getFillType()) {
2789 case SkPath::kEvenOdd_FillType: 2765 case SkPath::kEvenOdd_FillType:
2790 case SkPath::kInverseEvenOdd_FillType: 2766 case SkPath::kInverseEvenOdd_FillType:
2791 w &= 1; 2767 w &= 1;
2792 break; 2768 break;
2793 default: 2769 default:
2794 break; 2770 break;
2795 } 2771 }
2796 return SkToBool(w); 2772 return SkToBool(w);
2797 } 2773 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkStrokerPriv.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698