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/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/geometry/FloatRect.h" | 9 #include "platform/geometry/FloatRect.h" |
10 #include "platform/graphics/paint/DisplayItemClient.h" | 10 #include "platform/graphics/paint/DisplayItemClient.h" |
| 11 #include "third_party/skia/include/core/SkRefCnt.h" |
11 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
12 #include "wtf/PassRefPtr.h" | |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 class SkMetaData; | 15 class SkMetaData; |
16 class SkPicture; | 16 class SkPicture; |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class GraphicsContext; | 20 class GraphicsContext; |
21 class PaintController; | 21 class PaintController; |
22 | 22 |
23 // When slimming paint ships we can remove this SkPicture abstraction and | 23 // When slimming paint ships we can remove this SkPicture abstraction and |
24 // rely on PaintController here. | 24 // rely on PaintController here. |
25 class PLATFORM_EXPORT SkPictureBuilder final : public DisplayItemClient { | 25 class PLATFORM_EXPORT SkPictureBuilder final : public DisplayItemClient { |
26 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); | 26 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); |
27 public: | 27 public: |
28 // Constructs a new builder with the given bounds for the resulting recorded
picture. If | 28 // Constructs a new builder with the given bounds for the resulting recorded
picture. If |
29 // |metadata| is specified, that metadata is propagated to the builder's int
ernal canvas. If | 29 // |metadata| is specified, that metadata is propagated to the builder's int
ernal canvas. If |
30 // |containingContext| is specified, the device scale factor, printing, and
disabled state are | 30 // |containingContext| is specified, the device scale factor, printing, and
disabled state are |
31 // propagated to the builder's internal context. | 31 // propagated to the builder's internal context. |
32 SkPictureBuilder(const FloatRect& bounds, SkMetaData* = nullptr, GraphicsCon
text* containingContext = nullptr); | 32 SkPictureBuilder(const FloatRect& bounds, SkMetaData* = nullptr, GraphicsCon
text* containingContext = nullptr); |
33 ~SkPictureBuilder(); | 33 ~SkPictureBuilder(); |
34 | 34 |
35 GraphicsContext& context() { return *m_context; } | 35 GraphicsContext& context() { return *m_context; } |
36 | 36 |
37 // Returns a picture capturing all drawing performed on the builder's contex
t since | 37 // Returns a picture capturing all drawing performed on the builder's contex
t since |
38 // construction. | 38 // construction. |
39 PassRefPtr<SkPicture> endRecording(); | 39 sk_sp<SkPicture> endRecording(); |
40 | 40 |
41 // DisplayItemClient methods | 41 // DisplayItemClient methods |
42 String debugName() const final { return "SkPictureBuilder"; } | 42 String debugName() const final { return "SkPictureBuilder"; } |
43 LayoutRect visualRect() const final { return LayoutRect(); } | 43 LayoutRect visualRect() const final { return LayoutRect(); } |
44 | 44 |
45 private: | 45 private: |
46 std::unique_ptr<PaintController> m_paintController; | 46 std::unique_ptr<PaintController> m_paintController; |
47 std::unique_ptr<GraphicsContext> m_context; | 47 std::unique_ptr<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 |