OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DisplayItemList_h | 5 #ifndef DisplayItemList_h |
6 #define DisplayItemList_h | 6 #define DisplayItemList_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/graphics/ContiguousContainer.h" | 9 #include "platform/graphics/ContiguousContainer.h" |
10 #include "platform/graphics/paint/DisplayItem.h" | 10 #include "platform/graphics/paint/DisplayItem.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Returns the approximate memory usage, excluding memory likely to be | 81 // Returns the approximate memory usage, excluding memory likely to be |
82 // shared with the embedder after copying to WebDisplayItemList. | 82 // shared with the embedder after copying to WebDisplayItemList. |
83 // Should only be called right after commitNewDisplayItems. | 83 // Should only be called right after commitNewDisplayItems. |
84 size_t approximateUnsharedMemoryUsage() const; | 84 size_t approximateUnsharedMemoryUsage() const; |
85 | 85 |
86 // Get the paint list generated after the last painting. | 86 // Get the paint list generated after the last painting. |
87 const DisplayItems& displayItems() const; | 87 const DisplayItems& displayItems() const; |
88 | 88 |
89 bool clientCacheIsValid(DisplayItemClient) const; | 89 bool clientCacheIsValid(DisplayItemClient) const; |
| 90 bool subtreeCacheIsValid(DisplayItemClient, DisplayItem::Type beginSubtreeTy
pe) const; |
90 | 91 |
91 // Commits the new display items and plays back the updated display items in
to the given context. | 92 // Commits the new display items and plays back the updated display items in
to the given context. |
92 void commitNewDisplayItemsAndReplay(GraphicsContext& context) | 93 void commitNewDisplayItemsAndReplay(GraphicsContext& context) |
93 { | 94 { |
94 commitNewDisplayItems(); | 95 commitNewDisplayItems(); |
95 replay(context); | 96 replay(context); |
96 } | 97 } |
97 | 98 |
98 void appendToWebDisplayItemList(WebDisplayItemList*); | 99 void appendToWebDisplayItemList(WebDisplayItemList*); |
99 void commitNewDisplayItemsAndAppendToWebDisplayItemList(WebDisplayItemList*)
; | 100 void commitNewDisplayItemsAndAppendToWebDisplayItemList(WebDisplayItemList*)
; |
100 | 101 |
101 bool displayItemConstructionIsDisabled() const { return m_constructionDisabl
ed; } | 102 bool displayItemConstructionIsDisabled() const { return m_constructionDisabl
ed; } |
102 void setDisplayItemConstructionIsDisabled(const bool disable) { m_constructi
onDisabled = disable; } | 103 void setDisplayItemConstructionIsDisabled(const bool disable) { m_constructi
onDisabled = disable; } |
103 | 104 |
104 #if ENABLE(ASSERT) | 105 #if ENABLE(ASSERT) |
105 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); } | 106 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); } |
106 #endif | 107 #endif |
107 | 108 |
108 #ifndef NDEBUG | 109 #ifndef NDEBUG |
109 void showDebugData() const; | 110 void showDebugData() const; |
110 #endif | 111 #endif |
111 | 112 |
112 protected: | 113 protected: |
113 DisplayItemList() | 114 DisplayItemList() |
114 : m_currentDisplayItems(kMaximumDisplayItemSize, 0) | 115 : m_currentDisplayItems(kMaximumDisplayItemSize, 0) |
115 , m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacit
y * kMaximumDisplayItemSize) | 116 , m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacit
y * kMaximumDisplayItemSize) |
116 , m_validlyCachedClientsDirty(false) | 117 , m_validlyCachedClientsDirty(false) |
| 118 , m_subtreeIndicesByClientDirty(false) |
117 , m_constructionDisabled(false) | 119 , m_constructionDisabled(false) |
118 , m_skippingCacheCount(0) | 120 , m_skippingCacheCount(0) |
119 , m_numCachedItems(0) | 121 , m_numCachedItems(0) |
120 , m_nextScope(1) { } | 122 , m_nextScope(1) { } |
121 | 123 |
122 private: | 124 private: |
123 friend class DisplayItemListTest; | 125 friend class DisplayItemListTest; |
124 friend class DisplayItemListPaintTest; | 126 friend class DisplayItemListPaintTest; |
125 friend class DisplayItemListPaintTestForSlimmingPaintV2; | 127 friend class DisplayItemListPaintTestForSlimmingPaintV2; |
126 friend class LayoutObjectDrawingRecorderTest; | 128 friend class LayoutObjectDrawingRecorderTest; |
127 | 129 |
128 // Set new item state (scopes, cache skipping, etc) for a new item. | 130 // Set new item state (scopes, cache skipping, etc) for a new item. |
129 // TODO(pdr): This only passes a pointer to make the patch easier to review.
Change to a reference. | 131 // TODO(pdr): This only passes a pointer to make the patch easier to review.
Change to a reference. |
130 void processNewItem(DisplayItem*); | 132 void processNewItem(DisplayItem*); |
131 | 133 |
132 void updateValidlyCachedClientsIfNeeded() const; | 134 void updateValidlyCachedClientsIfNeeded() const; |
| 135 void updateSubtreeIndicesByClientIfNeeded() const; |
133 | 136 |
134 #ifndef NDEBUG | 137 #ifndef NDEBUG |
135 WTF::String displayItemsAsDebugString(const DisplayItems&) const; | 138 WTF::String displayItemsAsDebugString(const DisplayItems&) const; |
136 #endif | 139 #endif |
137 | 140 |
138 // Indices into PaintList of all DrawingDisplayItems and BeginSubtreeDisplay
Items of each client. | 141 // Indices into DisplayItems of all certain types of display items of each c
lient. |
139 // Temporarily used during merge to find out-of-order display items. | |
140 using DisplayItemIndicesByClientMap = HashMap<DisplayItemClient, Vector<size
_t>>; | 142 using DisplayItemIndicesByClientMap = HashMap<DisplayItemClient, Vector<size
_t>>; |
141 | 143 |
142 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItems&); | 144 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItems&); |
143 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); | 145 static void addItemToIndex(const DisplayItem&, size_t index, DisplayItemIndi
cesByClientMap&); |
144 | 146 |
145 struct OutOfOrderIndexContext; | 147 struct OutOfOrderIndexContext; |
146 DisplayItems::iterator findOutOfOrderCachedItem(DisplayItems::iterator curre
ntIt, const DisplayItem::Id&, OutOfOrderIndexContext&); | 148 DisplayItems::iterator findOutOfOrderCachedItem(DisplayItems::iterator curre
ntIt, const DisplayItem::Id&, OutOfOrderIndexContext&); |
147 DisplayItems::iterator findOutOfOrderCachedItemForward(const DisplayItem::Id
&, OutOfOrderIndexContext&); | 149 DisplayItems::iterator findOutOfOrderCachedItemForward(DisplayItems::iterato
r currentIt, const DisplayItem::Id&, OutOfOrderIndexContext&); |
| 150 |
148 void copyCachedSubtree(DisplayItems::iterator& currentIt, DisplayItems& upda
tedList); | 151 void copyCachedSubtree(DisplayItems::iterator& currentIt, DisplayItems& upda
tedList); |
149 | 152 |
150 #if ENABLE(ASSERT) | 153 #if ENABLE(ASSERT) |
151 // The following two methods are for checking under-invalidations | 154 // The following two methods are for checking under-invalidations |
152 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). | 155 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). |
153 void checkCachedDisplayItemIsUnchanged(const DisplayItem&, DisplayItemIndice
sByClientMap&); | 156 void checkCachedDisplayItemIsUnchanged(const DisplayItem&, DisplayItemIndice
sByClientMap&); |
154 void checkNoRemainingCachedDisplayItems(); | 157 void checkNoRemainingCachedDisplayItems(); |
155 #endif | 158 #endif |
156 | 159 |
157 void replay(GraphicsContext&); | 160 void replay(GraphicsContext&); |
158 | 161 |
159 DisplayItems m_currentDisplayItems; | 162 DisplayItems m_currentDisplayItems; |
160 DisplayItems m_newDisplayItems; | 163 DisplayItems m_newDisplayItems; |
161 | 164 |
162 // Contains all clients having valid cached paintings if updated. | 165 // Contains all clients having valid cached paintings if updated. |
163 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). | 166 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). |
164 // FIXME: In the future we can replace this with client-side repaint flags | 167 // FIXME: In the future we can replace this with client-side repaint flags |
165 // to avoid the cost of building and querying the hash table. | 168 // to avoid the cost of building and querying the hash table. |
166 mutable HashSet<DisplayItemClient> m_validlyCachedClients; | 169 mutable HashSet<DisplayItemClient> m_validlyCachedClients; |
167 mutable bool m_validlyCachedClientsDirty; | 170 mutable bool m_validlyCachedClientsDirty; |
168 | 171 |
| 172 // Stores indices to BeginSubtree display items for subtreeCacheIsValid(). |
| 173 // It's lazily updated in updateSubtreeIndicesIfNeeded(). |
| 174 mutable DisplayItemIndicesByClientMap m_subtreeIndicesByClient; |
| 175 mutable bool m_subtreeIndicesByClientDirty; |
| 176 |
169 // Allow display item construction to be disabled to isolate the costs of co
nstruction | 177 // Allow display item construction to be disabled to isolate the costs of co
nstruction |
170 // in performance metrics. | 178 // in performance metrics. |
171 bool m_constructionDisabled; | 179 bool m_constructionDisabled; |
172 | 180 |
173 int m_skippingCacheCount; | 181 int m_skippingCacheCount; |
174 | 182 |
175 int m_numCachedItems; | 183 int m_numCachedItems; |
176 | 184 |
177 unsigned m_nextScope; | 185 unsigned m_nextScope; |
178 Vector<unsigned> m_scopeStack; | 186 Vector<unsigned> m_scopeStack; |
179 | 187 |
180 #if ENABLE(ASSERT) | 188 #if ENABLE(ASSERT) |
181 // This is used to check duplicated ids during add(). We could also check du
ring | 189 // This is used to check duplicated ids during add(). We could also check du
ring |
182 // updatePaintList(), but checking during add() helps developer easily find
where | 190 // updatePaintList(), but checking during add() helps developer easily find
where |
183 // the duplicated ids are from. | 191 // the duplicated ids are from. |
184 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 192 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
185 #endif | 193 #endif |
186 }; | 194 }; |
187 | 195 |
188 } // namespace blink | 196 } // namespace blink |
189 | 197 |
190 #endif // DisplayItemList_h | 198 #endif // DisplayItemList_h |
OLD | NEW |