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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
| 7 | 7 |
| 8 #include "platform/NotImplemented.h" | 8 #include "platform/NotImplemented.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/TraceEvent.h" | 10 #include "platform/TraceEvent.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 const DisplayItems& DisplayItemList::displayItems() const | 28 const DisplayItems& DisplayItemList::displayItems() const |
| 29 { | 29 { |
| 30 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 30 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 31 ASSERT(m_newDisplayItems.isEmpty()); | 31 ASSERT(m_newDisplayItems.isEmpty()); |
| 32 return m_currentDisplayItems; | 32 return m_currentDisplayItems; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void DisplayItemList::add(WTF::PassOwnPtr<DisplayItem> displayItem) | 35 void DisplayItemList::processNewItem(DisplayItem& addedDisplayItem) |
| 36 { | 36 { |
| 37 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 37 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 38 ASSERT(!m_constructionDisabled); | 38 ASSERT(!m_constructionDisabled); |
| 39 ASSERT(!skippingCache() || !displayItem->isCached()); | 39 ASSERT(!skippingCache() || !addedDisplayItem.isCached()); |
| 40 | 40 |
| 41 if (displayItem->isEnd()) { | 41 if (addedDisplayItem.isEnd()) { |
| 42 ASSERT(!m_newDisplayItems.isEmpty()); | 42 ASSERT(m_newDisplayItems.size() >= 2); |
| 43 if (m_newDisplayItems.last().isBegin() && !m_newDisplayItems.last().draw sContent()) { | 43 DisplayItems::ItemHandle previousDisplayItem = m_newDisplayItems[m_newDi splayItems.size() - 2]; |
| 44 ASSERT(displayItem->isEndAndPairedWith(m_newDisplayItems.last().type ())); | 44 if (previousDisplayItem.isBegin() && !previousDisplayItem.drawsContent() ) { |
| 45 // Remove the beginning display item of this empty pair. | |
| 46 m_newDisplayItems.removeLast(); | |
| 47 #if ENABLE(ASSERT) | 45 #if ENABLE(ASSERT) |
| 48 // Also remove the index pointing to the removed display item. | 46 ASSERT(addedDisplayItem.isEndAndPairedWith(previousDisplayItem.type( ))); |
| 49 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndices ByClient.find(displayItem->client()); | 47 // Remove the index pointing to the begin display item. |
| 48 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndices ByClient.find(previousDisplayItem.client()); | |
| 50 if (it != m_newDisplayItemIndicesByClient.end()) { | 49 if (it != m_newDisplayItemIndicesByClient.end()) { |
| 51 Vector<size_t>& indices = it->value; | 50 Vector<size_t>& indices = it->value; |
| 52 if (!indices.isEmpty() && indices.last() == m_newDisplayItems.si ze()) | 51 if (!indices.isEmpty() && indices.last() == m_newDisplayItems.si ze() - 1) |
| 53 indices.removeLast(); | 52 indices.removeLast(); |
| 54 } | 53 } |
| 55 #endif | 54 #endif |
| 55 // Remove the no-op pair. | |
| 56 m_newDisplayItems.removeLast(); | |
| 57 m_newDisplayItems.removeLast(); | |
| 56 return; | 58 return; |
| 57 } | 59 } |
| 58 } | 60 } |
| 59 | 61 |
| 60 if (!m_scopeStack.isEmpty()) | 62 if (!m_scopeStack.isEmpty()) |
| 61 displayItem->setScope(m_scopeStack.last().id, m_scopeStack.last().client ); | 63 addedDisplayItem.setScope(m_scopeStack.last().id, m_scopeStack.last().cl ient); |
| 62 | 64 |
| 63 #if ENABLE(ASSERT) | 65 #if ENABLE(ASSERT) |
| 64 size_t index = findMatchingItemFromIndex(displayItem->id(), displayItem->typ e(), m_newDisplayItemIndicesByClient, m_newDisplayItems); | 66 addItemToIndex(addedDisplayItem.client(), addedDisplayItem.type(), m_newDisp layItems.size() - 1, m_newDisplayItemIndicesByClient); |
| 65 if (index != kNotFound) { | |
| 66 #ifndef NDEBUG | |
| 67 showDebugData(); | |
| 68 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n", | |
| 69 displayItem->asDebugString().utf8().data(), m_newDisplayItems[index] .asDebugString().utf8().data(), static_cast<int>(index)); | |
| 70 #endif | 67 #endif |
| 71 ASSERT_NOT_REACHED(); | |
|
Xianzhu
2015/06/19 16:19:11
Is the above code moved elsewhere or removed?
| |
| 72 } | |
| 73 addItemToIndex(displayItem->client(), displayItem->type(), m_newDisplayItems .size(), m_newDisplayItemIndicesByClient); | |
| 74 #endif // ENABLE(ASSERT) | |
| 75 | 68 |
| 76 ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the fl ag. | 69 ASSERT(!addedDisplayItem.skippedCache()); // Only DisplayItemList can set th e flag. |
| 77 if (skippingCache()) | 70 if (skippingCache()) |
| 78 displayItem->setSkippedCache(); | 71 addedDisplayItem.setSkippedCache(); |
| 79 | |
| 80 m_newDisplayItems.append(displayItem); | |
| 81 } | 72 } |
| 82 | 73 |
| 83 void DisplayItemList::beginScope(DisplayItemClient client) | 74 void DisplayItemList::beginScope(DisplayItemClient client) |
| 84 { | 75 { |
| 85 ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); | 76 ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); |
| 86 int scopeId; | 77 int scopeId; |
| 87 if (it == m_clientScopeIdMap.end()) { | 78 if (it == m_clientScopeIdMap.end()) { |
| 88 m_clientScopeIdMap.add(client, 0); | 79 m_clientScopeIdMap.add(client, 0); |
| 89 scopeId = 0; | 80 scopeId = 0; |
| 90 } else { | 81 } else { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 | 461 |
| 471 void DisplayItemList::replay(GraphicsContext& context) const | 462 void DisplayItemList::replay(GraphicsContext& context) const |
| 472 { | 463 { |
| 473 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 464 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 474 ASSERT(m_newDisplayItems.isEmpty()); | 465 ASSERT(m_newDisplayItems.isEmpty()); |
| 475 for (auto& displayItem : m_currentDisplayItems) | 466 for (auto& displayItem : m_currentDisplayItems) |
| 476 displayItem.replay(context); | 467 displayItem.replay(context); |
| 477 } | 468 } |
| 478 | 469 |
| 479 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |