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

Side by Side 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 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 bool SubtreeRecorder::useCachedSubtreeIfPossible(GraphicsContext& context, const DisplayItemClientWrapper& client, int paintPhase)
pdr. 2015/08/20 22:45:06 int paintPhase -> PaintPhase phase, or maybe unsig
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 // 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
31 // Otherwise it means that we generated an empty subtree previously
32 // (e.g in PaintPhaseOutline phase but there is no descendant has outline).
33 if (context.displayItemList()->subtreeCacheIsValid(client.displayItemClient( ), DisplayItem::paintPhaseToBeginSubtreeType(paintPhase)))
34 context.displayItemList()->createAndAppend<CachedDisplayItem>(client, Di splayItem::paintPhaseToCachedSubtreeType(paintPhase));
35 return true;
36 }
37
16 SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClie ntWrapper& client, int paintPhase) 38 SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClie ntWrapper& client, int paintPhase)
17 : m_displayItemList(context.displayItemList()) 39 : m_displayItemList(context.displayItemList())
18 , m_client(client) 40 , m_client(client)
19 , m_paintPhase(paintPhase) 41 , m_paintPhase(paintPhase)
20 , m_canUseCache(false)
21 #if ENABLE(ASSERT)
22 , m_checkedCanUseCache(false)
23 #endif
24 { 42 {
25 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 43 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
26 return;
27
28 ASSERT(m_displayItemList); 44 ASSERT(m_displayItemList);
29 45
30 // TODO(wangxianzhu): Implement subtree caching. 46 // Must check SubtreeRecorder::useCachedSubtreeIfPossible before creating th e DrawingRecorder.
47 // ASSERT(!useCachedSubtreeIfPossible(context, client, paintPhase));
31 48
32 if (!m_canUseCache) 49 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(client, DisplayI tem::paintPhaseToBeginSubtreeType(paintPhase));
33 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client, Di splayItem::paintPhaseToBeginSubtreeType(paintPhase));
34 } 50 }
35 51
36 SubtreeRecorder::~SubtreeRecorder() 52 SubtreeRecorder::~SubtreeRecorder()
37 { 53 {
38 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 54 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
39 return;
40 55
41 ASSERT(m_checkedCanUseCache); 56 if (m_displayItemList->lastDisplayItemIsNoopBegin())
42 if (m_canUseCache)
43 m_displayItemList->createAndAppend<CachedDisplayItem>(m_client, DisplayI tem::paintPhaseToCachedSubtreeType(m_paintPhase));
44 else if (m_displayItemList->lastDisplayItemIsNoopBegin())
45 m_displayItemList->removeLastDisplayItem(); 57 m_displayItemList->removeLastDisplayItem();
46 else 58 else
47 m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client, Disp layItem::paintPhaseToEndSubtreeType(m_paintPhase)); 59 m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_client, Disp layItem::paintPhaseToEndSubtreeType(m_paintPhase));
48 } 60 }
49 61
50 bool SubtreeRecorder::canUseCache() const
51 {
52 #if ENABLE(ASSERT)
53 m_checkedCanUseCache = true;
54 #endif
55 return m_canUseCache;
56 }
57
58 } // namespace blink 62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698