Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1280)

Unified Diff: Source/core/paint/ViewDisplayList.cpp

Issue 697543002: First implementation of the paint slimming update algorithm (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/paint/ViewDisplayList.h ('k') | Source/core/paint/ViewDisplayListTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/ViewDisplayList.cpp
diff --git a/Source/core/paint/ViewDisplayList.cpp b/Source/core/paint/ViewDisplayList.cpp
index 780aff5b9c6082ee6bb9743fff11b2bb8152d861..eada499b53a868838e3d9faee750f688b9b9389e 100644
--- a/Source/core/paint/ViewDisplayList.cpp
+++ b/Source/core/paint/ViewDisplayList.cpp
@@ -20,7 +20,7 @@ const PaintList& ViewDisplayList::paintList()
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
updatePaintList();
- return m_newPaints;
+ return m_paintList;
}
void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
@@ -35,10 +35,38 @@ void ViewDisplayList::invalidate(const RenderObject* renderer)
m_invalidated.add(renderer);
}
-bool ViewDisplayList::isRepaint(PaintList::iterator begin, const DisplayItem& displayItem)
+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
{
- notImplemented();
- return false;
+ PaintList::iterator end = m_paintList.end();
+
+ if (wasInvalidated(displayItem))
+ return end;
+
+ if (displayItem.renderer() && !m_paintListRenderers.contains(displayItem.renderer()))
+ return end;
+
+ for (PaintList::iterator it = begin; it != end; ++it) {
+ DisplayItem& existing = **it;
+ if (existing.idsEqual(displayItem))
+ return it;
+ }
+
+ // This should only occur for non-renderer display items.
+ // FIXME: figure out how to handle clips/etc.
+ ASSERT(!displayItem.renderer());
+ return end;
+}
+
+bool ViewDisplayList::wasInvalidated(const DisplayItem& displayItem) const
+{
+ 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
+}
+
+static void appendDisplayItem(PaintList& list, HashSet<const RenderObject*>& renderers, WTF::PassOwnPtr<DisplayItem> displayItem)
+{
+ if (RenderObject* renderer = displayItem->renderer())
+ renderers.add(renderer);
+ list.append(displayItem);
}
// Update the existing paintList by removing invalidated entries, updating repainted existing ones, and
@@ -48,7 +76,39 @@ bool ViewDisplayList::isRepaint(PaintList::iterator begin, const DisplayItem& di
// implied by the existing paint list, extra treewalks are avoided.
void ViewDisplayList::updatePaintList()
{
- notImplemented();
+ PaintList updatedList;
+ HashSet<const RenderObject*> updatedRenderers;
+
+ PaintList::iterator currentListIt = m_paintList.begin();
+ PaintList::iterator paintListEnd = m_paintList.end();
+ for (PaintList::iterator newIt = m_newPaints.begin(); newIt != m_newPaints.end(); ++newIt) {
+ DisplayItem& repaintedDisplayItem = **newIt;
+ PaintList::iterator repaintIt = wasUninvalidatedRepaint(currentListIt, repaintedDisplayItem);
+ if (repaintIt != paintListEnd) {
+ // Copy all of the non-invalidated existing chunks over until we hit the repainted chunk.
+ for (; currentListIt != repaintIt; ++currentListIt) {
+ DisplayItem& displayItem = **currentListIt;
+ if (!wasInvalidated(displayItem))
+ appendDisplayItem(updatedList, updatedRenderers, currentListIt->release());
+ }
+ currentListIt++;
+ }
+ // Copy over the new paint.
+ appendDisplayItem(updatedList, updatedRenderers, newIt->release());
+ }
+
+ // Copy over any remaining paints that were not invalidated.
+ for (; currentListIt != paintListEnd; ++currentListIt) {
+ if (!wasInvalidated(**currentListIt))
+ appendDisplayItem(updatedList, updatedRenderers, currentListIt->release());
+ }
+
+ m_invalidated.clear();
+ m_newPaints.clear();
+ m_paintList.clear();
+ m_paintListRenderers.clear();
+ m_paintListRenderers.swap(updatedRenderers);
+ m_paintList.swap(updatedList);
}
#ifndef NDEBUG
« no previous file with comments | « Source/core/paint/ViewDisplayList.h ('k') | Source/core/paint/ViewDisplayListTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698