OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "platform/graphics/paint/SubtreeRecorder.h" | |
7 | |
8 #include "platform/RuntimeEnabledFeatures.h" | |
9 #include "platform/graphics/GraphicsContext.h" | |
10 #include "platform/graphics/paint/CachedDisplayItem.h" | |
11 #include "platform/graphics/paint/DisplayItemList.h" | |
12 #include "platform/graphics/paint/SubtreeDisplayItem.h" | |
13 | |
14 namespace blink { | |
15 | |
16 SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const DisplayItemClie
ntWrapper& client, int paintPhase) | |
17 : m_displayItemList(context.displayItemList()) | |
18 , m_client(client) | |
19 , m_paintPhase(paintPhase) | |
20 , m_canUseCache(false) | |
21 #if ENABLE(ASSERT) | |
22 , m_checkedCanUseCache(false) | |
23 #endif | |
24 { | |
25 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
26 return; | |
27 | |
28 ASSERT(m_displayItemList); | |
29 | |
30 // TODO(wangxianzhu): Implement subtree caching. | |
31 | |
32 if (!m_canUseCache) | |
33 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_client, Di
splayItem::paintPhaseToBeginSubtreeType(paintPhase)); | |
34 } | |
35 | |
36 SubtreeRecorder::~SubtreeRecorder() | |
37 { | |
38 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
39 return; | |
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()) | |
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 } | |
57 | |
58 } // namespace blink | |
OLD | NEW |