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