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

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

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

Powered by Google App Engine
This is Rietveld 408576698