| 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/ScopeRecorder.h" | 6 #include "core/paint/ScopeRecorder.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 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 ScopeRecorder::ScopeRecorder(GraphicsContext& context, const LayoutObject& objec
t) | 15 ScopeRecorder::ScopeRecorder(GraphicsContext& context, const LayoutObject& objec
t, ShouldBegin shouldBegin) |
| 16 : m_displayItemList(context.displayItemList()) | 16 : m_displayItemList(context.displayItemList()) |
| 17 , m_object(object) | 17 , m_object(object) |
| 18 , m_engaged(false) |
| 18 { | 19 { |
| 20 if (shouldBegin == BeginOnConstruction) |
| 21 begin(); |
| 22 } |
| 23 |
| 24 ScopeRecorder::~ScopeRecorder() |
| 25 { |
| 26 if (!m_engaged) |
| 27 return; |
| 28 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 29 return; |
| 30 |
| 31 m_displayItemList->endScope(m_object.displayItemClient()); |
| 32 } |
| 33 |
| 34 void ScopeRecorder::begin() |
| 35 { |
| 36 ASSERT(!m_engaged); |
| 37 m_engaged = true; |
| 38 |
| 19 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 39 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 20 return; | 40 return; |
| 21 | 41 |
| 22 ASSERT(m_displayItemList); | 42 ASSERT(m_displayItemList); |
| 23 m_displayItemList->beginScope(m_object.displayItemClient()); | 43 m_displayItemList->beginScope(m_object.displayItemClient()); |
| 24 } | 44 } |
| 25 | 45 |
| 26 ScopeRecorder::~ScopeRecorder() | |
| 27 { | |
| 28 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | |
| 29 return; | |
| 30 | |
| 31 m_displayItemList->endScope(m_object.displayItemClient()); | |
| 32 } | |
| 33 | |
| 34 } // namespace blink | 46 } // namespace blink |
| OLD | NEW |