OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 ((SkPoint*)((intptr_t)this + 0 * stride))->set(SkIntToScalar(l), | 36 ((SkPoint*)((intptr_t)this + 0 * stride))->set(SkIntToScalar(l), |
37 SkIntToScalar(t)); | 37 SkIntToScalar(t)); |
38 ((SkPoint*)((intptr_t)this + 1 * stride))->set(SkIntToScalar(l), | 38 ((SkPoint*)((intptr_t)this + 1 * stride))->set(SkIntToScalar(l), |
39 SkIntToScalar(b)); | 39 SkIntToScalar(b)); |
40 ((SkPoint*)((intptr_t)this + 2 * stride))->set(SkIntToScalar(r), | 40 ((SkPoint*)((intptr_t)this + 2 * stride))->set(SkIntToScalar(r), |
41 SkIntToScalar(b)); | 41 SkIntToScalar(b)); |
42 ((SkPoint*)((intptr_t)this + 3 * stride))->set(SkIntToScalar(r), | 42 ((SkPoint*)((intptr_t)this + 3 * stride))->set(SkIntToScalar(r), |
43 SkIntToScalar(t)); | 43 SkIntToScalar(t)); |
44 } | 44 } |
45 | 45 |
46 void SkPoint::setRectFan(SkScalar l, SkScalar t, SkScalar r, SkScalar b, | |
47 size_t stride) { | |
48 SkASSERT(stride >= sizeof(SkPoint)); | |
49 | |
50 ((SkPoint*)((intptr_t)this + 0 * stride))->set(l, t); | |
51 ((SkPoint*)((intptr_t)this + 1 * stride))->set(l, b); | |
52 ((SkPoint*)((intptr_t)this + 2 * stride))->set(r, b); | |
53 ((SkPoint*)((intptr_t)this + 3 * stride))->set(r, t); | |
54 } | |
55 | |
56 void SkPoint::rotateCW(SkPoint* dst) const { | 46 void SkPoint::rotateCW(SkPoint* dst) const { |
57 SkASSERT(dst); | 47 SkASSERT(dst); |
58 | 48 |
59 // use a tmp in case this == dst | 49 // use a tmp in case this == dst |
60 SkScalar tmp = fX; | 50 SkScalar tmp = fX; |
61 dst->fX = -fY; | 51 dst->fX = -fY; |
62 dst->fY = tmp; | 52 dst->fY = tmp; |
63 } | 53 } |
64 | 54 |
65 void SkPoint::rotateCCW(SkPoint* dst) const { | 55 void SkPoint::rotateCCW(SkPoint* dst) const { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 249 |
260 if (uDotV <= 0) { | 250 if (uDotV <= 0) { |
261 return v.lengthSqd(); | 251 return v.lengthSqd(); |
262 } else if (uDotV > uLengthSqd) { | 252 } else if (uDotV > uLengthSqd) { |
263 return b.distanceToSqd(*this); | 253 return b.distanceToSqd(*this); |
264 } else { | 254 } else { |
265 SkScalar det = u.cross(v); | 255 SkScalar det = u.cross(v); |
266 return SkScalarMulDiv(det, det, uLengthSqd); | 256 return SkScalarMulDiv(det, det, uLengthSqd); |
267 } | 257 } |
268 } | 258 } |
OLD | NEW |