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

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

Issue 994533002: Remove SK_SUPPORT_LEGACY_ADDOVAL (Closed) Base URL: https://chromium.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 | 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 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 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 if (isOval) { 1067 if (isOval) {
1068 fDirection = dir; 1068 fDirection = dir;
1069 } else { 1069 } else {
1070 fDirection = kUnknown_Direction; 1070 fDirection = kUnknown_Direction;
1071 } 1071 }
1072 1072
1073 SkAutoDisableDirectionCheck addc(this); 1073 SkAutoDisableDirectionCheck addc(this);
1074 1074
1075 SkAutoPathBoundsUpdate apbu(this, oval); 1075 SkAutoPathBoundsUpdate apbu(this, oval);
1076 1076
1077 #ifdef SK_SUPPORT_LEGACY_ADDOVAL
1078 SkScalar cx = oval.centerX();
1079 SkScalar cy = oval.centerY();
1080 SkScalar rx = SkScalarHalf(oval.width());
1081 SkScalar ry = SkScalarHalf(oval.height());
1082
1083 SkScalar sx = SkScalarMul(rx, SK_ScalarTanPIOver8);
1084 SkScalar sy = SkScalarMul(ry, SK_ScalarTanPIOver8);
1085 SkScalar mx = SkScalarMul(rx, SK_ScalarRoot2Over2);
1086 SkScalar my = SkScalarMul(ry, SK_ScalarRoot2Over2);
1087
1088 /*
1089 To handle imprecision in computing the center and radii, we revert to
1090 the provided bounds when we can (i.e. use oval.fLeft instead of cx-rx)
1091 to ensure that we don't exceed the oval's bounds *ever*, since we want
1092 to use oval for our fast-bounds, rather than have to recompute it.
1093 */
1094 const SkScalar L = oval.fLeft; // cx - rx
1095 const SkScalar T = oval.fTop; // cy - ry
1096 const SkScalar R = oval.fRight; // cx + rx
1097 const SkScalar B = oval.fBottom; // cy + ry
1098
1099 this->incReserve(17); // 8 quads + close
1100 this->moveTo(R, cy);
1101 if (dir == kCCW_Direction) {
1102 this->quadTo( R, cy - sy, cx + mx, cy - my);
1103 this->quadTo(cx + sx, T, cx , T);
1104 this->quadTo(cx - sx, T, cx - mx, cy - my);
1105 this->quadTo( L, cy - sy, L, cy );
1106 this->quadTo( L, cy + sy, cx - mx, cy + my);
1107 this->quadTo(cx - sx, B, cx , B);
1108 this->quadTo(cx + sx, B, cx + mx, cy + my);
1109 this->quadTo( R, cy + sy, R, cy );
1110 } else {
1111 this->quadTo( R, cy + sy, cx + mx, cy + my);
1112 this->quadTo(cx + sx, B, cx , B);
1113 this->quadTo(cx - sx, B, cx - mx, cy + my);
1114 this->quadTo( L, cy + sy, L, cy );
1115 this->quadTo( L, cy - sy, cx - mx, cy - my);
1116 this->quadTo(cx - sx, T, cx , T);
1117 this->quadTo(cx + sx, T, cx + mx, cy - my);
1118 this->quadTo( R, cy - sy, R, cy );
1119 }
1120 #else
1121 const SkScalar L = oval.fLeft; 1077 const SkScalar L = oval.fLeft;
1122 const SkScalar T = oval.fTop; 1078 const SkScalar T = oval.fTop;
1123 const SkScalar R = oval.fRight; 1079 const SkScalar R = oval.fRight;
1124 const SkScalar B = oval.fBottom; 1080 const SkScalar B = oval.fBottom;
1125 const SkScalar cx = oval.centerX(); 1081 const SkScalar cx = oval.centerX();
1126 const SkScalar cy = oval.centerY(); 1082 const SkScalar cy = oval.centerY();
1127 const SkScalar weight = SK_ScalarRoot2Over2; 1083 const SkScalar weight = SK_ScalarRoot2Over2;
1128 1084
1129 this->incReserve(9); // move + 4 conics 1085 this->incReserve(9); // move + 4 conics
1130 this->moveTo(R, cy); 1086 this->moveTo(R, cy);
1131 if (dir == kCCW_Direction) { 1087 if (dir == kCCW_Direction) {
1132 this->conicTo(R, T, cx, T, weight); 1088 this->conicTo(R, T, cx, T, weight);
1133 this->conicTo(L, T, L, cy, weight); 1089 this->conicTo(L, T, L, cy, weight);
1134 this->conicTo(L, B, cx, B, weight); 1090 this->conicTo(L, B, cx, B, weight);
1135 this->conicTo(R, B, R, cy, weight); 1091 this->conicTo(R, B, R, cy, weight);
1136 } else { 1092 } else {
1137 this->conicTo(R, B, cx, B, weight); 1093 this->conicTo(R, B, cx, B, weight);
1138 this->conicTo(L, B, L, cy, weight); 1094 this->conicTo(L, B, L, cy, weight);
1139 this->conicTo(L, T, cx, T, weight); 1095 this->conicTo(L, T, cx, T, weight);
1140 this->conicTo(R, T, R, cy, weight); 1096 this->conicTo(R, T, R, cy, weight);
1141 } 1097 }
1142 #endif
1143 this->close(); 1098 this->close();
1144 1099
1145 SkPathRef::Editor ed(&fPathRef); 1100 SkPathRef::Editor ed(&fPathRef);
1146 1101
1147 ed.setIsOval(isOval); 1102 ed.setIsOval(isOval);
1148 } 1103 }
1149 1104
1150 void SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, Direction dir) { 1105 void SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, Direction dir) {
1151 if (r > 0) { 1106 if (r > 0) {
1152 SkRect rect; 1107 SkRect rect;
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 switch (this->getFillType()) { 2788 switch (this->getFillType()) {
2834 case SkPath::kEvenOdd_FillType: 2789 case SkPath::kEvenOdd_FillType:
2835 case SkPath::kInverseEvenOdd_FillType: 2790 case SkPath::kInverseEvenOdd_FillType:
2836 w &= 1; 2791 w &= 1;
2837 break; 2792 break;
2838 default: 2793 default:
2839 break; 2794 break;
2840 } 2795 }
2841 return SkToBool(w); 2796 return SkToBool(w);
2842 } 2797 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698