[webkit-changes] [WebKit/WebKit] b64d04: Use DataRef for SVGPathByteStream::Data

Yusuke Suzuki noreply at github.com
Fri May 17 07:39:46 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b64d047f66814f52658e363698db26d29314164a
      https://github.com/WebKit/WebKit/commit/b64d047f66814f52658e363698db26d29314164a
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2024-05-17 (Fri, 17 May 2024)

  Changed paths:
    M Source/WTF/wtf/DataRef.h
    M Source/WebCore/svg/SVGPathByteStream.h
    M Source/WebCore/svg/SVGPathElement.cpp
    M Source/WebCore/svg/SVGPathSegList.h
    M Source/WebCore/svg/SVGPathUtilities.cpp
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in

  Log Message:
  -----------
  Use DataRef for SVGPathByteStream::Data
https://bugs.webkit.org/show_bug.cgi?id=274276
rdar://128219580

Reviewed by Matthieu Dubet.

We found that our SVG path caching is not enough. We only cache byte stream of SVG path.
But it turned out that creation of Path from that byte stream is super costly. blink is caching this final result,
and we should do the similar thing.

In this patch, we took sophisticated approach: making SVGPathByteStream::Data DataRef, and adding cached Path too inside it.
Then, we can share created Path, and we do not need to create this until we need it. And if we modify stream, then it clones and clears Path.

We extend DataRef to make it usable for HashMap's value. So now SVGPathElement's cache is holding DataRef<> instead of a raw Vector.

* Source/WTF/wtf/DataRef.h:
(WTF::DataRef::DataRef):
(WTF::DataRef::isHashTableDeletedValue const):
(WTF::DataRef::isHashTableEmptyValue const):
(WTF::DataRef::hashTableEmptyValue):
(WTF::HashTraits<DataRef<T>>::emptyValue):
(WTF::HashTraits<DataRef<T>>::constructEmptyValue):
(WTF::HashTraits<DataRef<T>>::isEmptyValue):
* Source/WebCore/svg/SVGPathByteStream.h:
(WebCore::SVGPathByteStream::SVGPathByteStream):
(WebCore::SVGPathByteStream::operator==):
(WebCore::SVGPathByteStream::begin const):
(WebCore::SVGPathByteStream::end const):
(WebCore::SVGPathByteStream::append):
(WebCore::SVGPathByteStream::clear):
(WebCore::SVGPathByteStream::isEmpty const):
(WebCore::SVGPathByteStream::size const):
(WebCore::SVGPathByteStream::shrinkToFit):
(WebCore::SVGPathByteStream::cachedPath const):
(WebCore::SVGPathByteStream::cachePath const):
(WebCore::SVGPathByteStream::bytes const):
(WebCore::SVGPathByteStream::data const):
(WebCore::SVGPathByteStream::setData):
(WebCore::SVGPathByteStream::operator=): Deleted.
* Source/WebCore/svg/SVGPathElement.cpp:
(WebCore::PathSegListCache::get const):
(WebCore::PathSegListCache::add):
(WebCore::SVGPathElement::attributeChanged):
* Source/WebCore/svg/SVGPathSegList.h:
* Source/WebCore/svg/SVGPathUtilities.cpp:
(WebCore::buildPathFromByteStream):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

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



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


More information about the webkit-changes mailing list