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 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 Loading... | |
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 Loading... | |
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 , |
Xianzhu
2017/04/05 22:39:17
Nit: Move ',' before #endif and the ',' before #if
chrishtr
2017/04/06 00:05:29
Done.
| |
218 m_underInvalidationCheckingBegin(0), | |
219 m_underInvalidationCheckingEnd(0) { | |
215 resetCurrentListIndices(); | 220 resetCurrentListIndices(); |
216 setTracksRasterInvalidations( | 221 setTracksRasterInvalidations( |
217 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()); | 222 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()); |
218 } | 223 } |
219 | 224 |
220 private: | 225 private: |
221 friend class PaintControllerTestBase; | 226 friend class PaintControllerTestBase; |
222 friend class PaintControllerPaintTestBase; | 227 friend class PaintControllerPaintTestBase; |
223 | 228 |
229 bool lastDisplayItemIsNoopBegin() const; | |
230 | |
224 void ensureNewDisplayItemListInitialCapacity() { | 231 void ensureNewDisplayItemListInitialCapacity() { |
225 if (m_newDisplayItemList.isEmpty()) { | 232 if (m_newDisplayItemList.isEmpty()) { |
226 // TODO(wangxianzhu): Consider revisiting this heuristic. | 233 // TODO(wangxianzhu): Consider revisiting this heuristic. |
227 m_newDisplayItemList = | 234 m_newDisplayItemList = |
228 DisplayItemList(m_currentPaintArtifact.getDisplayItemList().isEmpty() | 235 DisplayItemList(m_currentPaintArtifact.getDisplayItemList().isEmpty() |
229 ? kInitialDisplayItemListCapacityBytes | 236 ? kInitialDisplayItemListCapacityBytes |
230 : m_currentPaintArtifact.getDisplayItemList() | 237 : m_currentPaintArtifact.getDisplayItemList() |
231 .usedCapacityInBytes()); | 238 .usedCapacityInBytes()); |
232 } | 239 } |
233 } | 240 } |
(...skipping 11 matching lines...) Expand all Loading... | |
245 | 252 |
246 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, | 253 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, |
247 const IndicesByClientMap&, | 254 const IndicesByClientMap&, |
248 const DisplayItemList&); | 255 const DisplayItemList&); |
249 static void addItemToIndexIfNeeded(const DisplayItem&, | 256 static void addItemToIndexIfNeeded(const DisplayItem&, |
250 size_t index, | 257 size_t index, |
251 IndicesByClientMap&); | 258 IndicesByClientMap&); |
252 | 259 |
253 size_t findCachedItem(const DisplayItem::Id&); | 260 size_t findCachedItem(const DisplayItem::Id&); |
254 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); | 261 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); |
255 void copyCachedSubsequence(size_t&); | 262 void copyCachedSubsequence(size_t beginIndex, size_t endIndex); |
256 | 263 |
257 // Resets the indices (e.g. m_nextItemToMatch) of | 264 // Resets the indices (e.g. m_nextItemToMatch) of |
258 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This | 265 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This |
259 // should be called when the DisplayItemList in m_currentPaintArtifact is | 266 // should be called when the DisplayItemList in m_currentPaintArtifact is |
260 // newly created, or is changed causing the previous indices to be invalid. | 267 // newly created, or is changed causing the previous indices to be invalid. |
261 void resetCurrentListIndices(); | 268 void resetCurrentListIndices(); |
262 | 269 |
263 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); | 270 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); |
264 void generateChunkRasterInvalidationRectsComparingOldChunk( | 271 void generateChunkRasterInvalidationRectsComparingOldChunk( |
265 PaintChunk& newChunk, | 272 PaintChunk& newChunk, |
266 const PaintChunk& oldChunk); | 273 const PaintChunk& oldChunk); |
267 void addRasterInvalidationInfo(const DisplayItemClient*, | 274 void addRasterInvalidationInfo(const DisplayItemClient*, |
268 PaintChunk&, | 275 PaintChunk&, |
269 const FloatRect&); | 276 const FloatRect&); |
270 | 277 |
271 // The following two methods are for checking under-invalidations | 278 // The following two methods are for checking under-invalidations |
272 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). | 279 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). |
273 void showUnderInvalidationError(const char* reason, | 280 void showUnderInvalidationError(const char* reason, |
274 const DisplayItem& newItem, | 281 const DisplayItem& newItem, |
275 const DisplayItem* oldItem) const; | 282 const DisplayItem* oldItem) const; |
283 | |
284 void showSequenceUnderInvalidationError(const char* reason, | |
285 const DisplayItemClient&, | |
286 int start, | |
287 int end); | |
288 | |
276 void checkUnderInvalidation(); | 289 void checkUnderInvalidation(); |
277 bool isCheckingUnderInvalidation() const { | 290 bool isCheckingUnderInvalidation() const { |
278 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin > | 291 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin > |
279 0; | 292 0; |
280 } | 293 } |
281 | 294 |
295 struct SubsequenceMarkers { | |
296 SubsequenceMarkers() : start(0), end(0) {} | |
297 SubsequenceMarkers(size_t startArg, size_t endArg) | |
298 : start(startArg), end(endArg) {} | |
299 // The start and end index within m_currentPaintArtifact of this | |
300 // subsequence. | |
301 size_t start; | |
302 size_t end; | |
303 }; | |
304 | |
305 SubsequenceMarkers* getSubsequenceMarkers(const DisplayItemClient&); | |
306 | |
282 // The last complete paint artifact. | 307 // The last complete paint artifact. |
283 // In SPv2, this includes paint chunks as well as display items. | 308 // In SPv2, this includes paint chunks as well as display items. |
284 PaintArtifact m_currentPaintArtifact; | 309 PaintArtifact m_currentPaintArtifact; |
285 | 310 |
286 // Data being used to build the next paint artifact. | 311 // Data being used to build the next paint artifact. |
287 DisplayItemList m_newDisplayItemList; | 312 DisplayItemList m_newDisplayItemList; |
288 PaintChunker m_newPaintChunks; | 313 PaintChunker m_newPaintChunks; |
289 | 314 |
290 // Stores indices into m_newDisplayItemList for display items that have been | 315 // Stores indices into m_newDisplayItemList for display items that have been |
291 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the | 316 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 | 392 |
368 // Number of probable under-invalidations that have been skipped temporarily | 393 // Number of probable under-invalidations that have been skipped temporarily |
369 // because the mismatching display items may be removed in the future because | 394 // because the mismatching display items may be removed in the future because |
370 // of no-op pairs or compositing folding. | 395 // of no-op pairs or compositing folding. |
371 int m_skippedProbableUnderInvalidationCount; | 396 int m_skippedProbableUnderInvalidationCount; |
372 String m_underInvalidationMessagePrefix; | 397 String m_underInvalidationMessagePrefix; |
373 | 398 |
374 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>> | 399 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>> |
375 m_paintChunksRasterInvalidationTrackingMap; | 400 m_paintChunksRasterInvalidationTrackingMap; |
376 | 401 |
377 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 402 typedef HashMap<const DisplayItemClient*, SubsequenceMarkers> |
378 // A stack recording subsequence clients that are currently painting. | 403 CachedSubsequenceMap; |
379 Vector<const DisplayItemClient*> m_currentSubsequenceClients; | 404 CachedSubsequenceMap m_currentCachedSubsequences; |
380 #endif | 405 CachedSubsequenceMap m_newCachedSubsequences; |
406 | |
407 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedSubsequenceSwapOrder); | |
408 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedNestedSubsequenceUpdate); | |
381 }; | 409 }; |
382 | 410 |
383 } // namespace blink | 411 } // namespace blink |
384 | 412 |
385 #endif // PaintController_h | 413 #endif // PaintController_h |
OLD | NEW |