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 10 matching lines...) Expand all Loading... |
21 - complete w/ image | 21 - complete w/ image |
22 - just metrics | 22 - just metrics |
23 - failed to get image, but has metrics | 23 - failed to get image, but has metrics |
24 - failed to get metrics | 24 - failed to get metrics |
25 */ | 25 */ |
26 struct GrGlyph { | 26 struct GrGlyph { |
27 enum MaskStyle { | 27 enum MaskStyle { |
28 kCoverage_MaskStyle, | 28 kCoverage_MaskStyle, |
29 kDistance_MaskStyle | 29 kDistance_MaskStyle |
30 }; | 30 }; |
31 | 31 |
32 typedef uint32_t PackedID; | 32 typedef uint32_t PackedID; |
33 | 33 |
34 GrBatchAtlas::AtlasID fID; | 34 GrBatchAtlas::AtlasID fID; |
35 SkPath* fPath; | 35 SkPath* fPath; |
36 PackedID fPackedID; | 36 PackedID fPackedID; |
37 GrMaskFormat fMaskFormat; | 37 GrMaskFormat fMaskFormat; |
38 GrIRect16 fBounds; | 38 GrIRect16 fBounds; |
39 SkIPoint16 fAtlasLocation; | 39 SkIPoint16 fAtlasLocation; |
40 bool fTooLargeForAtlas; | 40 bool fTooLargeForAtlas; |
41 | 41 |
42 void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat form
at) { | 42 void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat form
at) { |
43 fID = GrBatchAtlas::kInvalidAtlasID; | 43 fID = GrBatchAtlas::kInvalidAtlasID; |
44 fPath = nullptr; | 44 fPath = nullptr; |
45 fPackedID = packed; | 45 fPackedID = packed; |
46 fBounds.set(bounds); | 46 fBounds.set(bounds); |
47 fMaskFormat = format; | 47 fMaskFormat = format; |
48 fAtlasLocation.set(0, 0); | 48 fAtlasLocation.set(0, 0); |
49 fTooLargeForAtlas = GrBatchAtlas::GlyphTooLargeForAtlas(bounds.width(),
bounds.height()); | 49 fTooLargeForAtlas = GrBatchAtlas::GlyphTooLargeForAtlas(bounds.width(),
bounds.height()); |
50 } | 50 } |
51 | 51 |
52 void reset() { | 52 void free() { |
53 if (fPath) { | 53 if (fPath) { |
54 delete fPath; | 54 delete fPath; |
55 fPath = nullptr; | 55 fPath = nullptr; |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 int width() const { return fBounds.width(); } | 59 int width() const { return fBounds.width(); } |
60 int height() const { return fBounds.height(); } | 60 int height() const { return fBounds.height(); } |
61 bool isEmpty() const { return fBounds.isEmpty(); } | 61 bool isEmpty() const { return fBounds.isEmpty(); } |
62 uint16_t glyphID() const { return UnpackID(fPackedID); } | 62 uint16_t glyphID() const { return UnpackID(fPackedID); } |
(...skipping 16 matching lines...) Expand all Loading... |
79 return ((packed >> 18) & 3) << 14; | 79 return ((packed >> 18) & 3) << 14; |
80 } | 80 } |
81 | 81 |
82 static inline SkFixed UnpackFixedY(PackedID packed) { | 82 static inline SkFixed UnpackFixedY(PackedID packed) { |
83 return ((packed >> 16) & 3) << 14; | 83 return ((packed >> 16) & 3) << 14; |
84 } | 84 } |
85 | 85 |
86 static inline MaskStyle UnpackMaskStyle(PackedID packed) { | 86 static inline MaskStyle UnpackMaskStyle(PackedID packed) { |
87 return ((packed >> 20) & 1) ? kDistance_MaskStyle : kCoverage_MaskStyle; | 87 return ((packed >> 20) & 1) ? kDistance_MaskStyle : kCoverage_MaskStyle; |
88 } | 88 } |
89 | 89 |
90 static inline uint16_t UnpackID(PackedID packed) { | 90 static inline uint16_t UnpackID(PackedID packed) { |
91 return (uint16_t)packed; | 91 return (uint16_t)packed; |
92 } | 92 } |
93 | 93 |
94 static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) { | 94 static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) { |
95 return glyph.fPackedID; | 95 return glyph.fPackedID; |
96 } | 96 } |
97 | 97 |
98 static inline uint32_t Hash(GrGlyph::PackedID key) { | 98 static inline uint32_t Hash(GrGlyph::PackedID key) { |
99 return SkChecksum::Mix(key); | 99 return SkChecksum::Mix(key); |
100 } | 100 } |
101 }; | 101 }; |
102 | 102 |
103 #endif | 103 #endif |
OLD | NEW |