| OLD | NEW |
| 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 Loading... |
| 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; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 109 , m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacit
y * kMaximumDisplayItemSize) | 114 , m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacit
y * kMaximumDisplayItemSize) |
| 110 , m_validlyCachedClientsDirty(false) | 115 , m_validlyCachedClientsDirty(false) |
| 111 , m_constructionDisabled(false) | 116 , m_constructionDisabled(false) |
| 112 , m_skippingCacheCount(0) | 117 , m_skippingCacheCount(0) |
| 113 , m_numCachedItems(0) | 118 , m_numCachedItems(0) |
| 114 , m_nextScope(1) { } | 119 , m_nextScope(1) { } |
| 115 | 120 |
| 116 private: | 121 private: |
| 117 friend class DisplayItemListTest; | 122 friend class DisplayItemListTest; |
| 118 friend class DisplayItemListPaintTest; | 123 friend class DisplayItemListPaintTest; |
| 124 friend class DisplayItemListPaintTestForSlimmingPaintV2; |
| 119 friend class LayoutObjectDrawingRecorderTest; | 125 friend class LayoutObjectDrawingRecorderTest; |
| 120 | 126 |
| 121 // Set new item state (scopes, cache skipping, etc) for a new item. | 127 // 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. | 128 // TODO(pdr): This only passes a pointer to make the patch easier to review.
Change to a reference. |
| 123 void processNewItem(DisplayItem*); | 129 void processNewItem(DisplayItem*); |
| 124 | 130 |
| 125 void updateValidlyCachedClientsIfNeeded() const; | 131 void updateValidlyCachedClientsIfNeeded() const; |
| 126 | 132 |
| 127 #ifndef NDEBUG | 133 #ifndef NDEBUG |
| 128 WTF::String displayItemsAsDebugString(const DisplayItems&) const; | 134 WTF::String displayItemsAsDebugString(const DisplayItems&) const; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // This is used to check duplicated ids during add(). We could also check du
ring | 177 // This is used to check duplicated ids during add(). We could also check du
ring |
| 172 // updatePaintList(), but checking during add() helps developer easily find
where | 178 // updatePaintList(), but checking during add() helps developer easily find
where |
| 173 // the duplicated ids are from. | 179 // the duplicated ids are from. |
| 174 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 180 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
| 175 #endif | 181 #endif |
| 176 }; | 182 }; |
| 177 | 183 |
| 178 } // namespace blink | 184 } // namespace blink |
| 179 | 185 |
| 180 #endif // DisplayItemList_h | 186 #endif // DisplayItemList_h |
| OLD | NEW |