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 #include "GrFontScaler.h" | 8 #include "GrFontScaler.h" |
9 #include "SkDescriptor.h" | 9 #include "SkDescriptor.h" |
10 #include "SkDistanceFieldGen.h" | 10 #include "SkDistanceFieldGen.h" |
11 #include "SkGlyphCache.h" | 11 #include "SkGlyphCache.h" |
12 | 12 |
13 /////////////////////////////////////////////////////////////////////////////// | 13 /////////////////////////////////////////////////////////////////////////////// |
14 | 14 |
15 GrFontScaler::GrFontScaler(SkGlyphCache* strike) { | 15 GrFontScaler::GrFontScaler(SkGlyphCache* strike) { |
16 fStrike = strike; | 16 fStrike = strike; |
17 fKey = nullptr; | |
18 } | 17 } |
19 | 18 |
20 GrFontScaler::~GrFontScaler() { | 19 const SkDescriptor& GrFontScaler::getKey() { return fStrike->getDescriptor(); } |
21 SkSafeUnref(fKey); | |
22 } | |
23 | |
24 GrMaskFormat GrFontScaler::getMaskFormat() const { | |
25 SkMask::Format format = fStrike->getMaskFormat(); | |
26 switch (format) { | |
27 case SkMask::kBW_Format: | |
28 // fall through to kA8 -- we store BW glyphs in our 8-bit cache | |
29 case SkMask::kA8_Format: | |
30 return kA8_GrMaskFormat; | |
31 case SkMask::kLCD16_Format: | |
32 return kA565_GrMaskFormat; | |
33 case SkMask::kARGB32_Format: | |
34 return kARGB_GrMaskFormat; | |
35 default: | |
36 SkDEBUGFAIL("unsupported SkMask::Format"); | |
37 return kA8_GrMaskFormat; | |
38 } | |
39 } | |
40 | |
41 const GrFontDescKey* GrFontScaler::getKey() { | |
42 if (nullptr == fKey) { | |
43 fKey = new GrFontDescKey(fStrike->getDescriptor()); | |
44 } | |
45 return fKey; | |
46 } | |
47 | 20 |
48 GrMaskFormat GrFontScaler::getPackedGlyphMaskFormat(const SkGlyph& glyph) const
{ | 21 GrMaskFormat GrFontScaler::getPackedGlyphMaskFormat(const SkGlyph& glyph) const
{ |
49 SkMask::Format format = static_cast<SkMask::Format>(glyph.fMaskFormat); | 22 SkMask::Format format = static_cast<SkMask::Format>(glyph.fMaskFormat); |
50 switch (format) { | 23 switch (format) { |
51 case SkMask::kBW_Format: | 24 case SkMask::kBW_Format: |
52 // fall through to kA8 -- we store BW glyphs in our 8-bit cache | 25 // fall through to kA8 -- we store BW glyphs in our 8-bit cache |
53 case SkMask::kA8_Format: | 26 case SkMask::kA8_Format: |
54 return kA8_GrMaskFormat; | 27 return kA8_GrMaskFormat; |
55 case SkMask::kLCD16_Format: | 28 case SkMask::kLCD16_Format: |
56 return kA565_GrMaskFormat; | 29 return kA565_GrMaskFormat; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 170 |
198 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) { | 171 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) { |
199 return fStrike->findPath(glyph); | 172 return fStrike->findPath(glyph); |
200 } | 173 } |
201 | 174 |
202 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) { | 175 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) { |
203 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id), | 176 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id), |
204 GrGlyph::UnpackFixedX(id), | 177 GrGlyph::UnpackFixedX(id), |
205 GrGlyph::UnpackFixedY(id)); | 178 GrGlyph::UnpackFixedY(id)); |
206 } | 179 } |
OLD | NEW |