| 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 DisplayItemListPictureRecorder_h |
| 6 #define DisplayItemListPictureRecorder_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 DisplayItemListPictureRecorder { |
| 16 WTF_MAKE_NONCOPYABLE(DisplayItemListPictureRecorder); |
| 17 STACK_ALLOCATED(); |
| 18 public: |
| 19 DisplayItemListPictureRecorder(const FloatRect& bounds) |
| 20 : m_displayItemList(RuntimeEnabledFeatures::slimmingPaintEnabled() ? Dis
playItemList::create() : nullptr) |
| 21 , m_context(nullptr, m_displayItemList.get()) |
| 22 #if ENABLE(ASSERT) |
| 23 , m_recordingEnded(false) |
| 24 #endif |
| 25 { |
| 26 m_context.beginRecording(bounds); |
| 27 } |
| 28 |
| 29 ~DisplayItemListPictureRecorder() |
| 30 { |
| 31 ASSERT(m_recordingEnded); |
| 32 } |
| 33 |
| 34 GraphicsContext& context() { return m_context; } |
| 35 |
| 36 PassRefPtr<const SkPicture> endRecording() |
| 37 { |
| 38 #if ENABLE(ASSERT) |
| 39 ASSERT(!m_recordingEnded); |
| 40 m_recordingEnded = true; |
| 41 #endif |
| 42 |
| 43 if (m_displayItemList) |
| 44 m_displayItemList->replay(&m_context); |
| 45 |
| 46 return m_context.endRecording(); |
| 47 } |
| 48 |
| 49 private: |
| 50 OwnPtr<DisplayItemList> m_displayItemList; |
| 51 GraphicsContext m_context; |
| 52 |
| 53 #if ENABLE(ASSERT) |
| 54 bool m_recordingEnded; |
| 55 #endif |
| 56 }; |
| 57 |
| 58 } // namespace blink |
| 59 |
| 60 #endif // DisplayItemListPictureRecorder_h |
| OLD | NEW |