Modified: trunk/Source/WebCore/ChangeLog (293571 => 293572)
--- trunk/Source/WebCore/ChangeLog 2022-04-28 10:06:38 UTC (rev 293571)
+++ trunk/Source/WebCore/ChangeLog 2022-04-28 15:12:24 UTC (rev 293572)
@@ -1,3 +1,21 @@
+2022-04-28 Simon Fraser <[email protected]>
+
+ DisplayList::Recorder should lazily create the DrawGlyphsRecorder
+ https://bugs.webkit.org/show_bug.cgi?id=239829
+
+ Reviewed by Myles C. Maxfield.
+
+ Creating a DrawGlyphsRecorder does a bit of work that calls into Core Graphics. We don't need
+ to do this work for a layer that has no text, so delay this work until the first drawGlyphs() call.
+
+ This is a few % perf gain on the Images MotionMark subtest.
+
+ * platform/graphics/DrawGlyphsRecorder.h:
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+ (WebCore::DisplayList::Recorder::Recorder):
+ (WebCore::DisplayList::Recorder::drawGlyphs):
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+
2022-04-28 Said Abou-Hallawa <[email protected]>
[GPU Process] Make WebImage be backed by ImageBuffer
Modified: trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h (293571 => 293572)
--- trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h 2022-04-28 10:06:38 UTC (rev 293571)
+++ trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h 2022-04-28 15:12:24 UTC (rev 293572)
@@ -52,6 +52,8 @@
class GraphicsContext;
class DrawGlyphsRecorder {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(DrawGlyphsRecorder);
public:
enum class DeconstructDrawGlyphs : bool { No, Yes };
enum class DeriveFontFromContext : bool { No, Yes };
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (293571 => 293572)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2022-04-28 10:06:38 UTC (rev 293571)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2022-04-28 15:12:24 UTC (rev 293572)
@@ -48,7 +48,8 @@
Recorder::Recorder(const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, DrawGlyphsRecorder::DeconstructDrawGlyphs deconstructDrawGlyphs)
: GraphicsContext(state)
- , m_drawGlyphsRecorder(*this, initialCTM.xScale(), deconstructDrawGlyphs)
+ , m_initialScale(initialCTM.xScale())
+ , m_deconstructDrawGlyphs(deconstructDrawGlyphs)
{
m_stateStack.append({ state, initialCTM, initialCTM.mapRect(initialClip) });
}
@@ -161,7 +162,10 @@
void Recorder::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode)
{
- m_drawGlyphsRecorder.drawGlyphs(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);
+ if (!m_drawGlyphsRecorder)
+ m_drawGlyphsRecorder = makeUnique<DrawGlyphsRecorder>(*this, m_initialScale, m_deconstructDrawGlyphs);
+
+ m_drawGlyphsRecorder->drawGlyphs(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);
}
void Recorder::drawGlyphsAndCacheFont(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode)
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (293571 => 293572)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2022-04-28 10:06:38 UTC (rev 293571)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2022-04-28 15:12:24 UTC (rev 293572)
@@ -270,7 +270,9 @@
const AffineTransform& ctm() const;
Vector<ContextState, 4> m_stateStack;
- DrawGlyphsRecorder m_drawGlyphsRecorder;
+ std::unique_ptr<DrawGlyphsRecorder> m_drawGlyphsRecorder;
+ float m_initialScale { 1 };
+ DrawGlyphsRecorder::DeconstructDrawGlyphs m_deconstructDrawGlyphs { DrawGlyphsRecorder::DeconstructDrawGlyphs::No };
};
} // namespace DisplayList