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

Unified Diff: Source/core/paint/LayoutObjectSubtreeRecorder.h

Issue 1294233004: Subtree caching implementation in blink-core (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: s/setSelfNeedsRepaint/setNeedsRepaint/ Created 5 years, 4 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/LayoutObjectSubtreeRecorder.h
diff --git a/Source/core/paint/LayoutObjectSubtreeRecorder.h b/Source/core/paint/LayoutObjectSubtreeRecorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..2f0f0f88356b0cab0627388c757eb6696a62b0cd
--- /dev/null
+++ b/Source/core/paint/LayoutObjectSubtreeRecorder.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef LayoutObjectSubtreeRecorder_h
+#define LayoutObjectSubtreeRecorder_h
+
+#include "core/layout/LayoutObject.h"
+#include "core/paint/PaintPhase.h"
+#include "platform/graphics/paint/SubtreeRecorder.h"
+
+namespace blink {
+
+class GraphicsContext;
+
+// Convenience wrapper of SubtreeRecorder for LayoutObject painters.
pdr. 2015/08/20 22:45:06 Do we need subtree recorders for anything but layo
Xianzhu 2015/08/21 00:31:38 Done. Previously I moved SubtreeRecorder from cor
+class LayoutObjectSubtreeRecorder final {
+public:
+ LayoutObjectSubtreeRecorder(GraphicsContext& context, const LayoutObject& layoutObject, PaintPhase phase)
+ : m_canUseCache(false)
+#if ENABLE(ASSERT)
+#endif
+ {
+ if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
+ return;
+ if (!needsSubtreeRecorder(layoutObject))
+ return;
+
+ m_canUseCache = !layoutObject.shouldCheckForRepaint() && SubtreeRecorder::useCachedSubtreeIfPossible(context, layoutObject, phase);
+ if (!m_canUseCache)
+ m_subtreeRecorder.emplace(context, layoutObject, phase);
+ }
+
+ bool canUseCache() const { return m_canUseCache; }
+
+private:
+ // We need to balance the benefit of subtree optimization and the cost of subtree display items.
+ // Only output subtree information if the block has multiple children or multiple line boxes.
+ static bool needsSubtreeRecorder(const LayoutObject& layoutObject)
+ {
+ return (layoutObject.slowFirstChild() && layoutObject.slowFirstChild()->nextSibling())
+ || (layoutObject.isLayoutBlockFlow() && toLayoutBlockFlow(layoutObject).firstLineBox() && toLayoutBlockFlow(layoutObject).firstLineBox()->nextLineBox());
+ }
+
+ Optional<SubtreeRecorder> m_subtreeRecorder;
+ bool m_canUseCache;
pdr. 2015/08/20 22:45:06 I think we can reuse the pointer in m_subtreeRecor
Xianzhu 2015/08/21 00:31:38 Done.
+#if ENABLE(ASSERT)
pdr. 2015/08/20 22:45:06 Oops
Xianzhu 2015/08/21 00:31:38 Done.
+
+#endif
+};
+
+} // namespace blink
+
+#endif // LayoutObjectSubtreeRecorder_h

Powered by Google App Engine
This is Rietveld 408576698