Title: [257947] trunk/Source/WebCore
Revision
257947
Author
jacob_uph...@apple.com
Date
2020-03-05 14:32:56 -0800 (Thu, 05 Mar 2020)

Log Message

Unreviewed, rolling out r257945.

This causes tests to fail

Reverted changeset:

"Remove the optimization for discarding no operation
DisplayList items between Save and Restore items"
https://bugs.webkit.org/show_bug.cgi?id=208659
https://trac.webkit.org/changeset/257945

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257946 => 257947)


--- trunk/Source/WebCore/ChangeLog	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/ChangeLog	2020-03-05 22:32:56 UTC (rev 257947)
@@ -1,3 +1,16 @@
+2020-03-05  Jacob Uphoff  <jacob_uph...@apple.com>
+
+        Unreviewed, rolling out r257945.
+
+        This causes tests to fail
+
+        Reverted changeset:
+
+        "Remove the optimization for discarding no operation
+        DisplayList items between Save and Restore items"
+        https://bugs.webkit.org/show_bug.cgi?id=208659
+        https://trac.webkit.org/changeset/257945
+
 2020-03-05  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Remove the optimization for discarding no operation DisplayList items between Save and Restore items

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2020-03-05 22:32:56 UTC (rev 257947)
@@ -53,6 +53,11 @@
     m_list.clear();
 }
 
+void DisplayList::removeItemsFromIndex(size_t index)
+{
+    m_list.resize(index);
+}
+
 bool DisplayList::shouldDumpForFlags(AsTextFlags flags, const Item& item)
 {
     switch (item.type()) {

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h	2020-03-05 22:32:56 UTC (rev 257947)
@@ -178,6 +178,7 @@
     }
 
     WEBCORE_EXPORT void clear();
+    void removeItemsFromIndex(size_t);
 
     size_t itemCount() const { return m_list.size(); }
     size_t sizeInBytes() const;

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2020-03-05 22:32:56 UTC (rev 257947)
@@ -194,6 +194,12 @@
     context.save();
 }
 
+static TextStream& operator<<(TextStream& ts, const Save& item)
+{
+    ts.dumpProperty("restore-index", item.restoreIndex());
+    return ts;
+}
+
 Restore::Restore()
     : Item(ItemType::Restore)
 {

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2020-03-05 22:32:56 UTC (rev 257947)
@@ -75,6 +75,10 @@
 
     WEBCORE_EXPORT virtual ~Save();
 
+    // Index in the display list of the corresponding Restore item. 0 if unmatched.
+    size_t restoreIndex() const { return m_restoreIndex; }
+    void setRestoreIndex(size_t index) { m_restoreIndex = index; }
+
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static Optional<Ref<Save>> decode(Decoder&);
 
@@ -82,17 +86,28 @@
     WEBCORE_EXPORT Save();
 
     void apply(GraphicsContext&) const override;
+    
+    size_t m_restoreIndex { 0 };
 };
 
 template<class Encoder>
-void Save::encode(Encoder&) const
+void Save::encode(Encoder& encoder) const
 {
+    encoder << static_cast<uint64_t>(m_restoreIndex);
 }
 
 template<class Decoder>
-Optional<Ref<Save>> Save::decode(Decoder&)
+Optional<Ref<Save>> Save::decode(Decoder& decoder)
 {
-    return Save::create();
+    Optional<uint64_t> restoreIndex;
+    decoder >> restoreIndex;
+    if (!restoreIndex)
+        return WTF::nullopt;
+
+    // FIXME: Validate restoreIndex? But we don't have the list context here.
+    auto save = Save::create();
+    save->setRestoreIndex(static_cast<size_t>(*restoreIndex));
+    return save;
 }
 
 class Restore : public Item {

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (257946 => 257947)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2020-03-05 22:32:56 UTC (rev 257947)
@@ -143,7 +143,7 @@
 void Recorder::save()
 {
     appendItem(Save::create());
-    m_stateStack.append(m_stateStack.last().cloneForSave());
+    m_stateStack.append(m_stateStack.last().cloneForSave(m_displayList.itemCount() - 1));
 }
 
 void Recorder::restore()
@@ -152,12 +152,24 @@
         return;
 
     bool stateUsedForDrawing = currentState().wasUsedForDrawing;
+    size_t saveIndex = currentState().saveItemIndex;
 
     m_stateStack.removeLast();
     // Have to avoid eliding nested Save/Restore when a descendant state contains drawing items.
     currentState().wasUsedForDrawing |= stateUsedForDrawing;
 
+    if (!stateUsedForDrawing && saveIndex) {
+        // This Save/Restore didn't contain any drawing items. Roll back to just before the last save.
+        m_displayList.removeItemsFromIndex(saveIndex);
+        return;
+    }
+
     appendItem(Restore::create());
+
+    if (saveIndex) {
+        Save& saveItem = downcast<Save>(m_displayList.itemAt(saveIndex));
+        saveItem.setRestoreIndex(m_displayList.itemCount() - 1);
+    }
 }
 
 void Recorder::translate(float x, float y)

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


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-03-05 22:25:07 UTC (rev 257946)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-03-05 22:32:56 UTC (rev 257947)
@@ -145,6 +145,7 @@
         GraphicsContextStateChange stateChange;
         GraphicsContextState lastDrawingState;
         bool wasUsedForDrawing { false };
+        size_t saveItemIndex { 0 };
         
         ContextState(const GraphicsContextState& state, const AffineTransform& transform, const FloatRect& clip)
             : ctm(transform)
@@ -153,10 +154,11 @@
         {
         }
         
-        ContextState cloneForSave() const
+        ContextState cloneForSave(size_t saveIndex) const
         {
             ContextState state(lastDrawingState, ctm, clipBounds);
             state.stateChange = stateChange;
+            state.saveItemIndex = saveIndex;
             return state;
         }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to