Branch: refs/heads/webkitglib/2.52
  Home:   https://github.com/WebKit/WebKit
  Commit: 94f9f23594c108a6bca08453d216a5b9e3a0a4f2
      
https://github.com/WebKit/WebKit/commit/94f9f23594c108a6bca08453d216a5b9e3a0a4f2
  Author: Nikolas Zimmermann <[email protected]>
  Date:   2026-02-23 (Mon, 23 Feb 2026)

  Changed paths:
    A 
LayoutTests/fast/canvas/canvas-recording-clip-state-across-frames-expected.html
    A LayoutTests/fast/canvas/canvas-recording-clip-state-across-frames.html
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h
    M 
Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp
    M Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.h

  Log Message:
  -----------
  Cherry-pick 308033@main (84a16ff08493). 
https://bugs.webkit.org/show_bug.cgi?id=306621

    REGRESSION(305273@main): [GTK] Another PDF rendering regression
    https://bugs.webkit.org/show_bug.cgi?id=306621

    Reviewed by Carlos Garcia Campos.

    The canvas 2D operation recording feature (webkit.org/b/303575) introduced
    a mechanism to batch canvas operations into an SkPicture for deferred GPU
    replay. When flushing the recording, the implementation switched between a
    recording canvas and the GPU surface canvas. To preserve drawing state
    across these switches, it attempted to copy individual GraphicsContext
    properties (fill color, stroke, CTM, etc.) from one context to the other.
    This approach was inherently fragile: it could not reproduce the full
    save/restore nesting, clip stack, or transparency layer state,
    causing PDF rendering and other complex painting scenarios to break.

    Replace the state-copying approach with a state replay mechanism.
    GraphicsContextSkia now optionally tracks the full sequence of
    save/restore operations, transparency layers, and clip operations
    (rect, path, shader) along with their associated transforms. When
    the canvas recording is flushed and the switchable canvas is
    redirected to a new target, replayStateOnCanvas() reconstructs
    the exact save/clip/CTM nesting on that canvas, ensuring drawing
    state is fully preserved.

    Unify SkiaState and LayerState into a single SkiaState struct that
    handles both regular saves and transparency layers. Move recording
    context creation from lazy initialization into the constructor,
    eliminating the need for ensureCanvasRecordingContext() and the
    error-prone copyGraphicsState() helper.

    Test: fast/canvas/canvas-recording-clip-state-across-frames.html

    * 
LayoutTests/fast/canvas/canvas-recording-clip-state-across-frames-expected.html:
 Added.
    * LayoutTests/fast/canvas/canvas-recording-clip-state-across-frames.html: 
Added.
    * Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
    (WebCore::GraphicsContextSkia::pushSkiaState):
    (WebCore::GraphicsContextSkia::popSkiaState):
    (WebCore::GraphicsContextSkia::recordClipIfNeeded):
    (WebCore::GraphicsContextSkia::save):
    (WebCore::GraphicsContextSkia::restore):
    (WebCore::GraphicsContextSkia::drawOutsetShadow):
    (WebCore::GraphicsContextSkia::createFillPaint const):
    (WebCore::GraphicsContextSkia::createStrokePaint const):
    (WebCore::GraphicsContextSkia::clip):
    (WebCore::GraphicsContextSkia::clipPath):
    (WebCore::GraphicsContextSkia::clipToImageBuffer):
    (WebCore::GraphicsContextSkia::saveLayer):
    (WebCore::GraphicsContextSkia::restoreLayer):
    (WebCore::GraphicsContextSkia::setLineCap):
    (WebCore::GraphicsContextSkia::setLineDash):
    (WebCore::GraphicsContextSkia::setLineJoin):
    (WebCore::GraphicsContextSkia::setMiterLimit):
    (WebCore::GraphicsContextSkia::clipOut):
    (WebCore::GraphicsContextSkia::enableStateReplayTracking):
    (WebCore::GraphicsContextSkia::replayStateOnCanvas const):
    * Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:
    * 
Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp:
    
(WebCore::ImageBufferSkiaAcceleratedBackend::~ImageBufferSkiaAcceleratedBackend):
    (WebCore::ImageBufferSkiaAcceleratedBackend::context):
    (WebCore::ImageBufferSkiaAcceleratedBackend::ensureCanvasRecordingContext):
    
(WebCore::ImageBufferSkiaAcceleratedBackend::flushCanvasRecordingContextIfNeeded):
    (WebCore::ImageBufferSkiaAcceleratedBackend::flushContext):
    (WebCore::ImageBufferSkiaAcceleratedBackend::prepareForDisplay):
    (WebCore::ImageBufferSkiaAcceleratedBackend::copyGraphicsState): Deleted.
    * Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.h:

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

Canonical link: https://commits.webkit.org/305877.91@webkitglib/2.52



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

Reply via email to