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 |
| 32 const PaintList& newPaintListForTesting() const { return m_newPaints; } |
| 33 const PaintList& oldPaintListForTesting() const { return m_paintList; } |
| 34 |
31 void invalidate(DisplayItemClient); | 35 void invalidate(DisplayItemClient); |
32 void invalidateAll(); | 36 void invalidateAll(); |
33 bool clientCacheIsValid(DisplayItemClient) const; | 37 bool clientCacheIsValid(DisplayItemClient) const; |
34 | 38 |
35 // Plays back the current PaintList() into the given context. | 39 // Plays back the current PaintList() into the given context. |
36 void replay(GraphicsContext*); | 40 void replay(GraphicsContext*); |
37 | 41 |
38 #ifndef NDEBUG | 42 #ifndef NDEBUG |
39 void showDebugData() const; | 43 void showDebugData() const; |
40 #endif | 44 #endif |
41 | 45 |
42 protected: | 46 protected: |
43 DisplayItemList() { }; | 47 DisplayItemList() { }; |
44 | 48 |
45 private: | 49 private: |
46 PaintList::iterator findNextMatchingCachedItem(PaintList::iterator, const Di
splayItem&); | 50 size_t findMatchingCachedItem(const DisplayItem&); |
47 bool wasInvalidated(const DisplayItem&) const; | |
48 void updatePaintList(); | 51 void updatePaintList(); |
49 | 52 |
50 #ifndef NDEBUG | 53 #ifndef NDEBUG |
51 WTF::String paintListAsDebugString(const PaintList&) const; | 54 WTF::String paintListAsDebugString(const PaintList&) const; |
52 #endif | 55 #endif |
53 | 56 |
| 57 typedef HashSet<DisplayItemClient> DisplayItemClientSet; |
| 58 typedef HashMap<DisplayItem::Id, size_t> DisplayItemIndexMap; |
| 59 |
| 60 static void appendDisplayItem(WTF::PassOwnPtr<DisplayItem>, PaintList&, Disp
layItemClientSet&, DisplayItemIndexMap&); |
| 61 void copyCachedSubtree(const DisplayItem&, PaintList&, DisplayItemClientSet&
, DisplayItemIndexMap&); |
| 62 |
54 PaintList m_paintList; | 63 PaintList m_paintList; |
55 HashSet<DisplayItemClient> m_cachedClients; | 64 DisplayItemClientSet m_cachedClients; |
| 65 DisplayItemIndexMap m_displayItemIndexMap; |
56 PaintList m_newPaints; | 66 PaintList m_newPaints; |
| 67 #if ENABLE(ASSERT) |
| 68 HashSet<DisplayItem::Id> m_newPaintIds; |
| 69 #endif |
57 }; | 70 }; |
58 | 71 |
59 } // namespace blink | 72 } // namespace blink |
60 | 73 |
61 #endif // DisplayItemList_h | 74 #endif // DisplayItemList_h |
OLD | NEW |