Title: [157790] trunk/Source/WebCore
- Revision
- 157790
- Author
- akl...@apple.com
- Date
- 2013-10-22 07:42:28 -0700 (Tue, 22 Oct 2013)
Log Message
FontGlyphs constructor functions should return PassRef.
<https://webkit.org/b/123159>
Made the two FontGlyphs creator functions return PassRef and tweaked
the FontGlyphsCache in Font.cpp to make more efficient use of it.
Reviewed by Antti Koivisto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (157789 => 157790)
--- trunk/Source/WebCore/ChangeLog 2013-10-22 13:45:38 UTC (rev 157789)
+++ trunk/Source/WebCore/ChangeLog 2013-10-22 14:42:28 UTC (rev 157790)
@@ -1,5 +1,15 @@
2013-10-22 Andreas Kling <akl...@apple.com>
+ FontGlyphs constructor functions should return PassRef.
+ <https://webkit.org/b/123159>
+
+ Made the two FontGlyphs creator functions return PassRef and tweaked
+ the FontGlyphsCache in Font.cpp to make more efficient use of it.
+
+ Reviewed by Antti Koivisto.
+
+2013-10-22 Andreas Kling <akl...@apple.com>
+
Fix some more code to use RenderElement instead of RenderObject.
<https://webkit.org/b/123149>
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (157789 => 157790)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2013-10-22 13:45:38 UTC (rev 157789)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2013-10-22 14:42:28 UTC (rev 157790)
@@ -183,8 +183,9 @@
struct FontGlyphsCacheEntry {
WTF_MAKE_FAST_ALLOCATED;
public:
+ FontGlyphsCacheEntry(FontGlyphsCacheKey&& k, PassRef<FontGlyphs> g) : key(k), glyphs(std::move(g)) { }
FontGlyphsCacheKey key;
- RefPtr<FontGlyphs> glyphs;
+ Ref<FontGlyphs> glyphs;
};
typedef HashMap<unsigned, OwnPtr<FontGlyphsCacheEntry>, AlreadyHashed> FontGlyphsCache;
@@ -250,14 +251,14 @@
Vector<unsigned, 50> toRemove;
FontGlyphsCache::iterator end = fontGlyphsCache().end();
for (FontGlyphsCache::iterator it = fontGlyphsCache().begin(); it != end; ++it) {
- if (it->value->glyphs->hasOneRef())
+ if (it->value->glyphs.get().hasOneRef())
toRemove.append(it->key);
}
for (unsigned i = 0; i < toRemove.size(); ++i)
fontGlyphsCache().remove(toRemove[i]);
}
-static PassRefPtr<FontGlyphs> retrieveOrAddCachedFontGlyphs(const FontDescription& fontDescription, PassRefPtr<FontSelector> fontSelector)
+static PassRef<FontGlyphs> retrieveOrAddCachedFontGlyphs(const FontDescription& fontDescription, PassRefPtr<FontSelector> fontSelector)
{
FontGlyphsCacheKey key;
makeFontGlyphsCacheKey(key, fontDescription, fontSelector.get());
@@ -265,13 +266,11 @@
unsigned hash = computeFontGlyphsCacheHash(key);
FontGlyphsCache::AddResult addResult = fontGlyphsCache().add(hash, PassOwnPtr<FontGlyphsCacheEntry>());
if (!addResult.isNewEntry && addResult.iterator->value->key == key)
- return addResult.iterator->value->glyphs;
+ return addResult.iterator->value->glyphs.get();
OwnPtr<FontGlyphsCacheEntry>& newEntry = addResult.iterator->value;
- newEntry = adoptPtr(new FontGlyphsCacheEntry);
- newEntry->glyphs = FontGlyphs::create(fontSelector);
- newEntry->key = key;
- RefPtr<FontGlyphs> glyphs = newEntry->glyphs;
+ newEntry = adoptPtr(new FontGlyphsCacheEntry(std::move(key), FontGlyphs::create(fontSelector)));
+ PassRef<FontGlyphs> glyphs = newEntry->glyphs.get();
static const unsigned unreferencedPruneInterval = 50;
static const int maximumEntries = 400;
Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.h (157789 => 157790)
--- trunk/Source/WebCore/platform/graphics/FontGlyphs.h 2013-10-22 13:45:38 UTC (rev 157789)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.h 2013-10-22 14:42:28 UTC (rev 157790)
@@ -64,8 +64,8 @@
GlyphPageTreeNode* m_pageZero;
};
- static PassRefPtr<FontGlyphs> create(PassRefPtr<FontSelector> fontSelector) { return adoptRef(new FontGlyphs(fontSelector)); }
- static PassRefPtr<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(new FontGlyphs(platformData)); }
+ static PassRef<FontGlyphs> create(PassRefPtr<FontSelector> fontSelector) { return adoptRef(*new FontGlyphs(fontSelector)); }
+ static PassRef<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(*new FontGlyphs(platformData)); }
~FontGlyphs() { releaseFontData(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes