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

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

Issue 2380683006: SPv2: Add support for tracking raster paint invalidations in testing. (Closed)
Patch Set: none Created 4 years, 2 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"
11 #include "platform/geometry/LayoutPoint.h" 11 #include "platform/geometry/LayoutPoint.h"
12 #include "platform/graphics/ContiguousContainer.h" 12 #include "platform/graphics/ContiguousContainer.h"
13 #include "platform/graphics/paint/DisplayItem.h" 13 #include "platform/graphics/paint/DisplayItem.h"
14 #include "platform/graphics/paint/DisplayItemList.h" 14 #include "platform/graphics/paint/DisplayItemList.h"
15 #include "platform/graphics/paint/PaintArtifact.h" 15 #include "platform/graphics/paint/PaintArtifact.h"
16 #include "platform/graphics/paint/PaintChunk.h" 16 #include "platform/graphics/paint/PaintChunk.h"
17 #include "platform/graphics/paint/PaintChunker.h" 17 #include "platform/graphics/paint/PaintChunker.h"
18 #include "platform/graphics/paint/RasterInvalidationTracking.h"
18 #include "platform/graphics/paint/Transform3DDisplayItem.h" 19 #include "platform/graphics/paint/Transform3DDisplayItem.h"
19 #include "third_party/skia/include/core/SkRefCnt.h" 20 #include "third_party/skia/include/core/SkRefCnt.h"
20 #include "wtf/Alignment.h" 21 #include "wtf/Alignment.h"
21 #include "wtf/Assertions.h" 22 #include "wtf/Assertions.h"
22 #include "wtf/HashMap.h" 23 #include "wtf/HashMap.h"
23 #include "wtf/HashSet.h" 24 #include "wtf/HashSet.h"
24 #include "wtf/PtrUtil.h" 25 #include "wtf/PtrUtil.h"
25 #include "wtf/Vector.h" 26 #include "wtf/Vector.h"
26 #include <memory> 27 #include <memory>
27 #include <utility> 28 #include <utility>
28 29
29 class SkPicture; 30 class SkPicture;
30 31
31 namespace blink { 32 namespace blink {
32 33
33 class GraphicsContext; 34 class GraphicsContext;
34 35
35 static const size_t kInitialDisplayItemListCapacityBytes = 512; 36 static const size_t kInitialDisplayItemListCapacityBytes = 512;
36 37
38 template class RasterInvalidationTrackingMap<const PaintChunk>;
39
37 // Responsible for processing display items as they are produced, and producing 40 // Responsible for processing display items as they are produced, and producing
38 // a final paint artifact when complete. This class includes logic for caching, 41 // a final paint artifact when complete. This class includes logic for caching,
39 // cache invalidation, and merging. 42 // cache invalidation, and merging.
40 class PLATFORM_EXPORT PaintController { 43 class PLATFORM_EXPORT PaintController {
41 WTF_MAKE_NONCOPYABLE(PaintController); 44 WTF_MAKE_NONCOPYABLE(PaintController);
42 USING_FAST_MALLOC(PaintController); 45 USING_FAST_MALLOC(PaintController);
43 public: 46 public:
44 static std::unique_ptr<PaintController> create() 47 static std::unique_ptr<PaintController> create()
45 { 48 {
46 return wrapUnique(new PaintController()); 49 return wrapUnique(new PaintController());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 155
153 void showDebugData() const { showDebugDataInternal(false); } 156 void showDebugData() const { showDebugDataInternal(false); }
154 #ifndef NDEBUG 157 #ifndef NDEBUG
155 void showDebugDataWithPictures() const { showDebugDataInternal(true); } 158 void showDebugDataWithPictures() const { showDebugDataInternal(true); }
156 #endif 159 #endif
157 160
158 #if DCHECK_IS_ON() 161 #if DCHECK_IS_ON()
159 void assertDisplayItemClientsAreLive(); 162 void assertDisplayItemClientsAreLive();
160 #endif 163 #endif
161 164
165 void setTracksRasterInvalidations(bool value);
166 RasterInvalidationTrackingMap<const PaintChunk>* paintChunksRasterInvalidati onTrackingMap() { return m_paintChunksRasterInvalidationTrackingMap.get(); }
167
162 protected: 168 protected:
163 PaintController() 169 PaintController()
164 : m_newDisplayItemList(0) 170 : m_newDisplayItemList(0)
165 , m_constructionDisabled(false) 171 , m_constructionDisabled(false)
166 , m_subsequenceCachingDisabled(false) 172 , m_subsequenceCachingDisabled(false)
167 , m_textPainted(false) 173 , m_textPainted(false)
168 , m_imagePainted(false) 174 , m_imagePainted(false)
169 , m_skippingCacheCount(0) 175 , m_skippingCacheCount(0)
170 , m_numCachedNewItems(0) 176 , m_numCachedNewItems(0)
171 , m_currentCachedSubsequenceBeginIndexInNewList(kNotFound) 177 , m_currentCachedSubsequenceBeginIndexInNewList(kNotFound)
172 #ifndef NDEBUG 178 #ifndef NDEBUG
173 , m_numSequentialMatches(0) 179 , m_numSequentialMatches(0)
174 , m_numOutOfOrderMatches(0) 180 , m_numOutOfOrderMatches(0)
175 , m_numIndexedItems(0) 181 , m_numIndexedItems(0)
176 #endif 182 #endif
177 { 183 {
178 resetCurrentListIndices(); 184 resetCurrentListIndices();
185 setTracksRasterInvalidations(RuntimeEnabledFeatures::paintUnderInvalidat ionCheckingEnabled());
179 } 186 }
180 187
181 private: 188 private:
182 friend class PaintControllerTestBase; 189 friend class PaintControllerTestBase;
183 friend class PaintControllerPaintTestBase; 190 friend class PaintControllerPaintTestBase;
184 191
185 void ensureNewDisplayItemListInitialCapacity() 192 void ensureNewDisplayItemListInitialCapacity()
186 { 193 {
187 if (m_newDisplayItemList.isEmpty()) { 194 if (m_newDisplayItemList.isEmpty()) {
188 // TODO(wangxianzhu): Consider revisiting this heuristic. 195 // TODO(wangxianzhu): Consider revisiting this heuristic.
(...skipping 18 matching lines...) Expand all
207 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&); 214 size_t findOutOfOrderCachedItemForward(const DisplayItem::Id&);
208 void copyCachedSubsequence(size_t&); 215 void copyCachedSubsequence(size_t&);
209 216
210 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.get DisplayItemList() 217 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.get DisplayItemList()
211 // to their initial values. This should be called when the DisplayItemList i n m_currentPaintArtifact 218 // to their initial values. This should be called when the DisplayItemList i n m_currentPaintArtifact
212 // is newly created, or is changed causing the previous indices to be invali d. 219 // is newly created, or is changed causing the previous indices to be invali d.
213 void resetCurrentListIndices(); 220 void resetCurrentListIndices();
214 221
215 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); 222 void generateChunkRasterInvalidationRects(PaintChunk& newChunk);
216 void generateChunkRasterInvalidationRectsComparingOldChunk(PaintChunk& newCh unk, const PaintChunk& oldChunk); 223 void generateChunkRasterInvalidationRectsComparingOldChunk(PaintChunk& newCh unk, const PaintChunk& oldChunk);
224 void addRasterInvalidationInfo(const DisplayItemClient*, PaintChunk&, const FloatRect&);
217 225
218 // The following two methods are for checking under-invalidations 226 // The following two methods are for checking under-invalidations
219 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). 227 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled).
220 void showUnderInvalidationError(const char* reason, const DisplayItem& newIt em, const DisplayItem* oldItem) const; 228 void showUnderInvalidationError(const char* reason, const DisplayItem& newIt em, const DisplayItem* oldItem) const;
221 void checkUnderInvalidation(); 229 void checkUnderInvalidation();
222 bool isCheckingUnderInvalidation() const { return m_underInvalidationCheckin gEnd - m_underInvalidationCheckingBegin > 0; } 230 bool isCheckingUnderInvalidation() const { return m_underInvalidationCheckin gEnd - m_underInvalidationCheckingBegin > 0; }
223 231
224 // The last complete paint artifact. 232 // The last complete paint artifact.
225 // In SPv2, this includes paint chunks as well as display items. 233 // In SPv2, this includes paint chunks as well as display items.
226 PaintArtifact m_currentPaintArtifact; 234 PaintArtifact m_currentPaintArtifact;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 271
264 // The next item in the current list to be indexed for out-of-order cache re quests. 272 // The next item in the current list to be indexed for out-of-order cache re quests.
265 size_t m_nextItemToIndex; 273 size_t m_nextItemToIndex;
266 274
267 // Similar to m_outOfOrderItemIndices but 275 // Similar to m_outOfOrderItemIndices but
268 // - the indices are chunk indices in m_currentPaintArtifacts.paintChunks(); 276 // - the indices are chunk indices in m_currentPaintArtifacts.paintChunks();
269 // - chunks are matched not only for requests of cached display items, but a lso non-cached display items. 277 // - chunks are matched not only for requests of cached display items, but a lso non-cached display items.
270 IndicesByClientMap m_outOfOrderChunkIndices; 278 IndicesByClientMap m_outOfOrderChunkIndices;
271 279
272 size_t m_currentCachedSubsequenceBeginIndexInNewList; 280 size_t m_currentCachedSubsequenceBeginIndexInNewList;
281 bool m_isTrackingPaintInvalidations;
Xianzhu 2016/09/30 19:04:30 Nit: This seems not used.
chrishtr 2016/09/30 21:04:16 Fixed.
273 size_t m_nextChunkToMatch; 282 size_t m_nextChunkToMatch;
274 283
275 DisplayItemClient::CacheGenerationOrInvalidationReason m_currentCacheGenerat ion; 284 DisplayItemClient::CacheGenerationOrInvalidationReason m_currentCacheGenerat ion;
276 285
277 #ifndef NDEBUG 286 #ifndef NDEBUG
278 int m_numSequentialMatches; 287 int m_numSequentialMatches;
279 int m_numOutOfOrderMatches; 288 int m_numOutOfOrderMatches;
280 int m_numIndexedItems; 289 int m_numIndexedItems;
281 #endif 290 #endif
282 291
283 #if DCHECK_IS_ON() 292 #if DCHECK_IS_ON()
284 // This is used to check duplicated ids during createAndAppend(). 293 // This is used to check duplicated ids during createAndAppend().
285 IndicesByClientMap m_newDisplayItemIndicesByClient; 294 IndicesByClientMap m_newDisplayItemIndicesByClient;
286 #endif 295 #endif
287 296
288 // These are set in useCachedDrawingIfPossible() and useCachedSubsequenceIfP ossible() 297 // These are set in useCachedDrawingIfPossible() and useCachedSubsequenceIfP ossible()
289 // when we could use cached drawing or subsequence and under-invalidation ch ecking is on, 298 // when we could use cached drawing or subsequence and under-invalidation ch ecking is on,
290 // indicating the begin and end of the cached drawing or subsequence in the current list. 299 // indicating the begin and end of the cached drawing or subsequence in the current list.
291 // The functions return false to let the client do actual painting, and Pain tController 300 // The functions return false to let the client do actual painting, and Pain tController
292 // will check if the actual painting results are the same as the cached. 301 // will check if the actual painting results are the same as the cached.
293 size_t m_underInvalidationCheckingBegin; 302 size_t m_underInvalidationCheckingBegin;
294 size_t m_underInvalidationCheckingEnd; 303 size_t m_underInvalidationCheckingEnd;
295 // Number of probable under-invalidations that have been skipped temporarily because the 304 // Number of probable under-invalidations that have been skipped temporarily because the
296 // mismatching display items may be removed in the future because of no-op p airs or 305 // mismatching display items may be removed in the future because of no-op p airs or
297 // compositing folding. 306 // compositing folding.
298 int m_skippedProbableUnderInvalidationCount; 307 int m_skippedProbableUnderInvalidationCount;
299 String m_underInvalidationMessagePrefix; 308 String m_underInvalidationMessagePrefix;
300 309
310 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>> m_paintChun ksRasterInvalidationTrackingMap;
311
301 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 312 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
302 // A stack recording subsequence clients that are currently painting. 313 // A stack recording subsequence clients that are currently painting.
303 Vector<const DisplayItemClient*> m_currentSubsequenceClients; 314 Vector<const DisplayItemClient*> m_currentSubsequenceClients;
304 #endif 315 #endif
305 }; 316 };
306 317
307 } // namespace blink 318 } // namespace blink
308 319
309 #endif // PaintController_h 320 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698