OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
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 GrGlyph_DEFINED | 8 #ifndef GrGlyph_DEFINED |
9 #define GrGlyph_DEFINED | 9 #define GrGlyph_DEFINED |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 int width() const { return fBounds.width(); } | 46 int width() const { return fBounds.width(); } |
47 int height() const { return fBounds.height(); } | 47 int height() const { return fBounds.height(); } |
48 bool isEmpty() const { return fBounds.isEmpty(); } | 48 bool isEmpty() const { return fBounds.isEmpty(); } |
49 uint16_t glyphID() const { return UnpackID(fPackedID); } | 49 uint16_t glyphID() const { return UnpackID(fPackedID); } |
50 | 50 |
51 /////////////////////////////////////////////////////////////////////////// | 51 /////////////////////////////////////////////////////////////////////////// |
52 | 52 |
53 static inline unsigned ExtractSubPixelBitsFromFixed(GrFixed pos) { | 53 static inline unsigned ExtractSubPixelBitsFromFixed(SkFixed pos) { |
54 // two most significant fraction bits from fixed-point | 54 // two most significant fraction bits from fixed-point |
55 return (pos >> 14) & 3; | 55 return (pos >> 14) & 3; |
56 } | 56 } |
57 | 57 |
58 static inline PackedID Pack(uint16_t glyphID, GrFixed x, GrFixed y) { | 58 static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y) { |
59 x = ExtractSubPixelBitsFromFixed(x); | 59 x = ExtractSubPixelBitsFromFixed(x); |
60 y = ExtractSubPixelBitsFromFixed(y); | 60 y = ExtractSubPixelBitsFromFixed(y); |
61 return (x << 18) | (y << 16) | glyphID; | 61 return (x << 18) | (y << 16) | glyphID; |
62 } | 62 } |
63 | 63 |
64 static inline GrFixed UnpackFixedX(PackedID packed) { | 64 static inline SkFixed UnpackFixedX(PackedID packed) { |
65 return ((packed >> 18) & 3) << 14; | 65 return ((packed >> 18) & 3) << 14; |
66 } | 66 } |
67 | 67 |
68 static inline GrFixed UnpackFixedY(PackedID packed) { | 68 static inline SkFixed UnpackFixedY(PackedID packed) { |
69 return ((packed >> 16) & 3) << 14; | 69 return ((packed >> 16) & 3) << 14; |
70 } | 70 } |
71 | 71 |
72 static inline uint16_t UnpackID(PackedID packed) { | 72 static inline uint16_t UnpackID(PackedID packed) { |
73 return (uint16_t)packed; | 73 return (uint16_t)packed; |
74 } | 74 } |
75 }; | 75 }; |
76 | 76 |
77 | 77 |
78 #endif | 78 #endif |
OLD | NEW |