| 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 #ifndef PaintController_h | 5 #ifndef PaintController_h |
| 6 #define PaintController_h | 6 #define PaintController_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 { | 156 { |
| 157 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 157 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 158 m_trackedPaintInvalidationObjects = nullptr; | 158 m_trackedPaintInvalidationObjects = nullptr; |
| 159 } | 159 } |
| 160 Vector<String> trackedPaintInvalidationObjects() | 160 Vector<String> trackedPaintInvalidationObjects() |
| 161 { | 161 { |
| 162 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 162 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 163 return m_trackedPaintInvalidationObjects ? *m_trackedPaintInvalidationOb
jects : Vector<String>(); | 163 return m_trackedPaintInvalidationObjects ? *m_trackedPaintInvalidationOb
jects : Vector<String>(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool clientHasCheckedPaintInvalidation(const DisplayItemClient& client) cons
t | |
| 167 { | |
| 168 return m_clientsCheckedPaintInvalidation.contains(&client); | |
| 169 } | |
| 170 void setClientHasCheckedPaintInvalidation(const DisplayItemClient& client) | |
| 171 { | |
| 172 m_clientsCheckedPaintInvalidation.add(&client); | |
| 173 } | |
| 174 | |
| 175 #if ENABLE(ASSERT) | 166 #if ENABLE(ASSERT) |
| 176 void assertDisplayItemClientsAreLive(); | 167 void assertDisplayItemClientsAreLive(); |
| 177 #endif | 168 #endif |
| 178 | 169 |
| 170 bool canUseClientCacheStatus() const { return m_canUseClientCacheStatus; } |
| 171 void setCanUseClientCacheStatus(bool b) { m_canUseClientCacheStatus = b; } |
| 172 |
| 173 unsigned currentCacheGeneration() const { return m_currentCacheGeneration; } |
| 174 |
| 179 protected: | 175 protected: |
| 180 PaintController() | 176 PaintController() |
| 181 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) | 177 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) |
| 182 , m_validlyCachedClientsDirty(false) | |
| 183 , m_constructionDisabled(false) | 178 , m_constructionDisabled(false) |
| 184 , m_subsequenceCachingDisabled(false) | 179 , m_subsequenceCachingDisabled(false) |
| 185 , m_textPainted(false) | 180 , m_textPainted(false) |
| 186 , m_imagePainted(false) | 181 , m_imagePainted(false) |
| 187 , m_skippingCacheCount(0) | 182 , m_skippingCacheCount(0) |
| 188 , m_numCachedNewItems(0) | 183 , m_numCachedNewItems(0) |
| 189 , m_nextScope(1) { } | 184 , m_nextScope(1) |
| 185 , m_canUseClientCacheStatus(false) |
| 186 , m_currentCacheGeneration(DisplayItemClient::kInvalidCacheGeneration) |
| 187 { } |
| 190 | 188 |
| 191 private: | 189 private: |
| 192 // Set new item state (scopes, cache skipping, etc) for a new item. | 190 // Set new item state (scopes, cache skipping, etc) for a new item. |
| 193 void processNewItem(DisplayItem&); | 191 void processNewItem(DisplayItem&); |
| 194 | 192 |
| 195 void updateValidlyCachedClientsIfNeeded() const; | |
| 196 | |
| 197 #ifndef NDEBUG | 193 #ifndef NDEBUG |
| 198 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; | 194 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; |
| 199 #endif | 195 #endif |
| 200 | 196 |
| 201 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. | 197 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. |
| 202 // Temporarily used during merge to find out-of-order display items. | 198 // Temporarily used during merge to find out-of-order display items. |
| 203 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; | 199 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; |
| 204 | 200 |
| 205 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItemList&); | 201 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItemList&); |
| 206 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); | 202 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); |
| 207 | 203 |
| 208 struct OutOfOrderIndexContext; | 204 struct OutOfOrderIndexContext; |
| 209 DisplayItemList::iterator findOutOfOrderCachedItem(const DisplayItem::Id&, O
utOfOrderIndexContext&); | 205 DisplayItemList::iterator findOutOfOrderCachedItem(const DisplayItem::Id&, O
utOfOrderIndexContext&); |
| 210 DisplayItemList::iterator findOutOfOrderCachedItemForward(const DisplayItem:
:Id&, OutOfOrderIndexContext&); | 206 DisplayItemList::iterator findOutOfOrderCachedItemForward(const DisplayItem:
:Id&, OutOfOrderIndexContext&); |
| 211 void copyCachedSubsequence(const DisplayItemList& currentList, DisplayItemLi
st::iterator& currentIt, DisplayItemList& updatedList); | 207 void copyCachedSubsequence(const DisplayItemList& currentList, DisplayItemLi
st::iterator& currentIt, DisplayItemList& updatedList); |
| 212 | 208 |
| 213 #if ENABLE(ASSERT) | 209 #if ENABLE(ASSERT) |
| 214 // The following two methods are for checking under-invalidations | 210 // The following two methods are for checking under-invalidations |
| 215 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). | 211 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). |
| 216 void checkUnderInvalidation(DisplayItemList::iterator& newIt, DisplayItemLis
t::iterator& currentIt); | 212 void checkUnderInvalidation(DisplayItemList::iterator& newIt, DisplayItemLis
t::iterator& currentIt); |
| 217 void checkCachedDisplayItemIsUnchanged(const char* messagePrefix, const Disp
layItem& newItem, const DisplayItem& oldItem); | 213 void checkCachedDisplayItemIsUnchanged(const char* messagePrefix, const Disp
layItem& newItem, const DisplayItem& oldItem); |
| 218 void checkNoRemainingCachedDisplayItems(); | 214 void checkNoRemainingCachedDisplayItems(); |
| 219 #endif | 215 #endif |
| 220 | 216 |
| 221 void commitNewDisplayItemsInternal(const LayoutSize& offsetFromLayoutObject)
; | 217 void commitNewDisplayItemsInternal(const LayoutSize& offsetFromLayoutObject)
; |
| 222 | 218 |
| 219 static unsigned nextCacheGeneration(); |
| 220 void updateCacheGeneration(); |
| 221 |
| 223 // The last complete paint artifact. | 222 // The last complete paint artifact. |
| 224 // In SPv2, this includes paint chunks as well as display items. | 223 // In SPv2, this includes paint chunks as well as display items. |
| 225 PaintArtifact m_currentPaintArtifact; | 224 PaintArtifact m_currentPaintArtifact; |
| 226 | 225 |
| 227 // Data being used to build the next paint artifact. | 226 // Data being used to build the next paint artifact. |
| 228 DisplayItemList m_newDisplayItemList; | 227 DisplayItemList m_newDisplayItemList; |
| 229 PaintChunker m_newPaintChunks; | 228 PaintChunker m_newPaintChunks; |
| 230 | 229 |
| 231 // Contains all clients having valid cached paintings if updated. | |
| 232 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). | |
| 233 // TODO(wangxianzhu): In the future we can replace this with client-side rep
aint flags | |
| 234 // to avoid the cost of building and querying the hash table. | |
| 235 mutable HashSet<const DisplayItemClient*> m_validlyCachedClients; | |
| 236 mutable bool m_validlyCachedClientsDirty; | |
| 237 | |
| 238 // Used during painting. Contains clients that have checked paint invalidati
on and | |
| 239 // are known to be valid. | |
| 240 // TODO(wangxianzhu): Use client side flag to avoid const of hash table. | |
| 241 HashSet<const DisplayItemClient*> m_clientsCheckedPaintInvalidation; | |
| 242 | |
| 243 #if ENABLE(ASSERT) | 230 #if ENABLE(ASSERT) |
| 244 // Set of clients which had paint offset changes since the last commit. This
is used for | 231 // Set of clients which had paint offset changes since the last commit. This
is used for |
| 245 // ensuring paint offsets are only updated once and are the same in all phas
es. | 232 // ensuring paint offsets are only updated once and are the same in all phas
es. |
| 246 HashSet<const DisplayItemClient*> m_clientsWithPaintOffsetInvalidations; | 233 HashSet<const DisplayItemClient*> m_clientsWithPaintOffsetInvalidations; |
| 247 #endif | 234 #endif |
| 248 | 235 |
| 249 // Allow display item construction to be disabled to isolate the costs of co
nstruction | 236 // Allow display item construction to be disabled to isolate the costs of co
nstruction |
| 250 // in performance metrics. | 237 // in performance metrics. |
| 251 bool m_constructionDisabled; | 238 bool m_constructionDisabled; |
| 252 | 239 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 268 // Record the debug names of invalidated clients for assertion and debugging
. | 255 // Record the debug names of invalidated clients for assertion and debugging
. |
| 269 Vector<String> m_invalidations; | 256 Vector<String> m_invalidations; |
| 270 | 257 |
| 271 // This is used to check duplicated ids during add(). We could also check | 258 // This is used to check duplicated ids during add(). We could also check |
| 272 // during commitNewDisplayItems(), but checking during add() helps developer | 259 // during commitNewDisplayItems(), but checking during add() helps developer |
| 273 // easily find where the duplicated ids are from. | 260 // easily find where the duplicated ids are from. |
| 274 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 261 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
| 275 #endif | 262 #endif |
| 276 | 263 |
| 277 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 264 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
| 265 |
| 266 bool m_canUseClientCacheStatus; |
| 267 unsigned m_currentCacheGeneration; |
| 278 }; | 268 }; |
| 279 | 269 |
| 280 } // namespace blink | 270 } // namespace blink |
| 281 | 271 |
| 282 #endif // PaintController_h | 272 #endif // PaintController_h |
| OLD | NEW |