Changeset 257945 in webkit
- Timestamp:
- Mar 5, 2020 2:22:47 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r257939 r257945 1 2020-03-05 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Remove the optimization for discarding no operation DisplayList items between Save and Restore items 4 https://bugs.webkit.org/show_bug.cgi?id=208659 5 6 Reviewed by Simon Fraser. 7 8 This optimization is wrong in the case of drawing a canvas in general. 9 The original implementation of the DisplayList assumes balanced Save/ 10 Restore GraphicsContext. In canvas a GraphicsConext 'save' can be issued 11 in a frame and the corresponding restore is issued many frames later. 12 13 * platform/graphics/displaylists/DisplayList.cpp: 14 (WebCore::DisplayList::DisplayList::removeItemsFromIndex): Deleted. 15 * platform/graphics/displaylists/DisplayList.h: 16 * platform/graphics/displaylists/DisplayListItems.cpp: 17 * platform/graphics/displaylists/DisplayListItems.h: 18 (WebCore::DisplayList::Save::encode const): 19 (WebCore::DisplayList::Save::decode): 20 (WebCore::DisplayList::Save::restoreIndex const): Deleted. 21 (WebCore::DisplayList::Save::setRestoreIndex): Deleted. 22 * platform/graphics/displaylists/DisplayListRecorder.cpp: 23 (WebCore::DisplayList::Recorder::save): 24 (WebCore::DisplayList::Recorder::restore): 25 * platform/graphics/displaylists/DisplayListRecorder.h: 26 (WebCore::DisplayList::Recorder::ContextState::cloneForSave const): 27 1 28 2020-03-05 Antoine Quint <graouts@apple.com> 2 29 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp
r220503 r257945 52 52 { 53 53 m_list.clear(); 54 }55 56 void DisplayList::removeItemsFromIndex(size_t index)57 {58 m_list.resize(index);59 54 } 60 55 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h
r257730 r257945 179 179 180 180 WEBCORE_EXPORT void clear(); 181 void removeItemsFromIndex(size_t);182 181 183 182 size_t itemCount() const { return m_list.size(); } -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp
r254202 r257945 195 195 } 196 196 197 static TextStream& operator<<(TextStream& ts, const Save& item)198 {199 ts.dumpProperty("restore-index", item.restoreIndex());200 return ts;201 }202 203 197 Restore::Restore() 204 198 : Item(ItemType::Restore) -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h
r254202 r257945 76 76 WEBCORE_EXPORT virtual ~Save(); 77 77 78 // Index in the display list of the corresponding Restore item. 0 if unmatched.79 size_t restoreIndex() const { return m_restoreIndex; }80 void setRestoreIndex(size_t index) { m_restoreIndex = index; }81 82 78 template<class Encoder> void encode(Encoder&) const; 83 79 template<class Decoder> static Optional<Ref<Save>> decode(Decoder&); … … 87 83 88 84 void apply(GraphicsContext&) const override; 89 90 size_t m_restoreIndex { 0 }; 91 }; 92 93 template<class Encoder> 94 void Save::encode(Encoder& encoder) const 95 { 96 encoder << static_cast<uint64_t>(m_restoreIndex); 97 } 98 99 template<class Decoder> 100 Optional<Ref<Save>> Save::decode(Decoder& decoder) 101 { 102 Optional<uint64_t> restoreIndex; 103 decoder >> restoreIndex; 104 if (!restoreIndex) 105 return WTF::nullopt; 106 107 // FIXME: Validate restoreIndex? But we don't have the list context here. 108 auto save = Save::create(); 109 save->setRestoreIndex(static_cast<size_t>(*restoreIndex)); 110 return save; 85 }; 86 87 template<class Encoder> 88 void Save::encode(Encoder&) const 89 { 90 } 91 92 template<class Decoder> 93 Optional<Ref<Save>> Save::decode(Decoder&) 94 { 95 return Save::create(); 111 96 } 112 97 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
r253417 r257945 144 144 { 145 145 appendItem(Save::create()); 146 m_stateStack.append(m_stateStack.last().cloneForSave( m_displayList.itemCount() - 1));146 m_stateStack.append(m_stateStack.last().cloneForSave()); 147 147 } 148 148 … … 153 153 154 154 bool stateUsedForDrawing = currentState().wasUsedForDrawing; 155 size_t saveIndex = currentState().saveItemIndex;156 155 157 156 m_stateStack.removeLast(); … … 159 158 currentState().wasUsedForDrawing |= stateUsedForDrawing; 160 159 161 if (!stateUsedForDrawing && saveIndex) {162 // This Save/Restore didn't contain any drawing items. Roll back to just before the last save.163 m_displayList.removeItemsFromIndex(saveIndex);164 return;165 }166 167 160 appendItem(Restore::create()); 168 169 if (saveIndex) {170 Save& saveItem = downcast<Save>(m_displayList.itemAt(saveIndex));171 saveItem.setRestoreIndex(m_displayList.itemCount() - 1);172 }173 161 } 174 162 -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
r253417 r257945 146 146 GraphicsContextState lastDrawingState; 147 147 bool wasUsedForDrawing { false }; 148 size_t saveItemIndex { 0 };149 148 150 149 ContextState(const GraphicsContextState& state, const AffineTransform& transform, const FloatRect& clip) … … 155 154 } 156 155 157 ContextState cloneForSave( size_t saveIndex) const156 ContextState cloneForSave() const 158 157 { 159 158 ContextState state(lastDrawingState, ctm, clipBounds); 160 159 state.stateChange = stateChange; 161 state.saveItemIndex = saveIndex;162 160 return state; 163 161 }
Note: See TracChangeset
for help on using the changeset viewer.