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