Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintController.h

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

Powered by Google App Engine
This is Rietveld 408576698