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 "third_party/skia/include/core/SkRefCnt.h" |
12 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.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 | 27 |
28 public: | 28 public: |
29 // Constructs a new builder with the given bounds for the resulting recorded p
icture. If | 29 // Constructs a new builder with the given bounds for the resulting recorded |
30 // |metadata| is specified, that metadata is propagated to the builder's inter
nal canvas. If | 30 // picture. If |metadata| is specified, that metadata is propagated to the |
31 // |containingContext| is specified, the device scale factor, printing, and di
sabled state are | 31 // builder's internal canvas. If |containingContext| is specified, the device |
32 // propagated to the builder's internal context. | 32 // scale factor, printing, and disabled state are propagated to the builder's |
| 33 // internal context. |
33 SkPictureBuilder(const FloatRect& bounds, | 34 SkPictureBuilder(const FloatRect& bounds, |
34 SkMetaData* = nullptr, | 35 SkMetaData* = nullptr, |
35 GraphicsContext* containingContext = nullptr); | 36 GraphicsContext* containingContext = nullptr); |
36 ~SkPictureBuilder(); | 37 ~SkPictureBuilder(); |
37 | 38 |
38 GraphicsContext& context() { return *m_context; } | 39 GraphicsContext& context() { return *m_context; } |
39 | 40 |
40 // Returns a picture capturing all drawing performed on the builder's context
since | 41 // Returns a picture capturing all drawing performed on the builder's context |
41 // construction. | 42 // since construction. |
42 sk_sp<SkPicture> endRecording(); | 43 sk_sp<SkPicture> endRecording(); |
43 | 44 |
44 // DisplayItemClient methods | 45 // DisplayItemClient methods |
45 String debugName() const final { return "SkPictureBuilder"; } | 46 String debugName() const final { return "SkPictureBuilder"; } |
46 LayoutRect visualRect() const final { return LayoutRect(); } | 47 LayoutRect visualRect() const final { return LayoutRect(); } |
47 | 48 |
48 private: | 49 private: |
49 std::unique_ptr<PaintController> m_paintController; | 50 std::unique_ptr<PaintController> m_paintController; |
50 std::unique_ptr<GraphicsContext> m_context; | 51 std::unique_ptr<GraphicsContext> m_context; |
51 FloatRect m_bounds; | 52 FloatRect m_bounds; |
52 }; | 53 }; |
53 | 54 |
54 } // namespace blink | 55 } // namespace blink |
55 | 56 |
56 #endif // SkPictureBuilder_h | 57 #endif // SkPictureBuilder_h |
OLD | NEW |