| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void endItem(Args&&... args) | 82 void endItem(Args&&... args) |
| 83 { | 83 { |
| 84 if (displayItemConstructionIsDisabled()) | 84 if (displayItemConstructionIsDisabled()) |
| 85 return; | 85 return; |
| 86 if (lastDisplayItemIsNoopBegin()) | 86 if (lastDisplayItemIsNoopBegin()) |
| 87 removeLastDisplayItem(); | 87 removeLastDisplayItem(); |
| 88 else | 88 else |
| 89 createAndAppend<DisplayItemClass>(std::forward<Args>(args)...); | 89 createAndAppend<DisplayItemClass>(std::forward<Args>(args)...); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Scopes must be used to avoid duplicated display item ids when we paint so
me object | |
| 93 // multiple times and generate multiple display items with the same type. | |
| 94 // We don't cache display items added in scopes. | |
| 95 void beginScope(); | |
| 96 void endScope(); | |
| 97 | |
| 98 // True if the last display item is a begin that doesn't draw content. | 92 // True if the last display item is a begin that doesn't draw content. |
| 99 bool lastDisplayItemIsNoopBegin() const; | 93 bool lastDisplayItemIsNoopBegin() const; |
| 100 void removeLastDisplayItem(); | 94 void removeLastDisplayItem(); |
| 101 | 95 |
| 102 void beginSkippingCache() { ++m_skippingCacheCount; } | 96 void beginSkippingCache() { ++m_skippingCacheCount; } |
| 103 void endSkippingCache() { DCHECK(m_skippingCacheCount > 0); --m_skippingCach
eCount; } | 97 void endSkippingCache() { DCHECK(m_skippingCacheCount > 0); --m_skippingCach
eCount; } |
| 104 bool skippingCache() const { return m_skippingCacheCount; } | 98 bool skippingCache() const { return m_skippingCacheCount; } |
| 105 | 99 |
| 106 // Must be called when a painting is finished. | 100 // Must be called when a painting is finished. |
| 107 // offsetFromLayoutObject is the offset between the space of the GraphicsLay
er which owns this | 101 // offsetFromLayoutObject is the offset between the space of the GraphicsLay
er which owns this |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 148 |
| 155 protected: | 149 protected: |
| 156 PaintController() | 150 PaintController() |
| 157 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) | 151 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) |
| 158 , m_constructionDisabled(false) | 152 , m_constructionDisabled(false) |
| 159 , m_subsequenceCachingDisabled(false) | 153 , m_subsequenceCachingDisabled(false) |
| 160 , m_textPainted(false) | 154 , m_textPainted(false) |
| 161 , m_imagePainted(false) | 155 , m_imagePainted(false) |
| 162 , m_skippingCacheCount(0) | 156 , m_skippingCacheCount(0) |
| 163 , m_numCachedNewItems(0) | 157 , m_numCachedNewItems(0) |
| 164 , m_nextScope(1) | |
| 165 { } | 158 { } |
| 166 | 159 |
| 167 private: | 160 private: |
| 168 // Set new item state (scopes, cache skipping, etc) for a new item. | 161 // Set new item state (cache skipping, etc) for a new item. |
| 169 void processNewItem(DisplayItem&); | 162 void processNewItem(DisplayItem&); |
| 170 | 163 |
| 171 #ifndef NDEBUG | 164 #ifndef NDEBUG |
| 172 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; | 165 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; |
| 173 #endif | 166 #endif |
| 174 | 167 |
| 175 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. | 168 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. |
| 176 // Temporarily used during merge to find out-of-order display items. | 169 // Temporarily used during merge to find out-of-order display items. |
| 177 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; | 170 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; |
| 178 | 171 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 bool m_subsequenceCachingDisabled; | 209 bool m_subsequenceCachingDisabled; |
| 217 | 210 |
| 218 // Indicates this PaintController has ever had text. It is never reset to fa
lse. | 211 // Indicates this PaintController has ever had text. It is never reset to fa
lse. |
| 219 bool m_textPainted; | 212 bool m_textPainted; |
| 220 bool m_imagePainted; | 213 bool m_imagePainted; |
| 221 | 214 |
| 222 int m_skippingCacheCount; | 215 int m_skippingCacheCount; |
| 223 | 216 |
| 224 int m_numCachedNewItems; | 217 int m_numCachedNewItems; |
| 225 | 218 |
| 226 unsigned m_nextScope; | |
| 227 Vector<unsigned> m_scopeStack; | |
| 228 | |
| 229 #if DCHECK_IS_ON() | 219 #if DCHECK_IS_ON() |
| 230 // Record the debug names of invalidated clients for assertion and debugging
. | 220 // Record the debug names of invalidated clients for assertion and debugging
. |
| 231 Vector<String> m_invalidations; | 221 Vector<String> m_invalidations; |
| 232 | 222 |
| 233 // This is used to check duplicated ids during add(). We could also check | 223 // This is used to check duplicated ids during add(). We could also check |
| 234 // during commitNewDisplayItems(), but checking during add() helps developer | 224 // during commitNewDisplayItems(), but checking during add() helps developer |
| 235 // easily find where the duplicated ids are from. | 225 // easily find where the duplicated ids are from. |
| 236 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 226 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
| 237 #endif | 227 #endif |
| 238 | 228 |
| 239 DisplayItemCacheGeneration m_currentCacheGeneration; | 229 DisplayItemCacheGeneration m_currentCacheGeneration; |
| 240 }; | 230 }; |
| 241 | 231 |
| 242 } // namespace blink | 232 } // namespace blink |
| 243 | 233 |
| 244 #endif // PaintController_h | 234 #endif // PaintController_h |
| OLD | NEW |