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

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

Issue 1416053003: Let synchronized painting generate correct paint invalidation rects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For landing Created 5 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/PaintInvalidationReason.h" 13 #include "platform/graphics/PaintInvalidationReason.h"
14 #include "platform/graphics/paint/DisplayItem.h" 14 #include "platform/graphics/paint/DisplayItem.h"
15 #include "platform/graphics/paint/DisplayItemList.h" 15 #include "platform/graphics/paint/DisplayItemList.h"
16 #include "platform/graphics/paint/PaintArtifact.h" 16 #include "platform/graphics/paint/PaintArtifact.h"
17 #include "platform/graphics/paint/PaintChunk.h" 17 #include "platform/graphics/paint/PaintChunk.h"
18 #include "platform/graphics/paint/PaintChunker.h" 18 #include "platform/graphics/paint/PaintChunker.h"
19 #include "platform/graphics/paint/Transform3DDisplayItem.h" 19 #include "platform/graphics/paint/Transform3DDisplayItem.h"
20 #include "wtf/Alignment.h" 20 #include "wtf/Alignment.h"
21 #include "wtf/HashMap.h" 21 #include "wtf/HashMap.h"
22 #include "wtf/PassOwnPtr.h" 22 #include "wtf/PassOwnPtr.h"
23 #include "wtf/Utility.h" 23 #include "wtf/Utility.h"
24 #include "wtf/Vector.h" 24 #include "wtf/Vector.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 class GraphicsLayer;
29 class GraphicsContext; 28 class GraphicsContext;
30 29
31 static const size_t kInitialDisplayItemListCapacityBytes = 512; 30 static const size_t kInitialDisplayItemListCapacityBytes = 512;
32 31
33 // Responsible for processing display items as they are produced, and producing 32 // Responsible for processing display items as they are produced, and producing
34 // a final paint artifact when complete. This class includes logic for caching, 33 // a final paint artifact when complete. This class includes logic for caching,
35 // cache invalidation, and merging. 34 // cache invalidation, and merging.
36 class PLATFORM_EXPORT PaintController { 35 class PLATFORM_EXPORT PaintController {
37 WTF_MAKE_NONCOPYABLE(PaintController); 36 WTF_MAKE_NONCOPYABLE(PaintController);
38 WTF_MAKE_FAST_ALLOCATED(PaintController); 37 WTF_MAKE_FAST_ALLOCATED(PaintController);
39 public: 38 public:
40 static PassOwnPtr<PaintController> create() 39 static PassOwnPtr<PaintController> create()
41 { 40 {
42 return adoptPtr(new PaintController()); 41 return adoptPtr(new PaintController());
43 } 42 }
44 43
45 // These methods are called during paint invalidation (or paint if SlimmingP aintSynchronizedPainting is on). 44 // These methods are called during paint invalidation (or paint if SlimmingP aintV2 is on).
46 void invalidate(const DisplayItemClientWrapper&, PaintInvalidationReason, co nst IntRect& previousPaintInvalidationRect, const IntRect& newPaintInvalidationR ect); 45
46 // If |visualRect| is not nullptr, for slimming paint v1, it contains all pi xels within the GraphicsLayer
47 // which might be painted into by the display item client, in coordinate spa ce of the GraphicsLayer.
48 // TODO(pdr): define it for spv2.
49 // |visualRect| can be nullptr if we know it's unchanged and PaintController has cached the previous value.
50 void invalidate(const DisplayItemClientWrapper&, PaintInvalidationReason, co nst IntRect* visualRect);
47 void invalidateUntracked(DisplayItemClient); 51 void invalidateUntracked(DisplayItemClient);
48 void invalidateAll(); 52 void invalidateAll();
49 53
50 // Record when paint offsets change during paint. 54 // Record when paint offsets change during paint.
51 void invalidatePaintOffset(const DisplayItemClientWrapper&); 55 void invalidatePaintOffset(const DisplayItemClientWrapper&);
52 #if ENABLE(ASSERT) 56 #if ENABLE(ASSERT)
53 bool paintOffsetWasInvalidated(DisplayItemClient) const; 57 bool paintOffsetWasInvalidated(DisplayItemClient) const;
54 #endif 58 #endif
55 59
56 // These methods are called during painting. 60 // These methods are called during painting.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void endScope(); 100 void endScope();
97 101
98 // True if the last display item is a begin that doesn't draw content. 102 // True if the last display item is a begin that doesn't draw content.
99 bool lastDisplayItemIsNoopBegin() const; 103 bool lastDisplayItemIsNoopBegin() const;
100 void removeLastDisplayItem(); 104 void removeLastDisplayItem();
101 105
102 void beginSkippingCache() { ++m_skippingCacheCount; } 106 void beginSkippingCache() { ++m_skippingCacheCount; }
103 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; } 107 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; }
104 bool skippingCache() const { return m_skippingCacheCount; } 108 bool skippingCache() const { return m_skippingCacheCount; }
105 109
106 // Must be called when a painting is finished. If passed, invalidations are recorded on the given 110 // Must be called when a painting is finished.
107 // GraphicsLayer. 111 void commitNewDisplayItems();
108 void commitNewDisplayItems(GraphicsLayer* = nullptr);
109 112
110 // Returns the approximate memory usage, excluding memory likely to be 113 // Returns the approximate memory usage, excluding memory likely to be
111 // shared with the embedder after copying to WebPaintController. 114 // shared with the embedder after copying to WebPaintController.
112 // Should only be called right after commitNewDisplayItems. 115 // Should only be called right after commitNewDisplayItems.
113 size_t approximateUnsharedMemoryUsage() const; 116 size_t approximateUnsharedMemoryUsage() const;
114 117
115 // Get the artifact generated after the last commit. 118 // Get the artifact generated after the last commit.
116 const PaintArtifact& paintArtifact() const; 119 const PaintArtifact& paintArtifact() const;
117 const DisplayItemList& displayItemList() const { return paintArtifact().disp layItemList(); } 120 const DisplayItemList& displayItemList() const { return paintArtifact().disp layItemList(); }
118 const Vector<PaintChunk>& paintChunks() const { return paintArtifact().paint Chunks(); } 121 const Vector<PaintChunk>& paintChunks() const { return paintArtifact().paint Chunks(); }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Indicates this PaintController has ever had text. It is never reset to fa lse. 238 // Indicates this PaintController has ever had text. It is never reset to fa lse.
236 bool m_textPainted; 239 bool m_textPainted;
237 240
238 int m_skippingCacheCount; 241 int m_skippingCacheCount;
239 242
240 int m_numCachedItems; 243 int m_numCachedItems;
241 244
242 unsigned m_nextScope; 245 unsigned m_nextScope;
243 Vector<unsigned> m_scopeStack; 246 Vector<unsigned> m_scopeStack;
244 247
245 struct Invalidation { 248 #if ENABLE(ASSERT)
246 IntRect rect; 249 // Record the debug names of invalidated clients for assertion and debugging .
247 PaintInvalidationReason invalidationReason; 250 Vector<String> m_invalidations;
248 };
249 251
250 Vector<Invalidation> m_invalidations;
251
252 #if ENABLE(ASSERT)
253 // This is used to check duplicated ids during add(). We could also check 252 // This is used to check duplicated ids during add(). We could also check
254 // during commitNewDisplayItems(), but checking during add() helps developer 253 // during commitNewDisplayItems(), but checking during add() helps developer
255 // easily find where the duplicated ids are from. 254 // easily find where the duplicated ids are from.
256 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; 255 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient;
257 #endif 256 #endif
258 257
259 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; 258 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects;
260 }; 259 };
261 260
262 } // namespace blink 261 } // namespace blink
263 262
264 #endif // PaintController_h 263 #endif // PaintController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698