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 #include "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/TraceEvent.h" | 7 #include "platform/TraceEvent.h" |
| 8 #include "platform/graphics/GraphicsLayer.h" | 8 #include "platform/graphics/GraphicsLayer.h" |
| 9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 9 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" | 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 updatedList.appendByMoving(*newIt, visualRectForDisplayItem(*newIt, offsetFromLayoutObject), gpuAnalyzer); | 358 updatedList.appendByMoving(*newIt, visualRectForDisplayItem(*newIt, offsetFromLayoutObject), gpuAnalyzer); |
| 359 | 359 |
| 360 if (isSynchronized) | 360 if (isSynchronized) |
| 361 ++currentIt; | 361 ++currentIt; |
| 362 } | 362 } |
| 363 // Items before currentIt should have been copied so we don't need to in dex them. | 363 // Items before currentIt should have been copied so we don't need to in dex them. |
| 364 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) | 364 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) |
| 365 outOfOrderIndexContext.nextItemToIndex = currentIt; | 365 outOfOrderIndexContext.nextItemToIndex = currentIt; |
| 366 } | 366 } |
| 367 | 367 |
| 368 #if DCHECK_IS_ON() | |
| 369 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) | |
| 370 checkNoRemainingCachedDisplayItems(); | |
| 371 #endif | |
|
Xianzhu
2016/06/09 22:56:02
This is removed because it doesn't apply to the ne
| |
| 372 | |
| 373 // TODO(jbroman): When subsequence caching applies to SPv2, we'll need to | 368 // TODO(jbroman): When subsequence caching applies to SPv2, we'll need to |
| 374 // merge the paint chunks as well. | 369 // merge the paint chunks as well. |
| 375 m_currentPaintArtifact = PaintArtifact(std::move(updatedList), m_newPaintChu nks.releasePaintChunks(), gpuAnalyzer.suitableForGpuRasterization()); | 370 m_currentPaintArtifact = PaintArtifact(std::move(updatedList), m_newPaintChu nks.releasePaintChunks(), gpuAnalyzer.suitableForGpuRasterization()); |
| 376 | 371 |
| 377 m_newDisplayItemList = DisplayItemList(kInitialDisplayItemListCapacityBytes) ; | 372 m_newDisplayItemList = DisplayItemList(kInitialDisplayItemListCapacityBytes) ; |
| 378 updateCacheGeneration(); | 373 updateCacheGeneration(); |
| 379 } | 374 } |
| 380 | 375 |
| 381 size_t PaintController::approximateUnsharedMemoryUsage() const | 376 size_t PaintController::approximateUnsharedMemoryUsage() const |
| 382 { | 377 { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 409 for (const DisplayItem& displayItem : m_currentPaintArtifact.getDisplayItemL ist()) { | 404 for (const DisplayItem& displayItem : m_currentPaintArtifact.getDisplayItemL ist()) { |
| 410 if (!displayItem.isCacheable()) | 405 if (!displayItem.isCacheable()) |
| 411 continue; | 406 continue; |
| 412 displayItem.client().setDisplayItemsCached(m_currentCacheGeneration); | 407 displayItem.client().setDisplayItemsCached(m_currentCacheGeneration); |
| 413 } | 408 } |
| 414 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 409 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 415 DisplayItemClient::endShouldKeepAliveAllClients(this); | 410 DisplayItemClient::endShouldKeepAliveAllClients(this); |
| 416 #endif | 411 #endif |
| 417 } | 412 } |
| 418 | 413 |
| 414 void PaintController::appendDebugDrawingAfterCommit(const DisplayItemClient& dis playItemClient, PassRefPtr<SkPicture> picture, const LayoutSize& offsetFromLayou tObject) | |
| 415 { | |
| 416 DCHECK(m_newDisplayItemList.isEmpty()); | |
| 417 DrawingDisplayItem& displayItem = m_currentPaintArtifact.getDisplayItemList( ).allocateAndConstruct<DrawingDisplayItem>(displayItemClient, DisplayItem::Debug Drawing, picture); | |
| 418 displayItem.setSkippedCache(); | |
| 419 m_currentPaintArtifact.getDisplayItemList().appendVisualRect(visualRectForDi splayItem(displayItem, offsetFromLayoutObject)); | |
| 420 } | |
| 421 | |
| 419 #if DCHECK_IS_ON() | 422 #if DCHECK_IS_ON() |
| 420 | 423 |
| 421 void PaintController::checkUnderInvalidation(DisplayItemList::iterator& newIt, D isplayItemList::iterator& currentIt) | 424 void PaintController::checkUnderInvalidation(DisplayItemList::iterator& newIt, D isplayItemList::iterator& currentIt) |
| 422 { | 425 { |
| 423 DCHECK(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled ()); | 426 DCHECK(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled ()); |
| 424 DCHECK(newIt->isCached()); | 427 DCHECK(newIt->isCached()); |
| 425 | 428 |
| 426 // When under-invalidation-checking is enabled, the forced painting is follo wing the cached display item. | 429 // When under-invalidation-checking is enabled, the forced painting is follo wing the cached display item. |
| 427 DisplayItem::Type nextItemType = DisplayItem::nonCachedType(newIt->getType() ); | 430 DisplayItem::Type nextItemType = DisplayItem::nonCachedType(newIt->getType() ); |
| 428 ++newIt; | 431 ++newIt; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 String oldPictureDebugString = oldPicture ? pictureAsDebugString(oldPict ure.get()) : "None"; | 499 String oldPictureDebugString = oldPicture ? pictureAsDebugString(oldPict ure.get()) : "None"; |
| 497 String newPictureDebugString = newPicture ? pictureAsDebugString(newPict ure.get()) : "None"; | 500 String newPictureDebugString = newPicture ? pictureAsDebugString(newPict ure.get()) : "None"; |
| 498 WTFLogAlways("old picture:\n%s\n", oldPictureDebugString.utf8().data()); | 501 WTFLogAlways("old picture:\n%s\n", oldPictureDebugString.utf8().data()); |
| 499 WTFLogAlways("new picture:\n%s\n", newPictureDebugString.utf8().data()); | 502 WTFLogAlways("new picture:\n%s\n", newPictureDebugString.utf8().data()); |
| 500 } | 503 } |
| 501 #endif // NDEBUG | 504 #endif // NDEBUG |
| 502 | 505 |
| 503 NOTREACHED(); | 506 NOTREACHED(); |
| 504 } | 507 } |
| 505 | 508 |
| 506 void PaintController::checkNoRemainingCachedDisplayItems() | |
| 507 { | |
| 508 DCHECK(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled ()); | |
| 509 | |
| 510 for (const auto& displayItem : m_currentPaintArtifact.getDisplayItemList()) { | |
| 511 if (!displayItem.hasValidClient() || !displayItem.isCacheable() || !clie ntCacheIsValid(displayItem.client())) | |
| 512 continue; | |
| 513 showUnderInvalidationError("", "May be under-invalidation: no new displa y item", nullptr, &displayItem); | |
| 514 } | |
| 515 } | |
| 516 | |
| 517 #endif // DCHECK_IS_ON() | 509 #endif // DCHECK_IS_ON() |
| 518 | 510 |
| 519 #ifndef NDEBUG | 511 #ifndef NDEBUG |
| 520 | 512 |
| 521 WTF::String PaintController::displayItemListAsDebugString(const DisplayItemList& list) const | 513 WTF::String PaintController::displayItemListAsDebugString(const DisplayItemList& list) const |
| 522 { | 514 { |
| 523 StringBuilder stringBuilder; | 515 StringBuilder stringBuilder; |
| 524 size_t i = 0; | 516 size_t i = 0; |
| 525 for (auto it = list.begin(); it != list.end(); ++it, ++i) { | 517 for (auto it = list.begin(); it != list.end(); ++it, ++i) { |
| 526 const DisplayItem& displayItem = *it; | 518 const DisplayItem& displayItem = *it; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 539 | 531 |
| 540 void PaintController::showDebugData() const | 532 void PaintController::showDebugData() const |
| 541 { | 533 { |
| 542 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); | 534 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); |
| 543 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); | 535 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); |
| 544 } | 536 } |
| 545 | 537 |
| 546 #endif // ifndef NDEBUG | 538 #endif // ifndef NDEBUG |
| 547 | 539 |
| 548 } // namespace blink | 540 } // namespace blink |
| OLD | NEW |