Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3bb1910992a8f7a844a547104eb0f890696f339c
      
https://github.com/WebKit/WebKit/commit/3bb1910992a8f7a844a547104eb0f890696f339c
  Author: Dan Glastonbury <[email protected]>
  Date:   2026-06-01 (Mon, 01 Jun 2026)

  Changed paths:
    M Source/WebCore/platform/graphics/GraphicsContext.cpp
    M Source/WebCore/platform/graphics/GraphicsContext.h
    M Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
    M Source/WebCore/platform/graphics/cg/GraphicsContextCG.h
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContext.cpp

  Log Message:
  -----------
  [Cocoa] Avoid Path allocation when stroking a single line on CoreGraphics
https://bugs.webkit.org/show_bug.cgi?id=315985
rdar://178398284

Reviewed by Kimmo Kinnunen.

RemoteGraphicsContext::strokeLine() currently fulfils a single-segment line
stroke by constructing a Path containing one PathDataLine and calling
strokePath(). That allocates a Path, wraps the segment in a PathSegment, and
routes through the full path-stroking machinery — significant overhead for what,
on CoreGraphics, is one CGContextStrokeLineSegments() call.

CoreGraphics can stroke a line directly. The only case where we still need a
real path is when the stroke is a gradient: that is implemented by building the
stroked outline of the path and clipping the gradient fill to it, which
CGContextStrokeLineSegments() cannot express. Stroke patterns are fine as long
as the pattern is bound first, matching what strokePath() does on the fast path.

Introduce GraphicsContext::strokeLine(const PathDataLine&) as a virtual method
with a Path-based default, override it in GraphicsContextCG to call
CGContextStrokeLineSegments() directly (falling back to the base class for
gradient strokes), and have RemoteGraphicsContext::strokeLine() forward to it
instead of synthesising a Path.

* Source/WebCore/platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::strokeLine):
* Source/WebCore/platform/graphics/GraphicsContext.h:
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContextCG::strokeLine):
* Source/WebCore/platform/graphics/cg/GraphicsContextCG.h:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContext.cpp:
(WebKit::RemoteGraphicsContext::strokeLine):

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



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

Reply via email to