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 SkGlyph_DEFINED | 8 #ifndef SkGlyph_DEFINED |
9 #define SkGlyph_DEFINED | 9 #define SkGlyph_DEFINED |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 int8_t fForceBW; | 46 int8_t fForceBW; |
47 | 47 |
48 void initWithGlyphID(uint32_t glyph_id) { | 48 void initWithGlyphID(uint32_t glyph_id) { |
49 this->initCommon(MakeID(glyph_id)); | 49 this->initCommon(MakeID(glyph_id)); |
50 } | 50 } |
51 | 51 |
52 void initGlyphIdFrom(const SkGlyph& glyph) { | 52 void initGlyphIdFrom(const SkGlyph& glyph) { |
53 this->initCommon(glyph.fID); | 53 this->initCommon(glyph.fID); |
54 } | 54 } |
55 | 55 |
| 56 void initGlyphFromCombinedID(uint32_t combined_id) { |
| 57 this->initCommon(combined_id); |
| 58 } |
| 59 |
56 /** | 60 /** |
57 * Compute the rowbytes for the specified width and mask-format. | 61 * Compute the rowbytes for the specified width and mask-format. |
58 */ | 62 */ |
59 static unsigned ComputeRowBytes(unsigned width, SkMask::Format format) { | 63 static unsigned ComputeRowBytes(unsigned width, SkMask::Format format) { |
60 unsigned rb = width; | 64 unsigned rb = width; |
61 if (SkMask::kBW_Format == format) { | 65 if (SkMask::kBW_Format == format) { |
62 rb = (rb + 7) >> 3; | 66 rb = (rb + 7) >> 3; |
63 } else if (SkMask::kARGB32_Format == format) { | 67 } else if (SkMask::kARGB32_Format == format) { |
64 rb <<= 2; | 68 rb <<= 2; |
65 } else if (SkMask::kLCD16_Format == format) { | 69 } else if (SkMask::kLCD16_Format == format) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 103 } |
100 | 104 |
101 size_t computeImageSize() const; | 105 size_t computeImageSize() const; |
102 | 106 |
103 /** Call this to set all of the metrics fields to 0 (e.g. if the scaler | 107 /** Call this to set all of the metrics fields to 0 (e.g. if the scaler |
104 encounters an error measuring a glyph). Note: this does not alter the | 108 encounters an error measuring a glyph). Note: this does not alter the |
105 fImage, fPath, fID, fMaskFormat fields. | 109 fImage, fPath, fID, fMaskFormat fields. |
106 */ | 110 */ |
107 void zeroMetrics(); | 111 void zeroMetrics(); |
108 | 112 |
109 | |
110 void toMask(SkMask* mask) const; | 113 void toMask(SkMask* mask) const; |
111 | 114 |
112 private: | 115 private: |
113 // TODO(herb) remove friend statement after SkGlyphCache cleanup. | 116 // TODO(herb) remove friend statement after SkGlyphCache cleanup. |
114 friend class SkGlyphCache; | 117 friend class SkGlyphCache; |
115 | 118 |
116 void initCommon(uint32_t id) { | 119 void initCommon(uint32_t id) { |
117 fID = id; | 120 fID = id; |
118 fImage = NULL; | 121 fImage = NULL; |
119 fPath = NULL; | 122 fPath = NULL; |
120 fMaskFormat = MASK_FORMAT_UNKNOWN; | 123 fMaskFormat = MASK_FORMAT_UNKNOWN; |
121 fForceBW = 0; | 124 fForceBW = 0; |
122 } | 125 } |
| 126 |
123 static unsigned ID2Code(uint32_t id) { | 127 static unsigned ID2Code(uint32_t id) { |
124 return (id & kCodeMask); | 128 return id & kCodeMask; |
125 } | 129 } |
126 | 130 |
127 static unsigned ID2SubX(uint32_t id) { | 131 static unsigned ID2SubX(uint32_t id) { |
128 return id >> (kSubShift + kSubShiftX); | 132 return id >> (kSubShift + kSubShiftX); |
129 } | 133 } |
130 | 134 |
131 static unsigned ID2SubY(uint32_t id) { | 135 static unsigned ID2SubY(uint32_t id) { |
132 return (id >> (kSubShift + kSubShiftY)) & kSubMask; | 136 return (id >> (kSubShift + kSubShiftY)) & kSubMask; |
133 } | 137 } |
134 | 138 |
135 static unsigned FixedToSub(SkFixed n) { | 139 static unsigned FixedToSub(SkFixed n) { |
136 return (n >> (16 - kSubBits)) & kSubMask; | 140 return (n >> (16 - kSubBits)) & kSubMask; |
137 } | 141 } |
138 | 142 |
139 static SkFixed SubToFixed(unsigned sub) { | 143 static SkFixed SubToFixed(unsigned sub) { |
140 SkASSERT(sub <= kSubMask); | 144 SkASSERT(sub <= kSubMask); |
141 return sub << (16 - kSubBits); | 145 return sub << (16 - kSubBits); |
142 } | 146 } |
143 | 147 |
144 static uint32_t MakeID(unsigned code) { | 148 static uint32_t MakeID(unsigned code) { |
| 149 SkASSERT(code <= kCodeMask); |
145 return code; | 150 return code; |
146 } | 151 } |
147 | 152 |
148 static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) { | 153 static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) { |
149 SkASSERT(code <= kCodeMask); | 154 SkASSERT(code <= kCodeMask); |
150 x = FixedToSub(x); | 155 x = FixedToSub(x); |
151 y = FixedToSub(y); | 156 y = FixedToSub(y); |
152 return (x << (kSubShift + kSubShiftX)) | | 157 return (x << (kSubShift + kSubShiftX)) | |
153 (y << (kSubShift + kSubShiftY)) | | 158 (y << (kSubShift + kSubShiftY)) | |
154 code; | 159 code; |
155 } | 160 } |
156 | 161 |
157 // FIXME - This is needed because the Android frame work directly | 162 // FIXME - This is needed because the Android frame work directly |
158 // accesses fID. Remove when fID accesses are cleaned up. | 163 // accesses fID. Remove when fID accesses are cleaned up. |
159 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 164 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
160 public: | 165 public: |
161 #endif | 166 #endif |
162 uint32_t fID; | 167 uint32_t fID; |
163 }; | 168 }; |
164 | 169 |
165 #endif | 170 #endif |
OLD | NEW |