Diff
Modified: trunk/Source/WebCore/ChangeLog (294144 => 294145)
--- trunk/Source/WebCore/ChangeLog 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/ChangeLog 2022-05-13 07:29:08 UTC (rev 294145)
@@ -1,3 +1,43 @@
+2022-05-13 Simon Fraser <[email protected]>
+
+ Simplify the usage of DrawGlyphsRecorder
+ https://bugs.webkit.org/show_bug.cgi?id=240363
+
+ Reviewed by Myles Maxfield.
+
+ Move the DeconstructDrawGlyphs switch from inside DrawGlyphsRecorder to
+ DisplayList::Recorder, so that DrawGlyphsRecorder is only ever used when deconstructing
+ glyphs.
+
+ Also, ensure that the only time that glyph deconstruction is enabled is when
+ recording display lists via RemoteDisplayListRecorderProxy. There's no reason for
+ paintAttachmentText() to need glyph deconstruction.
+
+ This is a small perf improvement on the MotionMark Design subtest.
+
+ * platform/graphics/DrawGlyphsRecorder.h:
+ (WebCore::DrawGlyphsRecorder::deconstructDrawGlyphs const): Deleted.
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::displayListForTextRun const):
+ * platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:
+ (WebCore::DrawGlyphsRecorder::DrawGlyphsRecorder):
+ (WebCore::DrawGlyphsRecorder::drawGlyphs):
+ (WebCore::DrawGlyphsRecorder::drawNativeText):
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+ (WebCore::DisplayList::Recorder::Recorder):
+ (WebCore::DisplayList::Recorder::drawGlyphs):
+ (WebCore::DisplayList::Recorder::drawGlyphsAndCacheFont):
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+ * platform/graphics/displaylists/DisplayListRecorderImpl.cpp:
+ (WebCore::DisplayList::RecorderImpl::RecorderImpl):
+ * platform/graphics/displaylists/DisplayListRecorderImpl.h:
+ * platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp:
+ (WebCore::DrawGlyphsRecorder::DrawGlyphsRecorder):
+ * platform/graphics/win/DrawGlyphsRecorderWin.cpp:
+ (WebCore::DrawGlyphsRecorder::DrawGlyphsRecorder):
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::paintAttachmentText):
+
2022-05-12 Manuel Rego Casasnovas <[email protected]>
Remove unneeded check in HTMLSlotElement::assignedNodes()
Modified: trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h 2022-05-13 07:29:08 UTC (rev 294145)
@@ -55,9 +55,8 @@
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(DrawGlyphsRecorder);
public:
- enum class DeconstructDrawGlyphs : bool { No, Yes };
enum class DeriveFontFromContext : bool { No, Yes };
- explicit DrawGlyphsRecorder(GraphicsContext&, float scaleFactor = 1, DeconstructDrawGlyphs = DeconstructDrawGlyphs::No, DeriveFontFromContext = DeriveFontFromContext::No);
+ explicit DrawGlyphsRecorder(GraphicsContext&, float scaleFactor = 1, DeriveFontFromContext = DeriveFontFromContext::No);
void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode);
@@ -70,8 +69,6 @@
void recordDrawImage(CGRenderingStateRef, CGGStateRef, CGRect, CGImageRef);
#endif
- DeconstructDrawGlyphs deconstructDrawGlyphs() const { return m_deconstructDrawGlyphs; }
-
private:
#if USE(CORE_TEXT) && !PLATFORM(WIN)
UniqueRef<GraphicsContext> createInternalContext();
@@ -104,8 +101,6 @@
#endif
GraphicsContext& m_owner;
- DeconstructDrawGlyphs m_deconstructDrawGlyphs;
- DeriveFontFromContext m_deriveFontFromContext;
#if USE(CORE_TEXT) && !PLATFORM(WIN)
UniqueRef<GraphicsContext> m_internalContext;
@@ -112,7 +107,10 @@
#endif
const Font* m_originalFont { nullptr };
+
+ const DeriveFontFromContext m_deriveFontFromContext;
FontSmoothingMode m_smoothingMode { FontSmoothingMode::AutoSmoothing };
+
AffineTransform m_originalTextMatrix;
struct State {
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -213,7 +213,7 @@
return nullptr;
std::unique_ptr<DisplayList::InMemoryDisplayList> displayList = makeUnique<DisplayList::InMemoryDisplayList>();
- DisplayList::RecorderImpl recordingContext(*displayList, context.state().cloneForRecording(), FloatRect(), AffineTransform(), DrawGlyphsRecorder::DeconstructDrawGlyphs::No);
+ DisplayList::RecorderImpl recordingContext(*displayList, context.state().cloneForRecording(), { }, { });
FloatPoint startPoint = toFloatPoint(WebCore::size(glyphBuffer.initialAdvance()));
drawGlyphBuffer(recordingContext, glyphBuffer, startPoint, customFontNotReadyAction);
Modified: trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -86,11 +86,10 @@
return makeUniqueRef<GraphicsContextCG>(context.get());
}
-DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, float scaleFactor, DeconstructDrawGlyphs deconstructDrawGlyphs, DeriveFontFromContext deriveFontFromContext)
+DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, float scaleFactor, DeriveFontFromContext deriveFontFromContext)
: m_owner(owner)
- , m_deconstructDrawGlyphs(deconstructDrawGlyphs)
+ , m_internalContext(createInternalContext())
, m_deriveFontFromContext(deriveFontFromContext)
- , m_internalContext(createInternalContext())
{
m_internalContext->applyDeviceScaleFactor(scaleFactor);
}
@@ -398,20 +397,11 @@
void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode)
{
- if (m_deconstructDrawGlyphs == DeconstructDrawGlyphs::No) {
- m_owner.drawGlyphsAndCacheFont(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);
- return;
- }
-
- ASSERT(m_deconstructDrawGlyphs == DeconstructDrawGlyphs::Yes);
-
drawBySplittingIntoOTSVGAndNonOTSVGRuns(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);
}
void DrawGlyphsRecorder::drawNativeText(CTFontRef font, CGFloat fontSize, CTLineRef line, CGRect lineRect)
{
- ASSERT(m_deconstructDrawGlyphs == DeconstructDrawGlyphs::Yes);
-
GraphicsContextStateSaver saver(m_owner);
m_owner.translate(lineRect.origin.x, lineRect.origin.y + lineRect.size.height);
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -46,7 +46,7 @@
namespace WebCore {
namespace DisplayList {
-Recorder::Recorder(const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, DrawGlyphsRecorder::DeconstructDrawGlyphs deconstructDrawGlyphs)
+Recorder::Recorder(const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, DeconstructDrawGlyphs deconstructDrawGlyphs)
: GraphicsContext(state)
, m_initialScale(initialCTM.xScale())
, m_deconstructDrawGlyphs(deconstructDrawGlyphs)
@@ -163,17 +163,22 @@
void Recorder::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode)
{
- if (!m_drawGlyphsRecorder)
- m_drawGlyphsRecorder = makeUnique<DrawGlyphsRecorder>(*this, m_initialScale, m_deconstructDrawGlyphs);
+ if (m_deconstructDrawGlyphs == DeconstructDrawGlyphs::Yes) {
+ if (!m_drawGlyphsRecorder)
+ m_drawGlyphsRecorder = makeUnique<DrawGlyphsRecorder>(*this, m_initialScale);
- m_drawGlyphsRecorder->drawGlyphs(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);
+ m_drawGlyphsRecorder->drawGlyphs(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);
+ return;
+ }
+
+ drawGlyphsAndCacheFont(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)
+void Recorder::drawGlyphsAndCacheFont(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode)
{
appendStateChangeItemIfNecessary();
recordResourceUse(const_cast<Font&>(font));
- recordDrawGlyphs(font, glyphs, advances, count, localAnchor, smoothingMode);
+ recordDrawGlyphs(font, glyphs, advances, numGlyphs, localAnchor, smoothingMode);
}
void Recorder::drawImageBuffer(ImageBuffer& imageBuffer, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2022-05-13 07:29:08 UTC (rev 294145)
@@ -51,7 +51,9 @@
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(Recorder);
public:
- WEBCORE_EXPORT Recorder(const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DrawGlyphsRecorder::DeconstructDrawGlyphs = DrawGlyphsRecorder::DeconstructDrawGlyphs::Yes);
+ enum class DeconstructDrawGlyphs : bool { No, Yes };
+
+ WEBCORE_EXPORT Recorder(const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DeconstructDrawGlyphs = DeconstructDrawGlyphs::No);
WEBCORE_EXPORT virtual ~Recorder();
virtual void convertToLuminanceMask() = 0;
@@ -271,7 +273,7 @@
Vector<ContextState, 4> m_stateStack;
std::unique_ptr<DrawGlyphsRecorder> m_drawGlyphsRecorder;
float m_initialScale { 1 };
- DrawGlyphsRecorder::DeconstructDrawGlyphs m_deconstructDrawGlyphs { DrawGlyphsRecorder::DeconstructDrawGlyphs::No };
+ const DeconstructDrawGlyphs m_deconstructDrawGlyphs { DeconstructDrawGlyphs::No };
};
} // namespace DisplayList
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -42,7 +42,7 @@
namespace WebCore {
namespace DisplayList {
-RecorderImpl::RecorderImpl(DisplayList& displayList, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, DrawGlyphsRecorder::DeconstructDrawGlyphs deconstructDrawGlyphs)
+RecorderImpl::RecorderImpl(DisplayList& displayList, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, DeconstructDrawGlyphs deconstructDrawGlyphs)
: Recorder(state, initialClip, initialCTM, deconstructDrawGlyphs)
, m_displayList(displayList)
{
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h 2022-05-13 07:29:08 UTC (rev 294145)
@@ -35,7 +35,7 @@
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(RecorderImpl);
public:
- WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DrawGlyphsRecorder::DeconstructDrawGlyphs = DrawGlyphsRecorder::DeconstructDrawGlyphs::Yes);
+ WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DeconstructDrawGlyphs = DeconstructDrawGlyphs::No);
WEBCORE_EXPORT virtual ~RecorderImpl();
bool isEmpty() const { return m_displayList.isEmpty(); }
Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -32,8 +32,9 @@
namespace WebCore {
-DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, float, DeconstructDrawGlyphs, DeriveFontFromContext)
+DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, float, DeriveFontFromContext deriveFontFromContext)
: m_owner(owner)
+ , m_deriveFontFromContext(deriveFontFromContext)
{
}
Modified: trunk/Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp (294144 => 294145)
--- trunk/Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -32,8 +32,9 @@
namespace WebCore {
-DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, float, DeconstructDrawGlyphs, DeriveFontFromContext)
+DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, float, DeriveFontFromContext deriveFontFromContext)
: m_owner(owner)
+ , m_deriveFontFromContext(deriveFontFromContext)
{
}
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (294144 => 294145)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2022-05-13 07:29:08 UTC (rev 294145)
@@ -1919,7 +1919,7 @@
static void paintAttachmentText(GraphicsContext& context, RenderAttachmentInfo& info)
{
- DrawGlyphsRecorder recorder(context, 1, DrawGlyphsRecorder::DeconstructDrawGlyphs::Yes, DrawGlyphsRecorder::DeriveFontFromContext::Yes);
+ DrawGlyphsRecorder recorder(context, 1, DrawGlyphsRecorder::DeriveFontFromContext::Yes);
for (const auto& line : info.lines)
recorder.drawNativeText(line.font.get(), CTFontGetSize(line.font.get()), line.line.get(), line.rect);
Modified: trunk/Source/WebKit/ChangeLog (294144 => 294145)
--- trunk/Source/WebKit/ChangeLog 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebKit/ChangeLog 2022-05-13 07:29:08 UTC (rev 294145)
@@ -1,3 +1,25 @@
+2022-05-13 Simon Fraser <[email protected]>
+
+ Simplify the usage of DrawGlyphsRecorder
+ https://bugs.webkit.org/show_bug.cgi?id=240363
+
+ Reviewed by Myles Maxfield.
+
+ Move the DeconstructDrawGlyphs switch from inside DrawGlyphsRecorder to
+ DisplayList::Recorder, so that DrawGlyphsRecorder is only ever used when deconstructing
+ glyphs.
+
+ Also, ensure that the only time that glyph deconstruction is enabled is when
+ recording display lists via RemoteDisplayListRecorderProxy. There's no reason for
+ paintAttachmentText() to need glyph deconstruction.
+
+ This is a small perf improvement on the MotionMark Design subtest.
+
+ * WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
+ (WebKit::RemoteDisplayListRecorderProxy::RemoteDisplayListRecorderProxy):
+ (WebKit::m_renderingBackend):
+ * WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
+
2022-05-12 Michael Catanzaro <[email protected]>
-Wunused-result in WebCoreSupport/WebContextMenuClient.cpp
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp (294144 => 294145)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp 2022-05-13 07:29:08 UTC (rev 294145)
@@ -44,8 +44,8 @@
namespace WebKit {
using namespace WebCore;
-RemoteDisplayListRecorderProxy::RemoteDisplayListRecorderProxy(ImageBuffer& imageBuffer, RemoteRenderingBackendProxy& renderingBackend, const FloatRect& initialClip, const AffineTransform& initialCTM, DrawGlyphsRecorder::DeconstructDrawGlyphs deconstructDrawGlyphs)
- : DisplayList::Recorder({ }, initialClip, initialCTM, deconstructDrawGlyphs)
+RemoteDisplayListRecorderProxy::RemoteDisplayListRecorderProxy(ImageBuffer& imageBuffer, RemoteRenderingBackendProxy& renderingBackend, const FloatRect& initialClip, const AffineTransform& initialCTM)
+ : DisplayList::Recorder({ }, initialClip, initialCTM, DeconstructDrawGlyphs::Yes)
, m_destinationBufferIdentifier(imageBuffer.renderingResourceIdentifier())
, m_imageBuffer(imageBuffer)
, m_renderingBackend(renderingBackend)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h (294144 => 294145)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h 2022-05-13 07:26:01 UTC (rev 294144)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h 2022-05-13 07:29:08 UTC (rev 294145)
@@ -39,7 +39,7 @@
class RemoteDisplayListRecorderProxy : public WebCore::DisplayList::Recorder {
public:
- RemoteDisplayListRecorderProxy(WebCore::ImageBuffer&, RemoteRenderingBackendProxy&, const WebCore::FloatRect& initialClip, const WebCore::AffineTransform&, WebCore::DrawGlyphsRecorder::DeconstructDrawGlyphs = WebCore::DrawGlyphsRecorder::DeconstructDrawGlyphs::Yes);
+ RemoteDisplayListRecorderProxy(WebCore::ImageBuffer&, RemoteRenderingBackendProxy&, const WebCore::FloatRect& initialClip, const WebCore::AffineTransform&);
~RemoteDisplayListRecorderProxy() = default;
void resetNeedsFlush() { m_needsFlush = false; }