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

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

Issue 1287093004: Slimming Paint phase 2 compositing algorithm plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase from space Created 5 years, 4 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/ContiguousContainer.h" 9 #include "platform/graphics/ContiguousContainer.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 "wtf/Alignment.h" 12 #include "wtf/Alignment.h"
13 #include "wtf/HashMap.h" 13 #include "wtf/HashMap.h"
14 #include "wtf/PassOwnPtr.h" 14 #include "wtf/PassOwnPtr.h"
15 #include "wtf/Utility.h" 15 #include "wtf/Utility.h"
16 #include "wtf/Vector.h" 16 #include "wtf/Vector.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class GraphicsContext; 20 class GraphicsContext;
21 21
22 // kDisplayItemAlignment must be a multiple of alignof(derived display item) for 22 // kDisplayItemAlignment must be a multiple of alignof(derived display item) for
23 // each derived display item; the ideal value is the least common multiple. 23 // each derived display item; the ideal value is the least common multiple.
24 // Currently the limiting factor is TransformtionMatrix (in 24 // Currently the limiting factor is TransformtionMatrix (in
25 // BeginTransform3DDisplayItem), which requests 16-byte alignment. 25 // BeginTransform3DDisplayItem), which requests 16-byte alignment.
26 static const size_t kDisplayItemAlignment = WTF_ALIGN_OF(BeginTransform3DDisplay Item); 26 static const size_t kDisplayItemAlignment = WTF_ALIGN_OF(BeginTransform3DDisplay Item);
27 static const size_t kInitialDisplayItemsCapacity = 64; 27 static const size_t kInitialDisplayItemsCapacity = 64;
28 static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem ); 28 static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem );
29 29
30 // Map from SimpleLayer.startPoint to the DrawingDisplayItems within its range
31 // which were invalidated on this frame and do not change SimpleLayers.
32 using DisplayListDiff = HashMap<DisplayItemClient, DisplayItem*>;
33
30 using DisplayItems = ContiguousContainer<DisplayItem, kDisplayItemAlignment>; 34 using DisplayItems = ContiguousContainer<DisplayItem, kDisplayItemAlignment>;
31 35
32 class PLATFORM_EXPORT DisplayItemList { 36 class PLATFORM_EXPORT DisplayItemList {
33 WTF_MAKE_NONCOPYABLE(DisplayItemList); 37 WTF_MAKE_NONCOPYABLE(DisplayItemList);
34 WTF_MAKE_FAST_ALLOCATED(DisplayItemList); 38 WTF_MAKE_FAST_ALLOCATED(DisplayItemList);
35 public: 39 public:
36 static PassOwnPtr<DisplayItemList> create() 40 static PassOwnPtr<DisplayItemList> create()
37 { 41 {
38 return adoptPtr(new DisplayItemList()); 42 return adoptPtr(new DisplayItemList());
39 } 43 }
(...skipping 23 matching lines...) Expand all
63 void endScope(); 67 void endScope();
64 68
65 // True if the last display item is a begin that doesn't draw content. 69 // True if the last display item is a begin that doesn't draw content.
66 bool lastDisplayItemIsNoopBegin() const; 70 bool lastDisplayItemIsNoopBegin() const;
67 void removeLastDisplayItem(); 71 void removeLastDisplayItem();
68 72
69 void beginSkippingCache() { ++m_skippingCacheCount; } 73 void beginSkippingCache() { ++m_skippingCacheCount; }
70 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; } 74 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; }
71 bool skippingCache() const { return m_skippingCacheCount; } 75 bool skippingCache() const { return m_skippingCacheCount; }
72 76
73 // Must be called when a painting is finished. 77 // Must be called when a painting is finished. If passed, a DisplayListDiff
74 void commitNewDisplayItems(); 78 // is initialized and created.
79 void commitNewDisplayItems(DisplayListDiff* = 0);
75 80
76 // Returns the approximate memory usage, excluding memory likely to be 81 // Returns the approximate memory usage, excluding memory likely to be
77 // shared with the embedder after copying to WebDisplayItemList. 82 // shared with the embedder after copying to WebDisplayItemList.
78 // Should only be called right after commitNewDisplayItems. 83 // Should only be called right after commitNewDisplayItems.
79 size_t approximateUnsharedMemoryUsage() const; 84 size_t approximateUnsharedMemoryUsage() const;
80 85
81 // Get the paint list generated after the last painting. 86 // Get the paint list generated after the last painting.
82 const DisplayItems& displayItems() const; 87 const DisplayItems& displayItems() const;
83 88
84 bool clientCacheIsValid(DisplayItemClient) const; 89 bool clientCacheIsValid(DisplayItemClient) const;
85 90
86 // Commits the new display items and plays back the updated display items in to the given context. 91 // Commits the new display items and plays back the updated display items in to the given context.
87 void commitNewDisplayItemsAndReplay(GraphicsContext& context) 92 void commitNewDisplayItemsAndReplay(GraphicsContext& context)
88 { 93 {
89 commitNewDisplayItems(); 94 commitNewDisplayItems();
90 replay(context); 95 replay(context);
91 } 96 }
92 97
98 void appendToWebDisplayItemList(WebDisplayItemList*);
93 void commitNewDisplayItemsAndAppendToWebDisplayItemList(WebDisplayItemList*) ; 99 void commitNewDisplayItemsAndAppendToWebDisplayItemList(WebDisplayItemList*) ;
94 100
95 bool displayItemConstructionIsDisabled() const { return m_constructionDisabl ed; } 101 bool displayItemConstructionIsDisabled() const { return m_constructionDisabl ed; }
96 void setDisplayItemConstructionIsDisabled(const bool disable) { m_constructi onDisabled = disable; } 102 void setDisplayItemConstructionIsDisabled(const bool disable) { m_constructi onDisabled = disable; }
97 103
98 #if ENABLE(ASSERT) 104 #if ENABLE(ASSERT)
99 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); } 105 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); }
100 #endif 106 #endif
101 107
102 #ifndef NDEBUG 108 #ifndef NDEBUG
103 void showDebugData() const; 109 void showDebugData() const;
104 #endif 110 #endif
105 111
106 protected: 112 protected:
107 DisplayItemList() 113 DisplayItemList()
108 : m_currentDisplayItems(kMaximumDisplayItemSize, 0) 114 : m_currentDisplayItems(kMaximumDisplayItemSize, 0)
109 , m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacit y * kMaximumDisplayItemSize) 115 , m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacit y * kMaximumDisplayItemSize)
110 , m_validlyCachedClientsDirty(false) 116 , m_validlyCachedClientsDirty(false)
111 , m_constructionDisabled(false) 117 , m_constructionDisabled(false)
112 , m_skippingCacheCount(0) 118 , m_skippingCacheCount(0)
113 , m_numCachedItems(0) 119 , m_numCachedItems(0)
114 , m_nextScope(1) { } 120 , m_nextScope(1) { }
115 121
116 private: 122 private:
117 friend class DisplayItemListTest; 123 friend class DisplayItemListTest;
118 friend class DisplayItemListPaintTest; 124 friend class DisplayItemListPaintTest;
125 friend class DisplayItemListPaintTestForSlimmingPaintV2;
119 friend class LayoutObjectDrawingRecorderTest; 126 friend class LayoutObjectDrawingRecorderTest;
120 127
121 // Set new item state (scopes, cache skipping, etc) for a new item. 128 // Set new item state (scopes, cache skipping, etc) for a new item.
122 // TODO(pdr): This only passes a pointer to make the patch easier to review. Change to a reference. 129 // TODO(pdr): This only passes a pointer to make the patch easier to review. Change to a reference.
123 void processNewItem(DisplayItem*); 130 void processNewItem(DisplayItem*);
124 131
125 void updateValidlyCachedClientsIfNeeded() const; 132 void updateValidlyCachedClientsIfNeeded() const;
126 133
127 #ifndef NDEBUG 134 #ifndef NDEBUG
128 WTF::String displayItemsAsDebugString(const DisplayItems&) const; 135 WTF::String displayItemsAsDebugString(const DisplayItems&) const;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // 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
173 // updatePaintList(), but checking during add() helps developer easily find where 180 // updatePaintList(), but checking during add() helps developer easily find where
174 // the duplicated ids are from. 181 // the duplicated ids are from.
175 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; 182 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient;
176 #endif 183 #endif
177 }; 184 };
178 185
179 } // namespace blink 186 } // namespace blink
180 187
181 #endif // DisplayItemList_h 188 #endif // DisplayItemList_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/ContentLayerDelegate.cpp ('k') | Source/platform/graphics/paint/DisplayItemList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698