Title: [294196] trunk/Source/WebCore
Revision
294196
Author
simon.fra...@apple.com
Date
2022-05-14 08:59:33 -0700 (Sat, 14 May 2022)

Log Message

Use an OptionSet<> for DisplayList::AsTextFlags
https://bugs.webkit.org/show_bug.cgi?id=240415

Reviewed by Alan Bujtas.

Simple adoption of OptionSet<DisplayList::AsTextFlag> in place of DisplayList::AsTextFlags.

* html/HTMLCanvasElement.h:
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::displayListAsText const):
(WebCore::GraphicsLayer::replayDisplayListAsText const):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::displayListAsText const):
(WebCore::GraphicsLayerCA::replayDisplayListAsText const):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::shouldDumpForFlags):
(WebCore::DisplayList::DisplayList::asText const):
* platform/graphics/displaylists/DisplayList.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::displayListAsText const):
(WebCore::RenderLayerBacking::replayDisplayListAsText const):
* rendering/RenderLayerBacking.h:
* rendering/TextPainter.cpp:
(WebCore::TextPainter::cachedGlyphDisplayListsForTextNodeAsText):
* rendering/TextPainter.h:
* testing/Internals.cpp:
(WebCore::Internals::displayListForElement):
(WebCore::Internals::replayDisplayListForElement):
(WebCore::Internals::cachedGlyphDisplayListsForTextNode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (294195 => 294196)


--- trunk/Source/WebCore/ChangeLog	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/ChangeLog	2022-05-14 15:59:33 UTC (rev 294196)
@@ -1,3 +1,36 @@
+2022-05-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Use an OptionSet<> for DisplayList::AsTextFlags
+        https://bugs.webkit.org/show_bug.cgi?id=240415
+
+        Reviewed by Alan Bujtas.
+
+        Simple adoption of OptionSet<DisplayList::AsTextFlag> in place of DisplayList::AsTextFlags.
+
+        * html/HTMLCanvasElement.h:
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::displayListAsText const):
+        (WebCore::GraphicsLayer::replayDisplayListAsText const):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::displayListAsText const):
+        (WebCore::GraphicsLayerCA::replayDisplayListAsText const):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/displaylists/DisplayList.cpp:
+        (WebCore::DisplayList::DisplayList::shouldDumpForFlags):
+        (WebCore::DisplayList::DisplayList::asText const):
+        * platform/graphics/displaylists/DisplayList.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::displayListAsText const):
+        (WebCore::RenderLayerBacking::replayDisplayListAsText const):
+        * rendering/RenderLayerBacking.h:
+        * rendering/TextPainter.cpp:
+        (WebCore::TextPainter::cachedGlyphDisplayListsForTextNodeAsText):
+        * rendering/TextPainter.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::displayListForElement):
+        (WebCore::Internals::replayDisplayListForElement):
+        (WebCore::Internals::cachedGlyphDisplayListsForTextNode):
+
 2022-05-14  Alan Bujtas  <za...@apple.com>
 
         [Repaint] Border ignores currentColor change when hovering

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (294195 => 294196)


--- trunk/Source/WebCore/html/HTMLCanvasElement.h	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h	2022-05-14 15:59:33 UTC (rev 294196)
@@ -57,10 +57,6 @@
 struct ImageBitmapRenderingContextSettings;
 struct UncachedString;
 
-namespace DisplayList {
-using AsTextFlags = unsigned;
-}
-
 class HTMLCanvasElement final : public HTMLElement, public CanvasBase, public ActiveDOMObject {
     WTF_MAKE_ISO_ALLOCATED(HTMLCanvasElement);
 public:

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (294195 => 294196)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2022-05-14 15:59:33 UTC (rev 294196)
@@ -66,7 +66,7 @@
 class TransformationMatrix;
 
 namespace DisplayList {
-typedef unsigned AsTextFlags;
+enum class AsTextFlag : uint8_t;
 }
 
 // Base class for animation values (also used for transitions). Here to
@@ -615,13 +615,13 @@
     WEBCORE_EXPORT String layerTreeAsText(OptionSet<LayerTreeAsTextOptions> = { }) const;
 
     // For testing.
-    virtual String displayListAsText(DisplayList::AsTextFlags) const { return String(); }
+    virtual String displayListAsText(OptionSet<DisplayList::AsTextFlag>) const { return String(); }
 
     virtual String platformLayerTreeAsText(OptionSet<PlatformLayerTreeAsTextFlags>) const { return String(); }
 
     virtual void setIsTrackingDisplayListReplay(bool isTracking) { m_isTrackingDisplayListReplay = isTracking; }
     virtual bool isTrackingDisplayListReplay() const { return m_isTrackingDisplayListReplay; }
-    virtual String replayDisplayListAsText(DisplayList::AsTextFlags) const { return String(); }
+    virtual String replayDisplayListAsText(OptionSet<DisplayList::AsTextFlag>) const { return String(); }
 
     // Return an estimate of the backing store memory cost (in bytes). May be incorrect for tiled layers.
     WEBCORE_EXPORT virtual double backingStoreMemoryEstimate() const;

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (294195 => 294196)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2022-05-14 15:59:33 UTC (rev 294196)
@@ -4028,7 +4028,7 @@
     noteLayerPropertyChanged(DebugIndicatorsChanged);
 }
 
-String GraphicsLayerCA::displayListAsText(DisplayList::AsTextFlags flags) const
+String GraphicsLayerCA::displayListAsText(OptionSet<DisplayList::AsTextFlag> flags) const
 {
     if (!m_displayList)
         return String();
@@ -4055,7 +4055,7 @@
         layerDisplayListMap().remove(this);
 }
 
-String GraphicsLayerCA::replayDisplayListAsText(DisplayList::AsTextFlags flags) const
+String GraphicsLayerCA::replayDisplayListAsText(OptionSet<DisplayList::AsTextFlag> flags) const
 {
     auto it = layerDisplayListMap().find(this);
     if (it != layerDisplayListMap().end()) {

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (294195 => 294196)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2022-05-14 15:59:33 UTC (rev 294196)
@@ -233,12 +233,12 @@
     WEBCORE_EXPORT void setAllowsBackingStoreDetaching(bool) override;
     bool allowsBackingStoreDetaching() const override { return m_allowsBackingStoreDetaching; }
 
-    WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const override;
+    WEBCORE_EXPORT String displayListAsText(OptionSet<DisplayList::AsTextFlag>) const override;
 
     WEBCORE_EXPORT String platformLayerTreeAsText(OptionSet<PlatformLayerTreeAsTextFlags>) const override;
 
     WEBCORE_EXPORT void setIsTrackingDisplayListReplay(bool) override;
-    WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const override;
+    WEBCORE_EXPORT String replayDisplayListAsText(OptionSet<DisplayList::AsTextFlag>) const override;
 
 #if HAVE(CORE_ANIMATION_SEPARATED_LAYERS) && HAVE(CORE_ANIMATION_SEPARATED_PORTALS)
     WEBCORE_EXPORT void setIsDescendentOfSeparatedPortal(bool) override;

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (294195 => 294196)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2022-05-14 15:59:33 UTC (rev 294196)
@@ -83,11 +83,11 @@
     m_resourceHeap.clear();
 }
 
-bool DisplayList::shouldDumpForFlags(AsTextFlags flags, ItemHandle item)
+bool DisplayList::shouldDumpForFlags(OptionSet<AsTextFlag> flags, ItemHandle item)
 {
     switch (item.type()) {
     case ItemType::SetState:
-        if (!(flags & AsTextFlag::IncludesPlatformOperations)) {
+        if (!flags.contains(AsTextFlag::IncludesPlatformOperations)) {
             const auto& stateItem = item.get<SetState>();
             // FIXME: for now, only drop the item if the only state-change flags are platform-specific.
             if (stateItem.state().changes() == GraphicsContextState::Change::ShouldSubpixelQuantizeFonts)
@@ -97,7 +97,7 @@
 #if USE(CG)
     case ItemType::ApplyFillPattern:
     case ItemType::ApplyStrokePattern:
-        if (!(flags & AsTextFlag::IncludesPlatformOperations))
+        if (!flags.contains(AsTextFlag::IncludesPlatformOperations))
             return false;
         break;
 #endif
@@ -107,7 +107,7 @@
     return true;
 }
 
-String DisplayList::asText(AsTextFlags flags) const
+String DisplayList::asText(OptionSet<AsTextFlag> flags) const
 {
     TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect);
     for (auto displayListItem : *this) {

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h (294195 => 294196)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h	2022-05-14 15:59:33 UTC (rev 294196)
@@ -46,13 +46,12 @@
 
 namespace DisplayList {
 
-enum AsTextFlag {
-    None                            = 0,
+enum class AsTextFlag : uint8_t {
     IncludesPlatformOperations      = 1 << 0,
+    IncludesResourceIdentifiers     = 1 << 1,
+    DecomposesDrawGlyphs            = 1 << 2,
 };
 
-typedef unsigned AsTextFlags;
-
 class DisplayList {
     WTF_MAKE_NONCOPYABLE(DisplayList); WTF_MAKE_FAST_ALLOCATED;
     friend class RecorderImpl;
@@ -72,7 +71,7 @@
     WEBCORE_EXPORT bool isEmpty() const;
     WEBCORE_EXPORT size_t sizeInBytes() const;
 
-    String asText(AsTextFlags) const;
+    String asText(OptionSet<AsTextFlag>) const;
 
     const ResourceHeap& resourceHeap() const { return m_resourceHeap; }
 
@@ -125,7 +124,7 @@
         m_resourceHeap.add(font.renderingResourceIdentifier(), Ref { font });
     }
 
-    static bool shouldDumpForFlags(AsTextFlags, ItemHandle);
+    static bool shouldDumpForFlags(OptionSet<AsTextFlag>, ItemHandle);
 
     LocalResourceHeap m_resourceHeap;
     std::unique_ptr<ItemBuffer> m_items;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (294195 => 294196)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2022-05-14 15:59:33 UTC (rev 294196)
@@ -367,7 +367,7 @@
         m_graphicsLayer->setNeedsDisplay();
 }
 
-String RenderLayerBacking::displayListAsText(DisplayList::AsTextFlags flags) const
+String RenderLayerBacking::displayListAsText(OptionSet<DisplayList::AsTextFlag> flags) const
 {
     return m_graphicsLayer->displayListAsText(flags);
 }
@@ -377,7 +377,7 @@
     m_graphicsLayer->setIsTrackingDisplayListReplay(isTrackingReplay);
 }
 
-String RenderLayerBacking::replayDisplayListAsText(DisplayList::AsTextFlags flags) const
+String RenderLayerBacking::replayDisplayListAsText(OptionSet<DisplayList::AsTextFlag> flags) const
 {
     return m_graphicsLayer->replayDisplayListAsText(flags);
 }

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (294195 => 294196)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2022-05-14 15:59:33 UTC (rev 294196)
@@ -283,10 +283,10 @@
     
     // For testing only.
     WEBCORE_EXPORT void setUsesDisplayListDrawing(bool);
-    WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const;
+    WEBCORE_EXPORT String displayListAsText(OptionSet<DisplayList::AsTextFlag>) const;
 
     WEBCORE_EXPORT void setIsTrackingDisplayListReplay(bool);
-    WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const;
+    WEBCORE_EXPORT String replayDisplayListAsText(OptionSet<DisplayList::AsTextFlag>) const;
 
 private:
     friend class PaintedContentsInfo;

Modified: trunk/Source/WebCore/rendering/TextPainter.cpp (294195 => 294196)


--- trunk/Source/WebCore/rendering/TextPainter.cpp	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/rendering/TextPainter.cpp	2022-05-14 15:59:33 UTC (rev 294196)
@@ -239,7 +239,7 @@
     forceUseGlyphDisplayListForTesting = enabled;
 }
 
-String TextPainter::cachedGlyphDisplayListsForTextNodeAsText(Text& textNode, DisplayList::AsTextFlags flags)
+String TextPainter::cachedGlyphDisplayListsForTextNodeAsText(Text& textNode, OptionSet<DisplayList::AsTextFlag> flags)
 {
     if (!textNode.renderer())
         return String();

Modified: trunk/Source/WebCore/rendering/TextPainter.h (294195 => 294196)


--- trunk/Source/WebCore/rendering/TextPainter.h	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/rendering/TextPainter.h	2022-05-14 15:59:33 UTC (rev 294196)
@@ -75,7 +75,7 @@
     static void clearGlyphDisplayLists();
     static bool shouldUseGlyphDisplayList(const PaintInfo&);
     WEBCORE_EXPORT static void setForceUseGlyphDisplayListForTesting(bool);
-    WEBCORE_EXPORT static String cachedGlyphDisplayListsForTextNodeAsText(Text&, DisplayList::AsTextFlags);
+    WEBCORE_EXPORT static String cachedGlyphDisplayListsForTextNodeAsText(Text&, OptionSet<DisplayList::AsTextFlag>);
 
 private:
     template<typename LayoutRun>

Modified: trunk/Source/WebCore/testing/Internals.cpp (294195 => 294196)


--- trunk/Source/WebCore/testing/Internals.cpp	2022-05-14 15:24:29 UTC (rev 294195)
+++ trunk/Source/WebCore/testing/Internals.cpp	2022-05-14 15:59:33 UTC (rev 294196)
@@ -3171,9 +3171,9 @@
     if (!element.renderer())
         return Exception { InvalidAccessError };
 
-    DisplayList::AsTextFlags displayListFlags = 0;
+    OptionSet<DisplayList::AsTextFlag> displayListFlags;
     if (flags & DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS)
-        displayListFlags |= DisplayList::AsTextFlag::IncludesPlatformOperations;
+        displayListFlags.add(DisplayList::AsTextFlag::IncludesPlatformOperations);
 
     if (!element.renderer()->hasLayer())
         return Exception { InvalidAccessError };
@@ -3196,9 +3196,9 @@
     if (!element.renderer())
         return Exception { InvalidAccessError };
 
-    DisplayList::AsTextFlags displayListFlags = 0;
+    OptionSet<DisplayList::AsTextFlag> displayListFlags;
     if (flags & DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS)
-        displayListFlags |= DisplayList::AsTextFlag::IncludesPlatformOperations;
+        displayListFlags.add(DisplayList::AsTextFlag::IncludesPlatformOperations);
 
     if (!element.renderer()->hasLayer())
         return Exception { InvalidAccessError };
@@ -3229,9 +3229,9 @@
     if (!node.renderer())
         return Exception { InvalidAccessError };
 
-    DisplayList::AsTextFlags displayListFlags = 0;
+    OptionSet<DisplayList::AsTextFlag> displayListFlags;
     if (flags & DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS)
-        displayListFlags |= DisplayList::AsTextFlag::IncludesPlatformOperations;
+        displayListFlags.add(DisplayList::AsTextFlag::IncludesPlatformOperations);
 
     return TextPainter::cachedGlyphDisplayListsForTextNodeAsText(downcast<Text>(node), displayListFlags);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to