OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2007-2008 Torch Mobile, Inc. | 3 * Copyright (C) 2007-2008 Torch Mobile, Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 14 matching lines...) Expand all Loading... |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef FontCache_h | 30 #ifndef FontCache_h |
31 #define FontCache_h | 31 #define FontCache_h |
32 | 32 |
33 #include <limits.h> | 33 #include <limits.h> |
34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "platform/fonts/FontFaceCreationParams.h" |
35 #include "wtf/Forward.h" | 36 #include "wtf/Forward.h" |
36 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
37 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
38 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
39 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
40 #include "wtf/text/CString.h" | 41 #include "wtf/text/CString.h" |
41 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
42 #include "wtf/unicode/Unicode.h" | 43 #include "wtf/unicode/Unicode.h" |
43 | 44 |
44 #if OS(WIN) | 45 #if OS(WIN) |
45 #include "SkFontMgr.h" | 46 #include "SkFontMgr.h" |
46 #include <windows.h> | 47 #include <windows.h> |
47 #include <objidl.h> | 48 #include <objidl.h> |
48 #include <mlang.h> | 49 #include <mlang.h> |
49 struct IDWriteFactory; | 50 struct IDWriteFactory; |
50 #endif | 51 #endif |
51 | 52 |
52 #if OS(ANDROID) | 53 #if OS(ANDROID) |
53 #include <unicode/uscript.h> | 54 #include <unicode/uscript.h> |
54 #endif | 55 #endif |
55 | 56 |
56 class SkTypeface; | 57 class SkTypeface; |
57 | 58 |
58 namespace WebCore { | 59 namespace WebCore { |
59 | 60 |
60 class FontCacheClient; | 61 class FontCacheClient; |
| 62 class FontFaceCreationParams; |
61 class FontPlatformData; | 63 class FontPlatformData; |
62 class FontData; | 64 class FontData; |
63 class FontDescription; | 65 class FontDescription; |
64 class OpenTypeVerticalData; | 66 class OpenTypeVerticalData; |
65 class SimpleFontData; | 67 class SimpleFontData; |
66 | 68 |
67 enum ShouldRetain { Retain, DoNotRetain }; | 69 enum ShouldRetain { Retain, DoNotRetain }; |
68 enum PurgeSeverity { PurgeIfNeeded, ForcePurge }; | 70 enum PurgeSeverity { PurgeIfNeeded, ForcePurge }; |
69 | 71 |
70 class PLATFORM_EXPORT FontCache { | 72 class PLATFORM_EXPORT FontCache { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 typedef uint32_t FontFileKey; | 116 typedef uint32_t FontFileKey; |
115 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const F
ontPlatformData&); | 117 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const F
ontPlatformData&); |
116 #endif | 118 #endif |
117 | 119 |
118 #if OS(ANDROID) | 120 #if OS(ANDROID) |
119 static AtomicString getGenericFamilyNameForScript(const AtomicString& family
Name, UScriptCode); | 121 static AtomicString getGenericFamilyNameForScript(const AtomicString& family
Name, UScriptCode); |
120 #else | 122 #else |
121 struct PlatformFallbackFont { | 123 struct PlatformFallbackFont { |
122 String name; | 124 String name; |
123 CString filename; | 125 CString filename; |
| 126 int fontconfigInterfaceId; |
124 int ttcIndex; | 127 int ttcIndex; |
125 bool isBold; | 128 bool isBold; |
126 bool isItalic; | 129 bool isItalic; |
127 }; | 130 }; |
128 static void getFontForCharacter(UChar32, const char* preferredLocale, Platfo
rmFallbackFont*); | 131 static void getFontForCharacter(UChar32, const char* preferredLocale, Platfo
rmFallbackFont*); |
129 #endif | 132 #endif |
130 | 133 |
131 private: | 134 private: |
132 FontCache(); | 135 FontCache(); |
133 ~FontCache(); | 136 ~FontCache(); |
134 | 137 |
135 void purge(PurgeSeverity = PurgeIfNeeded); | 138 void purge(PurgeSeverity = PurgeIfNeeded); |
136 | 139 |
137 void disablePurging() { m_purgePreventCount++; } | 140 void disablePurging() { m_purgePreventCount++; } |
138 void enablePurging() | 141 void enablePurging() |
139 { | 142 { |
140 ASSERT(m_purgePreventCount); | 143 ASSERT(m_purgePreventCount); |
141 if (!--m_purgePreventCount) | 144 if (!--m_purgePreventCount) |
142 purge(PurgeIfNeeded); | 145 purge(PurgeIfNeeded); |
143 } | 146 } |
144 | 147 |
145 // FIXME: This method should eventually be removed. | 148 // FIXME: This method should eventually be removed. |
146 FontPlatformData* getFontPlatformData(const FontDescription&, const AtomicSt
ring& family, bool checkingAlternateName = false); | 149 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); |
147 | 150 |
148 // These methods are implemented by each platform. | 151 // These methods are implemented by each platform. |
149 FontPlatformData* createFontPlatformData(const FontDescription&, const Atomi
cString& family, float fontSize); | 152 FontPlatformData* createFontPlatformData(const FontDescription&, const FontF
aceCreationParams&, float fontSize); |
150 | 153 |
151 // Implemented on skia platforms. | 154 // Implemented on skia platforms. |
152 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const AtomicSt
ring& family, CString& name); | 155 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace
CreationParams&, CString& name); |
153 | 156 |
154 PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformDa
ta*, ShouldRetain = Retain); | 157 PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformDa
ta*, ShouldRetain = Retain); |
155 | 158 |
156 // Don't purge if this count is > 0; | 159 // Don't purge if this count is > 0; |
157 int m_purgePreventCount; | 160 int m_purgePreventCount; |
158 | 161 |
159 #if OS(WIN) | 162 #if OS(WIN) |
160 OwnPtr<SkFontMgr> m_fontManager; | 163 OwnPtr<SkFontMgr> m_fontManager; |
161 static bool s_useDirectWrite; | 164 static bool s_useDirectWrite; |
162 static IDWriteFactory* s_directWriteFactory; | 165 static IDWriteFactory* s_directWriteFactory; |
(...skipping 10 matching lines...) Expand all Loading... |
173 | 176 |
174 class PLATFORM_EXPORT FontCachePurgePreventer { | 177 class PLATFORM_EXPORT FontCachePurgePreventer { |
175 public: | 178 public: |
176 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } | 179 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } |
177 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } | 180 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } |
178 }; | 181 }; |
179 | 182 |
180 } | 183 } |
181 | 184 |
182 #endif | 185 #endif |
OLD | NEW |