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..fa05c69e0c26773d19bc340a7d2910c7c4a307e4 |
--- /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& subtreeRoot, PaintPhase paintPhase) |
+ : m_displayItemList(context->displayItemList()) |
+ , m_subtreeRoot(subtreeRoot) |
+ , m_paintPhase(paintPhase) |
+ , m_begun(false) |
+{ |
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled() || !RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled()) |
+ return; |
+ |
+ ASSERT(m_displayItemList); |
+} |
+ |
+SubtreeInfoRecorder::~SubtreeInfoRecorder() |
+{ |
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled() || !RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled()) |
+ return; |
+ |
+ if (m_begun) |
+ addDisplayItem(EndSubtreeDisplayItem::create(m_subtreeRoot.displayItemClient(), DisplayItem::paintPhaseToEndSubtreeType(m_paintPhase))); |
+ else if (m_displayItemList->clientCacheIsValid(m_subtreeRoot.displayItemClient())) |
+ addDisplayItem(SubtreeCachedDisplayItem::create(m_subtreeRoot.displayItemClient(), DisplayItem::paintPhaseToSubtreeCachedType(m_paintPhase))); |
+} |
+ |
+void SubtreeInfoRecorder::begin() |
+{ |
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled() || !RuntimeEnabledFeatures::slimmingPaintDisplayItemCacheEnabled()) |
+ return; |
+ |
+ addDisplayItem(BeginSubtreeDisplayItem::create(m_subtreeRoot.displayItemClient(), DisplayItem::paintPhaseToBeginSubtreeType(m_paintPhase))); |
+ m_begun = true; |
+} |
+ |
+void SubtreeInfoRecorder::addDisplayItem(PassOwnPtr<DisplayItem> displayItem) |
+{ |
+#ifndef NDEBUG |
+ displayItem->setClientDebugString(String::format("subtreeRoot: \"%p %s\"", &m_subtreeRoot, m_subtreeRoot.debugName().utf8().data())); |
+#endif |
+ m_displayItemList->add(displayItem); |
+} |
+ |
+} // namespace blink |