OLD | NEW |
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 #ifndef SkPoint_DEFINED | 8 #ifndef SkPoint_DEFINED |
9 #define SkPoint_DEFINED | 9 #define SkPoint_DEFINED |
10 | 10 |
11 #include "SkMath.h" | 11 #include "SkMath.h" |
12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
13 | 13 |
| 14 /** \struct SkIPoint16 |
| 15 |
| 16 SkIPoint holds two 16 bit integer coordinates |
| 17 */ |
| 18 struct SkIPoint16 { |
| 19 int16_t fX, fY; |
| 20 |
| 21 static SkIPoint16 Make(int x, int y) { |
| 22 SkIPoint16 pt; |
| 23 pt.set(x, y); |
| 24 return pt; |
| 25 } |
| 26 |
| 27 int16_t x() const { return fX; } |
| 28 int16_t y() const { return fY; } |
| 29 |
| 30 void set(int x, int y) { |
| 31 fX = SkToS16(x); |
| 32 fY = SkToS16(y); |
| 33 } |
| 34 }; |
| 35 |
14 /** \struct SkIPoint | 36 /** \struct SkIPoint |
15 | 37 |
16 SkIPoint holds two 32 bit integer coordinates | 38 SkIPoint holds two 32 bit integer coordinates |
17 */ | 39 */ |
18 struct SkIPoint { | 40 struct SkIPoint { |
19 int32_t fX, fY; | 41 int32_t fX, fY; |
20 | 42 |
21 static SkIPoint Make(int32_t x, int32_t y) { | 43 static SkIPoint Make(int32_t x, int32_t y) { |
22 SkIPoint pt; | 44 SkIPoint pt; |
23 pt.set(x, y); | 45 pt.set(x, y); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 524 |
503 /** | 525 /** |
504 * cast-safe way to treat the point as an array of (2) SkScalars. | 526 * cast-safe way to treat the point as an array of (2) SkScalars. |
505 */ | 527 */ |
506 const SkScalar* asScalars() const { return &fX; } | 528 const SkScalar* asScalars() const { return &fX; } |
507 }; | 529 }; |
508 | 530 |
509 typedef SkPoint SkVector; | 531 typedef SkPoint SkVector; |
510 | 532 |
511 #endif | 533 #endif |
OLD | NEW |