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

Unified Diff: Source/platform/graphics/paint/SubtreeRecorder.cpp

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/platform/graphics/paint/SubtreeRecorder.cpp
diff --git a/Source/platform/graphics/paint/SubtreeRecorder.cpp b/Source/platform/graphics/paint/SubtreeRecorder.cpp
index 5cc1e8caf64f7784318d66d3480247c9ab8fd53c..f8a3163ace99a9dcf2db5648ec221bc43d1991c4 100644
--- a/Source/platform/graphics/paint/SubtreeRecorder.cpp
+++ b/Source/platform/graphics/paint/SubtreeRecorder.cpp
@@ -13,46 +13,50 @@
namespace blink {
+bool SubtreeRecorder::useCachedSubtreeIfPossible(GraphicsContext& context, const DisplayItemClientWrapper& client, int paintPhase)
pdr. 2015/08/20 22:45:06 int paintPhase -> PaintPhase phase, or maybe unsig
+{
+ // The conditions of returning false is not complete for a specific client.
+ // The client must check additional conditions before calling this function.
+
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ ASSERT(context.displayItemList());
+
+ if (context.displayItemList()->displayItemConstructionIsDisabled() || RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
+ return false;
+
+ if (!context.displayItemList()->clientCacheIsValid(client.displayItemClient()))
+ return false;
+
+ // Append CachedSubtree display item only if we have cached the subtree.
pdr. 2015/08/20 22:45:06 WDYT about disabling the empty pair optimization f
Xianzhu 2015/08/21 00:31:38 That will generate empty subtrees for paint phases
+ // Otherwise it means that we generated an empty subtree previously
+ // (e.g in PaintPhaseOutline phase but there is no descendant has outline).
+ if (context.displayItemList()->subtreeCacheIsValid(client.displayItemClient(), DisplayItem::paintPhaseToBeginSubtreeType(paintPhase)))
+ context.displayItemList()->createAndAppend<CachedDisplayItem>(client, DisplayItem::paintPhaseToCachedSubtreeType(paintPhase));
+ return true;
+}
+
SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClientWrapper& client, int paintPhase)
: m_displayItemList(context.displayItemList())
, m_client(client)
, m_paintPhase(paintPhase)
- , m_canUseCache(false)
-#if ENABLE(ASSERT)
- , m_checkedCanUseCache(false)
-#endif
{
- if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
- return;
-
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
ASSERT(m_displayItemList);
- // TODO(wangxianzhu): Implement subtree caching.
+ // Must check SubtreeRecorder::useCachedSubtreeIfPossible before creating the DrawingRecorder.
+ // ASSERT(!useCachedSubtreeIfPossible(context, client, paintPhase));
- if (!m_canUseCache)
- m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client, DisplayItem::paintPhaseToBeginSubtreeType(paintPhase));
+ m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(client, DisplayItem::paintPhaseToBeginSubtreeType(paintPhase));
}
SubtreeRecorder::~SubtreeRecorder()
{
- if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
- return;
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
- ASSERT(m_checkedCanUseCache);
- if (m_canUseCache)
- m_displayItemList->createAndAppend<CachedDisplayItem>(m_client, DisplayItem::paintPhaseToCachedSubtreeType(m_paintPhase));
- else if (m_displayItemList->lastDisplayItemIsNoopBegin())
+ if (m_displayItemList->lastDisplayItemIsNoopBegin())
m_displayItemList->removeLastDisplayItem();
else
m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client, DisplayItem::paintPhaseToEndSubtreeType(m_paintPhase));
}
-bool SubtreeRecorder::canUseCache() const
-{
-#if ENABLE(ASSERT)
- m_checkedCanUseCache = true;
-#endif
- return m_canUseCache;
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698