[webkit-changes] [WebKit/WebKit] 7fcf20: PathStream::currentPoint should have a fast path f...

Yusuke Suzuki noreply at github.com
Thu Aug 24 09:52:31 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7fcf207fdda17d52fb187617f33064b721f2d556
      https://github.com/WebKit/WebKit/commit/7fcf207fdda17d52fb187617f33064b721f2d556
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2023-08-24 (Thu, 24 Aug 2023)

  Changed paths:
    M Source/WebCore/platform/graphics/PathSegment.cpp
    M Source/WebCore/platform/graphics/PathSegment.h
    M Source/WebCore/platform/graphics/PathSegmentData.cpp
    M Source/WebCore/platform/graphics/PathSegmentData.h
    M Source/WebCore/platform/graphics/PathStream.cpp

  Log Message:
  -----------
  PathStream::currentPoint should have a fast path for getting end point immediately
https://bugs.webkit.org/show_bug.cgi?id=260652
rdar://114371099

Reviewed by Cameron McCormack.

PathStream::currentPoint is computing the end point by traversing all the past segments.
But if we would like to get the end point, in most of cases, we can immediately get that
from the last segment's information. We are traversing this every time we call `lineTo`
function, and this becomes costly when the path gets many segments.
This patch adds a fast path covering most of cases. We add tryGetEndPointWithoutContext
function, which may return the end point if it can compute it directly without context.
And lineTo function calls this for the last segment and attempt to skip traversing of
segments.

* Source/WebCore/platform/graphics/PathSegment.cpp:
(WebCore::PathSegment::tryGetEndPointWithoutContext const):
* Source/WebCore/platform/graphics/PathSegment.h:
* Source/WebCore/platform/graphics/PathSegmentData.cpp:
(WebCore::PathMoveTo::tryGetEndPointWithoutContext const):
(WebCore::PathLineTo::tryGetEndPointWithoutContext const):
(WebCore::PathQuadCurveTo::tryGetEndPointWithoutContext const):
(WebCore::PathBezierCurveTo::tryGetEndPointWithoutContext const):
(WebCore::PathArcTo::tryGetEndPointWithoutContext const):
(WebCore::PathArc::tryGetEndPointWithoutContext const):
(WebCore::PathEllipse::tryGetEndPointWithoutContext const):
(WebCore::PathEllipseInRect::tryGetEndPointWithoutContext const):
(WebCore::PathRect::tryGetEndPointWithoutContext const):
(WebCore::PathRoundedRect::tryGetEndPointWithoutContext const):
(WebCore::PathDataLine::tryGetEndPointWithoutContext const):
(WebCore::PathDataQuadCurve::tryGetEndPointWithoutContext const):
(WebCore::PathDataBezierCurve::tryGetEndPointWithoutContext const):
(WebCore::PathDataArc::tryGetEndPointWithoutContext const):
(WebCore::PathCloseSubpath::tryGetEndPointWithoutContext const):
* Source/WebCore/platform/graphics/PathSegmentData.h:
* Source/WebCore/platform/graphics/PathStream.cpp:
(WebCore::PathStream::currentPoint const):

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




More information about the webkit-changes mailing list