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

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

Issue 847783003: New display item caching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: New method, supporting partial paint Created 5 years, 11 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
Index: Source/core/paint/SubtreeInfoRecorder.cpp
diff --git a/Source/core/paint/SubtreeInfoRecorder.cpp b/Source/core/paint/SubtreeInfoRecorder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2a4b48785244faebc2ed736fd313637afd554b08
--- /dev/null
+++ b/Source/core/paint/SubtreeInfoRecorder.cpp
@@ -0,0 +1,56 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/paint/SubtreeInfoRecorder.h"
+
+#include "core/rendering/RenderObject.h"
+#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/paint/DisplayItemList.h"
+#include "platform/graphics/paint/SubtreeDisplayItem.h"
+
+namespace blink {
+
+SubtreeInfoRecorder::SubtreeInfoRecorder(GraphicsContext* context, const RenderObject& renderer, PaintPhase paintPhase)
+ : m_displayItemList(context->displayItemList())
+ , m_renderer(renderer)
+ , m_displayItemType(static_cast<DisplayItem::Type>(paintPhase))
+ , m_begun(false)
+{
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
+ return;
+
+ ASSERT(m_displayItemList);
+}
+
+SubtreeInfoRecorder::~SubtreeInfoRecorder()
+{
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
+ return;
+
+ if (m_begun)
+ addDisplayItem(EndSubtreeDisplayItem::create(m_renderer.displayItemClient(), m_displayItemType));
+ else if (m_displayItemList->clientCacheIsValid(m_renderer.displayItemClient()))
+ addDisplayItem(SubtreeCachedDisplayItem::create(m_renderer.displayItemClient(), m_displayItemType));
+}
+
+void SubtreeInfoRecorder::begin()
+{
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
+ return;
+
+ addDisplayItem(BeginSubtreeDisplayItem::create(m_renderer.displayItemClient(), m_displayItemType));
+ m_begun = true;
+}
+
+void SubtreeInfoRecorder::addDisplayItem(PassOwnPtr<DisplayItem> displayItem)
+{
+#ifndef NDEBUG
+ displayItem->setClientDebugString(String::format("renderer: \"%p %s\"", &m_renderer, m_renderer.debugName().utf8().data()));
+#endif
+ m_displayItemList->add(displayItem);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698