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 17 matching lines...) Expand all Loading... |
28 */ | 28 */ |
29 | 29 |
30 #ifndef FontCache_h | 30 #ifndef FontCache_h |
31 #define FontCache_h | 31 #define FontCache_h |
32 | 32 |
33 #include "platform/PlatformExport.h" | 33 #include "platform/PlatformExport.h" |
34 #include "platform/fonts/FallbackListCompositeKey.h" | 34 #include "platform/fonts/FallbackListCompositeKey.h" |
35 #include "platform/fonts/FontCacheKey.h" | 35 #include "platform/fonts/FontCacheKey.h" |
36 #include "platform/fonts/FontFaceCreationParams.h" | 36 #include "platform/fonts/FontFaceCreationParams.h" |
37 #include "platform/fonts/FontFallbackPriority.h" | 37 #include "platform/fonts/FontFallbackPriority.h" |
| 38 #include "third_party/skia/include/core/SkRefCnt.h" |
38 #include "wtf/Allocator.h" | 39 #include "wtf/Allocator.h" |
39 #include "wtf/Forward.h" | 40 #include "wtf/Forward.h" |
40 #include "wtf/HashMap.h" | 41 #include "wtf/HashMap.h" |
41 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
42 #include "wtf/RefPtr.h" | |
43 #include "wtf/text/CString.h" | 43 #include "wtf/text/CString.h" |
44 #include "wtf/text/Unicode.h" | 44 #include "wtf/text/Unicode.h" |
45 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
46 #include <limits.h> | 46 #include <limits.h> |
47 #include <memory> | 47 #include <memory> |
48 | 48 |
49 #include "SkFontMgr.h" | 49 #include "SkFontMgr.h" |
50 | 50 |
51 class SkTypeface; | 51 class SkTypeface; |
52 | 52 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // be valid for the duration of the current session, as controlled by | 99 // be valid for the duration of the current session, as controlled by |
100 // disable/enablePurging. | 100 // disable/enablePurging. |
101 ShapeCache* getShapeCache(const FallbackListCompositeKey&); | 101 ShapeCache* getShapeCache(const FallbackListCompositeKey&); |
102 | 102 |
103 void addClient(FontCacheClient*); | 103 void addClient(FontCacheClient*); |
104 | 104 |
105 unsigned short generation(); | 105 unsigned short generation(); |
106 void invalidate(); | 106 void invalidate(); |
107 | 107 |
108 SkFontMgr* fontManager() { return m_fontManager.get(); } | 108 SkFontMgr* fontManager() { return m_fontManager.get(); } |
109 static void setFontManager(const RefPtr<SkFontMgr>&); | 109 static void setFontManager(const sk_sp<SkFontMgr>&); |
110 | 110 |
111 #if OS(WIN) | 111 #if OS(WIN) |
112 static bool antialiasedTextEnabled() { return s_antialiasedTextEnabled; } | 112 static bool antialiasedTextEnabled() { return s_antialiasedTextEnabled; } |
113 static bool lcdTextEnabled() { return s_lcdTextEnabled; } | 113 static bool lcdTextEnabled() { return s_lcdTextEnabled; } |
114 static float deviceScaleFactor() { return s_deviceScaleFactor; } | 114 static float deviceScaleFactor() { return s_deviceScaleFactor; } |
115 static void setAntialiasedTextEnabled(bool enabled) { s_antialiasedTextEnabl
ed = enabled; } | 115 static void setAntialiasedTextEnabled(bool enabled) { s_antialiasedTextEnabl
ed = enabled; } |
116 static void setLCDTextEnabled(bool enabled) { s_lcdTextEnabled = enabled; } | 116 static void setLCDTextEnabled(bool enabled) { s_lcdTextEnabled = enabled; } |
117 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac
tor = deviceScaleFactor; } | 117 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac
tor = deviceScaleFactor; } |
118 static void addSideloadedFontForTesting(SkTypeface*); | 118 static void addSideloadedFontForTesting(SkTypeface*); |
119 // Functions to cache and retrieve the system font metrics. | 119 // Functions to cache and retrieve the system font metrics. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 // FIXME: This method should eventually be removed. | 172 // FIXME: This method should eventually be removed. |
173 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); | 173 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); |
174 | 174 |
175 // These methods are implemented by each platform. | 175 // These methods are implemented by each platform. |
176 std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescripti
on&, const FontFaceCreationParams&, float fontSize); | 176 std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescripti
on&, const FontFaceCreationParams&, float fontSize); |
177 std::unique_ptr<FontPlatformData> scaleFontPlatformData(const FontPlatformDa
ta&, const FontDescription&, const FontFaceCreationParams&, float fontSize); | 177 std::unique_ptr<FontPlatformData> scaleFontPlatformData(const FontPlatformDa
ta&, const FontDescription&, const FontFaceCreationParams&, float fontSize); |
178 | 178 |
179 // Implemented on skia platforms. | 179 // Implemented on skia platforms. |
180 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace
CreationParams&, CString& name); | 180 sk_sp<SkTypeface> createTypeface(const FontDescription&, const FontFaceCreat
ionParams&, CString& name); |
181 | 181 |
182 #if OS(ANDROID) || OS(LINUX) | 182 #if OS(ANDROID) || OS(LINUX) |
183 static AtomicString getFamilyNameForCharacter(SkFontMgr*, UChar32, const Fon
tDescription&, FontFallbackPriority); | 183 static AtomicString getFamilyNameForCharacter(SkFontMgr*, UChar32, const Fon
tDescription&, FontFallbackPriority); |
184 #endif | 184 #endif |
185 | 185 |
186 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription
&, UChar32); | 186 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription
&, UChar32); |
187 | 187 |
188 // Don't purge if this count is > 0; | 188 // Don't purge if this count is > 0; |
189 int m_purgePreventCount; | 189 int m_purgePreventCount; |
190 | 190 |
191 RefPtr<SkFontMgr> m_fontManager; | 191 sk_sp<SkFontMgr> m_fontManager; |
192 | 192 |
193 static SkFontMgr* s_staticFontManager; | 193 static SkFontMgr* s_staticFontManager; |
194 | 194 |
195 #if OS(WIN) | 195 #if OS(WIN) |
196 static bool s_antialiasedTextEnabled; | 196 static bool s_antialiasedTextEnabled; |
197 static bool s_lcdTextEnabled; | 197 static bool s_lcdTextEnabled; |
198 static float s_deviceScaleFactor; | 198 static float s_deviceScaleFactor; |
199 static HashMap<String, RefPtr<SkTypeface>>* s_sideloadedFonts; | 199 static HashMap<String, sk_sp<SkTypeface>>* s_sideloadedFonts; |
200 // The system font metrics cache. | 200 // The system font metrics cache. |
201 static AtomicString* s_menuFontFamilyName; | 201 static AtomicString* s_menuFontFamilyName; |
202 static int32_t s_menuFontHeight; | 202 static int32_t s_menuFontHeight; |
203 static AtomicString* s_smallCaptionFontFamilyName; | 203 static AtomicString* s_smallCaptionFontFamilyName; |
204 static int32_t s_smallCaptionFontHeight; | 204 static int32_t s_smallCaptionFontHeight; |
205 static AtomicString* s_statusFontFamilyName; | 205 static AtomicString* s_statusFontFamilyName; |
206 static int32_t s_statusFontHeight; | 206 static int32_t s_statusFontHeight; |
207 static bool s_useSkiaFontFallback; | 207 static bool s_useSkiaFontFallback; |
208 #endif | 208 #endif |
209 | 209 |
210 friend class SimpleFontData; // For fontDataFromFontPlatformData | 210 friend class SimpleFontData; // For fontDataFromFontPlatformData |
211 friend class FontFallbackList; | 211 friend class FontFallbackList; |
212 }; | 212 }; |
213 | 213 |
214 class PLATFORM_EXPORT FontCachePurgePreventer { | 214 class PLATFORM_EXPORT FontCachePurgePreventer { |
215 USING_FAST_MALLOC(FontCachePurgePreventer); | 215 USING_FAST_MALLOC(FontCachePurgePreventer); |
216 WTF_MAKE_NONCOPYABLE(FontCachePurgePreventer); | 216 WTF_MAKE_NONCOPYABLE(FontCachePurgePreventer); |
217 public: | 217 public: |
218 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } | 218 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } |
219 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } | 219 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } |
220 }; | 220 }; |
221 | 221 |
222 } // namespace blink | 222 } // namespace blink |
223 | 223 |
224 #endif | 224 #endif |
OLD | NEW |