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 "SkEdge.h" | 10 #include "SkEdge.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 return value << (16 - 6 - 1); | 29 return value << (16 - 6 - 1); |
30 } | 30 } |
31 | 31 |
32 ///////////////////////////////////////////////////////////////////////// | 32 ///////////////////////////////////////////////////////////////////////// |
33 | 33 |
34 int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, const SkIRect* clip, | 34 int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, const SkIRect* clip, |
35 int shift) { | 35 int shift) { |
36 SkFDot6 x0, y0, x1, y1; | 36 SkFDot6 x0, y0, x1, y1; |
37 | 37 |
38 { | 38 { |
39 #ifdef SK_SCALAR_IS_FLOAT | |
40 float scale = float(1 << (shift + 6)); | 39 float scale = float(1 << (shift + 6)); |
41 x0 = int(p0.fX * scale); | 40 x0 = int(p0.fX * scale); |
42 y0 = int(p0.fY * scale); | 41 y0 = int(p0.fY * scale); |
43 x1 = int(p1.fX * scale); | 42 x1 = int(p1.fX * scale); |
44 y1 = int(p1.fY * scale); | 43 y1 = int(p1.fY * scale); |
45 #else | |
46 shift = 10 - shift; | |
47 x0 = p0.fX >> shift; | |
48 y0 = p0.fY >> shift; | |
49 x1 = p1.fX >> shift; | |
50 y1 = p1.fY >> shift; | |
51 #endif | |
52 } | 44 } |
53 | 45 |
54 int winding = 1; | 46 int winding = 1; |
55 | 47 |
56 if (y0 > y1) { | 48 if (y0 > y1) { |
57 SkTSwap(x0, x1); | 49 SkTSwap(x0, x1); |
58 SkTSwap(y0, y1); | 50 SkTSwap(y0, y1); |
59 winding = -1; | 51 winding = -1; |
60 } | 52 } |
61 | 53 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 164 |
173 // each subdivision (shift value) cuts this dist (error) by 1/4 | 165 // each subdivision (shift value) cuts this dist (error) by 1/4 |
174 return (32 - SkCLZ(dist)) >> 1; | 166 return (32 - SkCLZ(dist)) >> 1; |
175 } | 167 } |
176 | 168 |
177 int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], int shift) | 169 int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], int shift) |
178 { | 170 { |
179 SkFDot6 x0, y0, x1, y1, x2, y2; | 171 SkFDot6 x0, y0, x1, y1, x2, y2; |
180 | 172 |
181 { | 173 { |
182 #ifdef SK_SCALAR_IS_FLOAT | |
183 float scale = float(1 << (shift + 6)); | 174 float scale = float(1 << (shift + 6)); |
184 x0 = int(pts[0].fX * scale); | 175 x0 = int(pts[0].fX * scale); |
185 y0 = int(pts[0].fY * scale); | 176 y0 = int(pts[0].fY * scale); |
186 x1 = int(pts[1].fX * scale); | 177 x1 = int(pts[1].fX * scale); |
187 y1 = int(pts[1].fY * scale); | 178 y1 = int(pts[1].fY * scale); |
188 x2 = int(pts[2].fX * scale); | 179 x2 = int(pts[2].fX * scale); |
189 y2 = int(pts[2].fY * scale); | 180 y2 = int(pts[2].fY * scale); |
190 #else | |
191 shift = 10 - shift; | |
192 x0 = pts[0].fX >> shift; | |
193 y0 = pts[0].fY >> shift; | |
194 x1 = pts[1].fX >> shift; | |
195 y1 = pts[1].fY >> shift; | |
196 x2 = pts[2].fX >> shift; | |
197 y2 = pts[2].fY >> shift; | |
198 #endif | |
199 } | 181 } |
200 | 182 |
201 int winding = 1; | 183 int winding = 1; |
202 if (y0 > y2) | 184 if (y0 > y2) |
203 { | 185 { |
204 SkTSwap(x0, x2); | 186 SkTSwap(x0, x2); |
205 SkTSwap(y0, y2); | 187 SkTSwap(y0, y2); |
206 winding = -1; | 188 winding = -1; |
207 } | 189 } |
208 SkASSERT(y0 <= y1 && y1 <= y2); | 190 SkASSERT(y0 <= y1 && y1 <= y2); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 SkFDot6 twoThird = (a + 6*b - ((c << 4) - c) + (d << 3)) * 19 >> 9; | 314 SkFDot6 twoThird = (a + 6*b - ((c << 4) - c) + (d << 3)) * 19 >> 9; |
333 | 315 |
334 return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird)); | 316 return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird)); |
335 } | 317 } |
336 | 318 |
337 int SkCubicEdge::setCubic(const SkPoint pts[4], const SkIRect* clip, int shift) | 319 int SkCubicEdge::setCubic(const SkPoint pts[4], const SkIRect* clip, int shift) |
338 { | 320 { |
339 SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3; | 321 SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3; |
340 | 322 |
341 { | 323 { |
342 #ifdef SK_SCALAR_IS_FLOAT | |
343 float scale = float(1 << (shift + 6)); | 324 float scale = float(1 << (shift + 6)); |
344 x0 = int(pts[0].fX * scale); | 325 x0 = int(pts[0].fX * scale); |
345 y0 = int(pts[0].fY * scale); | 326 y0 = int(pts[0].fY * scale); |
346 x1 = int(pts[1].fX * scale); | 327 x1 = int(pts[1].fX * scale); |
347 y1 = int(pts[1].fY * scale); | 328 y1 = int(pts[1].fY * scale); |
348 x2 = int(pts[2].fX * scale); | 329 x2 = int(pts[2].fX * scale); |
349 y2 = int(pts[2].fY * scale); | 330 y2 = int(pts[2].fY * scale); |
350 x3 = int(pts[3].fX * scale); | 331 x3 = int(pts[3].fX * scale); |
351 y3 = int(pts[3].fY * scale); | 332 y3 = int(pts[3].fY * scale); |
352 #else | |
353 shift = 10 - shift; | |
354 x0 = pts[0].fX >> shift; | |
355 y0 = pts[0].fY >> shift; | |
356 x1 = pts[1].fX >> shift; | |
357 y1 = pts[1].fY >> shift; | |
358 x2 = pts[2].fX >> shift; | |
359 y2 = pts[2].fY >> shift; | |
360 x3 = pts[3].fX >> shift; | |
361 y3 = pts[3].fY >> shift; | |
362 #endif | |
363 } | 333 } |
364 | 334 |
365 int winding = 1; | 335 int winding = 1; |
366 if (y0 > y3) | 336 if (y0 > y3) |
367 { | 337 { |
368 SkTSwap(x0, x3); | 338 SkTSwap(x0, x3); |
369 SkTSwap(x1, x2); | 339 SkTSwap(x1, x2); |
370 SkTSwap(y0, y3); | 340 SkTSwap(y0, y3); |
371 SkTSwap(y1, y2); | 341 SkTSwap(y1, y2); |
372 winding = -1; | 342 winding = -1; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 success = this->updateLine(oldx, oldy, newx, newy); | 458 success = this->updateLine(oldx, oldy, newx, newy); |
489 oldx = newx; | 459 oldx = newx; |
490 oldy = newy; | 460 oldy = newy; |
491 } while (count < 0 && !success); | 461 } while (count < 0 && !success); |
492 | 462 |
493 fCx = newx; | 463 fCx = newx; |
494 fCy = newy; | 464 fCy = newy; |
495 fCurveCount = SkToS8(count); | 465 fCurveCount = SkToS8(count); |
496 return success; | 466 return success; |
497 } | 467 } |
OLD | NEW |