| 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 27 matching lines...) Expand all Loading... |
| 38 #include "wtf/Allocator.h" | 38 #include "wtf/Allocator.h" |
| 39 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 40 #include "wtf/HashMap.h" | 40 #include "wtf/HashMap.h" |
| 41 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
| 42 #include "wtf/RefPtr.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 | 47 |
| 48 #if OS(WIN) | |
| 49 #include "SkFontMgr.h" | 48 #include "SkFontMgr.h" |
| 50 #endif | |
| 51 | 49 |
| 52 class SkTypeface; | 50 class SkTypeface; |
| 53 | 51 |
| 54 namespace blink { | 52 namespace blink { |
| 55 | 53 |
| 56 class FontCacheClient; | 54 class FontCacheClient; |
| 57 class FontFaceCreationParams; | 55 class FontFaceCreationParams; |
| 58 class FontPlatformData; | 56 class FontPlatformData; |
| 59 class FontDescription; | 57 class FontDescription; |
| 60 class OpenTypeVerticalData; | 58 class OpenTypeVerticalData; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ShapeCache* getShapeCache(const FallbackListCompositeKey&); | 95 ShapeCache* getShapeCache(const FallbackListCompositeKey&); |
| 98 | 96 |
| 99 void addClient(FontCacheClient*); | 97 void addClient(FontCacheClient*); |
| 100 #if !ENABLE(OILPAN) | 98 #if !ENABLE(OILPAN) |
| 101 void removeClient(FontCacheClient*); | 99 void removeClient(FontCacheClient*); |
| 102 #endif | 100 #endif |
| 103 | 101 |
| 104 unsigned short generation(); | 102 unsigned short generation(); |
| 105 void invalidate(); | 103 void invalidate(); |
| 106 | 104 |
| 105 SkFontMgr* fontManager() { return m_fontManager.get(); } |
| 106 static void setFontManager(const RefPtr<SkFontMgr>&); |
| 107 |
| 107 #if OS(WIN) | 108 #if OS(WIN) |
| 108 bool useSubpixelPositioning() const { return s_useSubpixelPositioning; } | 109 bool useSubpixelPositioning() const { return s_useSubpixelPositioning; } |
| 109 SkFontMgr* fontManager() { return m_fontManager.get(); } | |
| 110 static bool useDirectWrite() { return s_useDirectWrite; } | 110 static bool useDirectWrite() { return s_useDirectWrite; } |
| 111 static bool antialiasedTextEnabled() { return s_antialiasedTextEnabled; } | 111 static bool antialiasedTextEnabled() { return s_antialiasedTextEnabled; } |
| 112 static bool lcdTextEnabled() { return s_lcdTextEnabled; } | 112 static bool lcdTextEnabled() { return s_lcdTextEnabled; } |
| 113 static float deviceScaleFactor() { return s_deviceScaleFactor; } | 113 static float deviceScaleFactor() { return s_deviceScaleFactor; } |
| 114 static void setUseDirectWrite(bool useDirectWrite) { s_useDirectWrite = useD
irectWrite; } | 114 static void setUseDirectWrite(bool useDirectWrite) { s_useDirectWrite = useD
irectWrite; } |
| 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 setFontManager(const RefPtr<SkFontMgr>&); | |
| 118 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac
tor = deviceScaleFactor; } | 117 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac
tor = deviceScaleFactor; } |
| 119 static void addSideloadedFontForTesting(SkTypeface*); | 118 static void addSideloadedFontForTesting(SkTypeface*); |
| 120 // Functions to cache and retrieve the system font metrics. | 119 // Functions to cache and retrieve the system font metrics. |
| 121 static void setMenuFontMetrics(const wchar_t* familyName, int32_t fontHeight
); | 120 static void setMenuFontMetrics(const wchar_t* familyName, int32_t fontHeight
); |
| 122 static void setSmallCaptionFontMetrics(const wchar_t* familyName, int32_t fo
ntHeight); | 121 static void setSmallCaptionFontMetrics(const wchar_t* familyName, int32_t fo
ntHeight); |
| 123 static void setStatusFontMetrics(const wchar_t* familyName, int32_t fontHeig
ht); | 122 static void setStatusFontMetrics(const wchar_t* familyName, int32_t fontHeig
ht); |
| 124 static int32_t menuFontHeight() { return s_menuFontHeight; } | 123 static int32_t menuFontHeight() { return s_menuFontHeight; } |
| 125 static const AtomicString& menuFontFamily() { return *s_smallCaptionFontFami
lyName; } | 124 static const AtomicString& menuFontFamily() { return *s_smallCaptionFontFami
lyName; } |
| 126 static int32_t smallCaptionFontHeight() { return s_smallCaptionFontHeight; } | 125 static int32_t smallCaptionFontHeight() { return s_smallCaptionFontHeight; } |
| 127 static const AtomicString& smallCaptionFontFamily() { return *s_smallCaption
FontFamilyName; } | 126 static const AtomicString& smallCaptionFontFamily() { return *s_smallCaption
FontFamilyName; } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 170 |
| 172 // FIXME: This method should eventually be removed. | 171 // FIXME: This method should eventually be removed. |
| 173 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); | 172 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); |
| 174 | 173 |
| 175 // These methods are implemented by each platform. | 174 // These methods are implemented by each platform. |
| 176 PassOwnPtr<FontPlatformData> createFontPlatformData(const FontDescription&,
const FontFaceCreationParams&, float fontSize); | 175 PassOwnPtr<FontPlatformData> createFontPlatformData(const FontDescription&,
const FontFaceCreationParams&, float fontSize); |
| 177 | 176 |
| 178 // Implemented on skia platforms. | 177 // Implemented on skia platforms. |
| 179 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace
CreationParams&, CString& name); | 178 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace
CreationParams&, CString& name); |
| 180 | 179 |
| 180 #if OS(ANDROID) || OS(LINUX) |
| 181 static AtomicString getFamilyNameForCharacter(SkFontMgr*, UChar32, const Fon
tDescription&, FontFallbackPriority); |
| 182 #endif |
| 183 |
| 181 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription
&, UChar32); | 184 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription
&, UChar32); |
| 182 | 185 |
| 183 // Don't purge if this count is > 0; | 186 // Don't purge if this count is > 0; |
| 184 int m_purgePreventCount; | 187 int m_purgePreventCount; |
| 185 | 188 |
| 189 RefPtr<SkFontMgr> m_fontManager; |
| 190 |
| 191 static SkFontMgr* s_fontManager; |
| 192 |
| 186 #if OS(WIN) | 193 #if OS(WIN) |
| 187 RefPtr<SkFontMgr> m_fontManager; | |
| 188 static bool s_useDirectWrite; | 194 static bool s_useDirectWrite; |
| 189 static bool s_antialiasedTextEnabled; | 195 static bool s_antialiasedTextEnabled; |
| 190 static bool s_lcdTextEnabled; | 196 static bool s_lcdTextEnabled; |
| 191 static SkFontMgr* s_fontManager; | |
| 192 static float s_deviceScaleFactor; | 197 static float s_deviceScaleFactor; |
| 193 static bool s_useSubpixelPositioning; | 198 static bool s_useSubpixelPositioning; |
| 194 static HashMap<String, RefPtr<SkTypeface>>* s_sideloadedFonts; | 199 static HashMap<String, RefPtr<SkTypeface>>* s_sideloadedFonts; |
| 195 // The system font metrics cache. | 200 // The system font metrics cache. |
| 196 static AtomicString* s_menuFontFamilyName; | 201 static AtomicString* s_menuFontFamilyName; |
| 197 static int32_t s_menuFontHeight; | 202 static int32_t s_menuFontHeight; |
| 198 static AtomicString* s_smallCaptionFontFamilyName; | 203 static AtomicString* s_smallCaptionFontFamilyName; |
| 199 static int32_t s_smallCaptionFontHeight; | 204 static int32_t s_smallCaptionFontHeight; |
| 200 static AtomicString* s_statusFontFamilyName; | 205 static AtomicString* s_statusFontFamilyName; |
| 201 static int32_t s_statusFontHeight; | 206 static int32_t s_statusFontHeight; |
| 202 #endif | 207 #endif |
| 203 | 208 |
| 204 friend class SimpleFontData; // For fontDataFromFontPlatformData | 209 friend class SimpleFontData; // For fontDataFromFontPlatformData |
| 205 friend class FontFallbackList; | 210 friend class FontFallbackList; |
| 206 }; | 211 }; |
| 207 | 212 |
| 208 class PLATFORM_EXPORT FontCachePurgePreventer { | 213 class PLATFORM_EXPORT FontCachePurgePreventer { |
| 209 USING_FAST_MALLOC(FontCachePurgePreventer); | 214 USING_FAST_MALLOC(FontCachePurgePreventer); |
| 210 WTF_MAKE_NONCOPYABLE(FontCachePurgePreventer); | 215 WTF_MAKE_NONCOPYABLE(FontCachePurgePreventer); |
| 211 public: | 216 public: |
| 212 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } | 217 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } |
| 213 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } | 218 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } |
| 214 }; | 219 }; |
| 215 | 220 |
| 216 } // namespace blink | 221 } // namespace blink |
| 217 | 222 |
| 218 #endif | 223 #endif |
| OLD | NEW |