| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 , m_textPainted(false) | 164 , m_textPainted(false) |
| 165 , m_imagePainted(false) | 165 , m_imagePainted(false) |
| 166 , m_skippingCacheCount(0) | 166 , m_skippingCacheCount(0) |
| 167 , m_numCachedNewItems(0) | 167 , m_numCachedNewItems(0) |
| 168 #if DCHECK_IS_ON() | 168 #if DCHECK_IS_ON() |
| 169 , m_numSequentialMatches(0) | 169 , m_numSequentialMatches(0) |
| 170 , m_numOutOfOrderMatches(0) | 170 , m_numOutOfOrderMatches(0) |
| 171 , m_numIndexedItems(0) | 171 , m_numIndexedItems(0) |
| 172 #endif | 172 #endif |
| 173 { | 173 { |
| 174 resetCurrentListIterators(); | 174 resetCurrentListIndices(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 friend class PaintControllerTest; | 178 friend class PaintControllerTest; |
| 179 friend class PaintControllerPaintTestBase; | 179 friend class PaintControllerPaintTestBase; |
| 180 | 180 |
| 181 void ensureNewDisplayItemListInitialCapacity() | 181 void ensureNewDisplayItemListInitialCapacity() |
| 182 { | 182 { |
| 183 if (m_newDisplayItemList.isEmpty()) { | 183 if (m_newDisplayItemList.isEmpty()) { |
| 184 // TODO(wangxianzhu): Consider revisiting this heuristic. | 184 // TODO(wangxianzhu): Consider revisiting this heuristic. |
| 185 m_newDisplayItemList = DisplayItemList(m_currentPaintArtifact.getDis
playItemList().isEmpty() ? kInitialDisplayItemListCapacityBytes : m_currentPaint
Artifact.getDisplayItemList().usedCapacityInBytes()); | 185 m_newDisplayItemList = DisplayItemList(m_currentPaintArtifact.getDis
playItemList().isEmpty() ? kInitialDisplayItemListCapacityBytes : m_currentPaint
Artifact.getDisplayItemList().usedCapacityInBytes()); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Set new item state (cache skipping, etc) for a new item. | 189 // Set new item state (cache skipping, etc) for a new item. |
| 190 void processNewItem(DisplayItem&); | 190 void processNewItem(DisplayItem&); |
| 191 | 191 |
| 192 #ifndef NDEBUG | 192 #ifndef NDEBUG |
| 193 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; | 193 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; |
| 194 #endif | 194 #endif |
| 195 | 195 |
| 196 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. | 196 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. |
| 197 // Temporarily used during merge to find out-of-order display items. | 197 // Temporarily used during merge to find out-of-order display items. |
| 198 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; | 198 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; |
| 199 | 199 |
| 200 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItemList&); | 200 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItemList&); |
| 201 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); | 201 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); |
| 202 | 202 |
| 203 DisplayItemList::iterator findCachedItem(const DisplayItem::Id&); | 203 size_t findCachedItem(const DisplayItem::Id&); |
| 204 DisplayItemList::iterator findOutOfOrderCachedItemForward(const DisplayItem:
:Id&); | 204 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); |
| 205 void copyCachedSubsequence(DisplayItemList::iterator&); | 205 void copyCachedSubsequence(size_t&); |
| 206 | 206 |
| 207 // Resets the iterators (e.g. m_nextItemToMatch) of m_currentPaintArtifact.g
etDisplayItemList() | 207 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.get
DisplayItemList() |
| 208 // to their initial values. This should be called when the DisplayItemList i
n m_currentPaintArtifact | 208 // to their initial values. This should be called when the DisplayItemList i
n m_currentPaintArtifact |
| 209 // is newly created, or is changed causing the previous iterators to be inva
lid. | 209 // is newly created, or is changed causing the previous indices to be invali
d. |
| 210 void resetCurrentListIterators(); | 210 void resetCurrentListIndices(); |
| 211 | 211 |
| 212 #if DCHECK_IS_ON() | 212 #if DCHECK_IS_ON() |
| 213 // The following two methods are for checking under-invalidations | 213 // The following two methods are for checking under-invalidations |
| 214 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). | 214 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). |
| 215 void showUnderInvalidationError(const char* reason, const DisplayItem& newIt
em, const DisplayItem& oldItem) const; | 215 void showUnderInvalidationError(const char* reason, const DisplayItem& newIt
em, const DisplayItem& oldItem) const; |
| 216 void checkUnderInvalidation(); | 216 void checkUnderInvalidation(); |
| 217 bool isCheckingUnderInvalidation() const { return m_underInvalidationCheckin
gEnd - m_underInvalidationCheckingBegin > 0; } | 217 bool isCheckingUnderInvalidation() const { return m_underInvalidationCheckin
gEnd - m_underInvalidationCheckingBegin > 0; } |
| 218 #endif | 218 #endif |
| 219 | 219 |
| 220 // The last complete paint artifact. | 220 // The last complete paint artifact. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 242 | 242 |
| 243 // Stores indices to valid DrawingDisplayItems in current display list that
have not been | 243 // Stores indices to valid DrawingDisplayItems in current display list that
have not been |
| 244 // matched by CachedDisplayItems during sequential matching. The indexed ite
ms will be | 244 // matched by CachedDisplayItems during sequential matching. The indexed ite
ms will be |
| 245 // matched by later out-of-order requests of cached display items. This ensu
res that when | 245 // matched by later out-of-order requests of cached display items. This ensu
res that when |
| 246 // out-of-order cached display items are requested, we only traverse at most
once over | 246 // out-of-order cached display items are requested, we only traverse at most
once over |
| 247 // the current display list looking for potential matches. Thus we can ensur
e that the | 247 // the current display list looking for potential matches. Thus we can ensur
e that the |
| 248 // algorithm runs in linear time. | 248 // algorithm runs in linear time. |
| 249 DisplayItemIndicesByClientMap m_outOfOrderItemIndices; | 249 DisplayItemIndicesByClientMap m_outOfOrderItemIndices; |
| 250 | 250 |
| 251 // The next item in the current list for sequential match. | 251 // The next item in the current list for sequential match. |
| 252 DisplayItemList::iterator m_nextItemToMatch; | 252 size_t m_nextItemToMatch; |
| 253 | 253 |
| 254 // The next item in the current list to be indexed for out-of-order cache re
quests. | 254 // The next item in the current list to be indexed for out-of-order cache re
quests. |
| 255 DisplayItemList::iterator m_nextItemToIndex; | 255 size_t m_nextItemToIndex; |
| 256 | 256 |
| 257 DisplayItemClient::CacheGenerationOrInvalidationReason m_currentCacheGenerat
ion; | 257 DisplayItemClient::CacheGenerationOrInvalidationReason m_currentCacheGenerat
ion; |
| 258 | 258 |
| 259 #if DCHECK_IS_ON() | 259 #if DCHECK_IS_ON() |
| 260 int m_numSequentialMatches; | 260 int m_numSequentialMatches; |
| 261 int m_numOutOfOrderMatches; | 261 int m_numOutOfOrderMatches; |
| 262 int m_numIndexedItems; | 262 int m_numIndexedItems; |
| 263 | 263 |
| 264 // This is used to check duplicated ids during createAndAppend(). | 264 // This is used to check duplicated ids during createAndAppend(). |
| 265 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 265 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
| 266 | 266 |
| 267 // These are set in useCachedDrawingIfPossible() and useCachedSubsequenceIfP
ossible() | 267 // These are set in useCachedDrawingIfPossible() and useCachedSubsequenceIfP
ossible() |
| 268 // when we could use cached drawing or subsequence and under-invalidation ch
ecking is on, | 268 // when we could use cached drawing or subsequence and under-invalidation ch
ecking is on, |
| 269 // indicating the begin and end of the cached drawing or subsequence in the
current list. | 269 // indicating the begin and end of the cached drawing or subsequence in the
current list. |
| 270 // The functions return false to let the client do actual painting, and Pain
tController | 270 // The functions return false to let the client do actual painting, and Pain
tController |
| 271 // will check if the actual painting results are the same as the cached. | 271 // will check if the actual painting results are the same as the cached. |
| 272 DisplayItemList::iterator m_underInvalidationCheckingBegin; | 272 size_t m_underInvalidationCheckingBegin; |
| 273 DisplayItemList::iterator m_underInvalidationCheckingEnd; | 273 size_t m_underInvalidationCheckingEnd; |
| 274 String m_underInvalidationMessagePrefix; | 274 String m_underInvalidationMessagePrefix; |
| 275 #endif | 275 #endif |
| 276 | 276 |
| 277 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 277 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 278 // A stack recording subsequence clients that are currently painting. | 278 // A stack recording subsequence clients that are currently painting. |
| 279 Vector<const DisplayItemClient*> m_currentSubsequenceClients; | 279 Vector<const DisplayItemClient*> m_currentSubsequenceClients; |
| 280 #endif | 280 #endif |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 } // namespace blink | 283 } // namespace blink |
| 284 | 284 |
| 285 #endif // PaintController_h | 285 #endif // PaintController_h |
| OLD | NEW |