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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 #if ENABLE(ASSERT) | 84 #if ENABLE(ASSERT) |
| 85 size_t index = findMatchingItemFromIndex(displayItem->nonCachedId(), m_newDi splayItemIndicesByClient, m_newDisplayItems); | 85 size_t index = findMatchingItemFromIndex(displayItem->nonCachedId(), m_newDi splayItemIndicesByClient, m_newDisplayItems); |
| 86 if (index != kNotFound) { | 86 if (index != kNotFound) { |
| 87 #ifndef NDEBUG | 87 #ifndef NDEBUG |
| 88 showDebugData(); | 88 showDebugData(); |
| 89 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n", | 89 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n", |
| 90 displayItem->asDebugString().utf8().data(), m_newDisplayItems[index] .asDebugString().utf8().data(), static_cast<int>(index)); | 90 displayItem->asDebugString().utf8().data(), m_newDisplayItems[index] .asDebugString().utf8().data(), static_cast<int>(index)); |
| 91 #endif | 91 #endif |
| 92 ASSERT_NOT_REACHED(); | 92 ASSERT_NOT_REACHED(); |
| 93 } | 93 } |
| 94 addItemToIndexIfNeeded(*displayItem, m_newDisplayItems.size() - 1, m_newDisp layItemIndicesByClient); | 94 // TODO: Do we need to check duplicated ids for other types? |
| 95 if (displayItem->isCached() || displayItem->isCacheable()) | |
| 96 addItemToIndex(*displayItem, m_newDisplayItems.size() - 1, m_newDisplayI temIndicesByClient); | |
| 95 #endif // ENABLE(ASSERT) | 97 #endif // ENABLE(ASSERT) |
| 96 | 98 |
| 97 ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the fl ag. | 99 ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the fl ag. |
| 98 if (skippingCache()) | 100 if (skippingCache()) |
| 99 displayItem->setSkippedCache(); | 101 displayItem->setSkippedCache(); |
| 100 } | 102 } |
| 101 | 103 |
| 102 void DisplayItemList::beginScope() | 104 void DisplayItemList::beginScope() |
| 103 { | 105 { |
| 104 ASSERT_WITH_SECURITY_IMPLICATION(m_nextScope < UINT_MAX); | 106 ASSERT_WITH_SECURITY_IMPLICATION(m_nextScope < UINT_MAX); |
| 105 m_scopeStack.append(m_nextScope++); | 107 m_scopeStack.append(m_nextScope++); |
| 106 beginSkippingCache(); | 108 beginSkippingCache(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void DisplayItemList::endScope() | 111 void DisplayItemList::endScope() |
| 110 { | 112 { |
| 111 m_scopeStack.removeLast(); | 113 m_scopeStack.removeLast(); |
| 112 endSkippingCache(); | 114 endSkippingCache(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 void DisplayItemList::invalidate(DisplayItemClient client) | 117 void DisplayItemList::invalidate(DisplayItemClient client) |
| 116 { | 118 { |
| 117 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 119 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 118 // Can only be called during layout/paintInvalidation, not during painting. | 120 // Can only be called during layout/paintInvalidation, not during painting. |
| 119 ASSERT(m_newDisplayItems.isEmpty()); | 121 ASSERT(m_newDisplayItems.isEmpty()); |
| 120 updateValidlyCachedClientsIfNeeded(); | 122 updateValidlyCachedClientsIfNeeded(); |
| 121 m_validlyCachedClients.remove(client); | 123 m_validlyCachedClients.remove(client); |
| 124 m_subtreeIndicesByClient.remove(client); | |
| 122 } | 125 } |
| 123 | 126 |
| 124 void DisplayItemList::invalidateAll() | 127 void DisplayItemList::invalidateAll() |
| 125 { | 128 { |
| 126 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 129 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 127 // Can only be called during layout/paintInvalidation, not during painting. | 130 // Can only be called during layout/paintInvalidation, not during painting. |
| 128 ASSERT(m_newDisplayItems.isEmpty()); | 131 ASSERT(m_newDisplayItems.isEmpty()); |
| 129 m_currentDisplayItems.clear(); | 132 m_currentDisplayItems.clear(); |
| 130 m_validlyCachedClients.clear(); | 133 m_validlyCachedClients.clear(); |
| 131 m_validlyCachedClientsDirty = false; | 134 m_validlyCachedClientsDirty = false; |
| 135 m_subtreeIndicesByClient.clear(); | |
| 136 m_subtreeIndicesByClientDirty = false; | |
| 132 } | 137 } |
| 133 | 138 |
| 134 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const | 139 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const |
| 135 { | 140 { |
| 136 if (skippingCache()) | 141 if (skippingCache()) |
| 137 return false; | 142 return false; |
| 138 updateValidlyCachedClientsIfNeeded(); | 143 updateValidlyCachedClientsIfNeeded(); |
| 139 return m_validlyCachedClients.contains(client); | 144 return m_validlyCachedClients.contains(client); |
| 140 } | 145 } |
| 141 | 146 |
| 147 bool DisplayItemList::subtreeCacheIsValid(DisplayItemClient client, DisplayItem: :Type beginSubtreeType) const | |
| 148 { | |
| 149 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | |
| 150 ASSERT(DisplayItem::isBeginSubtreeType(beginSubtreeType)); | |
| 151 if (skippingCache()) | |
| 152 return false; | |
| 153 updateSubtreeIndicesByClientIfNeeded(); | |
| 154 return findMatchingItemFromIndex(DisplayItem::Id(client, beginSubtreeType, 0 ), m_subtreeIndicesByClient, m_currentDisplayItems) != kNotFound; | |
| 155 } | |
| 156 | |
| 142 size_t DisplayItemList::findMatchingItemFromIndex(const DisplayItem::Id& id, con st DisplayItemIndicesByClientMap& displayItemIndicesByClient, const DisplayItems & list) | 157 size_t DisplayItemList::findMatchingItemFromIndex(const DisplayItem::Id& id, con st DisplayItemIndicesByClientMap& displayItemIndicesByClient, const DisplayItems & list) |
| 143 { | 158 { |
| 144 DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien t.find(id.client); | 159 DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien t.find(id.client); |
| 145 if (it == displayItemIndicesByClient.end()) | 160 if (it == displayItemIndicesByClient.end()) |
| 146 return kNotFound; | 161 return kNotFound; |
| 147 | 162 |
| 148 const Vector<size_t>& indices = it->value; | 163 const Vector<size_t>& indices = it->value; |
| 149 for (size_t index : indices) { | 164 for (size_t index : indices) { |
| 150 const DisplayItem& existingItem = list[index]; | 165 const DisplayItem& existingItem = list[index]; |
| 151 ASSERT(!existingItem.isValid() || existingItem.client() == id.client); | 166 ASSERT(!existingItem.isValid() || existingItem.client() == id.client); |
| 152 if (existingItem.isValid() && id.matches(existingItem)) | 167 if (existingItem.isValid() && id.matches(existingItem)) |
| 153 return index; | 168 return index; |
| 154 } | 169 } |
| 155 | 170 |
| 156 return kNotFound; | 171 return kNotFound; |
| 157 } | 172 } |
| 158 | 173 |
| 159 void DisplayItemList::addItemToIndexIfNeeded(const DisplayItem& displayItem, siz e_t index, DisplayItemIndicesByClientMap& displayItemIndicesByClient) | 174 void DisplayItemList::addItemToIndex(const DisplayItem& displayItem, size_t inde x, DisplayItemIndicesByClientMap& displayItemIndicesByClient) |
| 160 { | 175 { |
| 161 if (!displayItem.isCacheable()) | 176 displayItemIndicesByClient.add(displayItem.client(), Vector<size_t>()).store dValue->value.append(index); |
| 162 return; | |
| 163 | |
| 164 DisplayItemIndicesByClientMap::iterator it = displayItemIndicesByClient.find (displayItem.client()); | |
| 165 Vector<size_t>& indices = it == displayItemIndicesByClient.end() ? | |
| 166 displayItemIndicesByClient.add(displayItem.client(), Vector<size_t>()).s toredValue->value : it->value; | |
| 167 indices.append(index); | |
| 168 } | 177 } |
| 169 | 178 |
| 170 struct DisplayItemList::OutOfOrderIndexContext { | 179 struct DisplayItemList::OutOfOrderIndexContext { |
| 171 OutOfOrderIndexContext(DisplayItems::iterator begin) : nextItemToIndex(begin ) { } | 180 OutOfOrderIndexContext(DisplayItems::iterator begin) : nextItemToIndex(begin ) { } |
| 172 | 181 |
| 173 DisplayItems::iterator nextItemToIndex; | 182 DisplayItems::iterator nextItemToIndex; |
| 174 DisplayItemIndicesByClientMap displayItemIndicesByClient; | 183 DisplayItemIndicesByClientMap displayItemIndicesByClient; |
| 175 }; | 184 }; |
| 176 | 185 |
| 177 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItem(DisplayItems::i terator currentIt, const DisplayItem::Id& id, OutOfOrderIndexContext& context) | 186 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItem(DisplayItems::i terator currentIt, const DisplayItem::Id& id, OutOfOrderIndexContext& context) |
| 178 { | 187 { |
| 179 ASSERT(clientCacheIsValid(id.client)); | 188 ASSERT(clientCacheIsValid(id.client)); |
| 180 | 189 |
| 181 // Skip indexing of copied items. | 190 // Skip indexing of copied items. |
| 182 if (currentIt - context.nextItemToIndex > 0) | 191 if (currentIt - context.nextItemToIndex > 0) |
| 183 context.nextItemToIndex = currentIt; | 192 context.nextItemToIndex = currentIt; |
| 184 | 193 |
| 185 size_t foundIndex = findMatchingItemFromIndex(id, context.displayItemIndices ByClient, m_currentDisplayItems); | 194 size_t foundIndex = findMatchingItemFromIndex(id, context.displayItemIndices ByClient, m_currentDisplayItems); |
| 186 if (foundIndex != kNotFound) | 195 if (foundIndex != kNotFound) |
| 187 return m_currentDisplayItems.begin() + foundIndex; | 196 return m_currentDisplayItems.begin() + foundIndex; |
| 188 | 197 |
| 198 // We have indexed all BeginSubtree display items, so don't need to find for ward. | |
|
pdr.
2015/08/24 20:30:10
Should this be a few lines up or do we need to cal
Xianzhu
2015/08/24 23:03:21
Rearranged the statements and rephrased the commen
| |
| 199 if (DisplayItem::isBeginSubtreeType(id.type)) | |
| 200 return m_currentDisplayItems.end(); | |
| 201 | |
| 189 return findOutOfOrderCachedItemForward(id, context); | 202 return findOutOfOrderCachedItemForward(id, context); |
| 190 } | 203 } |
| 191 | 204 |
| 192 // Find forward for the item and index all skipped indexable items. | 205 // Find forward for the item and index all skipped indexable items. |
| 193 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(const Di splayItem::Id& id, OutOfOrderIndexContext& context) | 206 DisplayItems::iterator DisplayItemList::findOutOfOrderCachedItemForward(const Di splayItem::Id& id, OutOfOrderIndexContext& context) |
| 194 { | 207 { |
| 195 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); | 208 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); |
| 196 for (; context.nextItemToIndex != currentEnd; ++context.nextItemToIndex) { | 209 for (; context.nextItemToIndex != currentEnd; ++context.nextItemToIndex) { |
| 197 const DisplayItem& item = *context.nextItemToIndex; | 210 const DisplayItem& item = *context.nextItemToIndex; |
| 198 ASSERT(item.isValid()); | 211 ASSERT(item.isValid()); |
| 199 if (item.isCacheable() && clientCacheIsValid(item.client())) { | 212 if (item.isCacheable() && clientCacheIsValid(item.client())) { |
| 200 if (id.matches(item)) | 213 if (id.matches(item)) |
| 201 return context.nextItemToIndex++; | 214 return context.nextItemToIndex++; |
| 202 | 215 |
| 203 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentDisp layItems.begin(), context.displayItemIndicesByClient); | 216 if (item.isDrawing() && !item.skippedCache()) |
| 217 addItemToIndex(item, context.nextItemToIndex - m_currentDisplayI tems.begin(), context.displayItemIndicesByClient); | |
| 204 } | 218 } |
| 205 } | 219 } |
| 206 return currentEnd; | 220 return currentEnd; |
| 207 } | 221 } |
| 208 | 222 |
| 209 void DisplayItemList::copyCachedSubtree(DisplayItems::iterator& currentIt, Displ ayItems& updatedList) | 223 void DisplayItemList::copyCachedSubtree(DisplayItems::iterator& currentIt, Displ ayItems& updatedList) |
| 210 { | 224 { |
| 211 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 225 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 212 ASSERT(currentIt->isBeginSubtree()); | 226 ASSERT(currentIt->isBeginSubtree()); |
| 213 ASSERT(!currentIt->scope()); | 227 ASSERT(!currentIt->scope()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 m_newDisplayItemIndicesByClient.clear(); | 260 m_newDisplayItemIndicesByClient.clear(); |
| 247 #endif | 261 #endif |
| 248 | 262 |
| 249 if (m_currentDisplayItems.isEmpty()) { | 263 if (m_currentDisplayItems.isEmpty()) { |
| 250 #if ENABLE(ASSERT) | 264 #if ENABLE(ASSERT) |
| 251 for (const auto& item : m_newDisplayItems) | 265 for (const auto& item : m_newDisplayItems) |
| 252 ASSERT(!item.isCached()); | 266 ASSERT(!item.isCached()); |
| 253 #endif | 267 #endif |
| 254 m_currentDisplayItems.swap(m_newDisplayItems); | 268 m_currentDisplayItems.swap(m_newDisplayItems); |
| 255 m_validlyCachedClientsDirty = true; | 269 m_validlyCachedClientsDirty = true; |
| 270 m_subtreeIndicesByClientDirty = true; | |
| 256 m_numCachedItems = 0; | 271 m_numCachedItems = 0; |
| 257 return; | 272 return; |
| 258 } | 273 } |
| 259 | 274 |
| 260 updateValidlyCachedClientsIfNeeded(); | 275 updateValidlyCachedClientsIfNeeded(); |
| 261 | 276 |
| 262 // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that have not been matched | 277 // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that have not been matched |
| 263 // by CachedDisplayItems during synchronized matching. The indexed items wil l be matched | 278 // by CachedDisplayItems during synchronized matching. The indexed items wil l be matched |
| 264 // by later out-of-order CachedDisplayItems in m_newDisplayItems. This ensur es that when | 279 // by later out-of-order CachedDisplayItems in m_newDisplayItems. This ensur es that when |
| 265 // out-of-order CachedDisplayItems occur, we only traverse at most once over m_currentDisplayItems | 280 // out-of-order CachedDisplayItems occur, we only traverse at most once over m_currentDisplayItems |
| 266 // looking for potential matches. Thus we can ensure that the algorithm runs in linear time. | 281 // looking for potential matches. Thus we can ensure that the algorithm runs in linear time. |
| 267 OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin()) ; | 282 OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin()) ; |
| 283 outOfOrderIndexContext.displayItemIndicesByClient.swap(m_subtreeIndicesByCli ent); | |
| 268 | 284 |
| 269 #if ENABLE(ASSERT) | 285 #if ENABLE(ASSERT) |
| 270 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { | 286 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { |
| 271 // Under-invalidation checking requires a full index of m_currentDisplay Items. | 287 // Under-invalidation checking requires a full index of m_currentDisplay Items. |
| 272 size_t i = 0; | 288 size_t i = 0; |
| 273 for (const auto& item : m_currentDisplayItems) { | 289 for (const auto& item : m_currentDisplayItems) { |
| 274 addItemToIndexIfNeeded(item, i, outOfOrderIndexContext.displayItemIn dicesByClient); | 290 addItemToIndex(item, i, outOfOrderIndexContext.displayItemIndicesByC lient); |
| 275 ++i; | 291 ++i; |
| 276 } | 292 } |
| 277 } | 293 } |
| 278 #endif // ENABLE(ASSERT) | 294 #endif // ENABLE(ASSERT) |
| 279 | 295 |
| 280 // TODO(jbroman): Consider revisiting this heuristic. | 296 // TODO(jbroman): Consider revisiting this heuristic. |
| 281 DisplayItems updatedList( | 297 DisplayItems updatedList( |
| 282 kMaximumDisplayItemSize, | 298 kMaximumDisplayItemSize, |
| 283 std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems. usedCapacityInBytes())); | 299 std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems. usedCapacityInBytes())); |
| 284 DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); | 300 DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); |
| 285 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); | 301 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); |
| 286 for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_ne wDisplayItems.end(); ++newIt) { | 302 for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_ne wDisplayItems.end(); ++newIt) { |
| 287 const DisplayItem& newDisplayItem = *newIt; | 303 const DisplayItem& newDisplayItem = *newIt; |
| 288 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); | 304 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); |
| 289 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt emId.type; | 305 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt emId.type; |
| 290 | 306 |
| 291 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche s(*currentIt); | 307 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche s(*currentIt); |
| 292 | 308 |
| 293 if (newDisplayItemHasCachedType) { | 309 if (newDisplayItemHasCachedType) { |
| 294 ASSERT(!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationChecki ngEnabled()); | 310 ASSERT(!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationChecki ngEnabled()); |
| 295 ASSERT(newDisplayItem.isCached()); | 311 ASSERT(newDisplayItem.isCached()); |
| 296 ASSERT(clientCacheIsValid(newDisplayItem.client())); | 312 ASSERT(clientCacheIsValid(newDisplayItem.client())); |
| 297 if (!isSynchronized) { | 313 if (!isSynchronized) { |
| 298 DisplayItems::iterator foundIt = findOutOfOrderCachedItem(curren tIt, newDisplayItemId, outOfOrderIndexContext); | 314 currentIt = findOutOfOrderCachedItem(currentIt, newDisplayItemId , outOfOrderIndexContext); |
| 299 | 315 if (currentIt == currentEnd) { |
| 300 if (foundIt == currentEnd) { | |
| 301 #ifndef NDEBUG | 316 #ifndef NDEBUG |
| 302 showDebugData(); | 317 showDebugData(); |
| 303 WTFLogAlways("%s not found in m_currentDisplayItems\n", newD isplayItem.asDebugString().utf8().data()); | 318 WTFLogAlways("%s not found in m_currentDisplayItems\n", newD isplayItem.asDebugString().utf8().data()); |
| 304 #endif | 319 #endif |
| 305 ASSERT_NOT_REACHED(); | 320 ASSERT_NOT_REACHED(); |
| 306 | 321 // We did not find the cached display item. This should be i mpossible, but may occur if there is a bug in |
| 307 // If foundIt == currentEnd, it means that we did not find t he cached display item. This should be impossible, but may occur | 322 // the system, such as under-invalidation, incorrect cache c hecking or duplicate display ids. In this case, |
| 308 // if there is a bug in the system, such as under-invalidati on, incorrect cache checking or duplicate display ids. In this case, | |
| 309 // attempt to recover rather than crashing or bailing on dis play of the rest of the display list. | 323 // attempt to recover rather than crashing or bailing on dis play of the rest of the display list. |
| 310 continue; | 324 continue; |
| 311 } | 325 } |
| 312 | |
| 313 ASSERT(foundIt != currentIt); // because we are in 'if (!isSynch ronized)' | |
| 314 currentIt = foundIt; | |
| 315 } | 326 } |
| 316 | 327 |
| 317 if (newDisplayItem.isCachedDrawing()) { | 328 if (newDisplayItem.isCachedDrawing()) { |
| 318 updatedList.appendByMoving(*currentIt, currentIt->derivedSize()) ; | 329 updatedList.appendByMoving(*currentIt, currentIt->derivedSize()) ; |
| 319 ++currentIt; | 330 ++currentIt; |
| 320 } else { | 331 } else { |
| 321 ASSERT(newDisplayItem.isCachedSubtree()); | 332 ASSERT(newDisplayItem.isCachedSubtree()); |
| 322 copyCachedSubtree(currentIt, updatedList); | 333 copyCachedSubtree(currentIt, updatedList); |
| 323 ASSERT(updatedList.last().isEndSubtree()); | 334 ASSERT(updatedList.last().isEndSubtree()); |
| 324 } | 335 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 336 } | 347 } |
| 337 } | 348 } |
| 338 | 349 |
| 339 #if ENABLE(ASSERT) | 350 #if ENABLE(ASSERT) |
| 340 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) | 351 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) |
| 341 checkNoRemainingCachedDisplayItems(); | 352 checkNoRemainingCachedDisplayItems(); |
| 342 #endif // ENABLE(ASSERT) | 353 #endif // ENABLE(ASSERT) |
| 343 | 354 |
| 344 m_newDisplayItems.clear(); | 355 m_newDisplayItems.clear(); |
| 345 m_validlyCachedClientsDirty = true; | 356 m_validlyCachedClientsDirty = true; |
| 357 m_subtreeIndicesByClientDirty = true; | |
| 346 m_currentDisplayItems.swap(updatedList); | 358 m_currentDisplayItems.swap(updatedList); |
| 347 m_numCachedItems = 0; | 359 m_numCachedItems = 0; |
| 348 } | 360 } |
| 349 | 361 |
| 350 size_t DisplayItemList::approximateUnsharedMemoryUsage() const | 362 size_t DisplayItemList::approximateUnsharedMemoryUsage() const |
| 351 { | 363 { |
| 352 size_t memoryUsage = sizeof(*this); | 364 size_t memoryUsage = sizeof(*this); |
| 353 | 365 |
| 354 // Memory outside this class due to m_currentDisplayItems. | 366 // Memory outside this class due to m_currentDisplayItems. |
| 355 memoryUsage += m_currentDisplayItems.memoryUsageInBytes(); | 367 memoryUsage += m_currentDisplayItems.memoryUsageInBytes(); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 383 DisplayItemClient lastClient = nullptr; | 395 DisplayItemClient lastClient = nullptr; |
| 384 for (const DisplayItem& displayItem : m_currentDisplayItems) { | 396 for (const DisplayItem& displayItem : m_currentDisplayItems) { |
| 385 if (displayItem.client() == lastClient) | 397 if (displayItem.client() == lastClient) |
| 386 continue; | 398 continue; |
| 387 lastClient = displayItem.client(); | 399 lastClient = displayItem.client(); |
| 388 if (!displayItem.skippedCache()) | 400 if (!displayItem.skippedCache()) |
| 389 m_validlyCachedClients.add(lastClient); | 401 m_validlyCachedClients.add(lastClient); |
| 390 } | 402 } |
| 391 } | 403 } |
| 392 | 404 |
| 405 void DisplayItemList::updateSubtreeIndicesByClientIfNeeded() const | |
| 406 { | |
| 407 if (!m_subtreeIndicesByClientDirty) | |
| 408 return; | |
| 409 | |
| 410 m_subtreeIndicesByClient.clear(); | |
| 411 m_subtreeIndicesByClientDirty = false; | |
| 412 | |
| 413 for (DisplayItems::const_iterator it = m_currentDisplayItems.begin(); it != m_currentDisplayItems.end(); ++it) { | |
| 414 if (it->isBeginSubtree() && !it->skippedCache()) | |
| 415 addItemToIndex(*it, it - m_currentDisplayItems.begin(), m_subtreeInd icesByClient); | |
| 416 } | |
| 417 } | |
| 418 | |
| 393 void DisplayItemList::appendToWebDisplayItemList(WebDisplayItemList* list) | 419 void DisplayItemList::appendToWebDisplayItemList(WebDisplayItemList* list) |
| 394 { | 420 { |
| 395 for (const DisplayItem& item : m_currentDisplayItems) | 421 for (const DisplayItem& item : m_currentDisplayItems) |
| 396 item.appendToWebDisplayItemList(list); | 422 item.appendToWebDisplayItemList(list); |
| 397 } | 423 } |
| 398 | 424 |
| 399 void DisplayItemList::commitNewDisplayItemsAndAppendToWebDisplayItemList(WebDisp layItemList* list) | 425 void DisplayItemList::commitNewDisplayItemsAndAppendToWebDisplayItemList(WebDisp layItemList* list) |
| 400 { | 426 { |
| 401 commitNewDisplayItems(); | 427 commitNewDisplayItems(); |
| 402 appendToWebDisplayItemList(list); | 428 appendToWebDisplayItemList(list); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 | 571 |
| 546 void DisplayItemList::replay(GraphicsContext& context) | 572 void DisplayItemList::replay(GraphicsContext& context) |
| 547 { | 573 { |
| 548 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 574 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 549 ASSERT(m_newDisplayItems.isEmpty()); | 575 ASSERT(m_newDisplayItems.isEmpty()); |
| 550 for (DisplayItem& displayItem : m_currentDisplayItems) | 576 for (DisplayItem& displayItem : m_currentDisplayItems) |
| 551 displayItem.replay(context); | 577 displayItem.replay(context); |
| 552 } | 578 } |
| 553 | 579 |
| 554 } // namespace blink | 580 } // namespace blink |
| OLD | NEW |