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

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 46
44 public: 47 public:
45 static std::unique_ptr<PaintController> create() { 48 static std::unique_ptr<PaintController> create() {
46 return wrapUnique(new PaintController()); 49 return wrapUnique(new PaintController());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 174
172 void showDebugData() const { showDebugDataInternal(false); } 175 void showDebugData() const { showDebugDataInternal(false); }
173 #ifndef NDEBUG 176 #ifndef NDEBUG
174 void showDebugDataWithPictures() const { showDebugDataInternal(true); } 177 void showDebugDataWithPictures() const { showDebugDataInternal(true); }
175 #endif 178 #endif
176 179
177 #if DCHECK_IS_ON() 180 #if DCHECK_IS_ON()
178 void assertDisplayItemClientsAreLive(); 181 void assertDisplayItemClientsAreLive();
179 #endif 182 #endif
180 183
184 void setTracksRasterInvalidations(bool value);
185 RasterInvalidationTrackingMap<const PaintChunk>*
186 paintChunksRasterInvalidationTrackingMap() {
187 return m_paintChunksRasterInvalidationTrackingMap.get();
188 }
189
181 protected: 190 protected:
182 PaintController() 191 PaintController()
183 : m_newDisplayItemList(0), 192 : m_newDisplayItemList(0),
184 m_constructionDisabled(false), 193 m_constructionDisabled(false),
185 m_subsequenceCachingDisabled(false), 194 m_subsequenceCachingDisabled(false),
186 m_textPainted(false), 195 m_textPainted(false),
187 m_imagePainted(false), 196 m_imagePainted(false),
188 m_skippingCacheCount(0), 197 m_skippingCacheCount(0),
189 m_numCachedNewItems(0), 198 m_numCachedNewItems(0),
190 m_currentCachedSubsequenceBeginIndexInNewList(kNotFound) 199 m_currentCachedSubsequenceBeginIndexInNewList(kNotFound)
191 #ifndef NDEBUG 200 #ifndef NDEBUG
192 , 201 ,
193 m_numSequentialMatches(0), 202 m_numSequentialMatches(0),
194 m_numOutOfOrderMatches(0), 203 m_numOutOfOrderMatches(0),
195 m_numIndexedItems(0) 204 m_numIndexedItems(0)
196 #endif 205 #endif
197 { 206 {
198 resetCurrentListIndices(); 207 resetCurrentListIndices();
208 setTracksRasterInvalidations(
209 RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled());
199 } 210 }
200 211
201 private: 212 private:
202 friend class PaintControllerTestBase; 213 friend class PaintControllerTestBase;
203 friend class PaintControllerPaintTestBase; 214 friend class PaintControllerPaintTestBase;
204 215
205 void ensureNewDisplayItemListInitialCapacity() { 216 void ensureNewDisplayItemListInitialCapacity() {
206 if (m_newDisplayItemList.isEmpty()) { 217 if (m_newDisplayItemList.isEmpty()) {
207 // TODO(wangxianzhu): Consider revisiting this heuristic. 218 // TODO(wangxianzhu): Consider revisiting this heuristic.
208 m_newDisplayItemList = 219 m_newDisplayItemList =
(...skipping 28 matching lines...) Expand all
237 248
238 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.getDi splayItemList() 249 // Resets the indices (e.g. m_nextItemToMatch) of m_currentPaintArtifact.getDi splayItemList()
239 // to their initial values. This should be called when the DisplayItemList in m_currentPaintArtifact 250 // to their initial values. This should be called when the DisplayItemList in m_currentPaintArtifact
240 // is newly created, or is changed causing the previous indices to be invalid. 251 // is newly created, or is changed causing the previous indices to be invalid.
241 void resetCurrentListIndices(); 252 void resetCurrentListIndices();
242 253
243 void generateChunkRasterInvalidationRects(PaintChunk& newChunk); 254 void generateChunkRasterInvalidationRects(PaintChunk& newChunk);
244 void generateChunkRasterInvalidationRectsComparingOldChunk( 255 void generateChunkRasterInvalidationRectsComparingOldChunk(
245 PaintChunk& newChunk, 256 PaintChunk& newChunk,
246 const PaintChunk& oldChunk); 257 const PaintChunk& oldChunk);
258 void addRasterInvalidationInfo(const DisplayItemClient*,
259 PaintChunk&,
260 const FloatRect&);
247 261
248 // The following two methods are for checking under-invalidations 262 // The following two methods are for checking under-invalidations
249 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled). 263 // (when RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled).
250 void showUnderInvalidationError(const char* reason, 264 void showUnderInvalidationError(const char* reason,
251 const DisplayItem& newItem, 265 const DisplayItem& newItem,
252 const DisplayItem* oldItem) const; 266 const DisplayItem* oldItem) const;
253 void checkUnderInvalidation(); 267 void checkUnderInvalidation();
254 bool isCheckingUnderInvalidation() const { 268 bool isCheckingUnderInvalidation() const {
255 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin > 269 return m_underInvalidationCheckingEnd - m_underInvalidationCheckingBegin >
256 0; 270 0;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // The functions return false to let the client do actual painting, and PaintC ontroller 341 // The functions return false to let the client do actual painting, and PaintC ontroller
328 // will check if the actual painting results are the same as the cached. 342 // will check if the actual painting results are the same as the cached.
329 size_t m_underInvalidationCheckingBegin; 343 size_t m_underInvalidationCheckingBegin;
330 size_t m_underInvalidationCheckingEnd; 344 size_t m_underInvalidationCheckingEnd;
331 // Number of probable under-invalidations that have been skipped temporarily b ecause the 345 // Number of probable under-invalidations that have been skipped temporarily b ecause the
332 // mismatching display items may be removed in the future because of no-op pai rs or 346 // mismatching display items may be removed in the future because of no-op pai rs or
333 // compositing folding. 347 // compositing folding.
334 int m_skippedProbableUnderInvalidationCount; 348 int m_skippedProbableUnderInvalidationCount;
335 String m_underInvalidationMessagePrefix; 349 String m_underInvalidationMessagePrefix;
336 350
351 std::unique_ptr<RasterInvalidationTrackingMap<const PaintChunk>>
352 m_paintChunksRasterInvalidationTrackingMap;
353
337 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 354 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
338 // A stack recording subsequence clients that are currently painting. 355 // A stack recording subsequence clients that are currently painting.
339 Vector<const DisplayItemClient*> m_currentSubsequenceClients; 356 Vector<const DisplayItemClient*> m_currentSubsequenceClients;
340 #endif 357 #endif
341 }; 358 };
342 359
343 } // namespace blink 360 } // namespace blink
344 361
345 #endif // PaintController_h 362 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698