| 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/graphics/paint/DrawingDisplayItem.h" | 10 #include "platform/graphics/paint/DrawingDisplayItem.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29 { | 29 { | 
| 30     ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 30     ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 
| 31 | 31 | 
| 32     if (displayItem->isEnd()) { | 32     if (displayItem->isEnd()) { | 
| 33         ASSERT(!m_newPaints.isEmpty()); | 33         ASSERT(!m_newPaints.isEmpty()); | 
| 34         if (m_newPaints.last()->isBegin() && !m_newPaints.last()->drawsContent()
     ) { | 34         if (m_newPaints.last()->isBegin() && !m_newPaints.last()->drawsContent()
     ) { | 
| 35             ASSERT(displayItem->isEndAndPairedWith(*m_newPaints.last())); | 35             ASSERT(displayItem->isEndAndPairedWith(*m_newPaints.last())); | 
| 36             // Remove the beginning display item of this empty pair. | 36             // Remove the beginning display item of this empty pair. | 
| 37             m_newPaints.removeLast(); | 37             m_newPaints.removeLast(); | 
| 38 #if ENABLE(ASSERT) | 38 #if ENABLE(ASSERT) | 
| 39             if (RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled()) 
     { | 39             // Also remove the index pointing to the removed display item. | 
| 40                 // Also remove the index pointing to the removed display item. | 40             Vector<size_t>& indices = m_newDisplayItemIndicesByClient.find(displ
     ayItem->client())->value; | 
| 41                 Vector<size_t>& indices = m_newDisplayItemIndicesByClient.find(d
     isplayItem->client())->value; | 41             if (!indices.isEmpty() && indices.last() == m_newPaints.size()) | 
| 42                 if (!indices.isEmpty() && indices.last() == m_newPaints.size()) | 42                 indices.removeLast(); | 
| 43                     indices.removeLast(); |  | 
| 44             } |  | 
| 45 #endif | 43 #endif | 
| 46             return; | 44             return; | 
| 47         } | 45         } | 
| 48     } | 46     } | 
| 49 | 47 | 
| 50     if (!m_scopeStack.isEmpty()) | 48     if (!m_scopeStack.isEmpty()) | 
| 51         displayItem->setScope(m_scopeStack.last().client, m_scopeStack.last().id
     ); | 49         displayItem->setScope(m_scopeStack.last().client, m_scopeStack.last().id
     ); | 
| 52 | 50 | 
| 53 #if ENABLE(ASSERT) | 51 #if ENABLE(ASSERT) | 
| 54     if (RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled()) { | 52     // This will check for duplicated display item ids. | 
| 55         // This will check for duplicated display item ids. | 53     appendDisplayItem(m_newPaints, m_newDisplayItemIndicesByClient, displayItem)
     ; | 
| 56         appendDisplayItem(m_newPaints, m_newDisplayItemIndicesByClient, displayI
     tem); | 54 #else | 
| 57         return; | 55     m_newPaints.append(displayItem); | 
| 58     } |  | 
| 59 #endif | 56 #endif | 
| 60     m_newPaints.append(displayItem); |  | 
| 61 } | 57 } | 
| 62 | 58 | 
| 63 void DisplayItemList::beginScope(DisplayItemClient client) | 59 void DisplayItemList::beginScope(DisplayItemClient client) | 
| 64 { | 60 { | 
| 65     ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); | 61     ClientScopeIdMap::iterator it = m_clientScopeIdMap.find(client); | 
| 66     int scopeId; | 62     int scopeId; | 
| 67     if (it == m_clientScopeIdMap.end()) { | 63     if (it == m_clientScopeIdMap.end()) { | 
| 68         m_clientScopeIdMap.add(client, 0); | 64         m_clientScopeIdMap.add(client, 0); | 
| 69         scopeId = 0; | 65         scopeId = 0; | 
| 70     } else { | 66     } else { | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 92 { | 88 { | 
| 93     ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 89     ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 
| 94     // Can only be called during layout/paintInvalidation, not during painting. | 90     // Can only be called during layout/paintInvalidation, not during painting. | 
| 95     ASSERT(m_newPaints.isEmpty()); | 91     ASSERT(m_newPaints.isEmpty()); | 
| 96     m_paintList.clear(); | 92     m_paintList.clear(); | 
| 97     m_cachedDisplayItemIndicesByClient.clear(); | 93     m_cachedDisplayItemIndicesByClient.clear(); | 
| 98 } | 94 } | 
| 99 | 95 | 
| 100 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const | 96 bool DisplayItemList::clientCacheIsValid(DisplayItemClient client) const | 
| 101 { | 97 { | 
| 102     return RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled() | 98     return m_cachedDisplayItemIndicesByClient.contains(client) | 
| 103         && m_cachedDisplayItemIndicesByClient.contains(client) |  | 
| 104         // If the scope is invalid, the client is treated invalid even if it's n
     ot invalidated explicitly. | 99         // If the scope is invalid, the client is treated invalid even if it's n
     ot invalidated explicitly. | 
| 105         && (m_scopeStack.isEmpty() || m_scopeStack.last().cacheIsValid); | 100         && (m_scopeStack.isEmpty() || m_scopeStack.last().cacheIsValid); | 
| 106 } | 101 } | 
| 107 | 102 | 
| 108 size_t DisplayItemList::findMatchingItem(const DisplayItem& displayItem, Display
     Item::Type matchingType, const DisplayItemIndicesByClientMap& displayItemIndices
     ByClient, const PaintList& list) | 103 size_t DisplayItemList::findMatchingItem(const DisplayItem& displayItem, Display
     Item::Type matchingType, const DisplayItemIndicesByClientMap& displayItemIndices
     ByClient, const PaintList& list) | 
| 109 { | 104 { | 
| 110     DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien
     t.find(displayItem.client()); | 105     DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien
     t.find(displayItem.client()); | 
| 111     if (it == displayItemIndicesByClient.end()) | 106     if (it == displayItemIndicesByClient.end()) | 
| 112         return kNotFound; | 107         return kNotFound; | 
| 113 | 108 | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 180 void DisplayItemList::updatePaintList() | 175 void DisplayItemList::updatePaintList() | 
| 181 { | 176 { | 
| 182     // These data structures are used during painting only. | 177     // These data structures are used during painting only. | 
| 183 #if ENABLE(ASSERT) | 178 #if ENABLE(ASSERT) | 
| 184     m_newDisplayItemIndicesByClient.clear(); | 179     m_newDisplayItemIndicesByClient.clear(); | 
| 185 #endif | 180 #endif | 
| 186     m_clientScopeIdMap.clear(); | 181     m_clientScopeIdMap.clear(); | 
| 187     ASSERT(m_scopeStack.isEmpty()); | 182     ASSERT(m_scopeStack.isEmpty()); | 
| 188     m_scopeStack.clear(); | 183     m_scopeStack.clear(); | 
| 189 | 184 | 
| 190     if (!RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled()) { |  | 
| 191         m_paintList.clear(); |  | 
| 192         m_paintList.swap(m_newPaints); |  | 
| 193         m_cachedDisplayItemIndicesByClient.clear(); |  | 
| 194         return; |  | 
| 195     } |  | 
| 196 |  | 
| 197     PaintList updatedList; | 185     PaintList updatedList; | 
| 198     DisplayItemIndicesByClientMap newCachedDisplayItemIndicesByClient; | 186     DisplayItemIndicesByClientMap newCachedDisplayItemIndicesByClient; | 
| 199 | 187 | 
| 200     for (OwnPtr<DisplayItem>& newDisplayItem : m_newPaints) { | 188     for (OwnPtr<DisplayItem>& newDisplayItem : m_newPaints) { | 
| 201         if (newDisplayItem->isCached() || newDisplayItem->isSubtreeCached()) { | 189         if (newDisplayItem->isCached() || newDisplayItem->isSubtreeCached()) { | 
| 202             copyCachedItems(*newDisplayItem, updatedList, newCachedDisplayItemIn
     dicesByClient); | 190             copyCachedItems(*newDisplayItem, updatedList, newCachedDisplayItemIn
     dicesByClient); | 
| 203         } else { | 191         } else { | 
| 204             if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
     abled()) | 192             if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEn
     abled()) | 
| 205                 checkCachedDisplayItemIsUnchangedFromPreviousPaintList(*newDispl
     ayItem); | 193                 checkCachedDisplayItemIsUnchangedFromPreviousPaintList(*newDispl
     ayItem); | 
| 206             // FIXME: Enable this assert after we resolve the scope invalidation
      issue. | 194             // FIXME: Enable this assert after we resolve the scope invalidation
      issue. | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 308 #endif // ifndef NDEBUG | 296 #endif // ifndef NDEBUG | 
| 309 | 297 | 
| 310 void DisplayItemList::replay(GraphicsContext* context) | 298 void DisplayItemList::replay(GraphicsContext* context) | 
| 311 { | 299 { | 
| 312     updatePaintList(); | 300     updatePaintList(); | 
| 313     for (auto& displayItem : m_paintList) | 301     for (auto& displayItem : m_paintList) | 
| 314         displayItem->replay(context); | 302         displayItem->replay(context); | 
| 315 } | 303 } | 
| 316 | 304 | 
| 317 } // namespace blink | 305 } // namespace blink | 
| OLD | NEW | 
|---|