[webkit-changes] [WebKit/WebKit] 09496e: Encode WebCore::Paths using a trailing "end of pat...

Cameron McCormack noreply at github.com
Wed Oct 12 13:46:25 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 09496e855222f4a787bed209454e539b1a732ba0
      https://github.com/WebKit/WebKit/commit/09496e855222f4a787bed209454e539b1a732ba0
  Author: Cameron McCormack <heycam at apple.com>
  Date:   2022-10-12 (Wed, 12 Oct 2022)

  Changed paths:
    M Source/WTF/wtf/EnumTraits.h
    M Source/WebCore/platform/graphics/GraphicsContextState.cpp
    M Source/WebCore/platform/graphics/Path.h

  Log Message:
  -----------
  Encode WebCore::Paths using a trailing "end of path" marker instead of an element count prefix
https://bugs.webkit.org/show_bug.cgi?id=246322
rdar://100873493

Reviewed by Wenson Hsieh.

The WebCore::Path decoder doesn't need to know the number of path elements ahead
of time. Changing to use an "end of path" marker saves some space in the
encoding, since it'll take up one byte as opposed to the 16 bytes for the path
element count.

Add EncodedPathElementType to represent "a PathElement::Type or an end of path
marker" and which can encode its value in a single byte. Do this rather than:

* using std::optional<PathElement::Type> or Markable<PathElement::Type>, as both
  will write out a boolean "is empty/present" value, which is wasteful,
  or

* adding an EndOfPath enum value to PathElement::Type, as then various call
  sites unrelated to encoding will need to worry about it.

* Source/WTF/wtf/EnumTraits.h:
* Source/WebCore/platform/graphics/GraphicsContextState.cpp:
(WebCore::toIndex):
* Source/WebCore/platform/graphics/Path.h:
(WebCore::Path::EncodedPathElementType::encode):
(WebCore::Path::EncodedPathElementType::decode):
(WebCore::Path::encode const):
(WebCore::Path::decode):

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




More information about the webkit-changes mailing list