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

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

Issue 2385123003: Rewrap comments to 80 columns in Source/platform/graphics/paint/. (Closed)
Patch Set: Resync Created 4 years, 2 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 class PLATFORM_EXPORT PaintController { 43 class PLATFORM_EXPORT PaintController {
44 WTF_MAKE_NONCOPYABLE(PaintController); 44 WTF_MAKE_NONCOPYABLE(PaintController);
45 USING_FAST_MALLOC(PaintController); 45 USING_FAST_MALLOC(PaintController);
46 46
47 public: 47 public:
48 static std::unique_ptr<PaintController> create() { 48 static std::unique_ptr<PaintController> create() {
49 return wrapUnique(new PaintController()); 49 return wrapUnique(new PaintController());
50 } 50 }
51 51
52 ~PaintController() { 52 ~PaintController() {
53 // New display items should be committed before PaintController is destructe d. 53 // New display items should be committed before PaintController is
54 // destructed.
54 DCHECK(m_newDisplayItemList.isEmpty()); 55 DCHECK(m_newDisplayItemList.isEmpty());
55 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 56 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
56 DisplayItemClient::endShouldKeepAliveAllClients(this); 57 DisplayItemClient::endShouldKeepAliveAllClients(this);
57 #endif 58 #endif
58 } 59 }
59 60
60 void invalidateAll(); 61 void invalidateAll();
61 62
62 // These methods are called during painting. 63 // These methods are called during painting.
63 64
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 template <typename DisplayItemClass, typename... Args> 96 template <typename DisplayItemClass, typename... Args>
96 void endItem(Args&&... args) { 97 void endItem(Args&&... args) {
97 if (displayItemConstructionIsDisabled()) 98 if (displayItemConstructionIsDisabled())
98 return; 99 return;
99 if (lastDisplayItemIsNoopBegin()) 100 if (lastDisplayItemIsNoopBegin())
100 removeLastDisplayItem(); 101 removeLastDisplayItem();
101 else 102 else
102 createAndAppend<DisplayItemClass>(std::forward<Args>(args)...); 103 createAndAppend<DisplayItemClass>(std::forward<Args>(args)...);
103 } 104 }
104 105
105 // Tries to find the cached drawing display item corresponding to the given pa rameters. If found, 106 // Tries to find the cached drawing display item corresponding to the given
106 // appends the cached display item to the new display list and returns true. O therwise returns false. 107 // parameters. If found, appends the cached display item to the new display
108 // list and returns true. Otherwise returns false.
107 bool useCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type); 109 bool useCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type);
108 110
109 // Tries to find the cached subsequence corresponding to the given parameters. If found, copies the 111 // Tries to find the cached subsequence corresponding to the given parameters.
110 // cache subsequence to the new display list and returns true. Otherwise retur ns false. 112 // If found, copies the cache subsequence to the new display list and returns
113 // true. Otherwise returns false.
111 bool useCachedSubsequenceIfPossible(const DisplayItemClient&); 114 bool useCachedSubsequenceIfPossible(const DisplayItemClient&);
112 115
113 // 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.
114 bool lastDisplayItemIsNoopBegin() const; 117 bool lastDisplayItemIsNoopBegin() const;
115 void removeLastDisplayItem(); 118 void removeLastDisplayItem();
116 const DisplayItem* lastDisplayItem(unsigned offset); 119 const DisplayItem* lastDisplayItem(unsigned offset);
117 120
118 void beginSkippingCache() { ++m_skippingCacheCount; } 121 void beginSkippingCache() { ++m_skippingCacheCount; }
119 void endSkippingCache() { 122 void endSkippingCache() {
120 DCHECK(m_skippingCacheCount > 0); 123 DCHECK(m_skippingCacheCount > 0);
121 --m_skippingCacheCount; 124 --m_skippingCacheCount;
122 } 125 }
123 bool isSkippingCache() const { return m_skippingCacheCount; } 126 bool isSkippingCache() const { return m_skippingCacheCount; }
124 127
125 // Must be called when a painting is finished. 128 // Must be called when a painting is finished. |offsetFromLayoutObject| is the
126 // offsetFromLayoutObject is the offset between the space of the GraphicsLayer which owns this 129 // offset between the space of the GraphicsLayer which owns this
127 // PaintController and the coordinate space of the owning LayoutObject. 130 // PaintController and the coordinate space of the owning LayoutObject.
128 void commitNewDisplayItems( 131 void commitNewDisplayItems(
129 const LayoutSize& offsetFromLayoutObject = LayoutSize()); 132 const LayoutSize& offsetFromLayoutObject = LayoutSize());
130 133
131 // Returns the approximate memory usage, excluding memory likely to be 134 // Returns the approximate memory usage, excluding memory likely to be
132 // shared with the embedder after copying to WebPaintController. 135 // shared with the embedder after copying to WebPaintController.
133 // Should only be called right after commitNewDisplayItems. 136 // Should only be called right after commitNewDisplayItems.
134 size_t approximateUnsharedMemoryUsage() const; 137 size_t approximateUnsharedMemoryUsage() const;
135 138
136 // Get the artifact generated after the last commit. 139 // Get the artifact generated after the last commit.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 const IndicesByClientMap&, 242 const IndicesByClientMap&,
240 const DisplayItemList&); 243 const DisplayItemList&);
241 static void addItemToIndexIfNeeded(const DisplayItem&, 244 static void addItemToIndexIfNeeded(const DisplayItem&,
242 size_t index, 245 size_t index,
243 IndicesByClientMap&); 246 IndicesByClientMap&);
244 247
245 size_t findCachedItem(const DisplayItem::Id&); 248 size_t findCachedItem(const DisplayItem::Id&);
246 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); 249 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&);
247 void copyCachedSubsequence(size_t&); 250 void copyCachedSubsequence(size_t&);
248 251
249 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.getDi splayItemList() 252 // Resets the indices (e.g. m_nextItemToMatch) of
250 // to their initial values. This should be called when the DisplayItemList in m_currentPaintArtifact 253 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This
251 // is newly created, or is changed causing the previous indices to be invalid. 254 // should be called when the DisplayItemList in m_currentPaintArtifact is
255 // newly created, or is changed causing the previous indices to be invalid.
252 void resetCurrentListIndices(); 256 void resetCurrentListIndices();
253 257
254 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); 258 void generateChunkRasterInvalidationRects(PaintChunk& newChunk);
255 void generateChunkRasterInvalidationRectsComparingOldChunk( 259 void generateChunkRasterInvalidationRectsComparingOldChunk(
256 PaintChunk& newChunk, 260 PaintChunk& newChunk,
257 const PaintChunk& oldChunk); 261 const PaintChunk& oldChunk);
258 void addRasterInvalidationInfo(const DisplayItemClient*, 262 void addRasterInvalidationInfo(const DisplayItemClient*,
259 PaintChunk&, 263 PaintChunk&,
260 const FloatRect&); 264 const FloatRect&);
261 265
262 // The following two methods are for checking under-invalidations 266 // The following two methods are for checking under-invalidations
263 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). 267 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled).
264 void showUnderInvalidationError(const char* reason, 268 void showUnderInvalidationError(const char* reason,
265 const DisplayItem& newItem, 269 const DisplayItem& newItem,
266 const DisplayItem* oldItem) const; 270 const DisplayItem* oldItem) const;
267 void checkUnderInvalidation(); 271 void checkUnderInvalidation();
268 bool isCheckingUnderInvalidation() const { 272 bool isCheckingUnderInvalidation() const {
269 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin > 273 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin >
270 0; 274 0;
271 } 275 }
272 276
273 // The last complete paint artifact. 277 // The last complete paint artifact.
274 // In SPv2, this includes paint chunks as well as display items. 278 // In SPv2, this includes paint chunks as well as display items.
275 PaintArtifact m_currentPaintArtifact; 279 PaintArtifact m_currentPaintArtifact;
276 280
277 // Data being used to build the next paint artifact. 281 // Data being used to build the next paint artifact.
278 DisplayItemList m_newDisplayItemList; 282 DisplayItemList m_newDisplayItemList;
279 PaintChunker m_newPaintChunks; 283 PaintChunker m_newPaintChunks;
280 284
281 // Stores indices into m_newDisplayItemList for display items that have been m oved from 285 // Stores indices into m_newDisplayItemList for display items that have been
282 // m_currentPaintArtifact.getDisplayItemList(), indexed by the positions of th e display 286 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the
283 // items before move. The values are undefined for display items that are not moved. 287 // positions of the display items before the move. The values are undefined
288 // for display items that are not moved.
284 Vector<size_t> m_itemsMovedIntoNewList; 289 Vector<size_t> m_itemsMovedIntoNewList;
285 290
286 // Allow display item construction to be disabled to isolate the costs of cons truction 291 // Allows display item construction to be disabled to isolate the costs of
287 // in performance metrics. 292 // construction in performance metrics.
288 bool m_constructionDisabled; 293 bool m_constructionDisabled;
289 294
290 // Allow subsequence caching to be disabled to test the cost of display item c aching. 295 // Allows subsequence caching to be disabled to test the cost of display item
296 // caching.
291 bool m_subsequenceCachingDisabled; 297 bool m_subsequenceCachingDisabled;
292 298
293 // Indicates this PaintController has ever had text. It is never reset to fals e. 299 // Indicates this PaintController has ever had text. It is never reset to
300 // false.
294 bool m_textPainted; 301 bool m_textPainted;
295 bool m_imagePainted; 302 bool m_imagePainted;
296 303
297 int m_skippingCacheCount; 304 int m_skippingCacheCount;
298 305
299 int m_numCachedNewItems; 306 int m_numCachedNewItems;
300 307
301 // Stores indices to valid cacheable display items in m_currentPaintArtifact.d isplayItemList() 308 // Stores indices to valid cacheable display items in
302 // that have not been matched by requests of cached display items (using useCa chedDrawingIfPossible() 309 // m_currentPaintArtifact.displayItemList() that have not been matched by
303 // and useCachedSubsequenceIfPossible()) during sequential matching . The inde xed items will be 310 // requests of cached display items (using useCachedDrawingIfPossible() and
304 // matched by later out-of-order requests of cached display items. This ensure s that when 311 // useCachedSubsequenceIfPossible()) during sequential matching. The indexed
305 // out-of-order cached display items are requested, we only traverse at most o nce over 312 // items will be matched by later out-of-order requests of cached display
306 // the current display list looking for potential matches. Thus we can ensure that the 313 // items. This ensures that when out-of-order cached display items are
307 // algorithm runs in linear time. 314 // requested, we only traverse at most once over the current display list
315 // looking for potential matches. Thus we can ensure that the algorithm runs
316 // in linear time.
308 IndicesByClientMap m_outOfOrderItemIndices; 317 IndicesByClientMap m_outOfOrderItemIndices;
309 318
310 // The next item in the current list for sequential match. 319 // The next item in the current list for sequential match.
311 size_t m_nextItemToMatch; 320 size_t m_nextItemToMatch;
312 321
313 // The next item in the current list to be indexed for out-of-order cache requ ests. 322 // The next item in the current list to be indexed for out-of-order cache
323 // requests.
314 size_t m_nextItemToIndex; 324 size_t m_nextItemToIndex;
315 325
316 // Similar to m_outOfOrderItemIndices but 326 // Similar to m_outOfOrderItemIndices but
317 // - the indices are chunk indices in m_currentPaintArtifacts.paintChunks(); 327 // - the indices are chunk indices in m_currentPaintArtifacts.paintChunks();
318 // - chunks are matched not only for requests of cached display items, but als o non-cached display items. 328 // - chunks are matched not only for requests of cached display items, but
329 // also non-cached display items.
319 IndicesByClientMap m_outOfOrderChunkIndices; 330 IndicesByClientMap m_outOfOrderChunkIndices;
320 331
321 size_t m_currentCachedSubsequenceBeginIndexInNewList; 332 size_t m_currentCachedSubsequenceBeginIndexInNewList;
322 size_t m_nextChunkToMatch; 333 size_t m_nextChunkToMatch;
323 334
324 DisplayItemClient::CacheGenerationOrInvalidationReason 335 DisplayItemClient::CacheGenerationOrInvalidationReason
325 m_currentCacheGeneration; 336 m_currentCacheGeneration;
326 337
327 #ifndef NDEBUG 338 #ifndef NDEBUG
328 int m_numSequentialMatches; 339 int m_numSequentialMatches;
329 int m_numOutOfOrderMatches; 340 int m_numOutOfOrderMatches;
330 int m_numIndexedItems; 341 int m_numIndexedItems;
331 #endif 342 #endif
332 343
333 #if DCHECK_IS_ON() 344 #if DCHECK_IS_ON()
334 // This is used to check duplicated ids during createAndAppend(). 345 // This is used to check duplicated ids during createAndAppend().
335 IndicesByClientMap m_newDisplayItemIndicesByClient; 346 IndicesByClientMap m_newDisplayItemIndicesByClient;
336 #endif 347 #endif
337 348
338 // These are set in useCachedDrawingIfPossible() and useCachedSubsequenceIfPos sible() 349 // These are set in useCachedDrawingIfPossible() and
339 // when we could use cached drawing or subsequence and under-invalidation chec king is on, 350 // useCachedSubsequenceIfPossible() when we could use cached drawing or
340 // indicating the begin and end of the cached drawing or subsequence in the cu rrent list. 351 // subsequence and under-invalidation checking is on, indicating the begin and
341 // The functions return false to let the client do actual painting, and PaintC ontroller 352 // end of the cached drawing or subsequence in the current list. The functions
342 // will check if the actual painting results are the same as the cached. 353 // return false to let the client do actual painting, and PaintController will
354 // check if the actual painting results are the same as the cached.
343 size_t m_underInvalidationCheckingBegin; 355 size_t m_underInvalidationCheckingBegin;
344 size_t m_underInvalidationCheckingEnd; 356 size_t m_underInvalidationCheckingEnd;
345 // Number of probable under-invalidations that have been skipped temporarily b ecause the 357
346 // mismatching display items may be removed in the future because of no-op pai rs or 358 // Number of probable under-invalidations that have been skipped temporarily
347 // compositing folding. 359 // because the mismatching display items may be removed in the future because
360 // of no-op pairs or compositing folding.
348 int m_skippedProbableUnderInvalidationCount; 361 int m_skippedProbableUnderInvalidationCount;
349 String m_underInvalidationMessagePrefix; 362 String m_underInvalidationMessagePrefix;
350 363
351 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>> 364 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>>
352 m_paintChunksRasterInvalidationTrackingMap; 365 m_paintChunksRasterInvalidationTrackingMap;
353 366
354 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 367 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
355 // A stack recording subsequence clients that are currently painting. 368 // A stack recording subsequence clients that are currently painting.
356 Vector<const DisplayItemClient*> m_currentSubsequenceClients; 369 Vector<const DisplayItemClient*> m_currentSubsequenceClients;
357 #endif 370 #endif
358 }; 371 };
359 372
360 } // namespace blink 373 } // namespace blink
361 374
362 #endif // PaintController_h 375 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698