Title: [269551] trunk
Revision
269551
Author
wenson_hs...@apple.com
Date
2020-11-06 16:39:59 -0800 (Fri, 06 Nov 2020)

Log Message

Add new display list item types in preparation for webkit.org/b/218426
https://bugs.webkit.org/show_bug.cgi?id=218588

Reviewed by Simon Fraser.

Source/WebCore:

Introduce these new item types. See below for more details.

* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::append):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::copyTo):
(WebCore::DisplayList::ItemBuffer::swapWritableBufferIfNeeded):

Let `ItemBuffer` automatically append "switch to command buffer" item whenever it runs out of space in its
current writable buffer, and either allocates a new buffer or calls into the client to grab a new buffer.

* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItemType.h:
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::FlushContext::apply const):
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::MetaCommandSwitchTo::apply const):
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::FlushContext::FlushContext):
(WebCore::DisplayList::FlushContext::identifier const):
(WebCore::DisplayList::FlushContext::localBounds const):
(WebCore::DisplayList::FlushContext::globalBounds const):

Add `FlushContext`, which will indicate to the client that it should flush its backing graphics context. The
only data in this item is a `DisplayList::FlushIdentifier`, which will be used by the display list client to
coordinate flush timing.

(WebCore::DisplayList::MetaCommandSwitchTo::MetaCommandSwitchTo):
(WebCore::DisplayList::MetaCommandSwitchTo::identifier const):
(WebCore::DisplayList::MetaCommandSwitchTo::localBounds const):
(WebCore::DisplayList::MetaCommandSwitchTo::globalBounds const):

Add an item to represent switching to a new item buffer. This is automatically appended by the display list
itself when it runs out of space on the current writable buffer, and will allow display list clients (in
particular, the remote rendering backend in the GPU process) to seamlessly continue reading display list items
when all item data in a display list item buffer has been exhausted.

Also, add a FIXME here for pulling `MetaCommandSwitchTo` out of the set of display list items. We plan on
tackling this as a part of generalizing concurrent display list architecture in a way that can be used for
serializing WebGL commands as well.

Source/WebKit:

Simply treat these new items as no-ops for the time being. See Source/WebCore/ChangeLog for more details.

* GPUProcess/graphics/RemoteImageBuffer.h:
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:

Tools:

Adjust an API test. See other ChangeLogs for more detail.

* TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269550 => 269551)


--- trunk/Source/WebCore/ChangeLog	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/ChangeLog	2020-11-07 00:39:59 UTC (rev 269551)
@@ -1,5 +1,58 @@
 2020-11-06  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        Add new display list item types in preparation for webkit.org/b/218426
+        https://bugs.webkit.org/show_bug.cgi?id=218588
+
+        Reviewed by Simon Fraser.
+
+        Introduce these new item types. See below for more details.
+
+        * platform/graphics/displaylists/DisplayList.cpp:
+        (WebCore::DisplayList::DisplayList::append):
+        * platform/graphics/displaylists/DisplayListItemBuffer.cpp:
+        (WebCore::DisplayList::ItemHandle::apply):
+        (WebCore::DisplayList::ItemHandle::destroy):
+        (WebCore::DisplayList::ItemHandle::copyTo):
+        (WebCore::DisplayList::ItemBuffer::swapWritableBufferIfNeeded):
+
+        Let `ItemBuffer` automatically append "switch to command buffer" item whenever it runs out of space in its
+        current writable buffer, and either allocates a new buffer or calls into the client to grab a new buffer.
+
+        * platform/graphics/displaylists/DisplayListItemType.cpp:
+        (WebCore::DisplayList::sizeOfItemInBytes):
+        (WebCore::DisplayList::isDrawingItem):
+        (WebCore::DisplayList::isInlineItem):
+        * platform/graphics/displaylists/DisplayListItemType.h:
+        * platform/graphics/displaylists/DisplayListItems.cpp:
+        (WebCore::DisplayList::FlushContext::apply const):
+        (WebCore::DisplayList::operator<<):
+        (WebCore::DisplayList::MetaCommandSwitchTo::apply const):
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::FlushContext::FlushContext):
+        (WebCore::DisplayList::FlushContext::identifier const):
+        (WebCore::DisplayList::FlushContext::localBounds const):
+        (WebCore::DisplayList::FlushContext::globalBounds const):
+
+        Add `FlushContext`, which will indicate to the client that it should flush its backing graphics context. The
+        only data in this item is a `DisplayList::FlushIdentifier`, which will be used by the display list client to
+        coordinate flush timing.
+
+        (WebCore::DisplayList::MetaCommandSwitchTo::MetaCommandSwitchTo):
+        (WebCore::DisplayList::MetaCommandSwitchTo::identifier const):
+        (WebCore::DisplayList::MetaCommandSwitchTo::localBounds const):
+        (WebCore::DisplayList::MetaCommandSwitchTo::globalBounds const):
+
+        Add an item to represent switching to a new item buffer. This is automatically appended by the display list
+        itself when it runs out of space on the current writable buffer, and will allow display list clients (in
+        particular, the remote rendering backend in the GPU process) to seamlessly continue reading display list items
+        when all item data in a display list item buffer has been exhausted.
+
+        Also, add a FIXME here for pulling `MetaCommandSwitchTo` out of the set of display list items. We plan on
+        tackling this as a part of generalizing concurrent display list architecture in a way that can be used for
+        serializing WebGL commands as well.
+
+2020-11-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
         Add a display list item to represent stroking a single line
         https://bugs.webkit.org/show_bug.cgi?id=218589
 

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2020-11-07 00:39:59 UTC (rev 269551)
@@ -277,6 +277,10 @@
         return append<FillPath>(item.get<FillPath>());
     case ItemType::FillEllipse:
         return append<FillEllipse>(item.get<FillEllipse>());
+    case ItemType::FlushContext:
+        return append<FlushContext>(item.get<FlushContext>());
+    case ItemType::MetaCommandSwitchTo:
+        return append<MetaCommandSwitchTo>(item.get<MetaCommandSwitchTo>());
     case ItemType::PutImageData:
         return append<PutImageData>(item.get<PutImageData>());
     case ItemType::PaintFrameForMedia:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp (269550 => 269551)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2020-11-07 00:39:59 UTC (rev 269551)
@@ -230,6 +230,12 @@
         get<FillEllipse>().apply(context);
         return;
     }
+    case ItemType::FlushContext: {
+        get<FlushContext>().apply(context);
+        return;
+    }
+    case ItemType::MetaCommandSwitchTo:
+        return;
     case ItemType::PutImageData: {
         get<PutImageData>().apply(context);
         return;
@@ -460,6 +466,14 @@
         static_assert(std::is_trivially_destructible<FillRect>::value);
         return;
     }
+    case ItemType::FlushContext: {
+        static_assert(std::is_trivially_destructible<FlushContext>::value);
+        return;
+    }
+    case ItemType::MetaCommandSwitchTo: {
+        static_assert(std::is_trivially_destructible<MetaCommandSwitchTo>::value);
+        return;
+    }
     case ItemType::PaintFrameForMedia: {
         static_assert(std::is_trivially_destructible<PaintFrameForMedia>::value);
         return;
@@ -710,6 +724,14 @@
         new (destination.data + sizeof(ItemType)) FillRect(get<FillRect>());
         return;
     }
+    case ItemType::FlushContext: {
+        new (destination.data + sizeof(ItemType)) FlushContext(get<FlushContext>());
+        return;
+    }
+    case ItemType::MetaCommandSwitchTo: {
+        new (destination.data + sizeof(ItemType)) MetaCommandSwitchTo(get<MetaCommandSwitchTo>());
+        return;
+    }
     case ItemType::PaintFrameForMedia: {
         new (destination.data + sizeof(ItemType)) PaintFrameForMedia(get<PaintFrameForMedia>());
         return;
@@ -861,11 +883,14 @@
 
 void ItemBuffer::swapWritableBufferIfNeeded(size_t numberOfBytes)
 {
-    if (m_writtenNumberOfBytes + numberOfBytes <= m_writableBuffer.capacity)
+    constexpr auto sizeForBufferSwitchItem = sizeof(ItemType) + sizeof(MetaCommandSwitchTo);
+    if (m_writtenNumberOfBytes + numberOfBytes + sizeForBufferSwitchItem <= m_writableBuffer.capacity)
         return;
 
-    auto nextBuffer = createItemBuffer(numberOfBytes);
+    auto nextBuffer = createItemBuffer(numberOfBytes + sizeForBufferSwitchItem);
     bool hadPreviousBuffer = m_writableBuffer;
+    if (hadPreviousBuffer)
+        uncheckedAppend<MetaCommandSwitchTo>(nextBuffer.identifier);
     auto previousBuffer = std::exchange(m_writableBuffer, { });
     previousBuffer.capacity = std::exchange(m_writtenNumberOfBytes, 0);
     if (hadPreviousBuffer)

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp (269550 => 269551)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp	2020-11-07 00:39:59 UTC (rev 269551)
@@ -128,6 +128,10 @@
         return sizeof(FillPath);
     case ItemType::FillEllipse:
         return sizeof(FillEllipse);
+    case ItemType::FlushContext:
+        return sizeof(FlushContext);
+    case ItemType::MetaCommandSwitchTo:
+        return sizeof(MetaCommandSwitchTo);
     case ItemType::PutImageData:
         return sizeof(PutImageData);
     case ItemType::PaintFrameForMedia:
@@ -178,6 +182,8 @@
     case ItemType::ClipPath:
     case ItemType::ClipToDrawingCommands:
     case ItemType::ConcatenateCTM:
+    case ItemType::FlushContext:
+    case ItemType::MetaCommandSwitchTo:
     case ItemType::Restore:
     case ItemType::Rotate:
     case ItemType::Save:
@@ -287,6 +293,8 @@
     case ItemType::FillInlinePath:
 #endif
     case ItemType::FillRect:
+    case ItemType::FlushContext:
+    case ItemType::MetaCommandSwitchTo:
     case ItemType::PaintFrameForMedia:
     case ItemType::Restore:
     case ItemType::Rotate:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h (269550 => 269551)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h	2020-11-07 00:39:59 UTC (rev 269551)
@@ -77,6 +77,8 @@
 #endif
     FillPath,
     FillEllipse,
+    FlushContext,
+    MetaCommandSwitchTo,
     PutImageData,
     PaintFrameForMedia,
     StrokeRect,

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (269550 => 269551)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2020-11-07 00:39:59 UTC (rev 269551)
@@ -1012,6 +1012,23 @@
     return ts;
 }
 
+void FlushContext::apply(GraphicsContext&) const
+{
+    // Handled by client.
+}
+
+static TextStream& operator<<(TextStream& ts, const FlushContext& item)
+{
+    ts.dumpProperty("identifier", item.identifier());
+    return ts;
+}
+
+static TextStream& operator<<(TextStream& ts, const MetaCommandSwitchTo& item)
+{
+    ts.dumpProperty("identifier", item.identifier());
+    return ts;
+}
+
 static TextStream& operator<<(TextStream& ts, ItemType type)
 {
     switch (type) {
@@ -1062,6 +1079,8 @@
 #endif
     case ItemType::FillPath: ts << "fill-path"; break;
     case ItemType::FillEllipse: ts << "fill-ellipse"; break;
+    case ItemType::FlushContext: ts << "flush-context"; break;
+    case ItemType::MetaCommandSwitchTo: ts << "meta-command-switch-to"; break;
     case ItemType::PutImageData: ts << "put-image-data"; break;
     case ItemType::PaintFrameForMedia: ts << "paint-frame-for-media"; break;
     case ItemType::StrokeRect: ts << "stroke-rect"; break;
@@ -1220,6 +1239,12 @@
     case ItemType::FillEllipse:
         ts << item.get<FillEllipse>();
         break;
+    case ItemType::FlushContext:
+        ts << item.get<FlushContext>();
+        break;
+    case ItemType::MetaCommandSwitchTo:
+        ts << item.get<MetaCommandSwitchTo>();
+        break;
     case ItemType::PutImageData:
         ts << item.get<PutImageData>();
         break;

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (269550 => 269551)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2020-11-07 00:39:59 UTC (rev 269551)
@@ -2608,6 +2608,50 @@
     float m_scaleFactor { 1 };
 };
 
+class FlushContext {
+public:
+    static constexpr ItemType itemType = ItemType::FlushContext;
+    static constexpr bool isInlineItem = true;
+    static constexpr bool isDrawingItem = false;
+
+    FlushContext(FlushIdentifier identifier)
+        : m_identifier(identifier)
+    {
+    }
+
+    FlushIdentifier identifier() const { return m_identifier; }
+
+    void apply(GraphicsContext&) const;
+
+    Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; }
+    Optional<FloatRect> globalBounds() const { return WTF::nullopt; }
+
+private:
+    FlushIdentifier m_identifier;
+};
+
+// FIXME: This should be refactored so that the command to "switch to the next item buffer"
+// is not itself a drawing item.
+class MetaCommandSwitchTo {
+public:
+    static constexpr ItemType itemType = ItemType::MetaCommandSwitchTo;
+    static constexpr bool isInlineItem = true;
+    static constexpr bool isDrawingItem = false;
+
+    MetaCommandSwitchTo(ItemBufferIdentifier identifier)
+        : m_identifier(identifier)
+    {
+    }
+
+    ItemBufferIdentifier identifier() const { return m_identifier; }
+
+    Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; }
+    Optional<FloatRect> globalBounds() const { return WTF::nullopt; }
+
+private:
+    ItemBufferIdentifier m_identifier;
+};
+
 TextStream& operator<<(TextStream&, ItemHandle);
 
 } // namespace DisplayList
@@ -2666,6 +2710,8 @@
 #endif
     WebCore::DisplayList::ItemType::FillPath,
     WebCore::DisplayList::ItemType::FillEllipse,
+    WebCore::DisplayList::ItemType::FlushContext,
+    WebCore::DisplayList::ItemType::MetaCommandSwitchTo,
     WebCore::DisplayList::ItemType::PutImageData,
     WebCore::DisplayList::ItemType::PaintFrameForMedia,
     WebCore::DisplayList::ItemType::StrokeRect,

Modified: trunk/Source/WebKit/ChangeLog (269550 => 269551)


--- trunk/Source/WebKit/ChangeLog	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebKit/ChangeLog	2020-11-07 00:39:59 UTC (rev 269551)
@@ -1,3 +1,15 @@
+2020-11-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add new display list item types in preparation for webkit.org/b/218426
+        https://bugs.webkit.org/show_bug.cgi?id=218588
+
+        Reviewed by Simon Fraser.
+
+        Simply treat these new items as no-ops for the time being. See Source/WebCore/ChangeLog for more details.
+
+        * GPUProcess/graphics/RemoteImageBuffer.h:
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+
 2020-11-06  Per Arne Vollan  <pvol...@apple.com>
 
         [macOS] Add IOKIt message filtering

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (269550 => 269551)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h	2020-11-07 00:39:59 UTC (rev 269551)
@@ -82,6 +82,16 @@
             return true;
         }
 
+        if (item.is<WebCore::DisplayList::FlushContext>()) {
+            // FIXME: Not implemented yet.
+            return true;
+        }
+
+        if (item.is<WebCore::DisplayList::MetaCommandSwitchTo>()) {
+            // FIXME: Not implemented yet.
+            return true;
+        }
+
         return m_remoteRenderingBackend.applyMediaItem(item, context);
     }
 
@@ -156,6 +166,8 @@
         case WebCore::DisplayList::ItemType::FillInlinePath:
 #endif
         case WebCore::DisplayList::ItemType::FillRect:
+        case WebCore::DisplayList::ItemType::FlushContext:
+        case WebCore::DisplayList::ItemType::MetaCommandSwitchTo:
         case WebCore::DisplayList::ItemType::PaintFrameForMedia:
         case WebCore::DisplayList::ItemType::Restore:
         case WebCore::DisplayList::ItemType::Rotate:

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (269550 => 269551)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-11-07 00:39:59 UTC (rev 269551)
@@ -259,6 +259,8 @@
         case WebCore::DisplayList::ItemType::FillInlinePath:
 #endif
         case WebCore::DisplayList::ItemType::FillRect:
+        case WebCore::DisplayList::ItemType::FlushContext:
+        case WebCore::DisplayList::ItemType::MetaCommandSwitchTo:
         case WebCore::DisplayList::ItemType::PaintFrameForMedia:
         case WebCore::DisplayList::ItemType::Restore:
         case WebCore::DisplayList::ItemType::Rotate:

Modified: trunk/Tools/ChangeLog (269550 => 269551)


--- trunk/Tools/ChangeLog	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Tools/ChangeLog	2020-11-07 00:39:59 UTC (rev 269551)
@@ -1,5 +1,17 @@
 2020-11-06  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        Add new display list item types in preparation for webkit.org/b/218426
+        https://bugs.webkit.org/show_bug.cgi?id=218588
+
+        Reviewed by Simon Fraser.
+
+        Adjust an API test. See other ChangeLogs for more detail.
+
+        * TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp:
+        (TestWebKitAPI::TEST):
+
+2020-11-06  Wenson Hsieh  <wenson_hs...@apple.com>
+
         [Concurrent display lists] Add API tests for WebCore::DisplayList::DisplayList and related classes
         https://bugs.webkit.org/show_bug.cgi?id=218425
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp (269550 => 269551)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp	2020-11-07 00:31:49 UTC (rev 269550)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp	2020-11-07 00:39:59 UTC (rev 269551)
@@ -121,6 +121,8 @@
             break;
         }
 #endif
+        case ItemType::MetaCommandSwitchTo:
+            break;
         default: {
             observedUnexpectedItem = true;
             break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to