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

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

Issue 1238123004: Slimming Paint phase 2 compositing algorithm plumbing & skeleton display list API. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 | Annotate | Revision Log
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/ListContainer.h" 9 #include "platform/graphics/ListContainer.h"
10 #include "platform/graphics/paint/DisplayItem.h" 10 #include "platform/graphics/paint/DisplayItem.h"
11 #include "platform/graphics/paint/Transform3DDisplayItem.h" 11 #include "platform/graphics/paint/Transform3DDisplayItem.h"
12 #include "public/platform/WebDisplayList.h"
12 #include "wtf/HashMap.h" 13 #include "wtf/HashMap.h"
13 #include "wtf/PassOwnPtr.h" 14 #include "wtf/PassOwnPtr.h"
14 #include "wtf/Utility.h" 15 #include "wtf/Utility.h"
15 #include "wtf/Vector.h" 16 #include "wtf/Vector.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 class GraphicsContext; 20 class GraphicsContext;
20 21
21 using DisplayItems = ListContainer<DisplayItem>; 22 using DisplayItems = ListContainer<DisplayItem>;
22 23
23 static const size_t kInitialDisplayItemsCapacity = 64; 24 static const size_t kInitialDisplayItemsCapacity = 64;
24 static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem ); 25 static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem );
25 26
26 class PLATFORM_EXPORT DisplayItemList { 27 class PLATFORM_EXPORT DisplayItemList : public WebDisplayList {
27 WTF_MAKE_NONCOPYABLE(DisplayItemList); 28 WTF_MAKE_NONCOPYABLE(DisplayItemList);
28 WTF_MAKE_FAST_ALLOCATED(DisplayItemList); 29 WTF_MAKE_FAST_ALLOCATED(DisplayItemList);
29 public: 30 public:
30 static PassOwnPtr<DisplayItemList> create() 31 static PassOwnPtr<DisplayItemList> create()
31 { 32 {
32 return adoptPtr(new DisplayItemList()); 33 return adoptPtr(new DisplayItemList());
33 } 34 }
34 35
35 // These methods are called during paint invalidation. 36 // These methods are called during paint invalidation.
36 void invalidate(DisplayItemClient); 37 void invalidate(DisplayItemClient);
37 void invalidateAll(); 38 void invalidateAll();
38 39
39 // These methods are called during painting. 40 // These methods are called during painting.
40 template <typename DisplayItemClass, typename... Args> 41 template <typename DisplayItemClass, typename... Args>
41 DisplayItemClass& createAndAppend(Args&&... args) 42 DisplayItemClass& createAndAppend(Args&&... args)
42 { 43 {
43 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value, 44 static_assert(WTF::IsSubclass<DisplayItemClass, DisplayItem>::value,
44 "Can only createAndAppend subclasses of DisplayItem."); 45 "Can only createAndAppend subclasses of DisplayItem.");
45 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize, 46 static_assert(sizeof(DisplayItemClass) <= kMaximumDisplayItemSize,
46 "DisplayItem subclass is larger than kMaximumDisplayItemSize."); 47 "DisplayItem subclass is larger than kMaximumDisplayItemSize.");
47 48
48 DisplayItemClass* displayItem = m_newDisplayItems.allocateAndConstruct<D isplayItemClass>(WTF::forward<Args>(args)...); 49 DisplayItemClass* displayItem = m_newDisplayItems.allocateAndConstruct<D isplayItemClass>(WTF::forward<Args>(args)...);
49 processNewItem(displayItem); 50 processNewItem(displayItem);
50 return *displayItem; 51 return *displayItem;
51 } 52 }
52 void beginScope(DisplayItemClient); 53 void beginScope(DisplayItemClient);
53 void endScope(DisplayItemClient); 54 void endScope(DisplayItemClient);
54 55
56 void addPixelRef(const skia::PixelRefUtils::PositionPixelRef&);
57
55 // True if the last display item is a begin that doesn't draw content. 58 // True if the last display item is a begin that doesn't draw content.
56 bool lastDisplayItemIsNoopBegin() const; 59 bool lastDisplayItemIsNoopBegin() const;
57 void removeLastDisplayItem(); 60 void removeLastDisplayItem();
58 61
59 void beginSkippingCache() { ++m_skippingCacheCount; } 62 void beginSkippingCache() { ++m_skippingCacheCount; }
60 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; } 63 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; }
61 bool skippingCache() const { return m_skippingCacheCount; } 64 bool skippingCache() const { return m_skippingCacheCount; }
62 65
63 // Must be called when a painting is finished. 66 // Must be called when a painting is finished. If passed, the diff is initia lized
64 void commitNewDisplayItems(); 67 // to the difference of the new display list from the last time commitNewDis playItems() was called.
68 void commitNewDisplayItems(WebDisplayListDiff* = 0);
65 69
66 // Returns the approximate memory usage, excluding memory likely to be 70 // Returns the approximate memory usage, excluding memory likely to be
67 // shared with the embedder after copying to WebDisplayItemList. 71 // shared with the embedder after copying to WebDisplayItemList.
68 // Should only be called right after commitNewDisplayItems. 72 // Should only be called right after commitNewDisplayItems.
69 size_t approximateUnsharedMemoryUsage() const; 73 size_t approximateUnsharedMemoryUsage() const;
70 74
71 // Get the paint list generated after the last painting. 75 // Get the paint list generated after the last painting.
72 const DisplayItems& displayItems() const; 76 const DisplayItems& displayItems() const;
77 const WebVector<WebDisplayItem>& webDisplayItems() const override;
78 // Get the pixel refs generated after the last painting.
79 const skia::DiscardablePixelRefList& pixelRefs() const override;
73 80
74 bool clientCacheIsValid(DisplayItemClient) const; 81 bool clientCacheIsValid(DisplayItemClient) const;
75 82
76 // Commits the new display items and plays back the updated display items in to the given context. 83 // Commits the new display items and plays back the updated display items in to the given context.
77 void commitNewDisplayItemsAndReplay(GraphicsContext& context) 84 void commitNewDisplayItemsAndReplay(GraphicsContext& context)
78 { 85 {
79 commitNewDisplayItems(); 86 commitNewDisplayItems();
80 replay(context); 87 replay(context);
81 } 88 }
82 89
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // display items. 165 // display items.
159 struct Scope { 166 struct Scope {
160 Scope(DisplayItemClient c, int i) : client(c), id(i) { } 167 Scope(DisplayItemClient c, int i) : client(c), id(i) { }
161 DisplayItemClient client; 168 DisplayItemClient client;
162 int id; 169 int id;
163 }; 170 };
164 typedef HashMap<DisplayItemClient, int> ClientScopeIdMap; 171 typedef HashMap<DisplayItemClient, int> ClientScopeIdMap;
165 ClientScopeIdMap m_clientScopeIdMap; 172 ClientScopeIdMap m_clientScopeIdMap;
166 Vector<Scope> m_scopeStack; 173 Vector<Scope> m_scopeStack;
167 174
175 skia::DiscardablePixelRefList m_currentPixelRefs;
176 skia::DiscardablePixelRefList m_newPixelRefs;
177
168 #if ENABLE(ASSERT) 178 #if ENABLE(ASSERT)
169 // This is used to check duplicated ids during add(). We could also check du ring 179 // This is used to check duplicated ids during add(). We could also check du ring
170 // updatePaintList(), but checking during add() helps developer easily find where 180 // updatePaintList(), but checking during add() helps developer easily find where
171 // the duplicated ids are from. 181 // the duplicated ids are from.
172 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; 182 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient;
173 #endif 183 #endif
184
185 // This is a placeholder, not a real data structure.
186 WebVector<WebDisplayItem> m_webDisplayItems;
174 }; 187 };
175 188
176 } // namespace blink 189 } // namespace blink
177 190
178 #endif // DisplayItemList_h 191 #endif // DisplayItemList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698