Title: [269313] trunk/Source
Revision
269313
Author
[email protected]
Date
2020-11-03 10:00:54 -0800 (Tue, 03 Nov 2020)

Log Message

Replace DisplayList::itemCount with DisplayList::isEmpty
https://bugs.webkit.org/show_bug.cgi?id=218517

Reviewed by Geoffrey Garen.

Source/WebCore:

In preparation for larger changes to display lists and display list items in <webkit.org/b/218406>, replace
`DisplayList::itemCount()` with `DisplayList::isEmpty()`. Once display list items are no longer stored in a
Vector of ref-counted items, keeping track of the exact item count will be difficult and introduce unnecessary
overhead, especially when reconstructing display lists out of shared memory in the GPU process.

Instead, change this to simply return whether or not the display list is empty (i.e. contains at least one
item), which is what (nearly) all call sites end up using `itemCount()` to determine anyways.

No change in behavior.

* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::paintRenderingResultsToCanvas):
* platform/graphics/displaylists/DisplayList.h:
(WebCore::DisplayList::DisplayList::isEmpty const):
(WebCore::DisplayList::DisplayList::itemCount const): Deleted.
* platform/graphics/displaylists/DisplayListDrawingContext.cpp:
(WebCore::DisplayList::DrawingContext::replayDisplayList):
* platform/graphics/displaylists/DisplayListImageBuffer.h:
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::operator<<):
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::isEmpty const):
(WebCore::DisplayList::Recorder::itemCount const): Deleted.
* platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::Replayer::replay):

Source/WebKit:

Separately keep track of the item count in the context's display list. See WebCore/ChangeLog for more details.

* GPUProcess/graphics/RemoteImageBuffer.h: Use `isEmpty()` instead of checking `itemCount()`.
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
(WebKit::RemoteImageBufferProxy::flushDrawingContextAndCommit):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269312 => 269313)


--- trunk/Source/WebCore/ChangeLog	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/ChangeLog	2020-11-03 18:00:54 UTC (rev 269313)
@@ -1,3 +1,36 @@
+2020-11-03  Wenson Hsieh  <[email protected]>
+
+        Replace DisplayList::itemCount with DisplayList::isEmpty
+        https://bugs.webkit.org/show_bug.cgi?id=218517
+
+        Reviewed by Geoffrey Garen.
+
+        In preparation for larger changes to display lists and display list items in <webkit.org/b/218406>, replace
+        `DisplayList::itemCount()` with `DisplayList::isEmpty()`. Once display list items are no longer stored in a
+        Vector of ref-counted items, keeping track of the exact item count will be difficult and introduce unnecessary
+        overhead, especially when reconstructing display lists out of shared memory in the GPU process.
+
+        Instead, change this to simply return whether or not the display list is empty (i.e. contains at least one
+        item), which is what (nearly) all call sites end up using `itemCount()` to determine anyways.
+
+        No change in behavior.
+
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::paintRenderingResultsToCanvas):
+        * platform/graphics/displaylists/DisplayList.h:
+        (WebCore::DisplayList::DisplayList::isEmpty const):
+        (WebCore::DisplayList::DisplayList::itemCount const): Deleted.
+        * platform/graphics/displaylists/DisplayListDrawingContext.cpp:
+        (WebCore::DisplayList::DrawingContext::replayDisplayList):
+        * platform/graphics/displaylists/DisplayListImageBuffer.h:
+        * platform/graphics/displaylists/DisplayListItems.cpp:
+        (WebCore::DisplayList::operator<<):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        (WebCore::DisplayList::Recorder::isEmpty const):
+        (WebCore::DisplayList::Recorder::itemCount const): Deleted.
+        * platform/graphics/displaylists/DisplayListReplayer.cpp:
+        (WebCore::DisplayList::Replayer::replay):
+
 2020-11-02  Simon Fraser  <[email protected]>
 
         Scroll position can get reset after programmatic scroll

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (269312 => 269313)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2020-11-03 18:00:54 UTC (rev 269313)
@@ -2021,7 +2021,7 @@
     ASSERT(m_usesDisplayListDrawing);
 
     auto& displayList = m_recordingContext->displayList();
-    if (displayList.itemCount()) {
+    if (!displayList.isEmpty()) {
         DisplayList::Replayer replayer(*canvasBase().drawingContext(), displayList);
         replayer.replay({ FloatPoint::zero(), canvasBase().size() });
         displayList.clear();

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h	2020-11-03 18:00:54 UTC (rev 269313)
@@ -162,7 +162,7 @@
 
     WEBCORE_EXPORT void clear();
 
-    size_t itemCount() const { return m_list.size(); }
+    bool isEmpty() const { return m_list.isEmpty(); }
     size_t sizeInBytes() const;
     
     String asText(AsTextFlags) const;

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp (269312 => 269313)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp	2020-11-03 18:00:54 UTC (rev 269313)
@@ -55,7 +55,7 @@
 
 void DrawingContext::replayDisplayList(GraphicsContext& destContext)
 {
-    if (!m_displayList.itemCount())
+    if (m_displayList.isEmpty())
         return;
 
     Replayer replayer(destContext, m_displayList);

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h (269312 => 269313)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h	2020-11-03 18:00:54 UTC (rev 269313)
@@ -71,7 +71,7 @@
 
     void flushDrawingContext() override
     {
-        if (m_drawingContext.displayList().itemCount())
+        if (!m_drawingContext.displayList().isEmpty())
             m_drawingContext.replayDisplayList(BaseConcreteImageBuffer::context());
     }
 

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2020-11-03 18:00:54 UTC (rev 269313)
@@ -673,7 +673,6 @@
 {
     ts.dumpProperty("destination", item.destination());
     ts.dumpProperty("color-space", item.colorSpace());
-    ts.dumpProperty("drawing-commands-count", item.drawingCommands().itemCount());
     return ts;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (269312 => 269313)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-11-03 18:00:54 UTC (rev 269313)
@@ -60,7 +60,7 @@
 
     WEBCORE_EXPORT void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat);
 
-    size_t itemCount() const { return m_displayList.itemCount(); }
+    bool isEmpty() const { return m_displayList.isEmpty(); }
 
     class Delegate {
     public:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp (269312 => 269313)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp	2020-11-03 18:00:54 UTC (rev 269313)
@@ -52,9 +52,9 @@
     if (UNLIKELY(trackReplayList))
         replayList = makeUnique<DisplayList>();
 
-    size_t numItems = m_displayList.itemCount();
-    for (size_t i = 0; i < numItems; ++i) {
-        auto& item = m_displayList.list()[i].get();
+    auto& items = m_displayList.list();
+    for (size_t i = 0; i < items.size(); ++i) {
+        auto& item = items[i].get();
 
         if (!initialClip.isZero() && is<DrawingItem>(item)) {
             const DrawingItem& drawingItem = downcast<DrawingItem>(item);

Modified: trunk/Source/WebKit/ChangeLog (269312 => 269313)


--- trunk/Source/WebKit/ChangeLog	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebKit/ChangeLog	2020-11-03 18:00:54 UTC (rev 269313)
@@ -1,3 +1,16 @@
+2020-11-03  Wenson Hsieh  <[email protected]>
+
+        Replace DisplayList::itemCount with DisplayList::isEmpty
+        https://bugs.webkit.org/show_bug.cgi?id=218517
+
+        Reviewed by Geoffrey Garen.
+
+        Separately keep track of the item count in the context's display list. See WebCore/ChangeLog for more details.
+
+        * GPUProcess/graphics/RemoteImageBuffer.h: Use `isEmpty()` instead of checking `itemCount()`.
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+        (WebKit::RemoteImageBufferProxy::flushDrawingContextAndCommit):
+
 2020-11-02  Simon Fraser  <[email protected]>
 
         Scroll position can get reset after programmatic scroll

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (269312 => 269313)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h	2020-11-03 18:00:54 UTC (rev 269313)
@@ -64,7 +64,7 @@
 private:
     void flushDisplayList(const WebCore::DisplayList::DisplayList& displayList) override
     {
-        if (displayList.itemCount()) {
+        if (!displayList.isEmpty()) {
             WebCore::DisplayList::Replayer replayer(BaseConcreteImageBuffer::context(), displayList, this);
             replayer.replay();
         }

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


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-11-03 17:59:11 UTC (rev 269312)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-11-03 18:00:54 UTC (rev 269313)
@@ -104,9 +104,11 @@
         if (!m_remoteRenderingBackendProxy)
             return nullptr;
 
-        auto& displayList = const_cast<RemoteImageBufferProxy*>(this)->m_drawingContext.displayList();
-        if (displayList.itemCount()) {
-            const_cast<RemoteImageBufferProxy&>(*this).flushDisplayList(displayList);
+        auto& mutableThis = const_cast<RemoteImageBufferProxy&>(*this);
+        auto& displayList = mutableThis.m_drawingContext.displayList();
+        if (!displayList.isEmpty()) {
+            mutableThis.flushDisplayList(displayList);
+            mutableThis.m_itemCountInCurrentDisplayList = 0;
             displayList.clear();
         }
 
@@ -141,18 +143,19 @@
             return;
 
         auto& displayList = m_drawingContext.displayList();
-        if (!displayList.itemCount())
+        if (displayList.isEmpty())
             return;
 
         TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd, 1);
         m_sentFlushIdentifier = m_remoteRenderingBackendProxy->flushDisplayListAndCommit(displayList, m_renderingResourceIdentifier);
         m_remoteRenderingBackendProxy->remoteResourceCacheProxy().unlockRemoteResourcesForRemoteClient(m_renderingResourceIdentifier);
+        m_itemCountInCurrentDisplayList = 0;
         displayList.clear();
     }
 
     void flushDisplayList(const WebCore::DisplayList::DisplayList& displayList) override
     {
-        if (!m_remoteRenderingBackendProxy || !displayList.itemCount())
+        if (!m_remoteRenderingBackendProxy || displayList.isEmpty())
             return;
 
         TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd);
@@ -174,9 +177,10 @@
     {
         constexpr size_t DisplayListBatchSize = 512;
         auto& displayList = m_drawingContext.displayList();
-        if (displayList.itemCount() < DisplayListBatchSize)
+        if (++m_itemCountInCurrentDisplayList < DisplayListBatchSize)
             return;
 
+        m_itemCountInCurrentDisplayList = 0;
         flushDisplayList(displayList);
         displayList.clear();
     }
@@ -191,6 +195,7 @@
     DisplayListFlushIdentifier m_receivedFlushIdentifier;
     WebCore::RenderingResourceIdentifier m_renderingResourceIdentifier { WebCore::RenderingResourceIdentifier::generate() };
     WeakPtr<RemoteRenderingBackendProxy> m_remoteRenderingBackendProxy;
+    size_t m_itemCountInCurrentDisplayList { 0 };
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to