OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
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 #include "GrFontScaler.h" | 9 #include "GrFontScaler.h" |
10 #include "SkDescriptor.h" | 10 #include "SkDescriptor.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 int srcRB = glyph.rowBytes(); | 136 int srcRB = glyph.rowBytes(); |
137 // The windows font host sometimes has BW glyphs in a non-BW strike. So it i
s important here to | 137 // The windows font host sometimes has BW glyphs in a non-BW strike. So it i
s important here to |
138 // check the glyph's format, not the strike's format, and to be able to conv
ert to any of the | 138 // check the glyph's format, not the strike's format, and to be able to conv
ert to any of the |
139 // GrMaskFormats. | 139 // GrMaskFormats. |
140 if (SkMask::kBW_Format == glyph.fMaskFormat) { | 140 if (SkMask::kBW_Format == glyph.fMaskFormat) { |
141 // expand bits to our mask type | 141 // expand bits to our mask type |
142 const uint8_t* bits = reinterpret_cast<const uint8_t*>(src); | 142 const uint8_t* bits = reinterpret_cast<const uint8_t*>(src); |
143 switch (this->getMaskFormat()) { | 143 switch (expectedMaskFormat) { |
144 case kA8_GrMaskFormat:{ | 144 case kA8_GrMaskFormat:{ |
145 uint8_t* bytes = reinterpret_cast<uint8_t*>(dst); | 145 uint8_t* bytes = reinterpret_cast<uint8_t*>(dst); |
146 expand_bits(bytes, bits, width, height, dstRB, srcRB); | 146 expand_bits(bytes, bits, width, height, dstRB, srcRB); |
147 break; | 147 break; |
148 } | 148 } |
149 case kA565_GrMaskFormat: { | 149 case kA565_GrMaskFormat: { |
150 uint16_t* rgb565 = reinterpret_cast<uint16_t*>(dst); | 150 uint16_t* rgb565 = reinterpret_cast<uint16_t*>(dst); |
151 expand_bits(rgb565, bits, width, height, dstRB, srcRB); | 151 expand_bits(rgb565, bits, width, height, dstRB, srcRB); |
152 break; | 152 break; |
153 } | 153 } |
154 default: | 154 default: |
155 SkFAIL("Invalid GrMaskFormat"); | 155 SkFAIL("Invalid GrMaskFormat"); |
156 } | 156 } |
157 } else if (srcRB == dstRB) { | 157 } else if (srcRB == dstRB) { |
158 memcpy(dst, src, dstRB * height); | 158 memcpy(dst, src, dstRB * height); |
159 } else { | 159 } else { |
160 const int bbp = GrMaskFormatBytesPerPixel(this->getMaskFormat()); | 160 const int bbp = GrMaskFormatBytesPerPixel(expectedMaskFormat); |
161 for (int y = 0; y < height; y++) { | 161 for (int y = 0; y < height; y++) { |
162 memcpy(dst, src, width * bbp); | 162 memcpy(dst, src, width * bbp); |
163 src = (const char*)src + srcRB; | 163 src = (const char*)src + srcRB; |
164 dst = (char*)dst + dstRB; | 164 dst = (char*)dst + dstRB; |
165 } | 165 } |
166 } | 166 } |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 bool GrFontScaler::getPackedGlyphDFImage(const SkGlyph& glyph, int width, int he
ight, void* dst) { | 170 bool GrFontScaler::getPackedGlyphDFImage(const SkGlyph& glyph, int width, int he
ight, void* dst) { |
(...skipping 27 matching lines...) Expand all Loading... |
198 | 198 |
199 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) { | 199 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) { |
200 return fStrike->findPath(glyph); | 200 return fStrike->findPath(glyph); |
201 } | 201 } |
202 | 202 |
203 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) { | 203 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) { |
204 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id), | 204 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id), |
205 GrGlyph::UnpackFixedX(id), | 205 GrGlyph::UnpackFixedX(id), |
206 GrGlyph::UnpackFixedY(id)); | 206 GrGlyph::UnpackFixedY(id)); |
207 } | 207 } |
OLD | NEW |