| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/DisplayItemList.h" | 5 #include "platform/graphics/paint/DisplayItemList.h" |
| 6 | 6 |
| 7 #include "platform/graphics/paint/PaintChunk.h" | 7 #include "platform/graphics/paint/PaintChunk.h" |
| 8 | 8 |
| 9 #ifndef NDEBUG |
| 10 #include "wtf/text/WTFString.h" |
| 11 #endif |
| 12 |
| 9 namespace blink { | 13 namespace blink { |
| 10 | 14 |
| 15 DisplayItem& DisplayItemList::appendByMoving(DisplayItem& item, const IntRect& v
isualRect) |
| 16 { |
| 17 #ifndef NDEBUG |
| 18 String originalDebugString = item.asDebugString(); |
| 19 #endif |
| 20 ASSERT(item.hasValidClient()); |
| 21 DisplayItem& result = ContiguousContainer::appendByMoving(item, item.derived
Size()); |
| 22 // ContiguousContainer::appendByMoving() calls an in-place constructor |
| 23 // on item which replaces it with a tombstone/"dead display item" that |
| 24 // can be safely destructed but should never be used. |
| 25 ASSERT(!item.hasValidClient()); |
| 26 #ifndef NDEBUG |
| 27 // Save original debug string in the old item to help debugging. |
| 28 item.setClientDebugString(originalDebugString); |
| 29 #endif |
| 30 appendVisualRect(visualRect); |
| 31 return result; |
| 32 } |
| 33 |
| 34 #if ENABLE(ASSERT) |
| 35 void DisplayItemList::assertDisplayItemClientsAreAlive() const |
| 36 { |
| 37 for (auto& item : *this) { |
| 38 #ifdef NDEBUG |
| 39 DCHECK(DisplayItemClient::isAlive(item.client())) << "Short-lived Displa
yItemClient. See crbug.com/570030."; |
| 40 #else |
| 41 DCHECK(DisplayItemClient::isAlive(item.client())) << "Short-lived Displa
yItemClient: " << item.clientDebugString() << ". See crbug.com/570030."; |
| 42 #endif |
| 43 } |
| 44 } |
| 45 #endif |
| 46 |
| 11 void DisplayItemList::appendVisualRect(const IntRect& visualRect) | 47 void DisplayItemList::appendVisualRect(const IntRect& visualRect) |
| 12 { | 48 { |
| 13 size_t itemIndex = m_visualRects.size(); | 49 size_t itemIndex = m_visualRects.size(); |
| 14 const DisplayItem& item = (*this)[itemIndex]; | 50 const DisplayItem& item = (*this)[itemIndex]; |
| 15 | 51 |
| 16 // For paired display items such as transforms, since we are not guaranteed
containment, the | 52 // For paired display items such as transforms, since we are not guaranteed
containment, the |
| 17 // visual rect must comprise the union of the visual rects for all items wit
hin its block. | 53 // visual rect must comprise the union of the visual rects for all items wit
hin its block. |
| 18 | 54 |
| 19 if (item.isBegin()) { | 55 if (item.isBegin()) { |
| 20 m_visualRects.append(visualRect); | 56 m_visualRects.append(visualRect); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 48 return Range<iterator>(begin() + paintChunk.beginIndex, begin() + paintChunk
.endIndex); | 84 return Range<iterator>(begin() + paintChunk.beginIndex, begin() + paintChunk
.endIndex); |
| 49 } | 85 } |
| 50 | 86 |
| 51 DisplayItemList::Range<DisplayItemList::const_iterator> | 87 DisplayItemList::Range<DisplayItemList::const_iterator> |
| 52 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const | 88 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const |
| 53 { | 89 { |
| 54 return Range<const_iterator>(begin() + paintChunk.beginIndex, begin() + pain
tChunk.endIndex); | 90 return Range<const_iterator>(begin() + paintChunk.beginIndex, begin() + pain
tChunk.endIndex); |
| 55 } | 91 } |
| 56 | 92 |
| 57 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |