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 DisplayItemList_h | 5 #ifndef DisplayItemList_h |
6 #define DisplayItemList_h | 6 #define DisplayItemList_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/LayoutPoint.h" | 10 #include "platform/geometry/LayoutPoint.h" |
11 #include "platform/graphics/ContiguousContainer.h" | 11 #include "platform/graphics/ContiguousContainer.h" |
12 #include "platform/graphics/paint/DisplayItem.h" | 12 #include "platform/graphics/paint/DisplayItem.h" |
| 13 #include "platform/graphics/paint/PaintChunk.h" |
| 14 #include "platform/graphics/paint/PaintChunker.h" |
13 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 15 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
14 #include "wtf/Alignment.h" | 16 #include "wtf/Alignment.h" |
15 #include "wtf/HashMap.h" | 17 #include "wtf/HashMap.h" |
16 #include "wtf/PassOwnPtr.h" | 18 #include "wtf/PassOwnPtr.h" |
17 #include "wtf/Utility.h" | 19 #include "wtf/Utility.h" |
18 #include "wtf/Vector.h" | 20 #include "wtf/Vector.h" |
19 | 21 |
20 namespace blink { | 22 namespace blink { |
21 | 23 |
| 24 class CachedDisplayItem; |
| 25 class DrawingDisplayItem; |
22 class GraphicsContext; | 26 class GraphicsContext; |
23 | 27 |
24 // kDisplayItemAlignment must be a multiple of alignof(derived display item) for | 28 // kDisplayItemAlignment must be a multiple of alignof(derived display item) for |
25 // each derived display item; the ideal value is the least common multiple. | 29 // each derived display item; the ideal value is the least common multiple. |
26 // Currently the limiting factor is TransformtionMatrix (in | 30 // Currently the limiting factor is TransformtionMatrix (in |
27 // BeginTransform3DDisplayItem), which requests 16-byte alignment. | 31 // BeginTransform3DDisplayItem), which requests 16-byte alignment. |
28 static const size_t kDisplayItemAlignment = WTF_ALIGN_OF(BeginTransform3DDisplay
Item); | 32 static const size_t kDisplayItemAlignment = WTF_ALIGN_OF(BeginTransform3DDisplay
Item); |
29 static const size_t kInitialDisplayItemsCapacity = 64; | 33 static const size_t kInitialDisplayItemsCapacity = 64; |
30 static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem
); | 34 static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem
); |
31 | 35 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void invalidateUntracked(DisplayItemClient); | 73 void invalidateUntracked(DisplayItemClient); |
70 void invalidateAll(); | 74 void invalidateAll(); |
71 | 75 |
72 // Record when paint offsets change during paint. | 76 // Record when paint offsets change during paint. |
73 void invalidatePaintOffset(const DisplayItemClientWrapper&); | 77 void invalidatePaintOffset(const DisplayItemClientWrapper&); |
74 #if ENABLE(ASSERT) | 78 #if ENABLE(ASSERT) |
75 bool paintOffsetWasInvalidated(DisplayItemClient) const; | 79 bool paintOffsetWasInvalidated(DisplayItemClient) const; |
76 #endif | 80 #endif |
77 | 81 |
78 // These methods are called during painting. | 82 // These methods are called during painting. |
| 83 |
| 84 // Provide a new set of paint properties to apply to recorded display items, |
| 85 // for Slimming Paint v2. |
| 86 void updateCurrentPaintProperties(const PaintProperties&); |
| 87 |
79 template <typename DisplayItemClass, typename... Args> | 88 template <typename DisplayItemClass, typename... Args> |
80 DisplayItemClass& createAndAppend(Args&&... args) | 89 DisplayItemClass& createAndAppend(Args&&... args) |
81 { | 90 { |
82 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, | 91 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, |
83 "Can only createAndAppend subclasses of DisplayItem."); | 92 "Can only createAndAppend subclasses of DisplayItem."); |
84 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, | 93 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, |
85 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); | 94 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); |
86 | 95 |
87 DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<D
isplayItemClass>(WTF::forward<Args>(args)...); | 96 DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<D
isplayItemClass>(WTF::forward<Args>(args)...); |
88 processNewItem(displayItem); | 97 processNewItem(displayItem); |
(...skipping 19 matching lines...) Expand all Loading... |
108 void commitNewDisplayItems(DisplayListDiff* = 0); | 117 void commitNewDisplayItems(DisplayListDiff* = 0); |
109 | 118 |
110 // Returns the approximate memory usage, excluding memory likely to be | 119 // Returns the approximate memory usage, excluding memory likely to be |
111 // shared with the embedder after copying to WebDisplayItemList. | 120 // shared with the embedder after copying to WebDisplayItemList. |
112 // Should only be called right after commitNewDisplayItems. | 121 // Should only be called right after commitNewDisplayItems. |
113 size_t approximateUnsharedMemoryUsage() const; | 122 size_t approximateUnsharedMemoryUsage() const; |
114 | 123 |
115 // Get the paint list generated after the last painting. | 124 // Get the paint list generated after the last painting. |
116 const DisplayItems& displayItems() const; | 125 const DisplayItems& displayItems() const; |
117 | 126 |
| 127 // Get the paint chunks generated after the last painting. |
| 128 const Vector<PaintChunk>& paintChunks() const; |
| 129 |
118 bool clientCacheIsValid(DisplayItemClient) const; | 130 bool clientCacheIsValid(DisplayItemClient) const; |
119 | 131 |
120 // Commits the new display items and plays back the updated display items in
to the given context. | 132 // Commits the new display items and plays back the updated display items in
to the given context. |
121 void commitNewDisplayItemsAndReplay(GraphicsContext& context) | 133 void commitNewDisplayItemsAndReplay(GraphicsContext& context) |
122 { | 134 { |
123 commitNewDisplayItems(); | 135 commitNewDisplayItems(); |
124 replay(context); | 136 replay(context); |
125 } | 137 } |
126 | 138 |
127 void appendToWebDisplayItemList(WebDisplayItemList*); | 139 void appendToWebDisplayItemList(WebDisplayItemList*); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 void checkUnderInvalidation(DisplayItems::iterator& newIt, DisplayItems::ite
rator& currentIt); | 204 void checkUnderInvalidation(DisplayItems::iterator& newIt, DisplayItems::ite
rator& currentIt); |
193 void checkCachedDisplayItemIsUnchanged(const char* messagePrefix, const Disp
layItem& newItem, const DisplayItem& oldItem); | 205 void checkCachedDisplayItemIsUnchanged(const char* messagePrefix, const Disp
layItem& newItem, const DisplayItem& oldItem); |
194 void checkNoRemainingCachedDisplayItems(); | 206 void checkNoRemainingCachedDisplayItems(); |
195 #endif | 207 #endif |
196 | 208 |
197 void replay(GraphicsContext&); | 209 void replay(GraphicsContext&); |
198 | 210 |
199 DisplayItems m_currentDisplayItems; | 211 DisplayItems m_currentDisplayItems; |
200 DisplayItems m_newDisplayItems; | 212 DisplayItems m_newDisplayItems; |
201 | 213 |
| 214 // In Slimming Paint v2, paint properties (e.g. transform) useful for |
| 215 // compositing are stored in corresponding paint chunks instead of in the |
| 216 // display items. |
| 217 Vector<PaintChunk> m_currentPaintChunks; |
| 218 PaintChunker m_newPaintChunks; |
| 219 |
202 // Contains all clients having valid cached paintings if updated. | 220 // Contains all clients having valid cached paintings if updated. |
203 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). | 221 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). |
204 // FIXME: In the future we can replace this with client-side repaint flags | 222 // FIXME: In the future we can replace this with client-side repaint flags |
205 // to avoid the cost of building and querying the hash table. | 223 // to avoid the cost of building and querying the hash table. |
206 mutable HashSet<DisplayItemClient> m_validlyCachedClients; | 224 mutable HashSet<DisplayItemClient> m_validlyCachedClients; |
207 mutable bool m_validlyCachedClientsDirty; | 225 mutable bool m_validlyCachedClientsDirty; |
208 | 226 |
209 #if ENABLE(ASSERT) | 227 #if ENABLE(ASSERT) |
210 // Set of clients which had paint offset changes since the last commit. This
is used for | 228 // Set of clients which had paint offset changes since the last commit. This
is used for |
211 // ensuring paint offsets are only updated once and are the same in all phas
es. | 229 // ensuring paint offsets are only updated once and are the same in all phas
es. |
(...skipping 17 matching lines...) Expand all Loading... |
229 // the duplicated ids are from. | 247 // the duplicated ids are from. |
230 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 248 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
231 #endif | 249 #endif |
232 | 250 |
233 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 251 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
234 }; | 252 }; |
235 | 253 |
236 } // namespace blink | 254 } // namespace blink |
237 | 255 |
238 #endif // DisplayItemList_h | 256 #endif // DisplayItemList_h |
OLD | NEW |