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

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: 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
49 // These methods are called during painting. 56 // These methods are called during painting.
50 template <typename DisplayItemClass, typename... Args> 57 template <typename DisplayItemClass, typename... Args>
51 DisplayItemClass& createAndAppend(Args&&... args) 58 DisplayItemClass& createAndAppend(Args&&... args)
52 { 59 {
53 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, 60 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value,
54 "Can only createAndAppend subclasses of DisplayItem."); 61 "Can only createAndAppend subclasses of DisplayItem.");
55 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, 62 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize,
56 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); 63 "DisplayItem subclass is larger than kMaximumDisplayItemSize.");
57 64
58 DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<D isplayItemClass>(WTF::forward<Args>(args)...); 65 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) 124 , m_constructionDisabled(false)
118 , m_skippingCacheCount(0) 125 , m_skippingCacheCount(0)
119 , m_numCachedItems(0) 126 , m_numCachedItems(0)
120 , m_nextScope(1) { } 127 , m_nextScope(1) { }
121 128
122 private: 129 private:
123 friend class DisplayItemListTest; 130 friend class DisplayItemListTest;
124 friend class DisplayItemListPaintTest; 131 friend class DisplayItemListPaintTest;
125 friend class DisplayItemListPaintTestForSlimmingPaintV2; 132 friend class DisplayItemListPaintTestForSlimmingPaintV2;
126 friend class LayoutObjectDrawingRecorderTest; 133 friend class LayoutObjectDrawingRecorderTest;
134 friend class LayoutObjectDrawingRecorderTestForSlimmingPaintV2;
127 135
128 // Set new item state (scopes, cache skipping, etc) for a new item. 136 // 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. 137 // TODO(pdr): This only passes a pointer to make the patch easier to review. Change to a reference.
130 void processNewItem(DisplayItem*); 138 void processNewItem(DisplayItem*);
131 139
132 void updateValidlyCachedClientsIfNeeded() const; 140 void updateValidlyCachedClientsIfNeeded() const;
133 141
134 #ifndef NDEBUG 142 #ifndef NDEBUG
135 WTF::String displayItemsAsDebugString(const DisplayItems&) const; 143 WTF::String displayItemsAsDebugString(const DisplayItems&) const;
136 #endif 144 #endif
(...skipping 22 matching lines...) Expand all
159 DisplayItems m_currentDisplayItems; 167 DisplayItems m_currentDisplayItems;
160 DisplayItems m_newDisplayItems; 168 DisplayItems m_newDisplayItems;
161 169
162 // Contains all clients having valid cached paintings if updated. 170 // Contains all clients having valid cached paintings if updated.
163 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). 171 // It's lazily updated in updateValidlyCachedClientsIfNeeded().
164 // FIXME: In the future we can replace this with client-side repaint flags 172 // 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. 173 // to avoid the cost of building and querying the hash table.
166 mutable HashSet<DisplayItemClient> m_validlyCachedClients; 174 mutable HashSet<DisplayItemClient> m_validlyCachedClients;
167 mutable bool m_validlyCachedClientsDirty; 175 mutable bool m_validlyCachedClientsDirty;
168 176
177 #if ENABLE(ASSERT)
178 // Set of clients which had paint offset changes since the last commit. This is used for
179 // ensuring paint offsets are only updated once and are the same in all phas es.
180 HashSet<DisplayItemClient> m_clientsWithPaintOffsetInvalidations;
181 #endif
182
169 // Allow display item construction to be disabled to isolate the costs of co nstruction 183 // Allow display item construction to be disabled to isolate the costs of co nstruction
170 // in performance metrics. 184 // in performance metrics.
171 bool m_constructionDisabled; 185 bool m_constructionDisabled;
172 186
173 int m_skippingCacheCount; 187 int m_skippingCacheCount;
174 188
175 int m_numCachedItems; 189 int m_numCachedItems;
176 190
177 unsigned m_nextScope; 191 unsigned m_nextScope;
178 Vector<unsigned> m_scopeStack; 192 Vector<unsigned> m_scopeStack;
179 193
180 #if ENABLE(ASSERT) 194 #if ENABLE(ASSERT)
181 // This is used to check duplicated ids during add(). We could also check du ring 195 // 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 196 // updatePaintList(), but checking during add() helps developer easily find where
183 // the duplicated ids are from. 197 // the duplicated ids are from.
184 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; 198 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient;
185 #endif 199 #endif
186 }; 200 };
187 201
188 } // namespace blink 202 } // namespace blink
189 203
190 #endif // DisplayItemList_h 204 #endif // DisplayItemList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698