| 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 SkPictureBuilder_h |
| 6 #define SkPictureBuilder_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 // When slimming paint ships we can remove this SkPicture abstraction and |
| 16 // rely on DisplayItemList here. |
| 17 class SkPictureBuilder { |
| 18 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); |
| 19 STACK_ALLOCATED(); |
| 20 public: |
| 21 SkPictureBuilder(const FloatRect& bounds) |
| 22 { |
| 23 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 24 m_displayItemList = DisplayItemList::create(); |
| 25 m_context = adoptPtr(new GraphicsContext(m_displayItemList.get())); |
| 26 } else { |
| 27 m_context = GraphicsContext::deprecatedCreateWithCanvas(nullptr); |
| 28 } |
| 29 m_context->beginRecording(bounds); |
| 30 } |
| 31 |
| 32 GraphicsContext& context() { return *m_context; } |
| 33 |
| 34 PassRefPtr<const SkPicture> endRecording() |
| 35 { |
| 36 if (m_displayItemList) |
| 37 m_displayItemList->commitNewDisplayItemsAndReplay(*m_context); |
| 38 return m_context->endRecording(); |
| 39 } |
| 40 |
| 41 private: |
| 42 OwnPtr<DisplayItemList> m_displayItemList; |
| 43 OwnPtr<GraphicsContext> m_context; |
| 44 }; |
| 45 |
| 46 } // namespace blink |
| 47 |
| 48 #endif // SkPictureBuilder_h |
| OLD | NEW |