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; } | |
chrishtr
2015/02/03 22:30:48
friend classses would be better for these two. Chr
Xianzhu
2015/02/04 00:13:24
For now we can't include either <gtest/gtest.h> or
| |
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&); | |
47 bool wasInvalidated(const DisplayItem&) const; | |
48 void updatePaintList(); | |
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; |
67 DisplayItemIndexMap m_displayItemIndexMap; | |
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 |