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/TraceEvent.h" | 9 #include "platform/TraceEvent.h" |
| 10 #include "platform/graphics/GraphicsLayer.h" | 10 #include "platform/graphics/GraphicsLayer.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 } | 95 } |
| 96 | 96 |
| 97 void DisplayItemList::endScope() | 97 void DisplayItemList::endScope() |
| 98 { | 98 { |
| 99 m_scopeStack.removeLast(); | 99 m_scopeStack.removeLast(); |
| 100 endSkippingCache(); | 100 endSkippingCache(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void DisplayItemList::invalidate(const DisplayItemClientWrapper& client, PaintIn validationReason paintInvalidationReason, const IntRect& previousPaintInvalidati onRect, const IntRect& newPaintInvalidationRect) | 103 void DisplayItemList::invalidate(const DisplayItemClientWrapper& client, PaintIn validationReason paintInvalidationReason, const IntRect& previousPaintInvalidati onRect, const IntRect& newPaintInvalidationRect) |
| 104 { | 104 { |
| 105 invalidateUntracked(client.displayItemClient()); | 105 invalidateClient(client); |
| 106 | |
| 106 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 107 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 107 Invalidation invalidation = { previousPaintInvalidationRect, paintInvali dationReason }; | 108 Invalidation invalidation = { previousPaintInvalidationRect, paintInvali dationReason }; |
| 108 if (!previousPaintInvalidationRect.isEmpty()) | 109 if (!previousPaintInvalidationRect.isEmpty()) |
| 109 m_invalidations.append(invalidation); | 110 m_invalidations.append(invalidation); |
| 110 if (newPaintInvalidationRect != previousPaintInvalidationRect && !newPai ntInvalidationRect.isEmpty()) { | 111 if (newPaintInvalidationRect != previousPaintInvalidationRect && !newPai ntInvalidationRect.isEmpty()) { |
| 111 invalidation.rect = newPaintInvalidationRect; | 112 invalidation.rect = newPaintInvalidationRect; |
| 112 m_invalidations.append(invalidation); | 113 m_invalidations.append(invalidation); |
| 113 } | 114 } |
| 114 } | 115 } |
| 116 } | |
| 115 | 117 |
| 118 void DisplayItemList::invalidateClient(const DisplayItemClientWrapper& client) | |
| 119 { | |
| 120 invalidateUntracked(client.displayItemClient()); | |
| 116 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects) | 121 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects) |
| 117 m_trackedPaintInvalidationObjects->append(client.debugName()); | 122 m_trackedPaintInvalidationObjects->append(client.debugName()); |
| 118 } | 123 } |
| 119 | 124 |
| 120 void DisplayItemList::invalidateUntracked(DisplayItemClient client) | 125 void DisplayItemList::invalidateUntracked(DisplayItemClient client) |
| 121 { | 126 { |
| 122 // Can only be called during layout/paintInvalidation, not during painting. | 127 // This can be called during painting, but we can't invalidate already paint ed clients. |
| 123 ASSERT(m_newDisplayItems.isEmpty()); | 128 ASSERT(!m_newDisplayItemIndicesByClient.contains(client)); |
| 124 updateValidlyCachedClientsIfNeeded(); | 129 updateValidlyCachedClientsIfNeeded(); |
| 125 m_validlyCachedClients.remove(client); | 130 m_validlyCachedClients.remove(client); |
| 126 } | 131 } |
| 127 | 132 |
| 128 void DisplayItemList::invalidateAll() | 133 void DisplayItemList::invalidateAll() |
| 129 { | 134 { |
| 130 // Can only be called during layout/paintInvalidation, not during painting. | 135 // Can only be called during layout/paintInvalidation, not during painting. |
| 131 ASSERT(m_newDisplayItems.isEmpty()); | 136 ASSERT(m_newDisplayItems.isEmpty()); |
| 132 m_currentDisplayItems.clear(); | 137 m_currentDisplayItems.clear(); |
| 133 m_validlyCachedClients.clear(); | 138 m_validlyCachedClients.clear(); |
| 134 m_validlyCachedClientsDirty = false; | 139 m_validlyCachedClientsDirty = false; |
| 135 | 140 |
| 136 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects) | 141 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects) |
| 137 m_trackedPaintInvalidationObjects->append("##ALL##"); | 142 m_trackedPaintInvalidationObjects->append("##ALL##"); |
| 138 } | 143 } |
| 139 | 144 |
| 140 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const | 145 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const |
| 141 { | 146 { |
| 142 if (skippingCache()) | 147 if (skippingCache()) |
| 143 return false; | 148 return false; |
| 144 updateValidlyCachedClientsIfNeeded(); | 149 updateValidlyCachedClientsIfNeeded(); |
| 145 return m_validlyCachedClients.contains(client); | 150 return m_validlyCachedClients.contains(client); |
| 146 } | 151 } |
| 147 | 152 |
| 148 void DisplayItemList::invalidatePaintOffset(const DisplayItemClientWrapper& clie nt) | 153 void DisplayItemList::invalidatePaintOffset(const DisplayItemClientWrapper& clie nt) |
| 149 { | 154 { |
| 150 ASSERT(RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()); | 155 ASSERT(RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()); |
| 151 | 156 invalidateClient(client); |
| 152 updateValidlyCachedClientsIfNeeded(); | |
| 153 m_validlyCachedClients.remove(client.displayItemClient()); | |
| 154 | |
| 155 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects) | |
| 156 m_trackedPaintInvalidationObjects->append(client.debugName()); | |
| 157 | 157 |
| 158 #if ENABLE(ASSERT) | 158 #if ENABLE(ASSERT) |
| 159 ASSERT(!paintOffsetWasInvalidated(client.displayItemClient())); | |
| 159 m_clientsWithPaintOffsetInvalidations.add(client.displayItemClient()); | 160 m_clientsWithPaintOffsetInvalidations.add(client.displayItemClient()); |
| 160 | |
| 161 // Ensure no phases slipped in using the old paint offset which would indica te | |
| 162 // different phases used different paint offsets, which should not happen. | |
| 163 for (const auto& item : m_newDisplayItems) | |
| 164 ASSERT(!item.isCached() || item.client() != client.displayItemClient()); | |
|
chrishtr
2015/10/05 21:50:35
Why remove these asserts?
Xianzhu
2015/10/05 22:04:16
Now this method calls invalidateUntracked(). The a
| |
| 165 #endif | 161 #endif |
| 166 } | 162 } |
| 167 | 163 |
| 168 #if ENABLE(ASSERT) | 164 #if ENABLE(ASSERT) |
| 169 bool DisplayItemList::paintOffsetWasInvalidated(DisplayItemClient client) const | 165 bool DisplayItemList::paintOffsetWasInvalidated(DisplayItemClient client) const |
| 170 { | 166 { |
| 171 ASSERT(RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()); | 167 ASSERT(RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled()); |
| 172 return m_clientsWithPaintOffsetInvalidations.contains(client); | 168 return m_clientsWithPaintOffsetInvalidations.contains(client); |
| 173 } | 169 } |
| 174 #endif | 170 #endif |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 // | 259 // |
| 264 void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) | 260 void DisplayItemList::commitNewDisplayItems(GraphicsLayer* graphicsLayer) |
| 265 { | 261 { |
| 266 TRACE_EVENT2("blink,benchmark", "DisplayItemList::commitNewDisplayItems", "c urrent_display_list_size", (int)m_currentDisplayItems.size(), | 262 TRACE_EVENT2("blink,benchmark", "DisplayItemList::commitNewDisplayItems", "c urrent_display_list_size", (int)m_currentDisplayItems.size(), |
| 267 "num_non_cached_new_items", (int)m_newDisplayItems.size() - m_numCachedI tems); | 263 "num_non_cached_new_items", (int)m_newDisplayItems.size() - m_numCachedI tems); |
| 268 | 264 |
| 269 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 265 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 270 for (const auto& invalidation : m_invalidations) | 266 for (const auto& invalidation : m_invalidations) |
| 271 graphicsLayer->setNeedsDisplayInRect(invalidation.rect, invalidation .invalidationReason); | 267 graphicsLayer->setNeedsDisplayInRect(invalidation.rect, invalidation .invalidationReason); |
| 272 m_invalidations.clear(); | 268 m_invalidations.clear(); |
| 269 m_clientsCheckedPaintInvalidation.clear(); | |
| 273 } | 270 } |
| 274 | 271 |
| 275 // These data structures are used during painting only. | 272 // These data structures are used during painting only. |
| 276 ASSERT(m_scopeStack.isEmpty()); | 273 ASSERT(m_scopeStack.isEmpty()); |
| 277 m_scopeStack.clear(); | 274 m_scopeStack.clear(); |
| 278 m_nextScope = 1; | 275 m_nextScope = 1; |
| 279 ASSERT(!skippingCache()); | 276 ASSERT(!skippingCache()); |
| 280 #if ENABLE(ASSERT) | 277 #if ENABLE(ASSERT) |
| 281 m_newDisplayItemIndicesByClient.clear(); | 278 m_newDisplayItemIndicesByClient.clear(); |
| 279 m_clientsWithPaintOffsetInvalidations.clear(); | |
| 282 #endif | 280 #endif |
| 283 | 281 |
| 284 if (m_currentDisplayItems.isEmpty()) { | 282 if (m_currentDisplayItems.isEmpty()) { |
| 285 #if ENABLE(ASSERT) | 283 #if ENABLE(ASSERT) |
| 286 for (const auto& item : m_newDisplayItems) | 284 for (const auto& item : m_newDisplayItems) |
| 287 ASSERT(!item.isCached()); | 285 ASSERT(!item.isCached()); |
| 288 #endif | 286 #endif |
| 289 m_currentDisplayItems.swap(m_newDisplayItems); | 287 m_currentDisplayItems.swap(m_newDisplayItems); |
| 290 m_validlyCachedClientsDirty = true; | 288 m_validlyCachedClientsDirty = true; |
| 291 m_numCachedItems = 0; | 289 m_numCachedItems = 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 | 360 |
| 363 #if ENABLE(ASSERT) | 361 #if ENABLE(ASSERT) |
| 364 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) | 362 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) |
| 365 checkNoRemainingCachedDisplayItems(); | 363 checkNoRemainingCachedDisplayItems(); |
| 366 #endif // ENABLE(ASSERT) | 364 #endif // ENABLE(ASSERT) |
| 367 | 365 |
| 368 m_newDisplayItems.clear(); | 366 m_newDisplayItems.clear(); |
| 369 m_validlyCachedClientsDirty = true; | 367 m_validlyCachedClientsDirty = true; |
| 370 m_currentDisplayItems.swap(updatedList); | 368 m_currentDisplayItems.swap(updatedList); |
| 371 m_numCachedItems = 0; | 369 m_numCachedItems = 0; |
| 372 | |
| 373 #if ENABLE(ASSERT) | |
| 374 m_clientsWithPaintOffsetInvalidations.clear(); | |
| 375 #endif | |
| 376 } | 370 } |
| 377 | 371 |
| 378 size_t DisplayItemList::approximateUnsharedMemoryUsage() const | 372 size_t DisplayItemList::approximateUnsharedMemoryUsage() const |
| 379 { | 373 { |
| 380 size_t memoryUsage = sizeof(*this); | 374 size_t memoryUsage = sizeof(*this); |
| 381 | 375 |
| 382 // Memory outside this class due to m_currentDisplayItems. | 376 // Memory outside this class due to m_currentDisplayItems. |
| 383 memoryUsage += m_currentDisplayItems.memoryUsageInBytes(); | 377 memoryUsage += m_currentDisplayItems.memoryUsageInBytes(); |
| 384 | 378 |
| 385 // TODO(jbroman): If display items begin to have significant external memory | 379 // TODO(jbroman): If display items begin to have significant external memory |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 | 556 |
| 563 void DisplayItemList::replay(GraphicsContext& context) | 557 void DisplayItemList::replay(GraphicsContext& context) |
| 564 { | 558 { |
| 565 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); | 559 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); |
| 566 ASSERT(m_newDisplayItems.isEmpty()); | 560 ASSERT(m_newDisplayItems.isEmpty()); |
| 567 for (DisplayItem& displayItem : m_currentDisplayItems) | 561 for (DisplayItem& displayItem : m_currentDisplayItems) |
| 568 displayItem.replay(context); | 562 displayItem.replay(context); |
| 569 } | 563 } |
| 570 | 564 |
| 571 } // namespace blink | 565 } // namespace blink |
| OLD | NEW |