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::add(DisplayItem& displayItem) |
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() || !displayItem.isCached()); |
40 | 40 |
41 if (displayItem->isEnd()) { | 41 if (displayItem.isEnd()) { |
42 ASSERT(!m_newDisplayItems.isEmpty()); | 42 ASSERT(!m_newDisplayItems.isEmpty()); |
43 if (m_newDisplayItems.last().isBegin() && !m_newDisplayItems.last().draw
sContent()) { | 43 if (m_newDisplayItems.last().isBegin() && !m_newDisplayItems.last().draw
sContent()) { |
44 ASSERT(displayItem->isEndAndPairedWith(m_newDisplayItems.last().type
())); | 44 ASSERT(displayItem.isEndAndPairedWith(m_newDisplayItems.last().type(
))); |
45 // Remove the beginning display item of this empty pair. | 45 // Remove the beginning display item of this empty pair. |
46 m_newDisplayItems.removeLast(); | 46 m_newDisplayItems.removeLast(); |
47 #if ENABLE(ASSERT) | 47 #if ENABLE(ASSERT) |
48 // Also remove the index pointing to the removed display item. | 48 // Also remove the index pointing to the removed display item. |
49 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndices
ByClient.find(displayItem->client()); | 49 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndices
ByClient.find(displayItem.client()); |
50 if (it != m_newDisplayItemIndicesByClient.end()) { | 50 if (it != m_newDisplayItemIndicesByClient.end()) { |
51 Vector<size_t>& indices = it->value; | 51 Vector<size_t>& indices = it->value; |
52 if (!indices.isEmpty() && indices.last() == m_newDisplayItems.si
ze()) | 52 if (!indices.isEmpty() && indices.last() == m_newDisplayItems.si
ze()) |
53 indices.removeLast(); | 53 indices.removeLast(); |
54 } | 54 } |
55 #endif | 55 #endif |
56 return; | 56 return; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 if (!m_scopeStack.isEmpty()) | 60 if (!m_scopeStack.isEmpty()) |
61 displayItem->setScope(m_scopeStack.last().id, m_scopeStack.last().client
); | 61 displayItem.setScope(m_scopeStack.last().id, m_scopeStack.last().client)
; |
62 | 62 |
63 #if ENABLE(ASSERT) | 63 #if ENABLE(ASSERT) |
64 size_t index = findMatchingItemFromIndex(displayItem->id(), displayItem->typ
e(), m_newDisplayItemIndicesByClient, m_newDisplayItems); | 64 size_t index = findMatchingItemFromIndex(displayItem.id(), displayItem.type(
), m_newDisplayItemIndicesByClient, m_newDisplayItems); |
65 if (index != kNotFound) { | 65 if (index != kNotFound) { |
66 #ifndef NDEBUG | 66 #ifndef NDEBUG |
67 showDebugData(); | 67 showDebugData(); |
68 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=%
d)\n", | 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)); | 69 displayItem.asDebugString().utf8().data(), m_newDisplayItems[index].
asDebugString().utf8().data(), static_cast<int>(index)); |
70 #endif | 70 #endif |
71 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
72 } | 72 } |
73 addItemToIndex(displayItem->client(), displayItem->type(), m_newDisplayItems
.size(), m_newDisplayItemIndicesByClient); | 73 addItemToIndex(displayItem.client(), displayItem.type(), m_newDisplayItems.s
ize(), m_newDisplayItemIndicesByClient); |
74 #endif // ENABLE(ASSERT) | 74 #endif // ENABLE(ASSERT) |
75 | 75 |
76 ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the fl
ag. | 76 ASSERT(!displayItem.skippedCache()); // Only DisplayItemList can set the fla
g. |
77 if (skippingCache()) | 77 if (skippingCache()) |
78 displayItem->setSkippedCache(); | 78 displayItem.setSkippedCache(); |
79 | 79 |
80 m_newDisplayItems.append(displayItem); | 80 displayItem.appendByMoving(m_newDisplayItems); |
81 } | 81 } |
82 | 82 |
83 void DisplayItemList::beginScope(DisplayItemClient client) | 83 void DisplayItemList::beginScope(DisplayItemClient client) |
84 { | 84 { |
85 ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); | 85 ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); |
86 int scopeId; | 86 int scopeId; |
87 if (it == m_clientScopeIdMap.end()) { | 87 if (it == m_clientScopeIdMap.end()) { |
88 m_clientScopeIdMap.add(client, 0); | 88 m_clientScopeIdMap.add(client, 0); |
89 scopeId = 0; | 89 scopeId = 0; |
90 } else { | 90 } else { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 474 |
475 void DisplayItemList::replay(GraphicsContext& context) const | 475 void DisplayItemList::replay(GraphicsContext& context) const |
476 { | 476 { |
477 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 477 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
478 ASSERT(m_newDisplayItems.isEmpty()); | 478 ASSERT(m_newDisplayItems.isEmpty()); |
479 for (auto& displayItem : m_currentDisplayItems) | 479 for (auto& displayItem : m_currentDisplayItems) |
480 displayItem.replay(context); | 480 displayItem.replay(context); |
481 } | 481 } |
482 | 482 |
483 } // namespace blink | 483 } // namespace blink |
OLD | NEW |