Changeset 124397 in webkit
- Timestamp:
- Aug 1, 2012 6:26:52 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r124306 r124397 51 51 "${WEBCORE_DIR}/platform/graphics/harfbuzz" 52 52 "${WEBCORE_DIR}/platform/graphics/harfbuzz/ng" 53 "${WEBCORE_DIR}/platform/graphics/opentype" 53 54 "${WEBCORE_DIR}/platform/graphics/transforms" 54 55 "${WEBCORE_DIR}/platform/image-decoders" -
trunk/Source/WebCore/ChangeLog
r124396 r124397 1 2012-08-01 Koji Ishii <kojiishi@gmail.com> 2 3 Cache support for OpenTypeVerticalData 4 https://bugs.webkit.org/show_bug.cgi?id=81332 5 6 Reviewed by Tony Chang. 7 8 This patch adds FontCache to cache OpenTypeVerticalData class 9 instances that was introduced in bug 81326. 10 11 We need one instance of the class per OpenType font file, and we don't 12 have a class to hold such instances today. 13 14 ENABLE_OPENTYPE_VERTICAL isn't enabled for any platforms yet, so this 15 patch isn't on any code path. Apple Windows port (bug 48459) is going 16 to use this code, and probably Chromium (51450, 69282) as well. 17 18 "FIXME" comment in SimpleFontData.h will be implemented in 48459. 19 20 No new tests are required. No behavior changes. 21 22 * platform/graphics/FontCache.cpp: 23 (WebCore::FontCache::getCachedFontPlatformData): Ignore leading "@" on Windows to disable Windows feature for vertical flow. 24 (WebCore): 25 (WebCore::FontCache::getVerticalData): Get cached OpenTypeVerticalData from FontPlatformData, or crete one. 26 (WebCore::FontCache::purgeInactiveFontData): Purge inactive OpenTypeVerticalData. 27 * platform/graphics/FontCache.h: 28 (WebCore): 29 * platform/graphics/SimpleFontData.h: 30 (SimpleFontData): 31 (WebCore::SimpleFontData::verticalData): A dummy implementation for purgeInactiveFontData() to work. 32 * platform/graphics/opentype/OpenTypeVerticalData.h: Added m_inFontCache for mark & sweep. 33 (OpenTypeVerticalData): 34 1 35 2012-08-01 James Robinson <jamesr@chromium.org> 2 36 -
trunk/Source/WebCore/GNUmakefile.list.am
r124306 r124397 3419 3419 Source/WebCore/platform/graphics/MediaPlayer.h \ 3420 3420 Source/WebCore/platform/graphics/MediaPlayerPrivate.h \ 3421 Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.h \ 3421 3422 Source/WebCore/platform/graphics/Path.cpp \ 3422 3423 Source/WebCore/platform/graphics/Path.h \ -
trunk/Source/WebCore/Target.pri
r124306 r124397 2098 2098 platform/graphics/IntRect.h \ 2099 2099 platform/graphics/MediaPlayer.h \ 2100 platform/graphics/opentype/OpenTypeVerticalData.h \ 2100 2101 platform/graphics/Path.h \ 2101 2102 platform/graphics/PathTraversalState.h \ -
trunk/Source/WebCore/WebCore.pri
r123185 r124397 58 58 $$SOURCE_DIR/platform/graphics/filters/arm \ 59 59 $$SOURCE_DIR/platform/graphics/opengl \ 60 $$SOURCE_DIR/platform/graphics/opentype \ 60 61 $$SOURCE_DIR/platform/graphics/qt \ 61 62 $$SOURCE_DIR/platform/graphics/surfaces \ -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r107794 r124397 36 36 #include "FontSelector.h" 37 37 #include "GlyphPageTreeNode.h" 38 #include "OpenTypeVerticalData.h" 38 39 #include "WebKitFontFamilyNames.h" 39 40 #include <wtf/HashMap.h> 40 41 #include <wtf/ListHashSet.h> 41 42 #include <wtf/StdLibExtras.h> 43 #include <wtf/text/AtomicStringHash.h> 42 44 #include <wtf/text/StringHash.h> 43 45 … … 180 182 } 181 183 182 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, 183 const AtomicString& familyName,184 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, 185 const AtomicString& passedFamilyName, 184 186 bool checkingAlternateName) 185 187 { 188 #if OS(WINDOWS) && ENABLE(OPENTYPE_VERTICAL) 189 // Leading "@" in the font name enables Windows vertical flow flag for the font. 190 // Because we do vertical flow by ourselves, we don't want to use the Windows feature. 191 // IE disregards "@" regardless of the orientatoin, so we follow the behavior. 192 const AtomicString& familyName = (passedFamilyName.isEmpty() || passedFamilyName[0] != '@') ? 193 passedFamilyName : AtomicString(passedFamilyName.impl()->substring(1)); 194 #else 195 const AtomicString& familyName = passedFamilyName; 196 #endif 197 186 198 if (!gFontPlatformDataCache) { 187 199 gFontPlatformDataCache = new FontPlatformDataCache; … … 217 229 } 218 230 231 #if ENABLE(OPENTYPE_VERTICAL) 232 typedef HashMap<FontCache::FontFileKey, OwnPtr<OpenTypeVerticalData>> FontVerticalDataCache; 233 234 FontVerticalDataCache& fontVerticalDataCacheInstance() 235 { 236 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); 237 return fontVerticalDataCache; 238 } 239 240 OpenTypeVerticalData* FontCache::getVerticalData(const FontFileKey& key, const FontPlatformData& platformData) 241 { 242 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance(); 243 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); 244 if (result != fontVerticalDataCache.end()) 245 return result.get()->second.get(); 246 247 OpenTypeVerticalData* verticalData = new OpenTypeVerticalData(platformData); 248 if (!verticalData->isOpenType()) { 249 delete verticalData; 250 verticalData = 0; // Put 0 in cache to mark that this isn't an OpenType font. 251 } 252 fontVerticalDataCache.set(key, adoptPtr(verticalData)); 253 return verticalData; 254 } 255 #endif 256 219 257 struct FontDataCacheKeyHash { 220 258 static unsigned hash(const FontPlatformData& platformData) … … 382 420 } 383 421 422 #if ENABLE(OPENTYPE_VERTICAL) 423 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance(); 424 if (!fontVerticalDataCache.isEmpty()) { 425 // Mark & sweep unused verticalData 426 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache.end(); 427 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) { 428 if (verticalData->second) 429 verticalData->second->m_inFontCache = false; 430 } 431 FontDataCache::iterator fontDataEnd = gFontDataCache->end(); 432 for (FontDataCache::iterator fontData = gFontDataCache->begin(); fontData != fontDataEnd; ++fontData) { 433 OpenTypeVerticalData* verticalData = const_cast<OpenTypeVerticalData*>(fontData->second.first->verticalData()); 434 if (verticalData) 435 verticalData->m_inFontCache = true; 436 } 437 Vector<FontFileKey> keysToRemove; 438 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); 439 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) { 440 if (!verticalData->second || !verticalData->second->m_inFontCache) 441 keysToRemove.append(verticalData->first); 442 } 443 for (size_t i = 0, count = keysToRemove.size(); i < count; ++i) 444 fontVerticalDataCache.take(keysToRemove[i]); 445 } 446 #endif 447 384 448 isPurging = false; 385 449 } -
trunk/Source/WebCore/platform/graphics/FontCache.h
r123181 r124397 50 50 class FontDescription; 51 51 class FontSelector; 52 class OpenTypeVerticalData; 52 53 class SimpleFontData; 53 54 … … 105 106 #endif 106 107 108 #if ENABLE(OPENTYPE_VERTICAL) 109 typedef AtomicString FontFileKey; 110 OpenTypeVerticalData* getVerticalData(const FontFileKey&, const FontPlatformData&); 111 #endif 112 107 113 private: 108 114 FontCache(); -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r123181 r124397 32 32 #include "GlyphMetricsMap.h" 33 33 #include "GlyphPageTreeNode.h" 34 #if ENABLE(OPENTYPE_VERTICAL) 35 #include "OpenTypeVerticalData.h" 36 #endif 34 37 #include "TypesettingFeatures.h" 35 38 #include <wtf/OwnPtr.h> … … 89 92 90 93 const FontPlatformData& platformData() const { return m_platformData; } 94 #if ENABLE(OPENTYPE_VERTICAL) 95 const OpenTypeVerticalData* verticalData() const { return 0; } // FIXME: implement 96 #endif 91 97 92 98 SimpleFontData* smallCapsFontData(const FontDescription&) const; -
trunk/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.h
r122788 r124397 25 25 #ifndef OpenTypeVerticalData_h 26 26 #define OpenTypeVerticalData_h 27 28 #if ENABLE(OPENTYPE_VERTICAL) 27 29 28 30 #include "Glyph.h" … … 57 59 int16_t m_defaultVertOriginY; 58 60 HashMap<Glyph, int16_t> m_vertOriginY; 61 62 friend class FontCache; 63 bool m_inFontCache; // for mark & sweep in FontCache::purgeInactiveFontData() 59 64 }; 60 65 61 66 } // namespace WebCore 62 67 68 #endif // ENABLE(OPENTYPE_VERTICAL) 69 63 70 #endif // OpenTypeVerticalData_h
Note: See TracChangeset
for help on using the changeset viewer.