Diff
Modified: trunk/Source/WebCore/ChangeLog (257944 => 257945)
--- trunk/Source/WebCore/ChangeLog 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/ChangeLog 2020-03-05 22:22:47 UTC (rev 257945)
@@ -1,3 +1,30 @@
+2020-03-05 Said Abou-Hallawa <[email protected]>
+
+ Remove the optimization for discarding no operation DisplayList items between Save and Restore items
+ https://bugs.webkit.org/show_bug.cgi?id=208659
+
+ Reviewed by Simon Fraser.
+
+ This optimization is wrong in the case of drawing a canvas in general.
+ The original implementation of the DisplayList assumes balanced Save/
+ Restore GraphicsContext. In canvas a GraphicsConext 'save' can be issued
+ in a frame and the corresponding restore is issued many frames later.
+
+ * platform/graphics/displaylists/DisplayList.cpp:
+ (WebCore::DisplayList::DisplayList::removeItemsFromIndex): Deleted.
+ * platform/graphics/displaylists/DisplayList.h:
+ * platform/graphics/displaylists/DisplayListItems.cpp:
+ * platform/graphics/displaylists/DisplayListItems.h:
+ (WebCore::DisplayList::Save::encode const):
+ (WebCore::DisplayList::Save::decode):
+ (WebCore::DisplayList::Save::restoreIndex const): Deleted.
+ (WebCore::DisplayList::Save::setRestoreIndex): Deleted.
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+ (WebCore::DisplayList::Recorder::save):
+ (WebCore::DisplayList::Recorder::restore):
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+ (WebCore::DisplayList::Recorder::ContextState::cloneForSave const):
+
2020-03-05 Antoine Quint <[email protected]>
Page-specific UserStyleSheets should wait until the initial empty document has been removed to be injected
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (257944 => 257945)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp 2020-03-05 22:22:47 UTC (rev 257945)
@@ -53,11 +53,6 @@
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 (257944 => 257945)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2020-03-05 22:22:47 UTC (rev 257945)
@@ -178,7 +178,6 @@
}
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 (257944 => 257945)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-03-05 22:22:47 UTC (rev 257945)
@@ -194,12 +194,6 @@
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 (257944 => 257945)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2020-03-05 22:22:47 UTC (rev 257945)
@@ -75,10 +75,6 @@
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&);
@@ -86,28 +82,17 @@
WEBCORE_EXPORT Save();
void apply(GraphicsContext&) const override;
-
- size_t m_restoreIndex { 0 };
};
template<class Encoder>
-void Save::encode(Encoder& encoder) const
+void Save::encode(Encoder&) const
{
- encoder << static_cast<uint64_t>(m_restoreIndex);
}
template<class Decoder>
-Optional<Ref<Save>> Save::decode(Decoder& decoder)
+Optional<Ref<Save>> Save::decode(Decoder&)
{
- 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;
+ return Save::create();
}
class Restore : public Item {
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (257944 => 257945)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2020-03-05 22:22:47 UTC (rev 257945)
@@ -143,7 +143,7 @@
void Recorder::save()
{
appendItem(Save::create());
- m_stateStack.append(m_stateStack.last().cloneForSave(m_displayList.itemCount() - 1));
+ m_stateStack.append(m_stateStack.last().cloneForSave());
}
void Recorder::restore()
@@ -152,24 +152,12 @@
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 (257944 => 257945)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2020-03-05 22:10:02 UTC (rev 257944)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2020-03-05 22:22:47 UTC (rev 257945)
@@ -145,7 +145,6 @@
GraphicsContextStateChange stateChange;
GraphicsContextState lastDrawingState;
bool wasUsedForDrawing { false };
- size_t saveItemIndex { 0 };
ContextState(const GraphicsContextState& state, const AffineTransform& transform, const FloatRect& clip)
: ctm(transform)
@@ -154,11 +153,10 @@
{
}
- ContextState cloneForSave(size_t saveIndex) const
+ ContextState cloneForSave() const
{
ContextState state(lastDrawingState, ctm, clipBounds);
state.stateChange = stateChange;
- state.saveItemIndex = saveIndex;
return state;
}