| 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 #include "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/graphics/GraphicsLayer.h" | 7 #include "platform/graphics/GraphicsLayer.h" |
| 8 #include "platform/graphics/paint/DrawingDisplayItem.h" | 8 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 9 #include "platform/instrumentation/tracing/TraceEvent.h" | 9 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 10 #include "platform/wtf/AutoReset.h" | 10 #include "platform/wtf/AutoReset.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() && | 93 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() && |
| 94 isCheckingUnderInvalidation()) { | 94 isCheckingUnderInvalidation()) { |
| 95 // We are checking under-invalidation of an ancestor subsequence enclosing | 95 // We are checking under-invalidation of an ancestor subsequence enclosing |
| 96 // this one. The ancestor subsequence is supposed to have already "copied", | 96 // this one. The ancestor subsequence is supposed to have already "copied", |
| 97 // so we should let the client continue to actually paint the descendant | 97 // so we should let the client continue to actually paint the descendant |
| 98 // subsequences without "copying". | 98 // subsequences without "copying". |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 | 101 |
| 102 SubsequenceMarkers* markers = getSubsequenceMarkers(client); | 102 size_t cachedItem = |
| 103 if (!markers) { | 103 findCachedItem(DisplayItem::Id(client, DisplayItem::kSubsequence)); |
| 104 if (cachedItem == kNotFound) { |
| 105 NOTREACHED(); |
| 104 return false; | 106 return false; |
| 105 } | 107 } |
| 106 | 108 |
| 107 // |cachedItem| will point to the first item after the subsequence or end of | 109 // |cachedItem| will point to the first item after the subsequence or end of |
| 108 // the current list. | 110 // the current list. |
| 109 ensureNewDisplayItemListInitialCapacity(); | 111 ensureNewDisplayItemListInitialCapacity(); |
| 112 copyCachedSubsequence(cachedItem); |
| 110 | 113 |
| 111 size_t sizeBeforeCopy = m_newDisplayItemList.size(); | 114 m_nextItemToMatch = cachedItem; |
| 112 copyCachedSubsequence(markers->start, markers->end); | 115 // Items before |cachedItem| have been copied so we don't need to index them. |
| 113 | 116 if (cachedItem > m_nextItemToIndex) |
| 114 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 117 m_nextItemToIndex = cachedItem; |
| 115 addCachedSubsequence(client, sizeBeforeCopy, | |
| 116 m_newDisplayItemList.size() - 1); | |
| 117 } | |
| 118 | |
| 119 m_nextItemToMatch = markers->end + 1; | |
| 120 // Items before |m_nextItemToMatch| have been copied so we don't need to index | |
| 121 // them. | |
| 122 if (m_nextItemToMatch > m_nextItemToIndex) | |
| 123 m_nextItemToIndex = m_nextItemToMatch; | |
| 124 | 118 |
| 125 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 119 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 126 // Return false to let the painter actually paint. We will check if the new | 120 // Return false to let the painter actually paint. We will check if the new |
| 127 // painting is the same as the cached one. | 121 // painting is the same as the cached one. |
| 128 return false; | 122 return false; |
| 129 } | 123 } |
| 130 | 124 |
| 131 return true; | 125 return true; |
| 132 } | 126 } |
| 133 | 127 |
| 134 PaintController::SubsequenceMarkers* PaintController::getSubsequenceMarkers( | |
| 135 const DisplayItemClient& client) { | |
| 136 auto result = m_currentCachedSubsequences.find(&client); | |
| 137 if (result == m_currentCachedSubsequences.end()) | |
| 138 return nullptr; | |
| 139 return &result->value; | |
| 140 } | |
| 141 | |
| 142 void PaintController::addCachedSubsequence(const DisplayItemClient& client, | |
| 143 unsigned start, | |
| 144 unsigned end) { | |
| 145 DCHECK(start <= end); | |
| 146 DCHECK(end < m_newDisplayItemList.size()); | |
| 147 if (isCheckingUnderInvalidation()) { | |
| 148 SubsequenceMarkers* markers = getSubsequenceMarkers(client); | |
| 149 if (!markers) { | |
| 150 showSequenceUnderInvalidationError( | |
| 151 "under-invalidation : unexpected subsequence", client, start, end); | |
| 152 DCHECK(false); | |
| 153 } | |
| 154 if (markers->end - markers->start != end - start) { | |
| 155 showSequenceUnderInvalidationError( | |
| 156 "under-invalidation: new subsequence wrong length", client, start, | |
| 157 end); | |
| 158 DCHECK(false); | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 DCHECK(m_newCachedSubsequences.find(&client) == | |
| 163 m_newCachedSubsequences.end()); | |
| 164 | |
| 165 m_newCachedSubsequences.insert(&client, SubsequenceMarkers(start, end)); | |
| 166 } | |
| 167 | |
| 168 bool PaintController::lastDisplayItemIsNoopBegin() const { | 128 bool PaintController::lastDisplayItemIsNoopBegin() const { |
| 169 if (m_newDisplayItemList.isEmpty()) | 129 if (m_newDisplayItemList.isEmpty()) |
| 170 return false; | 130 return false; |
| 171 | 131 |
| 172 const auto& lastDisplayItem = m_newDisplayItemList.last(); | 132 const auto& lastDisplayItem = m_newDisplayItemList.last(); |
| 173 return lastDisplayItem.isBegin() && !lastDisplayItem.drawsContent(); | 133 return lastDisplayItem.isBegin() && !lastDisplayItem.drawsContent(); |
| 174 } | 134 } |
| 175 | 135 |
| 176 void PaintController::removeLastDisplayItem() { | 136 void PaintController::removeLastDisplayItem() { |
| 177 if (m_newDisplayItemList.isEmpty()) | 137 if (m_newDisplayItemList.isEmpty()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 203 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 163 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 204 m_newPaintChunks.decrementDisplayItemIndex(); | 164 m_newPaintChunks.decrementDisplayItemIndex(); |
| 205 } | 165 } |
| 206 | 166 |
| 207 const DisplayItem* PaintController::lastDisplayItem(unsigned offset) { | 167 const DisplayItem* PaintController::lastDisplayItem(unsigned offset) { |
| 208 if (offset < m_newDisplayItemList.size()) | 168 if (offset < m_newDisplayItemList.size()) |
| 209 return &m_newDisplayItemList[m_newDisplayItemList.size() - offset - 1]; | 169 return &m_newDisplayItemList[m_newDisplayItemList.size() - offset - 1]; |
| 210 return nullptr; | 170 return nullptr; |
| 211 } | 171 } |
| 212 | 172 |
| 213 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | |
| 214 void PaintController::beginShouldKeepAlive(const DisplayItemClient& client) { | |
| 215 if (!isSkippingCache()) { | |
| 216 // Mark the client shouldKeepAlive under this PaintController. | |
| 217 // The status will end after the new display items are committed. | |
| 218 client.beginShouldKeepAlive(this); | |
| 219 | |
| 220 if (!m_currentSubsequenceClients.isEmpty()) { | |
| 221 // Mark the client shouldKeepAlive under the current subsequence. | |
| 222 // The status will end when the subsequence owner is invalidated or | |
| 223 // deleted. | |
| 224 client.beginShouldKeepAlive(m_currentSubsequenceClients.back()); | |
| 225 } | |
| 226 } | |
| 227 } | |
| 228 #endif | |
| 229 | |
| 230 void PaintController::processNewItem(DisplayItem& displayItem) { | 173 void PaintController::processNewItem(DisplayItem& displayItem) { |
| 231 DCHECK(!m_constructionDisabled); | 174 DCHECK(!m_constructionDisabled); |
| 232 | 175 |
| 233 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 176 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 234 if (displayItem.isCacheable()) { | 177 if (!isSkippingCache()) { |
| 235 beginShouldKeepAlive(displayItem.client()); | 178 if (displayItem.isCacheable()) { |
| 179 // Mark the client shouldKeepAlive under this PaintController. |
| 180 // The status will end after the new display items are committed. |
| 181 displayItem.client().beginShouldKeepAlive(this); |
| 182 |
| 183 if (!m_currentSubsequenceClients.isEmpty()) { |
| 184 // Mark the client shouldKeepAlive under the current subsequence. |
| 185 // The status will end when the subsequence owner is invalidated or |
| 186 // deleted. |
| 187 displayItem.client().beginShouldKeepAlive( |
| 188 m_currentSubsequenceClients.back()); |
| 189 } |
| 190 } |
| 191 |
| 192 if (displayItem.getType() == DisplayItem::kSubsequence) { |
| 193 m_currentSubsequenceClients.push_back(&displayItem.client()); |
| 194 } else if (displayItem.getType() == DisplayItem::kEndSubsequence) { |
| 195 CHECK(m_currentSubsequenceClients.back() == &displayItem.client()); |
| 196 m_currentSubsequenceClients.pop_back(); |
| 197 } |
| 236 } | 198 } |
| 237 #endif | 199 #endif |
| 238 | 200 |
| 239 if (isSkippingCache()) | 201 if (isSkippingCache()) |
| 240 displayItem.setSkippedCache(); | 202 displayItem.setSkippedCache(); |
| 241 | 203 |
| 242 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 204 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 243 size_t lastChunkIndex = m_newPaintChunks.lastChunkIndex(); | 205 size_t lastChunkIndex = m_newPaintChunks.lastChunkIndex(); |
| 244 if (m_newPaintChunks.incrementDisplayItemIndex(displayItem)) { | 206 if (m_newPaintChunks.incrementDisplayItemIndex(displayItem)) { |
| 245 DCHECK(lastChunkIndex != m_newPaintChunks.lastChunkIndex()); | 207 DCHECK(lastChunkIndex != m_newPaintChunks.lastChunkIndex()); |
| 246 if (lastChunkIndex != kNotFound) | 208 if (lastChunkIndex != kNotFound) |
| 247 generateChunkRasterInvalidationRects( | 209 generateChunkRasterInvalidationRects( |
| 248 m_newPaintChunks.paintChunkAt(lastChunkIndex)); | 210 m_newPaintChunks.paintChunkAt(lastChunkIndex)); |
| 249 } | 211 } |
| 250 } | 212 } |
| 251 | 213 |
| 252 #if DCHECK_IS_ON() | 214 #if DCHECK_IS_ON() |
| 253 // Verify noop begin/end pairs have been removed. | 215 // Verify noop begin/end pairs have been removed. |
| 254 if (m_newDisplayItemList.size() >= 2 && displayItem.isEnd()) { | 216 if (m_newDisplayItemList.size() >= 2 && displayItem.isEnd()) { |
| 255 const auto& beginDisplayItem = | 217 const auto& beginDisplayItem = |
| 256 m_newDisplayItemList[m_newDisplayItemList.size() - 2]; | 218 m_newDisplayItemList[m_newDisplayItemList.size() - 2]; |
| 257 if (beginDisplayItem.isBegin() && | 219 if (beginDisplayItem.isBegin() && |
| 220 beginDisplayItem.getType() != DisplayItem::kSubsequence && |
| 258 !beginDisplayItem.drawsContent()) | 221 !beginDisplayItem.drawsContent()) |
| 259 DCHECK(!displayItem.isEndAndPairedWith(beginDisplayItem.getType())); | 222 DCHECK(!displayItem.isEndAndPairedWith(beginDisplayItem.getType())); |
| 260 } | 223 } |
| 261 | 224 |
| 262 size_t index = findMatchingItemFromIndex(displayItem.getId(), | 225 size_t index = findMatchingItemFromIndex(displayItem.getId(), |
| 263 m_newDisplayItemIndicesByClient, | 226 m_newDisplayItemIndicesByClient, |
| 264 m_newDisplayItemList); | 227 m_newDisplayItemList); |
| 265 if (index != kNotFound) { | 228 if (index != kNotFound) { |
| 266 #ifndef NDEBUG | 229 #ifndef NDEBUG |
| 267 showDebugData(); | 230 showDebugData(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) | 386 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
| 424 CHECK(false) << "Can't find cached display item"; | 387 CHECK(false) << "Can't find cached display item"; |
| 425 | 388 |
| 426 // We did not find the cached display item. This should be impossible, but may | 389 // We did not find the cached display item. This should be impossible, but may |
| 427 // occur if there is a bug in the system, such as under-invalidation, | 390 // occur if there is a bug in the system, such as under-invalidation, |
| 428 // incorrect cache checking or duplicate display ids. In this case, the caller | 391 // incorrect cache checking or duplicate display ids. In this case, the caller |
| 429 // should fall back to repaint the display item. | 392 // should fall back to repaint the display item. |
| 430 return kNotFound; | 393 return kNotFound; |
| 431 } | 394 } |
| 432 | 395 |
| 433 // Copies a cached subsequence from current list to the new list. | 396 // Copies a cached subsequence from current list to the new list. On return, |
| 434 // When paintUnderInvaldiationCheckingEnabled() we'll not actually | 397 // |cachedItemIndex| points to the item after the EndSubsequence item of the |
| 398 // subsequence. When paintUnderInvaldiationCheckingEnabled() we'll not actually |
| 435 // copy the subsequence, but mark the begin and end of the subsequence for | 399 // copy the subsequence, but mark the begin and end of the subsequence for |
| 436 // under-invalidation checking. | 400 // under-invalidation checking. |
| 437 void PaintController::copyCachedSubsequence(size_t beginIndex, | 401 void PaintController::copyCachedSubsequence(size_t& cachedItemIndex) { |
| 438 size_t endIndex) { | |
| 439 AutoReset<size_t> subsequenceBeginIndex( | 402 AutoReset<size_t> subsequenceBeginIndex( |
| 440 &m_currentCachedSubsequenceBeginIndexInNewList, | 403 &m_currentCachedSubsequenceBeginIndexInNewList, |
| 441 m_newDisplayItemList.size()); | 404 m_newDisplayItemList.size()); |
| 442 DisplayItem* cachedItem = | 405 DisplayItem* cachedItem = |
| 443 &m_currentPaintArtifact.getDisplayItemList()[beginIndex]; | 406 &m_currentPaintArtifact.getDisplayItemList()[cachedItemIndex]; |
| 407 DCHECK(cachedItem->getType() == DisplayItem::kSubsequence); |
| 444 | 408 |
| 445 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 409 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 446 DCHECK(!isCheckingUnderInvalidation()); | 410 DCHECK(!isCheckingUnderInvalidation()); |
| 447 m_underInvalidationCheckingBegin = beginIndex; | 411 m_underInvalidationCheckingBegin = cachedItemIndex; |
| 448 m_underInvalidationMessagePrefix = | 412 m_underInvalidationMessagePrefix = |
| 449 "(In cached subsequence of " + cachedItem->client().debugName() + ")"; | 413 "(In cached subsequence of " + cachedItem->client().debugName() + ")"; |
| 450 } | 414 } |
| 451 | 415 |
| 416 DisplayItem::Id endSubsequenceId(cachedItem->client(), |
| 417 DisplayItem::kEndSubsequence); |
| 452 Vector<PaintChunk>::const_iterator cachedChunk; | 418 Vector<PaintChunk>::const_iterator cachedChunk; |
| 453 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 419 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 454 cachedChunk = | 420 cachedChunk = |
| 455 m_currentPaintArtifact.findChunkByDisplayItemIndex(beginIndex); | 421 m_currentPaintArtifact.findChunkByDisplayItemIndex(cachedItemIndex); |
| 456 DCHECK(cachedChunk != m_currentPaintArtifact.paintChunks().end()); | 422 DCHECK(cachedChunk != m_currentPaintArtifact.paintChunks().end()); |
| 457 updateCurrentPaintChunkProperties( | 423 updateCurrentPaintChunkProperties( |
| 458 cachedChunk->id ? &*cachedChunk->id : nullptr, cachedChunk->properties); | 424 cachedChunk->id ? &*cachedChunk->id : nullptr, cachedChunk->properties); |
| 459 } else { | 425 } else { |
| 460 // Avoid uninitialized variable error on Windows. | 426 // Avoid uninitialized variable error on Windows. |
| 461 cachedChunk = m_currentPaintArtifact.paintChunks().begin(); | 427 cachedChunk = m_currentPaintArtifact.paintChunks().begin(); |
| 462 } | 428 } |
| 463 | 429 |
| 464 for (size_t currentIndex = beginIndex; currentIndex <= endIndex; | 430 while (true) { |
| 465 ++currentIndex) { | |
| 466 cachedItem = &m_currentPaintArtifact.getDisplayItemList()[currentIndex]; | |
| 467 DCHECK(cachedItem->hasValidClient()); | 431 DCHECK(cachedItem->hasValidClient()); |
| 468 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 432 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 469 CHECK(cachedItem->client().isAlive()); | 433 CHECK(cachedItem->client().isAlive()); |
| 470 #endif | 434 #endif |
| 471 ++m_numCachedNewItems; | 435 ++m_numCachedNewItems; |
| 436 bool metEndSubsequence = cachedItem->getId() == endSubsequenceId; |
| 472 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 437 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 473 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 438 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 474 currentIndex == cachedChunk->endIndex) { | 439 cachedItemIndex == cachedChunk->endIndex) { |
| 475 ++cachedChunk; | 440 ++cachedChunk; |
| 476 DCHECK(cachedChunk != m_currentPaintArtifact.paintChunks().end()); | 441 DCHECK(cachedChunk != m_currentPaintArtifact.paintChunks().end()); |
| 477 updateCurrentPaintChunkProperties( | 442 updateCurrentPaintChunkProperties( |
| 478 cachedChunk->id ? &*cachedChunk->id : nullptr, | 443 cachedChunk->id ? &*cachedChunk->id : nullptr, |
| 479 cachedChunk->properties); | 444 cachedChunk->properties); |
| 480 } | 445 } |
| 481 processNewItem(moveItemFromCurrentListToNewList(currentIndex)); | 446 processNewItem(moveItemFromCurrentListToNewList(cachedItemIndex)); |
| 482 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 447 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 483 DCHECK((!m_newPaintChunks.lastChunk().id && !cachedChunk->id) || | 448 DCHECK((!m_newPaintChunks.lastChunk().id && !cachedChunk->id) || |
| 484 m_newPaintChunks.lastChunk().matches(*cachedChunk)); | 449 m_newPaintChunks.lastChunk().matches(*cachedChunk)); |
| 485 } | 450 } |
| 451 |
| 452 ++cachedItemIndex; |
| 453 if (metEndSubsequence) |
| 454 break; |
| 455 |
| 456 // We should always be able to find the EndSubsequence display item. |
| 457 DCHECK(cachedItemIndex < |
| 458 m_currentPaintArtifact.getDisplayItemList().size()); |
| 459 cachedItem = &m_currentPaintArtifact.getDisplayItemList()[cachedItemIndex]; |
| 486 } | 460 } |
| 487 | 461 |
| 488 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 462 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 489 m_underInvalidationCheckingEnd = endIndex + 1; | 463 m_underInvalidationCheckingEnd = cachedItemIndex; |
| 490 DCHECK(isCheckingUnderInvalidation()); | 464 DCHECK(isCheckingUnderInvalidation()); |
| 491 } | 465 } |
| 492 } | 466 } |
| 493 | 467 |
| 494 DISABLE_CFI_PERF | 468 DISABLE_CFI_PERF |
| 495 static IntRect visualRectForDisplayItem( | 469 static IntRect visualRectForDisplayItem( |
| 496 const DisplayItem& displayItem, | 470 const DisplayItem& displayItem, |
| 497 const LayoutSize& offsetFromLayoutObject) { | 471 const LayoutSize& offsetFromLayoutObject) { |
| 498 LayoutRect visualRect = displayItem.client().visualRect(); | 472 LayoutRect visualRect = displayItem.client().visualRect(); |
| 499 visualRect.move(-offsetFromLayoutObject); | 473 visualRect.move(-offsetFromLayoutObject); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 511 | 485 |
| 512 DISABLE_CFI_PERF | 486 DISABLE_CFI_PERF |
| 513 void PaintController::commitNewDisplayItems( | 487 void PaintController::commitNewDisplayItems( |
| 514 const LayoutSize& offsetFromLayoutObject) { | 488 const LayoutSize& offsetFromLayoutObject) { |
| 515 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", | 489 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", |
| 516 "current_display_list_size", | 490 "current_display_list_size", |
| 517 (int)m_currentPaintArtifact.getDisplayItemList().size(), | 491 (int)m_currentPaintArtifact.getDisplayItemList().size(), |
| 518 "num_non_cached_new_items", | 492 "num_non_cached_new_items", |
| 519 (int)m_newDisplayItemList.size() - m_numCachedNewItems); | 493 (int)m_newDisplayItemList.size() - m_numCachedNewItems); |
| 520 m_numCachedNewItems = 0; | 494 m_numCachedNewItems = 0; |
| 495 |
| 521 // These data structures are used during painting only. | 496 // These data structures are used during painting only. |
| 522 DCHECK(!isSkippingCache()); | 497 DCHECK(!isSkippingCache()); |
| 523 #if DCHECK_IS_ON() | 498 #if DCHECK_IS_ON() |
| 524 m_newDisplayItemIndicesByClient.clear(); | 499 m_newDisplayItemIndicesByClient.clear(); |
| 525 #endif | 500 #endif |
| 526 | 501 |
| 527 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 502 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 528 !m_newDisplayItemList.isEmpty()) | 503 !m_newDisplayItemList.isEmpty()) |
| 529 generateChunkRasterInvalidationRects(m_newPaintChunks.lastChunk()); | 504 generateChunkRasterInvalidationRects(m_newPaintChunks.lastChunk()); |
| 530 | 505 |
| 531 SkPictureGpuAnalyzer gpuAnalyzer; | 506 SkPictureGpuAnalyzer gpuAnalyzer; |
| 532 | 507 |
| 533 m_currentCacheGeneration = | 508 m_currentCacheGeneration = |
| 534 DisplayItemClient::CacheGenerationOrInvalidationReason::next(); | 509 DisplayItemClient::CacheGenerationOrInvalidationReason::next(); |
| 535 | |
| 536 m_newCachedSubsequences.swap(m_currentCachedSubsequences); | |
| 537 m_newCachedSubsequences.clear(); | |
| 538 for (auto& item : m_currentCachedSubsequences) { | |
| 539 item.key->setDisplayItemsCached(m_currentCacheGeneration); | |
| 540 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | |
| 541 DisplayItemClient::endShouldKeepAliveAllClients(item.key); | |
| 542 #endif | |
| 543 } | |
| 544 | |
| 545 Vector<const DisplayItemClient*> skippedCacheClients; | 510 Vector<const DisplayItemClient*> skippedCacheClients; |
| 546 for (const auto& item : m_newDisplayItemList) { | 511 for (const auto& item : m_newDisplayItemList) { |
| 547 // No reason to continue the analysis once we have a veto. | 512 // No reason to continue the analysis once we have a veto. |
| 548 if (gpuAnalyzer.suitableForGpuRasterization()) | 513 if (gpuAnalyzer.suitableForGpuRasterization()) |
| 549 item.analyzeForGpuRasterization(gpuAnalyzer); | 514 item.analyzeForGpuRasterization(gpuAnalyzer); |
| 550 | 515 |
| 551 // TODO(wkorman): Only compute and append visual rect for drawings. | 516 // TODO(wkorman): Only compute and append visual rect for drawings. |
| 552 m_newDisplayItemList.appendVisualRect( | 517 m_newDisplayItemList.appendVisualRect( |
| 553 visualRectForDisplayItem(item, offsetFromLayoutObject)); | 518 visualRectForDisplayItem(item, offsetFromLayoutObject)); |
| 554 | 519 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 for (const auto& chunk : m_currentPaintArtifact.paintChunks()) { | 559 for (const auto& chunk : m_currentPaintArtifact.paintChunks()) { |
| 595 if (chunk.id && chunk.id->client.isJustCreated()) | 560 if (chunk.id && chunk.id->client.isJustCreated()) |
| 596 chunk.id->client.clearIsJustCreated(); | 561 chunk.id->client.clearIsJustCreated(); |
| 597 } | 562 } |
| 598 } | 563 } |
| 599 | 564 |
| 600 // We'll allocate the initial buffer when we start the next paint. | 565 // We'll allocate the initial buffer when we start the next paint. |
| 601 m_newDisplayItemList = DisplayItemList(0); | 566 m_newDisplayItemList = DisplayItemList(0); |
| 602 | 567 |
| 603 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 568 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 569 CHECK(m_currentSubsequenceClients.isEmpty()); |
| 604 DisplayItemClient::endShouldKeepAliveAllClients(this); | 570 DisplayItemClient::endShouldKeepAliveAllClients(this); |
| 605 #endif | 571 #endif |
| 606 | 572 |
| 607 #ifndef NDEBUG | 573 #ifndef NDEBUG |
| 608 m_numSequentialMatches = 0; | 574 m_numSequentialMatches = 0; |
| 609 m_numOutOfOrderMatches = 0; | 575 m_numOutOfOrderMatches = 0; |
| 610 m_numIndexedItems = 0; | 576 m_numIndexedItems = 0; |
| 611 #endif | 577 #endif |
| 612 } | 578 } |
| 613 | 579 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 778 } |
| 813 LOG(INFO) << "new record:\n" | 779 LOG(INFO) << "new record:\n" |
| 814 << (newRecord ? recordAsDebugString(newRecord) : "None"); | 780 << (newRecord ? recordAsDebugString(newRecord) : "None"); |
| 815 LOG(INFO) << "old record:\n" | 781 LOG(INFO) << "old record:\n" |
| 816 << (oldRecord ? recordAsDebugString(oldRecord) : "None"); | 782 << (oldRecord ? recordAsDebugString(oldRecord) : "None"); |
| 817 | 783 |
| 818 showDebugData(); | 784 showDebugData(); |
| 819 #endif // NDEBUG | 785 #endif // NDEBUG |
| 820 } | 786 } |
| 821 | 787 |
| 822 void PaintController::showSequenceUnderInvalidationError( | |
| 823 const char* reason, | |
| 824 const DisplayItemClient& client, | |
| 825 int start, | |
| 826 int end) { | |
| 827 LOG(ERROR) << m_underInvalidationMessagePrefix << " " << reason; | |
| 828 LOG(ERROR) << "Subsequence client: " << client.debugName(); | |
| 829 #ifndef NDEBUG | |
| 830 // showDebugData(); | |
| 831 #else | |
| 832 LOG(ERROR) << "Run debug build to get more details."; | |
| 833 #endif | |
| 834 LOG(ERROR) << "See http://crbug.com/619103."; | |
| 835 } | |
| 836 | |
| 837 void PaintController::checkUnderInvalidation() { | 788 void PaintController::checkUnderInvalidation() { |
| 838 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()); | 789 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()); |
| 839 | 790 |
| 840 if (!isCheckingUnderInvalidation()) | 791 if (!isCheckingUnderInvalidation()) |
| 841 return; | 792 return; |
| 842 | 793 |
| 843 const DisplayItem& newItem = m_newDisplayItemList.last(); | 794 const DisplayItem& newItem = m_newDisplayItemList.last(); |
| 844 size_t oldItemIndex = m_underInvalidationCheckingBegin + | 795 size_t oldItemIndex = m_underInvalidationCheckingBegin + |
| 845 m_skippedProbableUnderInvalidationCount; | 796 m_skippedProbableUnderInvalidationCount; |
| 846 DisplayItem* oldItem = | 797 DisplayItem* oldItem = |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 showPaintRecords | 863 showPaintRecords |
| 913 ? (DisplayItemList::JsonOptions::ShowPaintRecords | | 864 ? (DisplayItemList::JsonOptions::ShowPaintRecords | |
| 914 DisplayItemList::JsonOptions::ShowClientDebugName) | 865 DisplayItemList::JsonOptions::ShowClientDebugName) |
| 915 : DisplayItemList::JsonOptions::ShowClientDebugName) | 866 : DisplayItemList::JsonOptions::ShowClientDebugName) |
| 916 ->toPrettyJSONString() | 867 ->toPrettyJSONString() |
| 917 .utf8() | 868 .utf8() |
| 918 .data()); | 869 .data()); |
| 919 } | 870 } |
| 920 | 871 |
| 921 } // namespace blink | 872 } // namespace blink |
| OLD | NEW |