Diff
Modified: trunk/Source/WebCore/ChangeLog (275638 => 275639)
--- trunk/Source/WebCore/ChangeLog 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/ChangeLog 2021-04-07 22:46:13 UTC (rev 275639)
@@ -1,5 +1,31 @@
2021-04-07 Simon Fraser <[email protected]>
+ Wasted vector capacity in various DisplayList related code paths
+ https://bugs.webkit.org/show_bug.cgi?id=224304
+
+ Reviewed by Wenson Hsieh.
+
+ Add DisplayList::shrinkToFit() and have it shrink the vector of drawing extents (this
+ could be extended to shrink item buffers at some point). Call the shrink from
+ FontCascade which caches glyph buffers as an optimization.
+
+ Reduce the inline capacity of the Recorder's context stack; this sticks around
+ for GPU process canvases.
+
+ Reduce the inline capacity of the DrawGyph buffers from 128 to 16, as these items
+ persist for FontCascade cached lists (until a memory warning).
+
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::displayListForTextRun const):
+ * platform/graphics/displaylists/DisplayList.cpp:
+ (WebCore::DisplayList::DisplayList::shrinkToFit):
+ * platform/graphics/displaylists/DisplayList.h:
+ * platform/graphics/displaylists/DisplayListItems.h:
+ (WebCore::DisplayList::DrawGlyphs::glyphs const):
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+
+2021-04-07 Simon Fraser <[email protected]>
+
Wasted vector capacity under CSSFontFace::setUnicodeRange()
https://bugs.webkit.org/show_bug.cgi?id=224266
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2021-04-07 22:46:13 UTC (rev 275639)
@@ -235,6 +235,8 @@
FloatPoint startPoint = toFloatPoint(WebCore::size(glyphBuffer.initialAdvance()));
drawGlyphBuffer(recordingContext, glyphBuffer, startPoint, customFontNotReadyAction);
+
+ displayList->shrinkToFit();
return displayList;
}
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp 2021-04-07 22:46:13 UTC (rev 275639)
@@ -161,6 +161,14 @@
return *m_items;
}
+void DisplayList::shrinkToFit()
+{
+ if (auto* itemBuffer = itemBufferIfExists())
+ itemBuffer->shrinkToFit();
+
+ m_drawingItemExtents.shrinkToFit();
+}
+
void DisplayList::setItemBufferReadingClient(ItemBufferReadingClient* client)
{
itemBuffer().setClient(client);
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2021-04-07 22:46:13 UTC (rev 275639)
@@ -81,6 +81,8 @@
WEBCORE_EXPORT void setItemBufferWritingClient(ItemBufferWritingClient*);
WEBCORE_EXPORT void prepareToAppend(ItemBufferHandle&&);
+ void shrinkToFit();
+
#if !defined(NDEBUG) || !LOG_DISABLED
WTF::CString description() const;
WEBCORE_EXPORT void dump() const;
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp 2021-04-07 22:46:13 UTC (rev 275639)
@@ -664,6 +664,11 @@
m_writtenNumberOfBytes = 0;
}
+void ItemBuffer::shrinkToFit()
+{
+ m_allocatedBuffers.shrinkToFit();
+}
+
DidChangeItemBuffer ItemBuffer::swapWritableBufferIfNeeded(size_t numberOfBytes)
{
auto sizeForBufferSwitchItem = paddedSizeOfTypeAndItemInBytes(ItemType::MetaCommandChangeItemBuffer);
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h 2021-04-07 22:46:13 UTC (rev 275639)
@@ -150,6 +150,7 @@
}
void clear();
+ void shrinkToFit();
bool isEmpty() const
{
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2021-04-07 22:46:13 UTC (rev 275639)
@@ -920,7 +920,7 @@
RenderingResourceIdentifier fontIdentifier() { return m_fontIdentifier; }
const FloatPoint& localAnchor() const { return m_localAnchor; }
FloatPoint anchorPoint() const { return m_localAnchor; }
- const Vector<GlyphBufferGlyph, 128>& glyphs() const { return m_glyphs; }
+ const Vector<GlyphBufferGlyph, 16>& glyphs() const { return m_glyphs; }
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<DrawGlyphs> decode(Decoder&);
@@ -937,8 +937,8 @@
void computeBounds(const Font&);
RenderingResourceIdentifier m_fontIdentifier;
- Vector<GlyphBufferGlyph, 128> m_glyphs;
- Vector<GlyphBufferAdvance, 128> m_advances;
+ Vector<GlyphBufferGlyph, 16> m_glyphs;
+ Vector<GlyphBufferAdvance, 16> m_advances;
FloatRect m_bounds;
FloatPoint m_localAnchor;
FontSmoothingMode m_smoothingMode;
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (275638 => 275639)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2021-04-07 22:36:13 UTC (rev 275638)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2021-04-07 22:46:13 UTC (rev 275639)
@@ -228,7 +228,7 @@
DisplayList& m_displayList;
Delegate* m_delegate;
- Vector<ContextState, 32> m_stateStack;
+ Vector<ContextState, 4> m_stateStack;
DrawGlyphsRecorder m_drawGlyphsRecorder;
};