OLD | NEW |
---|---|
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 // |visualContentRect| can be nullptr if we know it's unchanged and PaintCon troller has cached the previous value. |
46 // Otherwise we must pass a correct value (bounds of the display item client in coordinates of the | |
chrishtr
2015/10/23 19:57:49
"bounds" needs to be defined here. I suggest just
Xianzhu
2015/10/23 20:56:53
Done.
chrishtr
2015/10/23 20:59:45
visualRect is ok then, with comment.
Xianzhu
2015/10/23 21:28:22
Done.
| |
47 // PaintController's GraphicsLayer (spv1) or TODO(pdr): definition of it for spv2. | |
48 void invalidate(const DisplayItemClientWrapper&, PaintInvalidationReason, co nst IntRect* visibleContentRect); | |
47 void invalidateUntracked(DisplayItemClient); | 49 void invalidateUntracked(DisplayItemClient); |
48 void invalidateAll(); | 50 void invalidateAll(); |
49 | 51 |
50 // Record when paint offsets change during paint. | 52 // Record when paint offsets change during paint. |
51 void invalidatePaintOffset(const DisplayItemClientWrapper&); | 53 void invalidatePaintOffset(const DisplayItemClientWrapper&); |
52 #if ENABLE(ASSERT) | 54 #if ENABLE(ASSERT) |
53 bool paintOffsetWasInvalidated(DisplayItemClient) const; | 55 bool paintOffsetWasInvalidated(DisplayItemClient) const; |
54 #endif | 56 #endif |
55 | 57 |
56 // These methods are called during painting. | 58 // These methods are called during painting. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 void endScope(); | 98 void endScope(); |
97 | 99 |
98 // True if the last display item is a begin that doesn't draw content. | 100 // True if the last display item is a begin that doesn't draw content. |
99 bool lastDisplayItemIsNoopBegin() const; | 101 bool lastDisplayItemIsNoopBegin() const; |
100 void removeLastDisplayItem(); | 102 void removeLastDisplayItem(); |
101 | 103 |
102 void beginSkippingCache() { ++m_skippingCacheCount; } | 104 void beginSkippingCache() { ++m_skippingCacheCount; } |
103 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; } | 105 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; } |
104 bool skippingCache() const { return m_skippingCacheCount; } | 106 bool skippingCache() const { return m_skippingCacheCount; } |
105 | 107 |
106 // Must be called when a painting is finished. If passed, invalidations are recorded on the given | 108 // Must be called when a painting is finished. |
107 // GraphicsLayer. | 109 void commitNewDisplayItems(); |
108 void commitNewDisplayItems(GraphicsLayer* = nullptr); | |
109 | 110 |
110 // Returns the approximate memory usage, excluding memory likely to be | 111 // Returns the approximate memory usage, excluding memory likely to be |
111 // shared with the embedder after copying to WebPaintController. | 112 // shared with the embedder after copying to WebPaintController. |
112 // Should only be called right after commitNewDisplayItems. | 113 // Should only be called right after commitNewDisplayItems. |
113 size_t approximateUnsharedMemoryUsage() const; | 114 size_t approximateUnsharedMemoryUsage() const; |
114 | 115 |
115 // Get the artifact generated after the last commit. | 116 // Get the artifact generated after the last commit. |
116 const PaintArtifact& paintArtifact() const; | 117 const PaintArtifact& paintArtifact() const; |
117 const DisplayItemList& displayItemList() const { return paintArtifact().disp layItemList(); } | 118 const DisplayItemList& displayItemList() const { return paintArtifact().disp layItemList(); } |
118 const Vector<PaintChunk>& paintChunks() const { return paintArtifact().paint Chunks(); } | 119 const Vector<PaintChunk>& paintChunks() const { return paintArtifact().paint Chunks(); } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 // Indicates this PaintController has ever had text. It is never reset to fa lse. | 236 // Indicates this PaintController has ever had text. It is never reset to fa lse. |
236 bool m_textPainted; | 237 bool m_textPainted; |
237 | 238 |
238 int m_skippingCacheCount; | 239 int m_skippingCacheCount; |
239 | 240 |
240 int m_numCachedItems; | 241 int m_numCachedItems; |
241 | 242 |
242 unsigned m_nextScope; | 243 unsigned m_nextScope; |
243 Vector<unsigned> m_scopeStack; | 244 Vector<unsigned> m_scopeStack; |
244 | 245 |
245 struct Invalidation { | 246 #if ENABLE(ASSERT) |
246 IntRect rect; | 247 // Record the debug names of invalidated clients for assertion and debugging . |
247 PaintInvalidationReason invalidationReason; | 248 Vector<String> m_invalidations; |
248 }; | |
249 | 249 |
250 Vector<Invalidation> m_invalidations; | |
251 | |
252 #if ENABLE(ASSERT) | |
253 // This is used to check duplicated ids during add(). We could also check | 250 // This is used to check duplicated ids during add(). We could also check |
254 // during commitNewDisplayItems(), but checking during add() helps developer | 251 // during commitNewDisplayItems(), but checking during add() helps developer |
255 // easily find where the duplicated ids are from. | 252 // easily find where the duplicated ids are from. |
256 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 253 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
257 #endif | 254 #endif |
258 | 255 |
259 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 256 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
260 }; | 257 }; |
261 | 258 |
262 } // namespace blink | 259 } // namespace blink |
263 | 260 |
264 #endif // PaintController_h | 261 #endif // PaintController_h |
OLD | NEW |