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

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

Issue 1313223002: Simplify subtree (now subsequence) caching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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..bc88938534de27bf4ee62f6256e0774cb81e0156 100644
--- a/Source/platform/graphics/paint/SubtreeRecorder.cpp
+++ b/Source/platform/graphics/paint/SubtreeRecorder.cpp
@@ -13,46 +13,37 @@
namespace blink {
-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
+bool SubtreeRecorder::useCachedSubtreeIfPossible(GraphicsContext& context, const DisplayItemClientWrapper& client)
{
- if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
- return;
+ // The conditions of returning false is not complete for a specific client.
+ // The client must check additional conditions before calling this function.
- ASSERT(m_displayItemList);
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ ASSERT(context.displayItemList());
- // TODO(wangxianzhu): Implement subtree caching.
+ if (context.displayItemList()->displayItemConstructionIsDisabled() || RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
+ return false;
- if (!m_canUseCache)
- m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client, DisplayItem::paintPhaseToBeginSubtreeType(paintPhase));
+ if (!context.displayItemList()->clientCacheIsValid(client.displayItemClient()))
+ return false;
+
+ context.displayItemList()->createAndAppend<CachedDisplayItem>(client, DisplayItem::CachedSubtree);
+ return true;
}
-SubtreeRecorder::~SubtreeRecorder()
+SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClientWrapper& client)
+ : m_displayItemList(context.displayItemList())
+ , m_client(client)
{
- if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
- return;
-
- ASSERT(m_checkedCanUseCache);
- if (m_canUseCache)
- m_displayItemList->createAndAppend<CachedDisplayItem>(m_client, DisplayItem::paintPhaseToCachedSubtreeType(m_paintPhase));
- else if (m_displayItemList->lastDisplayItemIsNoopBegin())
chrishtr 2015/08/25 23:48:19 The no-op optimization is no longer useful?
Xianzhu 2015/08/26 23:21:06 Right. The situation is similar to that of empty d
- m_displayItemList->removeLastDisplayItem();
- else
- m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client, DisplayItem::paintPhaseToEndSubtreeType(m_paintPhase));
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ ASSERT(m_displayItemList);
+ m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client);
}
-bool SubtreeRecorder::canUseCache() const
+SubtreeRecorder::~SubtreeRecorder()
{
-#if ENABLE(ASSERT)
- m_checkedCanUseCache = true;
-#endif
- return m_canUseCache;
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698