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

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

Issue 2793233002: Remove begin/end subseq. display items, and store on PaintController instead. (Closed)
Patch Set: none Created 3 years, 8 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Tries to find the cached drawing display item corresponding to the given 102 // Tries to find the cached drawing display item corresponding to the given
103 // parameters. If found, appends the cached display item to the new display 103 // parameters. If found, appends the cached display item to the new display
104 // list and returns true. Otherwise returns false. 104 // list and returns true. Otherwise returns false.
105 bool useCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type); 105 bool useCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type);
106 106
107 // Tries to find the cached subsequence corresponding to the given parameters. 107 // Tries to find the cached subsequence corresponding to the given parameters.
108 // If found, copies the cache subsequence to the new display list and returns 108 // If found, copies the cache subsequence to the new display list and returns
109 // true. Otherwise returns false. 109 // true. Otherwise returns false.
110 bool useCachedSubsequenceIfPossible(const DisplayItemClient&); 110 bool useCachedSubsequenceIfPossible(const DisplayItemClient&);
111 111
112 void addCachedSubsequence(const DisplayItemClient&,
113 unsigned start,
114 unsigned end);
115
112 // True if the last display item is a begin that doesn't draw content. 116 // True if the last display item is a begin that doesn't draw content.
113 bool lastDisplayItemIsNoopBegin() const;
114 void removeLastDisplayItem(); 117 void removeLastDisplayItem();
115 const DisplayItem* lastDisplayItem(unsigned offset); 118 const DisplayItem* lastDisplayItem(unsigned offset);
116 119
117 void beginSkippingCache() { ++m_skippingCacheCount; } 120 void beginSkippingCache() { ++m_skippingCacheCount; }
118 void endSkippingCache() { 121 void endSkippingCache() {
119 DCHECK(m_skippingCacheCount > 0); 122 DCHECK(m_skippingCacheCount > 0);
120 --m_skippingCacheCount; 123 --m_skippingCacheCount;
121 } 124 }
122 bool isSkippingCache() const { return m_skippingCacheCount; } 125 bool isSkippingCache() const { return m_skippingCacheCount; }
123 126
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 m_imagePainted(false), 207 m_imagePainted(false),
205 m_skippingCacheCount(0), 208 m_skippingCacheCount(0),
206 m_numCachedNewItems(0), 209 m_numCachedNewItems(0),
207 m_currentCachedSubsequenceBeginIndexInNewList(kNotFound) 210 m_currentCachedSubsequenceBeginIndexInNewList(kNotFound)
208 #ifndef NDEBUG 211 #ifndef NDEBUG
209 , 212 ,
210 m_numSequentialMatches(0), 213 m_numSequentialMatches(0),
211 m_numOutOfOrderMatches(0), 214 m_numOutOfOrderMatches(0),
212 m_numIndexedItems(0) 215 m_numIndexedItems(0)
213 #endif 216 #endif
214 { 217 ,
218 m_underInvalidationCheckingBegin(0),
219 m_underInvalidationCheckingEnd(0),
220 m_isCheckingSubsequenceUnderInvalidation(false) {
215 resetCurrentListIndices(); 221 resetCurrentListIndices();
216 setTracksRasterInvalidations( 222 setTracksRasterInvalidations(
217 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()); 223 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled());
218 } 224 }
219 225
220 private: 226 private:
221 friend class PaintControllerTestBase; 227 friend class PaintControllerTestBase;
222 friend class PaintControllerPaintTestBase; 228 friend class PaintControllerPaintTestBase;
223 229
230 bool lastDisplayItemIsNoopBegin() const;
231
224 void ensureNewDisplayItemListInitialCapacity() { 232 void ensureNewDisplayItemListInitialCapacity() {
225 if (m_newDisplayItemList.isEmpty()) { 233 if (m_newDisplayItemList.isEmpty()) {
226 // TODO(wangxianzhu): Consider revisiting this heuristic. 234 // TODO(wangxianzhu): Consider revisiting this heuristic.
227 m_newDisplayItemList = 235 m_newDisplayItemList =
228 DisplayItemList(m_currentPaintArtifact.getDisplayItemList().isEmpty() 236 DisplayItemList(m_currentPaintArtifact.getDisplayItemList().isEmpty()
229 ? kInitialDisplayItemListCapacityBytes 237 ? kInitialDisplayItemListCapacityBytes
230 : m_currentPaintArtifact.getDisplayItemList() 238 : m_currentPaintArtifact.getDisplayItemList()
231 .usedCapacityInBytes()); 239 .usedCapacityInBytes());
232 } 240 }
233 } 241 }
(...skipping 11 matching lines...) Expand all
245 253
246 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, 254 static size_t findMatchingItemFromIndex(const DisplayItem::Id&,
247 const IndicesByClientMap&, 255 const IndicesByClientMap&,
248 const DisplayItemList&); 256 const DisplayItemList&);
249 static void addItemToIndexIfNeeded(const DisplayItem&, 257 static void addItemToIndexIfNeeded(const DisplayItem&,
250 size_t index, 258 size_t index,
251 IndicesByClientMap&); 259 IndicesByClientMap&);
252 260
253 size_t findCachedItem(const DisplayItem::Id&); 261 size_t findCachedItem(const DisplayItem::Id&);
254 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); 262 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&);
255 void copyCachedSubsequence(size_t&); 263 void copyCachedSubsequence(size_t beginIndex, size_t endIndex);
256 264
257 // Resets the indices (e.g. m_nextItemToMatch) of 265 // Resets the indices (e.g. m_nextItemToMatch) of
258 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This 266 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This
259 // should be called when the DisplayItemList in m_currentPaintArtifact is 267 // should be called when the DisplayItemList in m_currentPaintArtifact is
260 // newly created, or is changed causing the previous indices to be invalid. 268 // newly created, or is changed causing the previous indices to be invalid.
261 void resetCurrentListIndices(); 269 void resetCurrentListIndices();
262 270
263 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); 271 void generateChunkRasterInvalidationRects(PaintChunk& newChunk);
264 void generateChunkRasterInvalidationRectsComparingOldChunk( 272 void generateChunkRasterInvalidationRectsComparingOldChunk(
265 PaintChunk& newChunk, 273 PaintChunk& newChunk,
266 const PaintChunk& oldChunk); 274 const PaintChunk& oldChunk);
267 void addRasterInvalidationInfo(const DisplayItemClient*, 275 void addRasterInvalidationInfo(const DisplayItemClient*,
268 PaintChunk&, 276 PaintChunk&,
269 const FloatRect&); 277 const FloatRect&);
270 278
271 // The following two methods are for checking under-invalidations 279 // The following two methods are for checking under-invalidations
272 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). 280 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled).
273 void showUnderInvalidationError(const char* reason, 281 void showUnderInvalidationError(const char* reason,
274 const DisplayItem& newItem, 282 const DisplayItem& newItem,
275 const DisplayItem* oldItem) const; 283 const DisplayItem* oldItem) const;
284
285 void showSequenceUnderInvalidationError(const char* reason,
286 const DisplayItemClient&,
287 int start,
288 int end);
289
276 void checkUnderInvalidation(); 290 void checkUnderInvalidation();
277 bool isCheckingUnderInvalidation() const { 291 bool isCheckingUnderInvalidation() const {
278 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin > 292 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin >
279 0; 293 0;
280 } 294 }
281 295
296 struct SubsequenceMarkers {
297 SubsequenceMarkers() : start(0), end(0) {}
298 SubsequenceMarkers(size_t startArg, size_t endArg)
299 : start(startArg), end(endArg) {}
300 // The start and end index within m_currentPaintArtifact of this
301 // subsequence.
302 size_t start;
303 size_t end;
304 };
305
306 SubsequenceMarkers* getSubsequenceMarkers(const DisplayItemClient&);
307
282 // The last complete paint artifact. 308 // The last complete paint artifact.
283 // In SPv2, this includes paint chunks as well as display items. 309 // In SPv2, this includes paint chunks as well as display items.
284 PaintArtifact m_currentPaintArtifact; 310 PaintArtifact m_currentPaintArtifact;
285 311
286 // Data being used to build the next paint artifact. 312 // Data being used to build the next paint artifact.
287 DisplayItemList m_newDisplayItemList; 313 DisplayItemList m_newDisplayItemList;
288 PaintChunker m_newPaintChunks; 314 PaintChunker m_newPaintChunks;
289 315
290 // Stores indices into m_newDisplayItemList for display items that have been 316 // Stores indices into m_newDisplayItemList for display items that have been
291 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the 317 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 #endif 383 #endif
358 384
359 // These are set in useCachedDrawingIfPossible() and 385 // These are set in useCachedDrawingIfPossible() and
360 // useCachedSubsequenceIfPossible() when we could use cached drawing or 386 // useCachedSubsequenceIfPossible() when we could use cached drawing or
361 // subsequence and under-invalidation checking is on, indicating the begin and 387 // subsequence and under-invalidation checking is on, indicating the begin and
362 // end of the cached drawing or subsequence in the current list. The functions 388 // end of the cached drawing or subsequence in the current list. The functions
363 // return false to let the client do actual painting, and PaintController will 389 // return false to let the client do actual painting, and PaintController will
364 // check if the actual painting results are the same as the cached. 390 // check if the actual painting results are the same as the cached.
365 size_t m_underInvalidationCheckingBegin; 391 size_t m_underInvalidationCheckingBegin;
366 size_t m_underInvalidationCheckingEnd; 392 size_t m_underInvalidationCheckingEnd;
393 bool m_isCheckingSubsequenceUnderInvalidation;
367 394
368 // Number of probable under-invalidations that have been skipped temporarily 395 // Number of probable under-invalidations that have been skipped temporarily
369 // because the mismatching display items may be removed in the future because 396 // because the mismatching display items may be removed in the future because
370 // of no-op pairs or compositing folding. 397 // of no-op pairs or compositing folding.
371 int m_skippedProbableUnderInvalidationCount; 398 int m_skippedProbableUnderInvalidationCount;
372 String m_underInvalidationMessagePrefix; 399 String m_underInvalidationMessagePrefix;
373 400
374 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>> 401 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>>
375 m_paintChunksRasterInvalidationTrackingMap; 402 m_paintChunksRasterInvalidationTrackingMap;
376 403
377 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 404 typedef HashMap<const DisplayItemClient*, SubsequenceMarkers>
378 // A stack recording subsequence clients that are currently painting. 405 CachedSubsequenceMap;
379 Vector<const DisplayItemClient*> m_currentSubsequenceClients; 406 CachedSubsequenceMap m_currentCachedSubsequences;
380 #endif 407 CachedSubsequenceMap m_newCachedSubsequences;
408
409 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedSubsequenceSwapOrder);
410 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedNestedSubsequenceUpdate);
381 }; 411 };
382 412
383 } // namespace blink 413 } // namespace blink
384 414
385 #endif // PaintController_h 415 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698