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