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