OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 * not additionally ref()ed. The typeface may be in the disposed state. | 32 * not additionally ref()ed. The typeface may be in the disposed state. |
33 */ | 33 */ |
34 typedef bool(*FindProc)(SkTypeface*, const SkFontStyle&, void* context); | 34 typedef bool(*FindProc)(SkTypeface*, const SkFontStyle&, void* context); |
35 | 35 |
36 /** | 36 /** |
37 * Add a typeface to the cache. This ref()s the typeface, so that the | 37 * Add a typeface to the cache. This ref()s the typeface, so that the |
38 * cache is also an owner. Later, if we need to purge the cache, typefaces | 38 * cache is also an owner. Later, if we need to purge the cache, typefaces |
39 * whose refcnt is 1 (meaning only the cache is an owner) will be | 39 * whose refcnt is 1 (meaning only the cache is an owner) will be |
40 * unref()ed. | 40 * unref()ed. |
41 */ | 41 */ |
42 void add(SkTypeface*, const SkFontStyle& requested, bool strong = true); | 42 void add(SkTypeface*, const SkFontStyle& requested); |
43 | 43 |
44 /** | 44 /** |
45 * Search the cache for a typeface with the specified fontID (uniqueID). | 45 * Search the cache for a typeface with the specified fontID (uniqueID). |
46 * If one is found, return it (its reference count is unmodified). If none | 46 * If one is found, return it (its reference count is unmodified). If none |
47 * is found, return NULL. The reference count is unmodified as it is | 47 * is found, return NULL. The reference count is unmodified as it is |
48 * assumed that the stack will contain a ref to the typeface. | 48 * assumed that the stack will contain a ref to the typeface. |
49 */ | 49 */ |
50 SkTypeface* findByID(SkFontID findID) const; | 50 SkTypeface* findByID(SkFontID findID) const; |
51 | 51 |
52 /** | 52 /** |
(...skipping 12 matching lines...) Expand all Loading... |
65 void purgeAll(); | 65 void purgeAll(); |
66 | 66 |
67 /** | 67 /** |
68 * Helper: returns a unique fontID to pass to the constructor of | 68 * Helper: returns a unique fontID to pass to the constructor of |
69 * your subclass of SkTypeface | 69 * your subclass of SkTypeface |
70 */ | 70 */ |
71 static SkFontID NewFontID(); | 71 static SkFontID NewFontID(); |
72 | 72 |
73 // These are static wrappers around a global instance of a cache. | 73 // These are static wrappers around a global instance of a cache. |
74 | 74 |
75 static void Add(SkTypeface*, | 75 static void Add(SkTypeface*, const SkFontStyle& requested); |
76 const SkFontStyle& requested, | |
77 bool strong = true); | |
78 static SkTypeface* FindByID(SkFontID fontID); | 76 static SkTypeface* FindByID(SkFontID fontID); |
79 static SkTypeface* FindByProcAndRef(FindProc proc, void* ctx); | 77 static SkTypeface* FindByProcAndRef(FindProc proc, void* ctx); |
80 static void PurgeAll(); | 78 static void PurgeAll(); |
81 | 79 |
82 /** | 80 /** |
83 * Debugging only: dumps the status of the typefaces in the cache | 81 * Debugging only: dumps the status of the typefaces in the cache |
84 */ | 82 */ |
85 static void Dump(); | 83 static void Dump(); |
86 | 84 |
87 private: | 85 private: |
88 static SkTypefaceCache& Get(); | 86 static SkTypefaceCache& Get(); |
89 | 87 |
90 void purge(int count); | 88 void purge(int count); |
91 | 89 |
92 struct Rec { | 90 struct Rec { |
93 SkTypeface* fFace; | 91 SkTypeface* fFace; |
94 bool fStrong; | |
95 SkFontStyle fRequestedStyle; | 92 SkFontStyle fRequestedStyle; |
96 }; | 93 }; |
97 SkTDArray<Rec> fArray; | 94 SkTDArray<Rec> fArray; |
98 }; | 95 }; |
99 | 96 |
100 #endif | 97 #endif |
OLD | NEW |