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

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

Issue 1203343002: WIP for display item list backed by ListContainer Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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/graphics/paint/DisplayItem.h" 9 #include "platform/graphics/paint/DisplayItem.h"
10 #include "platform/graphics/paint/DisplayItems.h" 10 #include "platform/graphics/paint/DisplayItems.h"
11 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
12 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
13 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class GraphicsContext; 17 class GraphicsContext;
18 18
19 static const size_t kInitialDisplayItemsCapacity = 32;
20
19 class PLATFORM_EXPORT DisplayItemList { 21 class PLATFORM_EXPORT DisplayItemList {
20 WTF_MAKE_NONCOPYABLE(DisplayItemList); 22 WTF_MAKE_NONCOPYABLE(DisplayItemList);
21 WTF_MAKE_FAST_ALLOCATED(DisplayItemList); 23 WTF_MAKE_FAST_ALLOCATED(DisplayItemList);
22 public: 24 public:
23 static PassOwnPtr<DisplayItemList> create() 25 static PassOwnPtr<DisplayItemList> create()
24 { 26 {
25 return adoptPtr(new DisplayItemList()); 27 return adoptPtr(new DisplayItemList());
26 } 28 }
27 29
28 // These methods are called during paint invalidation. 30 // These methods are called during paint invalidation.
29 void invalidate(DisplayItemClient); 31 void invalidate(DisplayItemClient);
30 void invalidateAll(); 32 void invalidateAll();
31 33
32 // These methods are called during painting. 34 // These methods are called during painting.
33 void add(WTF::PassOwnPtr<DisplayItem>); 35 template<typename DisplayItemClass>
36 DisplayItemClass& createAndAppend(const DisplayItemClientWrapper& client, Di splayItem::Type type)
37 {
38 DisplayItemClass& item = m_newDisplayItems.createAndAppend<DisplayItemCl ass>();
39 item.setClientAndType(client, type);
40 processNewItem(&item);
41 return item;
42 }
43 void add(WTF::PassOwnPtr<DisplayItem>) { } // REMOVE ME
34 void beginScope(DisplayItemClient); 44 void beginScope(DisplayItemClient);
35 void endScope(DisplayItemClient); 45 void endScope(DisplayItemClient);
36 46
37 // True if the last display item is a begin that doesn't draw content. 47 // True if the last display item is a begin that doesn't draw content.
38 bool lastDisplayItemIsNoopBegin() const; 48 bool lastDisplayItemIsNoopBegin() const;
39 void removeLastDisplayItem(); 49 void removeLastDisplayItem();
40 50
41 void beginSkippingCache() { ++m_skippingCacheCount; } 51 void beginSkippingCache() { ++m_skippingCacheCount; }
42 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; } 52 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; }
43 bool skippingCache() const { return m_skippingCacheCount; } 53 bool skippingCache() const { return m_skippingCacheCount; }
(...skipping 21 matching lines...) Expand all
65 #if ENABLE(ASSERT) 75 #if ENABLE(ASSERT)
66 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); } 76 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); }
67 #endif 77 #endif
68 78
69 #ifndef NDEBUG 79 #ifndef NDEBUG
70 void showDebugData() const; 80 void showDebugData() const;
71 #endif 81 #endif
72 82
73 protected: 83 protected:
74 DisplayItemList() 84 DisplayItemList()
75 : m_validlyCachedClientsDirty(false) 85 : m_currentDisplayItems(kInitialDisplayItemsCapacity)
86 , m_newDisplayItems(kInitialDisplayItemsCapacity)
87 , m_validlyCachedClientsDirty(false)
76 , m_constructionDisabled(false) 88 , m_constructionDisabled(false)
77 , m_skippingCacheCount(0) 89 , m_skippingCacheCount(0)
78 , m_numCachedItems(0) { } 90 , m_numCachedItems(0) { }
79 91
80 private: 92 private:
81 friend class DisplayItemListTest; 93 friend class DisplayItemListTest;
82 friend class DisplayItemListPaintTest; 94 friend class DisplayItemListPaintTest;
83 friend class LayoutObjectDrawingRecorderTest; 95 friend class LayoutObjectDrawingRecorderTest;
84 96
97 // Set new item state (scopes, cache skipping, etc) for a new item.
98 // TODO(pdr): This only passes a pointer to make the patch easier to review. Change to a reference.
99 void processNewItem(DisplayItem*);
100
85 void updateValidlyCachedClientsIfNeeded() const; 101 void updateValidlyCachedClientsIfNeeded() const;
86 102
87 #ifndef NDEBUG 103 #ifndef NDEBUG
88 WTF::String displayItemsAsDebugString(const DisplayItems&) const; 104 WTF::String displayItemsAsDebugString(const DisplayItems&) const;
89 #endif 105 #endif
90 106
91 // Indices into PaintList of all DrawingDisplayItems and BeginSubtreeDisplay Items of each client. 107 // Indices into PaintList of all DrawingDisplayItems and BeginSubtreeDisplay Items of each client.
92 // Temporarily used during merge to find out-of-order display items. 108 // Temporarily used during merge to find out-of-order display items.
93 using DisplayItemIndicesByClientMap = HashMap<DisplayItemClient, Vector<size _t>>; 109 using DisplayItemIndicesByClientMap = HashMap<DisplayItemClient, Vector<size _t>>;
94 110
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // This is used to check duplicated ids during add(). We could also check du ring 156 // This is used to check duplicated ids during add(). We could also check du ring
141 // updatePaintList(), but checking during add() helps developer easily find where 157 // updatePaintList(), but checking during add() helps developer easily find where
142 // the duplicated ids are from. 158 // the duplicated ids are from.
143 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; 159 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient;
144 #endif 160 #endif
145 }; 161 };
146 162
147 } // namespace blink 163 } // namespace blink
148 164
149 #endif // DisplayItemList_h 165 #endif // DisplayItemList_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/paint/DisplayItem.h ('k') | Source/platform/graphics/paint/DisplayItemList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698