| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 SkFontMgr* fontManager() { return m_fontManager.get(); } | 105 SkFontMgr* fontManager() { return m_fontManager.get(); } |
| 106 static bool useDirectWrite() { return s_useDirectWrite; } | 106 static bool useDirectWrite() { return s_useDirectWrite; } |
| 107 static float deviceScaleFactor() { return s_deviceScaleFactor; } | 107 static float deviceScaleFactor() { return s_deviceScaleFactor; } |
| 108 static void setUseDirectWrite(bool useDirectWrite) { s_useDirectWrite = useD
irectWrite; } | 108 static void setUseDirectWrite(bool useDirectWrite) { s_useDirectWrite = useD
irectWrite; } |
| 109 static void setDirectWriteFactory(IDWriteFactory* factory) { s_directWriteFa
ctory = factory; } | 109 static void setDirectWriteFactory(IDWriteFactory* factory) { s_directWriteFa
ctory = factory; } |
| 110 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac
tor = deviceScaleFactor; } | 110 static void setDeviceScaleFactor(float deviceScaleFactor) { s_deviceScaleFac
tor = deviceScaleFactor; } |
| 111 static void setUseSubpixelPositioning(bool useSubpixelPositioning) { s_useSu
bpixelPositioning = useSubpixelPositioning; } | 111 static void setUseSubpixelPositioning(bool useSubpixelPositioning) { s_useSu
bpixelPositioning = useSubpixelPositioning; } |
| 112 static void addSideloadedFontForTesting(SkTypeface*); | 112 static void addSideloadedFontForTesting(SkTypeface*); |
| 113 #endif | 113 #endif |
| 114 | 114 |
| 115 #if ENABLE(OPENTYPE_VERTICAL) | |
| 116 typedef uint32_t FontFileKey; | 115 typedef uint32_t FontFileKey; |
| 117 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const F
ontPlatformData&); | 116 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const F
ontPlatformData&); |
| 118 #endif | |
| 119 | 117 |
| 120 #if OS(ANDROID) | 118 #if OS(ANDROID) |
| 121 static AtomicString getGenericFamilyNameForScript(const AtomicString& family
Name, const FontDescription&); | 119 static AtomicString getGenericFamilyNameForScript(const AtomicString& family
Name, const FontDescription&); |
| 122 #else | 120 #else |
| 123 struct PlatformFallbackFont { | 121 struct PlatformFallbackFont { |
| 124 String name; | 122 String name; |
| 125 CString filename; | 123 CString filename; |
| 126 int fontconfigInterfaceId; | 124 int fontconfigInterfaceId; |
| 127 int ttcIndex; | 125 int ttcIndex; |
| 128 bool isBold; | 126 bool isBold; |
| 129 bool isItalic; | 127 bool isItalic; |
| 130 }; | 128 }; |
| 131 static void getFontForCharacter(UChar32, const char* preferredLocale, Platfo
rmFallbackFont*); | 129 static void getFontForCharacter(UChar32, const char* preferredLocale, Platfo
rmFallbackFont*); |
| 132 #endif | 130 #endif |
| 131 PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformDa
ta*, ShouldRetain = Retain); |
| 133 | 132 |
| 134 private: | 133 private: |
| 135 FontCache(); | 134 FontCache(); |
| 136 ~FontCache(); | 135 ~FontCache(); |
| 137 | 136 |
| 138 void purge(PurgeSeverity = PurgeIfNeeded); | 137 void purge(PurgeSeverity = PurgeIfNeeded); |
| 139 | 138 |
| 140 void disablePurging() { m_purgePreventCount++; } | 139 void disablePurging() { m_purgePreventCount++; } |
| 141 void enablePurging() | 140 void enablePurging() |
| 142 { | 141 { |
| 143 ASSERT(m_purgePreventCount); | 142 ASSERT(m_purgePreventCount); |
| 144 if (!--m_purgePreventCount) | 143 if (!--m_purgePreventCount) |
| 145 purge(PurgeIfNeeded); | 144 purge(PurgeIfNeeded); |
| 146 } | 145 } |
| 147 | 146 |
| 148 // FIXME: This method should eventually be removed. | 147 // FIXME: This method should eventually be removed. |
| 149 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); | 148 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace
CreationParams&, bool checkingAlternateName = false); |
| 150 | 149 |
| 151 // These methods are implemented by each platform. | 150 // These methods are implemented by each platform. |
| 152 FontPlatformData* createFontPlatformData(const FontDescription&, const FontF
aceCreationParams&, float fontSize); | 151 FontPlatformData* createFontPlatformData(const FontDescription&, const FontF
aceCreationParams&, float fontSize); |
| 153 | 152 |
| 154 // Implemented on skia platforms. | 153 // Implemented on skia platforms. |
| 155 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace
CreationParams&, CString& name); | 154 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace
CreationParams&, CString& name); |
| 156 | 155 |
| 157 PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformDa
ta*, ShouldRetain = Retain); | |
| 158 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription
&, UChar32); | 156 PassRefPtr<SimpleFontData> fallbackOnStandardFontStyle(const FontDescription
&, UChar32); |
| 159 | 157 |
| 160 // Don't purge if this count is > 0; | 158 // Don't purge if this count is > 0; |
| 161 int m_purgePreventCount; | 159 int m_purgePreventCount; |
| 162 | 160 |
| 163 #if OS(WIN) | 161 #if OS(WIN) |
| 164 OwnPtr<SkFontMgr> m_fontManager; | 162 OwnPtr<SkFontMgr> m_fontManager; |
| 165 static bool s_useDirectWrite; | 163 static bool s_useDirectWrite; |
| 166 static IDWriteFactory* s_directWriteFactory; | 164 static IDWriteFactory* s_directWriteFactory; |
| 167 static float s_deviceScaleFactor; | 165 static float s_deviceScaleFactor; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 178 | 176 |
| 179 class PLATFORM_EXPORT FontCachePurgePreventer { | 177 class PLATFORM_EXPORT FontCachePurgePreventer { |
| 180 public: | 178 public: |
| 181 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } | 179 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } |
| 182 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } | 180 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } |
| 183 }; | 181 }; |
| 184 | 182 |
| 185 } // namespace blink | 183 } // namespace blink |
| 186 | 184 |
| 187 #endif | 185 #endif |
| OLD | NEW |