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 #include "config.h" | 5 #include "config.h" |
6 #include "core/paint/ViewDisplayList.h" | 6 #include "core/paint/ViewDisplayList.h" |
7 | 7 |
8 #include "platform/NotImplemented.h" | 8 #include "platform/NotImplemented.h" |
9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
10 | 10 |
11 #ifndef NDEBUG | 11 #ifndef NDEBUG |
12 #include "core/rendering/RenderObject.h" | 12 #include "core/rendering/RenderObject.h" |
13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
14 #endif | 14 #endif |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 const PaintList& ViewDisplayList::paintList() | 18 const PaintList& ViewDisplayList::paintList() |
19 { | 19 { |
20 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 20 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
21 | 21 |
22 updatePaintList(); | 22 updatePaintList(); |
23 return m_newPaints; | 23 return m_paintList; |
24 } | 24 } |
25 | 25 |
26 void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem) | 26 void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem) |
27 { | 27 { |
28 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 28 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
29 m_newPaints.append(displayItem); | 29 m_newPaints.append(displayItem); |
30 } | 30 } |
31 | 31 |
32 void ViewDisplayList::invalidate(const RenderObject* renderer) | 32 void ViewDisplayList::invalidate(const RenderObject* renderer) |
33 { | 33 { |
34 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 34 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
35 m_invalidated.add(renderer); | 35 m_invalidated.add(renderer); |
36 } | 36 } |
37 | 37 |
38 bool ViewDisplayList::isRepaint(PaintList::iterator begin, const DisplayItem& di splayItem) | 38 PaintList::iterator ViewDisplayList::wasUninvalidatedRepaint(PaintList::iterator begin, const DisplayItem& displayItem) |
leviw_travelin_and_unemployed
2014/10/31 19:10:02
UninvalidatedRepaint? Let's come up with a better
pdr.
2014/10/31 20:37:56
Good catch. Went with findNotUnDeRepaintWithoutUnN
| |
39 { | 39 { |
40 notImplemented(); | 40 PaintList::iterator end = m_paintList.end(); |
41 return false; | 41 |
42 if (wasInvalidated(displayItem)) | |
43 return end; | |
44 | |
45 if (displayItem.renderer() && !m_paintListRenderers.contains(displayItem.ren derer())) | |
46 return end; | |
47 | |
48 for (PaintList::iterator it = begin; it != end; ++it) { | |
49 DisplayItem& existing = **it; | |
50 if (existing.idsEqual(displayItem)) | |
51 return it; | |
52 } | |
53 | |
54 // This should only occur for non-renderer display items. | |
55 // FIXME: figure out how to handle clips/etc. | |
56 ASSERT(!displayItem.renderer()); | |
57 return end; | |
58 } | |
59 | |
60 bool ViewDisplayList::wasInvalidated(const DisplayItem& displayItem) const | |
61 { | |
62 return displayItem.renderer() && m_invalidated.contains(displayItem.renderer ()); | |
leviw_travelin_and_unemployed
2014/10/31 19:10:02
I wonder if this hash lookup won't get expensive..
leviw_travelin_and_unemployed
2014/10/31 20:26:55
To be clear, I don't think we should take it away
pdr.
2014/10/31 20:37:56
We should be able to store both this lookup and th
| |
63 } | |
64 | |
65 static void appendDisplayItem(PaintList& list, HashSet<const RenderObject*>& ren derers, WTF::PassOwnPtr<DisplayItem> displayItem) | |
66 { | |
67 if (RenderObject* renderer = displayItem->renderer()) | |
68 renderers.add(renderer); | |
69 list.append(displayItem); | |
42 } | 70 } |
43 | 71 |
44 // Update the existing paintList by removing invalidated entries, updating repai nted existing ones, and | 72 // Update the existing paintList by removing invalidated entries, updating repai nted existing ones, and |
45 // appending new items. | 73 // appending new items. |
46 // | 74 // |
47 // The algorithm should be O(|existing paint list| + |newly painted list|). By u sing the ordering | 75 // The algorithm should be O(|existing paint list| + |newly painted list|). By u sing the ordering |
48 // implied by the existing paint list, extra treewalks are avoided. | 76 // implied by the existing paint list, extra treewalks are avoided. |
49 void ViewDisplayList::updatePaintList() | 77 void ViewDisplayList::updatePaintList() |
50 { | 78 { |
51 notImplemented(); | 79 PaintList updatedList; |
80 HashSet<const RenderObject*> updatedRenderers; | |
81 | |
82 PaintList::iterator currentListIt = m_paintList.begin(); | |
83 PaintList::iterator paintListEnd = m_paintList.end(); | |
84 for (PaintList::iterator newIt = m_newPaints.begin(); newIt != m_newPaints.e nd(); ++newIt) { | |
85 DisplayItem& repaintedDisplayItem = **newIt; | |
86 PaintList::iterator repaintIt = wasUninvalidatedRepaint(currentListIt, r epaintedDisplayItem); | |
87 if (repaintIt != paintListEnd) { | |
88 // Copy all of the non-invalidated existing chunks over until we hit the repainted chunk. | |
89 for (; currentListIt != repaintIt; ++currentListIt) { | |
90 DisplayItem& displayItem = **currentListIt; | |
91 if (!wasInvalidated(displayItem)) | |
92 appendDisplayItem(updatedList, updatedRenderers, currentList It->release()); | |
93 } | |
94 currentListIt++; | |
95 } | |
96 // Copy over the new paint. | |
97 appendDisplayItem(updatedList, updatedRenderers, newIt->release()); | |
98 } | |
99 | |
100 // Copy over any remaining paints that were not invalidated. | |
101 for (; currentListIt != paintListEnd; ++currentListIt) { | |
102 if (!wasInvalidated(**currentListIt)) | |
103 appendDisplayItem(updatedList, updatedRenderers, currentListIt->rele ase()); | |
104 } | |
105 | |
106 m_invalidated.clear(); | |
107 m_newPaints.clear(); | |
108 m_paintList.clear(); | |
109 m_paintListRenderers.clear(); | |
110 m_paintListRenderers.swap(updatedRenderers); | |
111 m_paintList.swap(updatedList); | |
52 } | 112 } |
53 | 113 |
54 #ifndef NDEBUG | 114 #ifndef NDEBUG |
55 WTF::String DisplayItem::typeAsDebugString(DisplayItem::Type type) | 115 WTF::String DisplayItem::typeAsDebugString(DisplayItem::Type type) |
56 { | 116 { |
57 switch (type) { | 117 switch (type) { |
58 case DisplayItem::DrawingPaintPhaseBlockBackground: return "DrawingPaintPhas eBlockBackground"; | 118 case DisplayItem::DrawingPaintPhaseBlockBackground: return "DrawingPaintPhas eBlockBackground"; |
59 case DisplayItem::DrawingPaintPhaseChildBlockBackground: return "DrawingPain tPhaseChildBlockBackground"; | 119 case DisplayItem::DrawingPaintPhaseChildBlockBackground: return "DrawingPain tPhaseChildBlockBackground"; |
60 case DisplayItem::DrawingPaintPhaseChildBlockBackgrounds: return "DrawingPai ntPhaseChildBlockBackgrounds"; | 120 case DisplayItem::DrawingPaintPhaseChildBlockBackgrounds: return "DrawingPai ntPhaseChildBlockBackgrounds"; |
61 case DisplayItem::DrawingPaintPhaseFloat: return "DrawingPaintPhaseFloat"; | 121 case DisplayItem::DrawingPaintPhaseFloat: return "DrawingPaintPhaseFloat"; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 } | 174 } |
115 | 175 |
116 void ViewDisplayList::showDebugData() const | 176 void ViewDisplayList::showDebugData() const |
117 { | 177 { |
118 fprintf(stderr, "paint list: [%s]\n", paintListAsDebugString(m_paintList).ut f8().data()); | 178 fprintf(stderr, "paint list: [%s]\n", paintListAsDebugString(m_paintList).ut f8().data()); |
119 fprintf(stderr, "new paints: [%s]\n", paintListAsDebugString(m_newPaints).ut f8().data()); | 179 fprintf(stderr, "new paints: [%s]\n", paintListAsDebugString(m_newPaints).ut f8().data()); |
120 } | 180 } |
121 #endif | 181 #endif |
122 | 182 |
123 } // namespace blink | 183 } // namespace blink |
OLD | NEW |