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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/graphics/paint/SubtreeRecorder.h" 6 #include "platform/graphics/paint/SubtreeRecorder.h"
7 7
8 #include "platform/RuntimeEnabledFeatures.h" 8 #include "platform/RuntimeEnabledFeatures.h"
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/paint/CachedDisplayItem.h" 10 #include "platform/graphics/paint/CachedDisplayItem.h"
11 #include "platform/graphics/paint/DisplayItemList.h" 11 #include "platform/graphics/paint/DisplayItemList.h"
12 #include "platform/graphics/paint/SubtreeDisplayItem.h" 12 #include "platform/graphics/paint/SubtreeDisplayItem.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClie ntWrapper& client, int paintPhase) 16 bool SubtreeRecorder::useCachedSubtreeIfPossible(GraphicsContext& context, const DisplayItemClientWrapper& client)
17 {
18 // The conditions of returning false is not complete for a specific client.
19 // The client must check additional conditions before calling this function.
20
21 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
22 ASSERT(context.displayItemList());
23
24 if (context.displayItemList()->displayItemConstructionIsDisabled() || Runtim eEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
25 return false;
26
27 if (!context.displayItemList()->clientCacheIsValid(client.displayItemClient( )))
28 return false;
29
30 context.displayItemList()->createAndAppend<CachedDisplayItem>(client, Displa yItem::CachedSubtree);
31 return true;
32 }
33
34 SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClie ntWrapper& client)
17 : m_displayItemList(context.displayItemList()) 35 : m_displayItemList(context.displayItemList())
18 , m_client(client) 36 , m_client(client)
19 , m_paintPhase(paintPhase)
20 , m_canUseCache(false)
21 #if ENABLE(ASSERT)
22 , m_checkedCanUseCache(false)
23 #endif
24 { 37 {
25 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 38 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
26 return;
27
28 ASSERT(m_displayItemList); 39 ASSERT(m_displayItemList);
29 40 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client);
30 // TODO(wangxianzhu): Implement subtree caching.
31
32 if (!m_canUseCache)
33 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client, Di splayItem::paintPhaseToBeginSubtreeType(paintPhase));
34 } 41 }
35 42
36 SubtreeRecorder::~SubtreeRecorder() 43 SubtreeRecorder::~SubtreeRecorder()
37 { 44 {
38 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 45 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
39 return; 46 m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client);
40
41 ASSERT(m_checkedCanUseCache);
42 if (m_canUseCache)
43 m_displayItemList->createAndAppend<CachedDisplayItem>(m_client, DisplayI tem::paintPhaseToCachedSubtreeType(m_paintPhase));
44 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
45 m_displayItemList->removeLastDisplayItem();
46 else
47 m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client, Disp layItem::paintPhaseToEndSubtreeType(m_paintPhase));
48 }
49
50 bool SubtreeRecorder::canUseCache() const
51 {
52 #if ENABLE(ASSERT)
53 m_checkedCanUseCache = true;
54 #endif
55 return m_canUseCache;
56 } 47 }
57 48
58 } // namespace blink 49 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698