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 |
166 #if ENABLE(ASSERT) | 175 #if ENABLE(ASSERT) |
167 void assertDisplayItemClientsAreLive(); | 176 void assertDisplayItemClientsAreLive(); |
168 #endif | 177 #endif |
169 | 178 |
170 protected: | 179 protected: |
171 PaintController() | 180 PaintController() |
172 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) | 181 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) |
| 182 , m_validlyCachedClientsDirty(false) |
173 , m_constructionDisabled(false) | 183 , m_constructionDisabled(false) |
174 , m_subsequenceCachingDisabled(false) | 184 , m_subsequenceCachingDisabled(false) |
175 , m_textPainted(false) | 185 , m_textPainted(false) |
176 , m_imagePainted(false) | 186 , m_imagePainted(false) |
177 , m_skippingCacheCount(0) | 187 , m_skippingCacheCount(0) |
178 , m_numCachedNewItems(0) | 188 , m_numCachedNewItems(0) |
179 , m_nextScope(1) | 189 , m_nextScope(1) { } |
180 { } | |
181 | 190 |
182 private: | 191 private: |
183 // Set new item state (scopes, cache skipping, etc) for a new item. | 192 // Set new item state (scopes, cache skipping, etc) for a new item. |
184 void processNewItem(DisplayItem&); | 193 void processNewItem(DisplayItem&); |
185 | 194 |
| 195 void updateValidlyCachedClientsIfNeeded() const; |
| 196 |
186 #ifndef NDEBUG | 197 #ifndef NDEBUG |
187 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; | 198 WTF::String displayItemListAsDebugString(const DisplayItemList&) const; |
188 #endif | 199 #endif |
189 | 200 |
190 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. | 201 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. |
191 // Temporarily used during merge to find out-of-order display items. | 202 // Temporarily used during merge to find out-of-order display items. |
192 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; | 203 using DisplayItemIndicesByClientMap = HashMap<const DisplayItemClient*, Vect
or<size_t>>; |
193 | 204 |
194 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItemList&); | 205 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItemList&); |
195 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); | 206 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); |
196 | 207 |
197 struct OutOfOrderIndexContext; | 208 struct OutOfOrderIndexContext; |
198 DisplayItemList::iterator findOutOfOrderCachedItem(const DisplayItem::Id&, O
utOfOrderIndexContext&); | 209 DisplayItemList::iterator findOutOfOrderCachedItem(const DisplayItem::Id&, O
utOfOrderIndexContext&); |
199 DisplayItemList::iterator findOutOfOrderCachedItemForward(const DisplayItem:
:Id&, OutOfOrderIndexContext&); | 210 DisplayItemList::iterator findOutOfOrderCachedItemForward(const DisplayItem:
:Id&, OutOfOrderIndexContext&); |
200 void copyCachedSubsequence(const DisplayItemList& currentList, DisplayItemLi
st::iterator& currentIt, DisplayItemList& updatedList); | 211 void copyCachedSubsequence(const DisplayItemList& currentList, DisplayItemLi
st::iterator& currentIt, DisplayItemList& updatedList); |
201 | 212 |
202 #if ENABLE(ASSERT) | 213 #if ENABLE(ASSERT) |
203 // The following two methods are for checking under-invalidations | 214 // The following two methods are for checking under-invalidations |
204 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). | 215 // (when RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabl
ed). |
205 void checkUnderInvalidation(DisplayItemList::iterator& newIt, DisplayItemLis
t::iterator& currentIt); | 216 void checkUnderInvalidation(DisplayItemList::iterator& newIt, DisplayItemLis
t::iterator& currentIt); |
206 void checkCachedDisplayItemIsUnchanged(const char* messagePrefix, const Disp
layItem& newItem, const DisplayItem& oldItem); | 217 void checkCachedDisplayItemIsUnchanged(const char* messagePrefix, const Disp
layItem& newItem, const DisplayItem& oldItem); |
207 void checkNoRemainingCachedDisplayItems(); | 218 void checkNoRemainingCachedDisplayItems(); |
208 #endif | 219 #endif |
209 | 220 |
210 void commitNewDisplayItemsInternal(const LayoutSize& offsetFromLayoutObject)
; | 221 void commitNewDisplayItemsInternal(const LayoutSize& offsetFromLayoutObject)
; |
211 | 222 |
212 void updateCacheGeneration(); | |
213 | |
214 // The last complete paint artifact. | 223 // The last complete paint artifact. |
215 // In SPv2, this includes paint chunks as well as display items. | 224 // In SPv2, this includes paint chunks as well as display items. |
216 PaintArtifact m_currentPaintArtifact; | 225 PaintArtifact m_currentPaintArtifact; |
217 | 226 |
218 // Data being used to build the next paint artifact. | 227 // Data being used to build the next paint artifact. |
219 DisplayItemList m_newDisplayItemList; | 228 DisplayItemList m_newDisplayItemList; |
220 PaintChunker m_newPaintChunks; | 229 PaintChunker m_newPaintChunks; |
221 | 230 |
| 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 |
222 #if ENABLE(ASSERT) | 243 #if ENABLE(ASSERT) |
223 // Set of clients which had paint offset changes since the last commit. This
is used for | 244 // Set of clients which had paint offset changes since the last commit. This
is used for |
224 // ensuring paint offsets are only updated once and are the same in all phas
es. | 245 // ensuring paint offsets are only updated once and are the same in all phas
es. |
225 HashSet<const DisplayItemClient*> m_clientsWithPaintOffsetInvalidations; | 246 HashSet<const DisplayItemClient*> m_clientsWithPaintOffsetInvalidations; |
226 #endif | 247 #endif |
227 | 248 |
228 // Allow display item construction to be disabled to isolate the costs of co
nstruction | 249 // Allow display item construction to be disabled to isolate the costs of co
nstruction |
229 // in performance metrics. | 250 // in performance metrics. |
230 bool m_constructionDisabled; | 251 bool m_constructionDisabled; |
231 | 252 |
(...skipping 15 matching lines...) Expand all Loading... |
247 // Record the debug names of invalidated clients for assertion and debugging
. | 268 // Record the debug names of invalidated clients for assertion and debugging
. |
248 Vector<String> m_invalidations; | 269 Vector<String> m_invalidations; |
249 | 270 |
250 // This is used to check duplicated ids during add(). We could also check | 271 // This is used to check duplicated ids during add(). We could also check |
251 // during commitNewDisplayItems(), but checking during add() helps developer | 272 // during commitNewDisplayItems(), but checking during add() helps developer |
252 // easily find where the duplicated ids are from. | 273 // easily find where the duplicated ids are from. |
253 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 274 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
254 #endif | 275 #endif |
255 | 276 |
256 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 277 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
257 | |
258 DisplayItemCacheGeneration m_currentCacheGeneration; | |
259 }; | 278 }; |
260 | 279 |
261 } // namespace blink | 280 } // namespace blink |
262 | 281 |
263 #endif // PaintController_h | 282 #endif // PaintController_h |
OLD | NEW |