Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6c4ecf631b202a0278763bd5aba21b04651f2b51
      
https://github.com/WebKit/WebKit/commit/6c4ecf631b202a0278763bd5aba21b04651f2b51
  Author: Kimmo Kinnunen <[email protected]>
  Date:   2026-08-19 (Wed, 19 Aug 2026)

  Changed paths:
    M Source/WebCore/platform/graphics/GraphicsContext.cpp
    M Source/WebCore/platform/graphics/GraphicsContext.h
    M Source/WebCore/platform/graphics/GraphicsContextState.cpp
    M Source/WebCore/platform/graphics/GraphicsContextState.h
    M Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
    M Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
    M Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h
    M Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextProxy.cpp

  Log Message:
  -----------
  DisplayList::Recorder has a copy of GraphicsContext state
https://bugs.webkit.org/show_bug.cgi?id=321918
rdar://185092232

Reviewed by Mike Wyrzykowski and Nikolas Zimmermann.

Recorder held a GraphicsContextState per level in its own state stack
while GraphicsContext::m_state held the same values as a shadow copy.
Every setter wrote both: setProperty() compared and assigned on m_state,
then didUpdateSingleState() dispatched through a 16-way switch in
mergeSingleChange() to compare and assign again on the authoritative
copy. Every save() copied both, 312 bytes plus 696, and every state
flush assigned a whole 312-byte state to lastDrawingState for
bookkeeping.

Make GraphicsContext::m_state the single current state.
Recorder::ContextState now holds only the data GraphicsContext does not
track: the CTM, the clip bounds and lastDrawingState.

This reduces save() / restore() overhead.

The redundancy filtering that mergeSingleChange() did per setter moves
to the flush: changes() is now conservative, and
appendStateChangeItemIfNecessary() calls removeChangesAlreadyIn() once
before deciding which items to record.

* Source/WebCore/platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::mergeLastChanges):
* Source/WebCore/platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::didUpdateSingleState):
(WebCore::GraphicsContext::state const): Deleted.
* Source/WebCore/platform/graphics/GraphicsContextState.cpp:
(WebCore::GraphicsContextState::mergeLastChanges):
(WebCore::GraphicsContextState::mergeSingleChange):
(WebCore::GraphicsContextState::mergeAllChanges):
(WebCore::GraphicsContextState::propertyEquals const):
(WebCore::GraphicsContextState::copyProperty const):
(WebCore::GraphicsContextState::changesDifferingFrom const):
(WebCore::GraphicsContextState::removeChangesAlreadyIn):
(WebCore::GraphicsContextState::copyChangesTo const):
(WebCore::GraphicsContextState::dump const):
* Source/WebCore/platform/graphics/GraphicsContextState.h:
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::Recorder):
(WebCore::DisplayList::Recorder::didUpdateState):
(WebCore::DisplayList::Recorder::state const): Deleted.
(WebCore::DisplayList::Recorder::didUpdateSingleState): Deleted.
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::ContextState::cloneForTransparencyLayer const):
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp:
(WebCore::DisplayList::RecorderImpl::appendStateChangeItemIfNecessary):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::didUpdateSingleState): Deleted.
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextProxy.cpp:
(WebKit::RemoteGraphicsContextProxy::appendStateChangeItemIfNecessary):
(WebKit::RemoteGraphicsContextProxy::inlineStrokeStateIfBatchable):

Canonical link: https://commits.webkit.org/319507@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to