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

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

Issue 2793233002: Remove begin/end subseq. display items, and store on PaintController instead. (Closed)
Patch Set: none Created 3 years, 8 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 <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include "platform/PlatformExport.h" 10 #include "platform/PlatformExport.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Tries to find the cached drawing display item corresponding to the given 102 // Tries to find the cached drawing display item corresponding to the given
103 // parameters. If found, appends the cached display item to the new display 103 // parameters. If found, appends the cached display item to the new display
104 // list and returns true. Otherwise returns false. 104 // list and returns true. Otherwise returns false.
105 bool useCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type); 105 bool useCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type);
106 106
107 // Tries to find the cached subsequence corresponding to the given parameters. 107 // Tries to find the cached subsequence corresponding to the given parameters.
108 // If found, copies the cache subsequence to the new display list and returns 108 // If found, copies the cache subsequence to the new display list and returns
109 // true. Otherwise returns false. 109 // true. Otherwise returns false.
110 bool useCachedSubsequenceIfPossible(const DisplayItemClient&); 110 bool useCachedSubsequenceIfPossible(const DisplayItemClient&);
111 111
112 void addCachedSubsequence(const DisplayItemClient&,
113 unsigned start,
114 unsigned end);
115
112 // True if the last display item is a begin that doesn't draw content. 116 // True if the last display item is a begin that doesn't draw content.
113 bool lastDisplayItemIsNoopBegin() const;
114 void removeLastDisplayItem(); 117 void removeLastDisplayItem();
115 const DisplayItem* lastDisplayItem(unsigned offset); 118 const DisplayItem* lastDisplayItem(unsigned offset);
116 119
117 void beginSkippingCache() { ++m_skippingCacheCount; } 120 void beginSkippingCache() { ++m_skippingCacheCount; }
118 void endSkippingCache() { 121 void endSkippingCache() {
119 DCHECK(m_skippingCacheCount > 0); 122 DCHECK(m_skippingCacheCount > 0);
120 --m_skippingCacheCount; 123 --m_skippingCacheCount;
121 } 124 }
122 bool isSkippingCache() const { return m_skippingCacheCount; } 125 bool isSkippingCache() const { return m_skippingCacheCount; }
123 126
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return m_usage == ForPaintRecordBuilder; 190 return m_usage == ForPaintRecordBuilder;
188 } 191 }
189 #endif 192 #endif
190 193
191 void setTracksRasterInvalidations(bool value); 194 void setTracksRasterInvalidations(bool value);
192 RasterInvalidationTrackingMap<const PaintChunk>* 195 RasterInvalidationTrackingMap<const PaintChunk>*
193 paintChunksRasterInvalidationTrackingMap() { 196 paintChunksRasterInvalidationTrackingMap() {
194 return m_paintChunksRasterInvalidationTrackingMap.get(); 197 return m_paintChunksRasterInvalidationTrackingMap.get();
195 } 198 }
196 199
200 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
201 void beginShouldKeepAlive(const DisplayItemClient&);
202
203 void beginSubsequence(const DisplayItemClient& client) {
204 m_currentSubsequenceClients.push_back(&client);
205 beginShouldKeepAlive(client);
206 }
207
208 void endSubsequence() { m_currentSubsequenceClients.pop_back(); }
209 #endif
210
197 protected: 211 protected:
198 PaintController() 212 PaintController()
199 : m_newDisplayItemList(0), 213 : m_newDisplayItemList(0),
200 m_constructionDisabled(false), 214 m_constructionDisabled(false),
201 m_subsequenceCachingDisabled(false), 215 m_subsequenceCachingDisabled(false),
202 m_firstPainted(false), 216 m_firstPainted(false),
203 m_textPainted(false), 217 m_textPainted(false),
204 m_imagePainted(false), 218 m_imagePainted(false),
205 m_skippingCacheCount(0), 219 m_skippingCacheCount(0),
206 m_numCachedNewItems(0), 220 m_numCachedNewItems(0),
207 m_currentCachedSubsequenceBeginIndexInNewList(kNotFound) 221 m_currentCachedSubsequenceBeginIndexInNewList(kNotFound),
208 #ifndef NDEBUG 222 #ifndef NDEBUG
209 ,
210 m_numSequentialMatches(0), 223 m_numSequentialMatches(0),
211 m_numOutOfOrderMatches(0), 224 m_numOutOfOrderMatches(0),
212 m_numIndexedItems(0) 225 m_numIndexedItems(0),
213 #endif 226 #endif
214 { 227 m_underInvalidationCheckingBegin(0),
228 m_underInvalidationCheckingEnd(0) {
215 resetCurrentListIndices(); 229 resetCurrentListIndices();
216 setTracksRasterInvalidations( 230 setTracksRasterInvalidations(
217 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()); 231 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled());
218 } 232 }
219 233
220 private: 234 private:
221 friend class PaintControllerTestBase; 235 friend class PaintControllerTestBase;
222 friend class PaintControllerPaintTestBase; 236 friend class PaintControllerPaintTestBase;
223 237
238 bool lastDisplayItemIsNoopBegin() const;
239
224 void ensureNewDisplayItemListInitialCapacity() { 240 void ensureNewDisplayItemListInitialCapacity() {
225 if (m_newDisplayItemList.isEmpty()) { 241 if (m_newDisplayItemList.isEmpty()) {
226 // TODO(wangxianzhu): Consider revisiting this heuristic. 242 // TODO(wangxianzhu): Consider revisiting this heuristic.
227 m_newDisplayItemList = 243 m_newDisplayItemList =
228 DisplayItemList(m_currentPaintArtifact.getDisplayItemList().isEmpty() 244 DisplayItemList(m_currentPaintArtifact.getDisplayItemList().isEmpty()
229 ? kInitialDisplayItemListCapacityBytes 245 ? kInitialDisplayItemListCapacityBytes
230 : m_currentPaintArtifact.getDisplayItemList() 246 : m_currentPaintArtifact.getDisplayItemList()
231 .usedCapacityInBytes()); 247 .usedCapacityInBytes());
232 } 248 }
233 } 249 }
(...skipping 11 matching lines...) Expand all
245 261
246 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, 262 static size_t findMatchingItemFromIndex(const DisplayItem::Id&,
247 const IndicesByClientMap&, 263 const IndicesByClientMap&,
248 const DisplayItemList&); 264 const DisplayItemList&);
249 static void addItemToIndexIfNeeded(const DisplayItem&, 265 static void addItemToIndexIfNeeded(const DisplayItem&,
250 size_t index, 266 size_t index,
251 IndicesByClientMap&); 267 IndicesByClientMap&);
252 268
253 size_t findCachedItem(const DisplayItem::Id&); 269 size_t findCachedItem(const DisplayItem::Id&);
254 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); 270 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&);
255 void copyCachedSubsequence(size_t&); 271 void copyCachedSubsequence(size_t beginIndex, size_t endIndex);
256 272
257 // Resets the indices (e.g. m_nextItemToMatch) of 273 // Resets the indices (e.g. m_nextItemToMatch) of
258 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This 274 // m_currentPaintArtifact.getDisplayItemList() to their initial values. This
259 // should be called when the DisplayItemList in m_currentPaintArtifact is 275 // should be called when the DisplayItemList in m_currentPaintArtifact is
260 // newly created, or is changed causing the previous indices to be invalid. 276 // newly created, or is changed causing the previous indices to be invalid.
261 void resetCurrentListIndices(); 277 void resetCurrentListIndices();
262 278
263 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); 279 void generateChunkRasterInvalidationRects(PaintChunk& newChunk);
264 void generateChunkRasterInvalidationRectsComparingOldChunk( 280 void generateChunkRasterInvalidationRectsComparingOldChunk(
265 PaintChunk& newChunk, 281 PaintChunk& newChunk,
266 const PaintChunk& oldChunk); 282 const PaintChunk& oldChunk);
267 void addRasterInvalidationInfo(const DisplayItemClient*, 283 void addRasterInvalidationInfo(const DisplayItemClient*,
268 PaintChunk&, 284 PaintChunk&,
269 const FloatRect&); 285 const FloatRect&);
270 286
271 // The following two methods are for checking under-invalidations 287 // The following two methods are for checking under-invalidations
272 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). 288 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled).
273 void showUnderInvalidationError(const char* reason, 289 void showUnderInvalidationError(const char* reason,
274 const DisplayItem& newItem, 290 const DisplayItem& newItem,
275 const DisplayItem* oldItem) const; 291 const DisplayItem* oldItem) const;
292
293 void showSequenceUnderInvalidationError(const char* reason,
294 const DisplayItemClient&,
295 int start,
296 int end);
297
276 void checkUnderInvalidation(); 298 void checkUnderInvalidation();
277 bool isCheckingUnderInvalidation() const { 299 bool isCheckingUnderInvalidation() const {
278 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin > 300 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin >
279 0; 301 0;
280 } 302 }
281 303
304 struct SubsequenceMarkers {
305 SubsequenceMarkers() : start(0), end(0) {}
306 SubsequenceMarkers(size_t startArg, size_t endArg)
307 : start(startArg), end(endArg) {}
308 // The start and end index within m_currentPaintArtifact of this
309 // subsequence.
310 size_t start;
311 size_t end;
312 };
313
314 SubsequenceMarkers* getSubsequenceMarkers(const DisplayItemClient&);
315
282 // The last complete paint artifact. 316 // The last complete paint artifact.
283 // In SPv2, this includes paint chunks as well as display items. 317 // In SPv2, this includes paint chunks as well as display items.
284 PaintArtifact m_currentPaintArtifact; 318 PaintArtifact m_currentPaintArtifact;
285 319
286 // Data being used to build the next paint artifact. 320 // Data being used to build the next paint artifact.
287 DisplayItemList m_newDisplayItemList; 321 DisplayItemList m_newDisplayItemList;
288 PaintChunker m_newPaintChunks; 322 PaintChunker m_newPaintChunks;
289 323
290 // Stores indices into m_newDisplayItemList for display items that have been 324 // Stores indices into m_newDisplayItemList for display items that have been
291 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the 325 // moved from m_currentPaintArtifact.getDisplayItemList(), indexed by the
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 int m_skippedProbableUnderInvalidationCount; 405 int m_skippedProbableUnderInvalidationCount;
372 String m_underInvalidationMessagePrefix; 406 String m_underInvalidationMessagePrefix;
373 407
374 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>> 408 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>>
375 m_paintChunksRasterInvalidationTrackingMap; 409 m_paintChunksRasterInvalidationTrackingMap;
376 410
377 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 411 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
378 // A stack recording subsequence clients that are currently painting. 412 // A stack recording subsequence clients that are currently painting.
379 Vector<const DisplayItemClient*> m_currentSubsequenceClients; 413 Vector<const DisplayItemClient*> m_currentSubsequenceClients;
380 #endif 414 #endif
415
416 typedef HashMap<const DisplayItemClient*, SubsequenceMarkers>
417 CachedSubsequenceMap;
418 CachedSubsequenceMap m_currentCachedSubsequences;
419 CachedSubsequenceMap m_newCachedSubsequences;
420
421 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedSubsequenceSwapOrder);
422 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedNestedSubsequenceUpdate);
381 }; 423 };
382 424
383 } // namespace blink 425 } // namespace blink
384 426
385 #endif // PaintController_h 427 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698