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 |
11 #include "GrBatchAtlas.h" | |
12 #include "GrRect.h" | 11 #include "GrRect.h" |
13 #include "GrTypes.h" | 12 #include "GrTypes.h" |
14 | 13 |
15 #include "SkChecksum.h" | 14 #include "SkChecksum.h" |
16 #include "SkPath.h" | 15 #include "SkPath.h" |
17 | 16 |
18 class GrPlot; | 17 class GrPlot; |
19 | 18 |
20 /* Need this to be quad-state: | 19 /* Need this to be quad-state: |
21 - complete w/ image | 20 - complete w/ image |
22 - just metrics | 21 - just metrics |
23 - failed to get image, but has metrics | 22 - failed to get image, but has metrics |
24 - failed to get metrics | 23 - failed to get metrics |
25 */ | 24 */ |
26 struct GrGlyph { | 25 struct GrGlyph { |
27 enum MaskStyle { | 26 enum MaskStyle { |
28 kCoverage_MaskStyle, | 27 kCoverage_MaskStyle, |
29 kDistance_MaskStyle | 28 kDistance_MaskStyle |
30 }; | 29 }; |
31 | 30 |
32 typedef uint32_t PackedID; | 31 typedef uint32_t PackedID; |
33 | 32 |
34 // TODO either plot or AtlasID will be valid, not both | 33 GrPlot* fPlot; |
35 GrBatchAtlas::AtlasID fID; | 34 SkPath* fPath; |
36 GrPlot* fPlot; | 35 PackedID fPackedID; |
37 SkPath* fPath; | 36 GrMaskFormat fMaskFormat; |
38 PackedID fPackedID; | 37 GrIRect16 fBounds; |
39 GrMaskFormat fMaskFormat; | 38 SkIPoint16 fAtlasLocation; |
40 GrIRect16 fBounds; | |
41 SkIPoint16 fAtlasLocation; | |
42 | 39 |
43 void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat form
at) { | 40 void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat form
at) { |
44 fID = GrBatchAtlas::kInvalidAtlasID; | |
45 fPlot = NULL; | 41 fPlot = NULL; |
46 fPath = NULL; | 42 fPath = NULL; |
47 fPackedID = packed; | 43 fPackedID = packed; |
48 fBounds.set(bounds); | 44 fBounds.set(bounds); |
49 fMaskFormat = format; | 45 fMaskFormat = format; |
50 fAtlasLocation.set(0, 0); | 46 fAtlasLocation.set(0, 0); |
51 } | 47 } |
52 | 48 |
53 void free() { | 49 void free() { |
54 if (fPath) { | 50 if (fPath) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) { | 91 static inline const GrGlyph::PackedID& GetKey(const GrGlyph& glyph) { |
96 return glyph.fPackedID; | 92 return glyph.fPackedID; |
97 } | 93 } |
98 | 94 |
99 static inline uint32_t Hash(GrGlyph::PackedID key) { | 95 static inline uint32_t Hash(GrGlyph::PackedID key) { |
100 return SkChecksum::Murmur3(&key, sizeof(key)); | 96 return SkChecksum::Murmur3(&key, sizeof(key)); |
101 } | 97 } |
102 }; | 98 }; |
103 | 99 |
104 #endif | 100 #endif |
OLD | NEW |