Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintController.h

Issue 2307623002: [SPv2] Defer decision of raster invalidation after paint for changes z-index, transform, etc. (Closed)
Patch Set: Remove duplicated spv2 expectation entries Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 PaintController_h 5 #ifndef PaintController_h
6 #define PaintController_h 6 #define PaintController_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/RuntimeEnabledFeatures.h" 9 #include "platform/RuntimeEnabledFeatures.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, 72 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value,
73 "Can only createAndAppend subclasses of DisplayItem."); 73 "Can only createAndAppend subclasses of DisplayItem.");
74 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, 74 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize,
75 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); 75 "DisplayItem subclass is larger than kMaximumDisplayItemSize.");
76 76
77 if (displayItemConstructionIsDisabled()) 77 if (displayItemConstructionIsDisabled())
78 return; 78 return;
79 79
80 ensureNewDisplayItemListInitialCapacity(); 80 ensureNewDisplayItemListInitialCapacity();
81 DisplayItemClass& displayItem = m_newDisplayItemList.allocateAndConstruc t<DisplayItemClass>(std::forward<Args>(args)...); 81 DisplayItemClass& displayItem = m_newDisplayItemList.allocateAndConstruc t<DisplayItemClass>(std::forward<Args>(args)...);
82 processNewItem(displayItem, NewPainting); 82 processNewItem(displayItem);
83 } 83 }
84 84
85 // Creates and appends an ending display item to pair with a preceding 85 // Creates and appends an ending display item to pair with a preceding
86 // beginning item iff the display item actually draws content. For no-op 86 // beginning item iff the display item actually draws content. For no-op
87 // items, rather than creating an ending item, the begin item will 87 // items, rather than creating an ending item, the begin item will
88 // instead be removed, thereby maintaining brevity of the list. If display 88 // instead be removed, thereby maintaining brevity of the list. If display
89 // item construction is disabled, no list mutations will be performed. 89 // item construction is disabled, no list mutations will be performed.
90 template <typename DisplayItemClass, typename... Args> 90 template <typename DisplayItemClass, typename... Args>
91 void endItem(Args&&... args) 91 void endItem(Args&&... args)
92 { 92 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 protected: 159 protected:
160 PaintController() 160 PaintController()
161 : m_newDisplayItemList(0) 161 : m_newDisplayItemList(0)
162 , m_constructionDisabled(false) 162 , m_constructionDisabled(false)
163 , m_subsequenceCachingDisabled(false) 163 , m_subsequenceCachingDisabled(false)
164 , m_textPainted(false) 164 , m_textPainted(false)
165 , m_imagePainted(false) 165 , m_imagePainted(false)
166 , m_skippingCacheCount(0) 166 , m_skippingCacheCount(0)
167 , m_numCachedNewItems(0) 167 , m_numCachedNewItems(0)
168 , m_currentChunkIsFromCachedSubsequence(true) 168 , m_currentCachedSubsequenceBeginIndexInNewList(kNotFound)
169 #ifndef NDEBUG 169 #ifndef NDEBUG
170 , m_numSequentialMatches(0) 170 , m_numSequentialMatches(0)
171 , m_numOutOfOrderMatches(0) 171 , m_numOutOfOrderMatches(0)
172 , m_numIndexedItems(0) 172 , m_numIndexedItems(0)
173 #endif 173 #endif
174 { 174 {
175 resetCurrentListIndices(); 175 resetCurrentListIndices();
176 } 176 }
177 177
178 private: 178 private:
179 friend class PaintControllerTestBase; 179 friend class PaintControllerTestBase;
180 friend class PaintControllerPaintTestBase; 180 friend class PaintControllerPaintTestBase;
181 181
182 void ensureNewDisplayItemListInitialCapacity() 182 void ensureNewDisplayItemListInitialCapacity()
183 { 183 {
184 if (m_newDisplayItemList.isEmpty()) { 184 if (m_newDisplayItemList.isEmpty()) {
185 // TODO(wangxianzhu): Consider revisiting this heuristic. 185 // TODO(wangxianzhu): Consider revisiting this heuristic.
186 m_newDisplayItemList = DisplayItemList(m_currentPaintArtifact.getDis playItemList().isEmpty() ? kInitialDisplayItemListCapacityBytes : m_currentPaint Artifact.getDisplayItemList().usedCapacityInBytes()); 186 m_newDisplayItemList = DisplayItemList(m_currentPaintArtifact.getDis playItemList().isEmpty() ? kInitialDisplayItemListCapacityBytes : m_currentPaint Artifact.getDisplayItemList().usedCapacityInBytes());
187 } 187 }
188 } 188 }
189 189
190 // Set new item state (cache skipping, etc) for a new item. 190 // Set new item state (cache skipping, etc) for a new item.
191 enum NewItemSource { FromCachedItem, FromCachedSubsequence, NewPainting }; 191 void processNewItem(DisplayItem&);
192 void processNewItem(DisplayItem&, NewItemSource); 192 DisplayItem& moveItemFromCurrentListToNewList(size_t);
193 193
194 String displayItemListAsDebugString(const DisplayItemList&) const; 194 String displayItemListAsDebugString(const DisplayItemList&) const;
195 195
196 // Maps clients to indices of display items or chunks of each client. 196 // Maps clients to indices of display items or chunks of each client.
197 using IndicesByClientMap = HashMap<const DisplayItemClient*, Vector<size_t>> ; 197 using IndicesByClientMap = HashMap<const DisplayItemClient*, Vector<size_t>> ;
198 198
199 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Indice sByClientMap&, const DisplayItemList&); 199 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Indice sByClientMap&, const DisplayItemList&);
200 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Indices ByClientMap&); 200 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Indices ByClientMap&);
201 201
202 size_t findCachedItem(const DisplayItem::Id&); 202 size_t findCachedItem(const DisplayItem::Id&);
203 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); 203 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&);
204 void copyCachedSubsequence(size_t&); 204 void copyCachedSubsequence(size_t&);
205 205
206 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.get DisplayItemList() 206 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.get DisplayItemList()
207 // to their initial values. This should be called when the DisplayItemList i n m_currentPaintArtifact 207 // to their initial values. This should be called when the DisplayItemList i n m_currentPaintArtifact
208 // is newly created, or is changed causing the previous indices to be invali d. 208 // is newly created, or is changed causing the previous indices to be invali d.
209 void resetCurrentListIndices(); 209 void resetCurrentListIndices();
210 210
211 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); 211 void generateChunkRasterInvalidationRects(PaintChunk& newChunk);
212 void generateChunkRasterInvalidationRectsComparingOldChunk(PaintChunk& newCh unk, const PaintChunk& oldChunk); 212 void generateChunkRasterInvalidationRectsComparingOldChunk(PaintChunk& newCh unk, const PaintChunk& oldChunk);
213 void generateChunkRasterInvalidationRectsForReorderedItems(PaintChunk& newCh unk, const PaintChunk& oldChunk,
214 Vector<size_t>::const_iterator, Vector<size_t>::const_iterator, Vector<s ize_t>::const_iterator, Vector<size_t>::const_iterator);
213 215
214 // The following two methods are for checking under-invalidations 216 // The following two methods are for checking under-invalidations
215 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). 217 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled).
216 void showUnderInvalidationError(const char* reason, const DisplayItem& newIt em, const DisplayItem* oldItem) const; 218 void showUnderInvalidationError(const char* reason, const DisplayItem& newIt em, const DisplayItem* oldItem) const;
217 void checkUnderInvalidation(); 219 void checkUnderInvalidation();
218 bool isCheckingUnderInvalidation() const { return m_underInvalidationCheckin gEnd - m_underInvalidationCheckingBegin > 0; } 220 bool isCheckingUnderInvalidation() const { return m_underInvalidationCheckin gEnd - m_underInvalidationCheckingBegin > 0; }
219 221
220 // The last complete paint artifact. 222 // The last complete paint artifact.
221 // In SPv2, this includes paint chunks as well as display items. 223 // In SPv2, this includes paint chunks as well as display items.
222 PaintArtifact m_currentPaintArtifact; 224 PaintArtifact m_currentPaintArtifact;
223 225
224 // Data being used to build the next paint artifact. 226 // Data being used to build the next paint artifact.
225 DisplayItemList m_newDisplayItemList; 227 DisplayItemList m_newDisplayItemList;
226 PaintChunker m_newPaintChunks; 228 PaintChunker m_newPaintChunks;
227 229
230 // Stores indices into m_newDisplayItemList for display items that have been moved from
231 // m_currentPaintArtifact.getDisplayItemList(), indexed by the positions of the display
232 // items before move. The values are undefined for display items that are no t moved.
233 Vector<size_t> m_itemsMovedIntoNewList;
234
228 // Allow display item construction to be disabled to isolate the costs of co nstruction 235 // Allow display item construction to be disabled to isolate the costs of co nstruction
229 // in performance metrics. 236 // in performance metrics.
230 bool m_constructionDisabled; 237 bool m_constructionDisabled;
231 238
232 // Allow subsequence caching to be disabled to test the cost of display item caching. 239 // Allow subsequence caching to be disabled to test the cost of display item caching.
233 bool m_subsequenceCachingDisabled; 240 bool m_subsequenceCachingDisabled;
234 241
235 // Indicates this PaintController has ever had text. It is never reset to fa lse. 242 // Indicates this PaintController has ever had text. It is never reset to fa lse.
236 bool m_textPainted; 243 bool m_textPainted;
237 bool m_imagePainted; 244 bool m_imagePainted;
(...skipping 15 matching lines...) Expand all
253 size_t m_nextItemToMatch; 260 size_t m_nextItemToMatch;
254 261
255 // The next item in the current list to be indexed for out-of-order cache re quests. 262 // The next item in the current list to be indexed for out-of-order cache re quests.
256 size_t m_nextItemToIndex; 263 size_t m_nextItemToIndex;
257 264
258 // Similar to m_outOfOrderItemIndices but 265 // Similar to m_outOfOrderItemIndices but
259 // - the indices are chunk indices in m_currentPaintArtifacts.paintChunks(); 266 // - the indices are chunk indices in m_currentPaintArtifacts.paintChunks();
260 // - chunks are matched not only for requests of cached display items, but a lso non-cached display items. 267 // - chunks are matched not only for requests of cached display items, but a lso non-cached display items.
261 IndicesByClientMap m_outOfOrderChunkIndices; 268 IndicesByClientMap m_outOfOrderChunkIndices;
262 269
263 bool m_currentChunkIsFromCachedSubsequence; 270 size_t m_currentCachedSubsequenceBeginIndexInNewList;
264 size_t m_nextChunkToMatch; 271 size_t m_nextChunkToMatch;
265 272
266 DisplayItemClient::CacheGenerationOrInvalidationReason m_currentCacheGenerat ion; 273 DisplayItemClient::CacheGenerationOrInvalidationReason m_currentCacheGenerat ion;
267 274
268 #ifndef NDEBUG 275 #ifndef NDEBUG
269 int m_numSequentialMatches; 276 int m_numSequentialMatches;
270 int m_numOutOfOrderMatches; 277 int m_numOutOfOrderMatches;
271 int m_numIndexedItems; 278 int m_numIndexedItems;
272 #endif 279 #endif
273 280
(...skipping 17 matching lines...) Expand all
291 298
292 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 299 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
293 // A stack recording subsequence clients that are currently painting. 300 // A stack recording subsequence clients that are currently painting.
294 Vector<const DisplayItemClient*> m_currentSubsequenceClients; 301 Vector<const DisplayItemClient*> m_currentSubsequenceClients;
295 #endif 302 #endif
296 }; 303 };
297 304
298 } // namespace blink 305 } // namespace blink
299 306
300 #endif // PaintController_h 307 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698