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/graphics/ContiguousContainer.h" | 11 #include "platform/graphics/ContiguousContainer.h" |
11 #include "platform/graphics/paint/DisplayItem.h" | 12 #include "platform/graphics/paint/DisplayItem.h" |
12 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 13 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
13 #include "wtf/Alignment.h" | 14 #include "wtf/Alignment.h" |
14 #include "wtf/HashMap.h" | 15 #include "wtf/HashMap.h" |
15 #include "wtf/PassOwnPtr.h" | 16 #include "wtf/PassOwnPtr.h" |
16 #include "wtf/Utility.h" | 17 #include "wtf/Utility.h" |
17 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
(...skipping 21 matching lines...) Expand all Loading... |
41 static PassOwnPtr<DisplayItemList> create() | 42 static PassOwnPtr<DisplayItemList> create() |
42 { | 43 { |
43 return adoptPtr(new DisplayItemList()); | 44 return adoptPtr(new DisplayItemList()); |
44 } | 45 } |
45 | 46 |
46 // These methods are called during paint invalidation. | 47 // These methods are called during paint invalidation. |
47 void invalidate(const DisplayItemClientWrapper&); | 48 void invalidate(const DisplayItemClientWrapper&); |
48 void invalidateUntracked(DisplayItemClient); | 49 void invalidateUntracked(DisplayItemClient); |
49 void invalidateAll(); | 50 void invalidateAll(); |
50 | 51 |
| 52 // Record when paint offsets change during paint. |
| 53 void invalidatePaintOffset(DisplayItemClient); |
| 54 #if ENABLE(ASSERT) |
| 55 bool paintOffsetWasInvalidated(DisplayItemClient) const; |
| 56 #endif |
| 57 |
| 58 // Record a new paint offset. |
| 59 // TODO(pdr): Remove these once the paint offset cache is on LayoutObject. |
| 60 void recordPaintOffset(DisplayItemClient, const LayoutPoint&); |
| 61 bool paintOffsetIsUnchanged(DisplayItemClient, const LayoutPoint&) const; |
| 62 |
51 // These methods are called during painting. | 63 // These methods are called during painting. |
52 template <typename DisplayItemClass, typename... Args> | 64 template <typename DisplayItemClass, typename... Args> |
53 DisplayItemClass& createAndAppend(Args&&... args) | 65 DisplayItemClass& createAndAppend(Args&&... args) |
54 { | 66 { |
55 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, | 67 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, |
56 "Can only createAndAppend subclasses of DisplayItem."); | 68 "Can only createAndAppend subclasses of DisplayItem."); |
57 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, | 69 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, |
58 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); | 70 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); |
59 | 71 |
60 DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<D
isplayItemClass>(WTF::forward<Args>(args)...); | 72 DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<D
isplayItemClass>(WTF::forward<Args>(args)...); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 , m_constructionDisabled(false) | 147 , m_constructionDisabled(false) |
136 , m_skippingCacheCount(0) | 148 , m_skippingCacheCount(0) |
137 , m_numCachedItems(0) | 149 , m_numCachedItems(0) |
138 , m_nextScope(1) { } | 150 , m_nextScope(1) { } |
139 | 151 |
140 private: | 152 private: |
141 friend class DisplayItemListTest; | 153 friend class DisplayItemListTest; |
142 friend class DisplayItemListPaintTest; | 154 friend class DisplayItemListPaintTest; |
143 friend class DisplayItemListPaintTestForSlimmingPaintV2; | 155 friend class DisplayItemListPaintTestForSlimmingPaintV2; |
144 friend class LayoutObjectDrawingRecorderTest; | 156 friend class LayoutObjectDrawingRecorderTest; |
| 157 friend class LayoutObjectDrawingRecorderTestForSlimmingPaintV2; |
145 | 158 |
146 // Set new item state (scopes, cache skipping, etc) for a new item. | 159 // Set new item state (scopes, cache skipping, etc) for a new item. |
147 // TODO(pdr): This only passes a pointer to make the patch easier to review.
Change to a reference. | 160 // TODO(pdr): This only passes a pointer to make the patch easier to review.
Change to a reference. |
148 void processNewItem(DisplayItem*); | 161 void processNewItem(DisplayItem*); |
149 | 162 |
150 void updateValidlyCachedClientsIfNeeded() const; | 163 void updateValidlyCachedClientsIfNeeded() const; |
151 | 164 |
| 165 // Update the recorded paint offsets to remove any items that no longer have |
| 166 // corresponding cached display items. |
| 167 // TODO(pdr): Remove this once the paint offset cache is on LayoutObject. |
| 168 void removeUnneededPaintOffsetEntries(); |
| 169 |
152 #ifndef NDEBUG | 170 #ifndef NDEBUG |
153 WTF::String displayItemsAsDebugString(const DisplayItems&) const; | 171 WTF::String displayItemsAsDebugString(const DisplayItems&) const; |
154 #endif | 172 #endif |
155 | 173 |
156 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. | 174 // Indices into PaintList of all DrawingDisplayItems and BeginSubsequenceDis
playItems of each client. |
157 // Temporarily used during merge to find out-of-order display items. | 175 // Temporarily used during merge to find out-of-order display items. |
158 using DisplayItemIndicesByClientMap = HashMap<DisplayItemClient, Vector<size
_t>>; | 176 using DisplayItemIndicesByClientMap = HashMap<DisplayItemClient, Vector<size
_t>>; |
159 | 177 |
160 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItems&); | 178 static size_t findMatchingItemFromIndex(const DisplayItem::Id&, const Displa
yItemIndicesByClientMap&, const DisplayItems&); |
161 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); | 179 static void addItemToIndexIfNeeded(const DisplayItem&, size_t index, Display
ItemIndicesByClientMap&); |
(...skipping 15 matching lines...) Expand all Loading... |
177 DisplayItems m_currentDisplayItems; | 195 DisplayItems m_currentDisplayItems; |
178 DisplayItems m_newDisplayItems; | 196 DisplayItems m_newDisplayItems; |
179 | 197 |
180 // Contains all clients having valid cached paintings if updated. | 198 // Contains all clients having valid cached paintings if updated. |
181 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). | 199 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). |
182 // FIXME: In the future we can replace this with client-side repaint flags | 200 // FIXME: In the future we can replace this with client-side repaint flags |
183 // to avoid the cost of building and querying the hash table. | 201 // to avoid the cost of building and querying the hash table. |
184 mutable HashSet<DisplayItemClient> m_validlyCachedClients; | 202 mutable HashSet<DisplayItemClient> m_validlyCachedClients; |
185 mutable bool m_validlyCachedClientsDirty; | 203 mutable bool m_validlyCachedClientsDirty; |
186 | 204 |
| 205 #if ENABLE(ASSERT) |
| 206 // Set of clients which had paint offset changes since the last commit. This
is used for |
| 207 // ensuring paint offsets are only updated once and are the same in all phas
es. |
| 208 HashSet<DisplayItemClient> m_clientsWithPaintOffsetInvalidations; |
| 209 #endif |
| 210 |
187 // Allow display item construction to be disabled to isolate the costs of co
nstruction | 211 // Allow display item construction to be disabled to isolate the costs of co
nstruction |
188 // in performance metrics. | 212 // in performance metrics. |
189 bool m_constructionDisabled; | 213 bool m_constructionDisabled; |
190 | 214 |
191 int m_skippingCacheCount; | 215 int m_skippingCacheCount; |
192 | 216 |
193 int m_numCachedItems; | 217 int m_numCachedItems; |
194 | 218 |
195 unsigned m_nextScope; | 219 unsigned m_nextScope; |
196 Vector<unsigned> m_scopeStack; | 220 Vector<unsigned> m_scopeStack; |
197 | 221 |
| 222 // Cache of LayoutObject paint offsets. |
| 223 // TODO(pdr): This should be on LayoutObject itself and is only on the displ
ay |
| 224 // item list temporarily until paint invalidation for v2 frees up space on |
| 225 // LayoutObject. |
| 226 using PreviousPaintOffsets = HashMap<DisplayItemClient, LayoutPoint>; |
| 227 PreviousPaintOffsets m_previousPaintOffsets; |
| 228 |
198 #if ENABLE(ASSERT) | 229 #if ENABLE(ASSERT) |
199 // This is used to check duplicated ids during add(). We could also check du
ring | 230 // This is used to check duplicated ids during add(). We could also check du
ring |
200 // updatePaintList(), but checking during add() helps developer easily find
where | 231 // updatePaintList(), but checking during add() helps developer easily find
where |
201 // the duplicated ids are from. | 232 // the duplicated ids are from. |
202 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 233 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
203 #endif | 234 #endif |
204 | 235 |
205 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; | 236 OwnPtr<Vector<String>> m_trackedPaintInvalidationObjects; |
206 }; | 237 }; |
207 | 238 |
208 } // namespace blink | 239 } // namespace blink |
209 | 240 |
210 #endif // DisplayItemList_h | 241 #endif // DisplayItemList_h |
OLD | NEW |