| 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 #ifndef DisplayItemListContextRecorder_h | 5 #ifndef DisplayItemListContextRecorder_h |
| 6 #define DisplayItemListContextRecorder_h | 6 #define DisplayItemListContextRecorder_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/DisplayItemList.h" | 10 #include "platform/graphics/paint/DisplayItemList.h" |
| 11 #include "wtf/OwnPtr.h" | 11 #include "wtf/OwnPtr.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class DisplayItemListContextRecorder { | 15 class DisplayItemListContextRecorder { |
| 16 WTF_MAKE_NONCOPYABLE(DisplayItemListContextRecorder); | 16 WTF_MAKE_NONCOPYABLE(DisplayItemListContextRecorder); |
| 17 STACK_ALLOCATED(); | 17 STACK_ALLOCATED(); |
| 18 public: | 18 public: |
| 19 DisplayItemListContextRecorder(GraphicsContext& context) | 19 DisplayItemListContextRecorder(GraphicsContext& context) |
| 20 : m_initialContext(context) | 20 : m_initialContext(context) |
| 21 { | 21 { |
| 22 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 22 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 m_displayItemList = DisplayItemList::create(); | 25 m_displayItemList = DisplayItemList::create(); |
| 26 m_displayItemListContext = adoptPtr(new GraphicsContext(m_displayItemLis
t.get(), | 26 m_displayItemListContext = adoptPtr(new GraphicsContext(m_displayItemLis
t.get(), |
| 27 context.contextDisabled() ? GraphicsContext::FullyDisabled : Graphic
sContext::NothingDisabled)); | 27 context.contextDisabled() ? GraphicsContext::FullyDisabled : Graphic
sContext::NothingDisabled)); |
| 28 m_displayItemListContext->setDeviceScaleFactor(context.deviceScaleFactor
()); |
| 29 m_displayItemListContext->setPrinting(context.printing()); |
| 28 } | 30 } |
| 29 | 31 |
| 30 ~DisplayItemListContextRecorder() | 32 ~DisplayItemListContextRecorder() |
| 31 { | 33 { |
| 32 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 33 return; | 35 return; |
| 34 | 36 |
| 35 ASSERT(m_displayItemList); | 37 ASSERT(m_displayItemList); |
| 36 m_displayItemList->commitNewDisplayItemsAndReplay(m_initialContext); | 38 m_displayItemList->commitNewDisplayItemsAndReplay(m_initialContext); |
| 37 } | 39 } |
| 38 | 40 |
| 39 GraphicsContext& context() const { return m_displayItemList ? *m_displayItem
ListContext : m_initialContext; } | 41 GraphicsContext& context() const { return m_displayItemList ? *m_displayItem
ListContext : m_initialContext; } |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 GraphicsContext& m_initialContext; | 44 GraphicsContext& m_initialContext; |
| 43 OwnPtr<DisplayItemList> m_displayItemList; | 45 OwnPtr<DisplayItemList> m_displayItemList; |
| 44 OwnPtr<GraphicsContext> m_displayItemListContext; | 46 OwnPtr<GraphicsContext> m_displayItemListContext; |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 } // namespace blink | 49 } // namespace blink |
| 48 | 50 |
| 49 #endif // DisplayItemListContextRecorder_h | 51 #endif // DisplayItemListContextRecorder_h |
| OLD | NEW |