OLD | NEW |
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 "core/paint/SubtreeRecorder.h" | 6 #include "core/paint/SubtreeRecorder.h" |
7 | 7 |
8 #include "core/layout/LayoutObject.h" | 8 #include "core/layout/LayoutObject.h" |
9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
10 #include "platform/graphics/GraphicsContext.h" | 10 #include "platform/graphics/GraphicsContext.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 LayoutObject& s
ubtreeRoot, PaintPhase paintPhase) | 16 SubtreeRecorder::SubtreeRecorder(GraphicsContext& context, const LayoutObject& s
ubtreeRoot, PaintPhase paintPhase) |
17 : m_displayItemList(context.displayItemList()) | 17 : m_displayItemList(context.displayItemList()) |
18 , m_subtreeRoot(subtreeRoot) | 18 , m_subtreeRoot(subtreeRoot) |
19 , m_paintPhase(paintPhase) | 19 , m_paintPhase(paintPhase) |
20 , m_begun(false) | 20 , m_canUseCache(false) |
| 21 #if ENABLE(ASSERT) |
| 22 , m_checkedCanUseCache(false) |
| 23 #endif |
21 { | 24 { |
22 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 25 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
23 return; | 26 return; |
24 | 27 |
25 ASSERT(m_displayItemList); | 28 ASSERT(m_displayItemList); |
| 29 |
| 30 // TODO(wangxianzhu): Implement subtree caching. |
| 31 |
| 32 if (!m_canUseCache) |
| 33 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_subtreeRoo
t, DisplayItem::paintPhaseToBeginSubtreeType(paintPhase)); |
26 } | 34 } |
27 | 35 |
28 SubtreeRecorder::~SubtreeRecorder() | 36 SubtreeRecorder::~SubtreeRecorder() |
29 { | 37 { |
30 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 38 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
31 return; | 39 return; |
32 | 40 |
33 if (m_begun) { | 41 ASSERT(m_checkedCanUseCache); |
34 if (m_displayItemList->lastDisplayItemIsNoopBegin()) | 42 if (m_canUseCache) |
35 m_displayItemList->removeLastDisplayItem(); | 43 m_displayItemList->createAndAppend<SubtreeCachedDisplayItem>(m_subtreeRo
ot, DisplayItem::paintPhaseToSubtreeCachedType(m_paintPhase)); |
36 else | 44 else if (m_displayItemList->lastDisplayItemIsNoopBegin()) |
37 m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_subtreeR
oot, DisplayItem::paintPhaseToEndSubtreeType(m_paintPhase)); | 45 m_displayItemList->removeLastDisplayItem(); |
38 } | 46 else |
| 47 m_displayItemList->createAndAppend<EndSubtreeDisplayItem>(m_subtreeRoot,
DisplayItem::paintPhaseToEndSubtreeType(m_paintPhase)); |
39 } | 48 } |
40 | 49 |
41 void SubtreeRecorder::begin() | 50 bool SubtreeRecorder::canUseCache() const |
42 { | 51 { |
43 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 52 #if ENABLE(ASSERT) |
44 return; | 53 m_checkedCanUseCache = true; |
45 if (m_displayItemList->displayItemConstructionIsDisabled()) | 54 #endif |
46 return; | 55 return m_canUseCache; |
47 m_displayItemList->createAndAppend<BeginSubtreeDisplayItem>(m_subtreeRoot, D
isplayItem::paintPhaseToBeginSubtreeType(m_paintPhase)); | |
48 m_begun = true; | |
49 } | 56 } |
50 | 57 |
51 } // namespace blink | 58 } // namespace blink |
OLD | NEW |