Chromium Code Reviews| 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/paint/DisplayItem.h" | 9 #include "platform/graphics/paint/DisplayItem.h" |
| 10 #include "wtf/HashMap.h" | |
| 10 #include "wtf/HashSet.h" | 11 #include "wtf/HashSet.h" |
| 11 #include "wtf/PassOwnPtr.h" | 12 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/Vector.h" | 13 #include "wtf/Vector.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class GraphicsContext; | 17 class GraphicsContext; |
| 17 | 18 |
| 18 typedef Vector<OwnPtr<DisplayItem>> PaintList; | 19 typedef Vector<OwnPtr<DisplayItem>> PaintList; |
| 19 | 20 |
| 20 class PLATFORM_EXPORT DisplayItemList { | 21 class PLATFORM_EXPORT DisplayItemList { |
| 21 WTF_MAKE_NONCOPYABLE(DisplayItemList); | 22 WTF_MAKE_NONCOPYABLE(DisplayItemList); |
| 22 WTF_MAKE_FAST_ALLOCATED; | 23 WTF_MAKE_FAST_ALLOCATED; |
| 23 public: | 24 public: |
| 24 static PassOwnPtr<DisplayItemList> create() { return adoptPtr(new DisplayIte mList); } | 25 static PassOwnPtr<DisplayItemList> create() { return adoptPtr(new DisplayIte mList); } |
| 25 | 26 |
| 26 void endNewPaints() { updatePaintList(); } | 27 void endNewPaints() { updatePaintList(); } |
| 27 | 28 |
| 28 const PaintList& paintList(); | 29 const PaintList& paintList() const; |
| 29 void add(WTF::PassOwnPtr<DisplayItem>); | 30 void add(WTF::PassOwnPtr<DisplayItem>); |
| 30 | 31 |
| 31 void invalidate(DisplayItemClient); | 32 void invalidate(DisplayItemClient); |
| 32 void invalidateAll(); | 33 void invalidateAll(); |
| 33 bool clientCacheIsValid(DisplayItemClient) const; | 34 bool clientCacheIsValid(DisplayItemClient) const; |
| 34 | 35 |
| 35 // Plays back the current PaintList() into the given context. | 36 // Plays back the current PaintList() into the given context. |
| 36 void replay(GraphicsContext*); | 37 void replay(GraphicsContext*); |
| 37 | 38 |
| 38 #ifndef NDEBUG | 39 #ifndef NDEBUG |
| 39 void showDebugData() const; | 40 void showDebugData() const; |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 protected: | 43 protected: |
| 43 DisplayItemList() { }; | 44 DisplayItemList() { }; |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 PaintList::iterator findNextMatchingCachedItem(PaintList::iterator, const Di splayItem&); | 47 friend class DrawingRecorderTest; |
| 47 bool wasInvalidated(const DisplayItem&) const; | 48 friend class ViewDisplayListTest; |
| 48 void updatePaintList(); | |
| 49 | 49 |
| 50 #ifndef NDEBUG | 50 #ifndef NDEBUG |
| 51 WTF::String paintListAsDebugString(const PaintList&) const; | 51 WTF::String paintListAsDebugString(const PaintList&) const; |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 void updatePaintList(); | |
| 55 | |
| 56 typedef HashSet<DisplayItemClient> DisplayItemClientSet; | |
| 57 typedef HashMap<DisplayItem::Id, size_t> DisplayItemIndexMap; | |
| 58 | |
| 59 size_t findDisplayItemById(const DisplayItem::Id&) const; | |
| 60 size_t findMatchingCachedItem(const DisplayItem&) const; | |
| 61 | |
| 62 static void appendDisplayItem(WTF::PassOwnPtr<DisplayItem>, PaintList&, Disp layItemClientSet&, DisplayItemIndexMap&); | |
| 63 void copyCachedSubtree(const DisplayItem&, PaintList&, DisplayItemClientSet& , DisplayItemIndexMap&); | |
| 64 | |
| 54 PaintList m_paintList; | 65 PaintList m_paintList; |
| 55 HashSet<DisplayItemClient> m_cachedClients; | 66 DisplayItemClientSet m_cachedClients; |
|
pdr.
2015/02/04 05:19:58
We're adding a lot of complexity (exposing Id, has
Xianzhu
2015/02/04 20:46:32
Actually the method was used in an older version o
| |
| 67 DisplayItemIndexMap m_displayItemIndexMap; | |
|
pdr.
2015/02/04 05:19:58
Can you add a comment here saying that this maps f
| |
| 56 PaintList m_newPaints; | 68 PaintList m_newPaints; |
| 69 #if ENABLE(ASSERT) | |
| 70 HashSet<DisplayItem::Id> m_newPaintIds; | |
| 71 #endif | |
| 57 }; | 72 }; |
| 58 | 73 |
| 59 } // namespace blink | 74 } // namespace blink |
| 60 | 75 |
| 61 #endif // DisplayItemList_h | 76 #endif // DisplayItemList_h |
| OLD | NEW |