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

Side by Side Diff: Source/platform/graphics/paint/DisplayItemList.h

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

Powered by Google App Engine
This is Rietveld 408576698