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 "platform/graphics/paint/PaintRecord.h" |
11 #include "third_party/skia/include/core/SkRefCnt.h" | 12 #include "third_party/skia/include/core/SkRefCnt.h" |
12 #include "wtf/Noncopyable.h" | 13 #include "wtf/Noncopyable.h" |
13 #include <memory> | 14 #include <memory> |
14 | 15 |
15 class SkMetaData; | 16 class SkMetaData; |
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 // TODO(enne): rename this class to not be named SkPicture |
| 24 // When slimming paint ships we can remove this PaintRecord abstraction and |
24 // rely on PaintController here. | 25 // rely on PaintController here. |
25 class PLATFORM_EXPORT SkPictureBuilder final : public DisplayItemClient { | 26 class PLATFORM_EXPORT SkPictureBuilder final : public DisplayItemClient { |
26 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); | 27 WTF_MAKE_NONCOPYABLE(SkPictureBuilder); |
27 | 28 |
28 public: | 29 public: |
29 // Constructs a new builder with the given bounds for the resulting recorded | 30 // Constructs a new builder with the given bounds for the resulting recorded |
30 // picture. If |metadata| is specified, that metadata is propagated to the | 31 // picture. If |metadata| is specified, that metadata is propagated to the |
31 // builder's internal canvas. If |containingContext| is specified, the device | 32 // builder's internal canvas. If |containingContext| is specified, the device |
32 // scale factor, printing, and disabled state are propagated to the builder's | 33 // scale factor, printing, and disabled state are propagated to the builder's |
33 // internal context. | 34 // internal context. |
34 // If a PaintController is passed, it is used as the PaintController for | 35 // If a PaintController is passed, it is used as the PaintController for |
35 // painting the picture (and hence we can use its cache). Otherwise, a new | 36 // painting the picture (and hence we can use its cache). Otherwise, a new |
36 // PaintController is used for the duration of the picture building, which | 37 // PaintController is used for the duration of the picture building, which |
37 // therefore has no caching. | 38 // therefore has no caching. |
38 SkPictureBuilder(const FloatRect& bounds, | 39 SkPictureBuilder(const FloatRect& bounds, |
39 SkMetaData* = nullptr, | 40 SkMetaData* = nullptr, |
40 GraphicsContext* containingContext = nullptr, | 41 GraphicsContext* containingContext = nullptr, |
41 PaintController* = nullptr); | 42 PaintController* = nullptr); |
42 ~SkPictureBuilder(); | 43 ~SkPictureBuilder(); |
43 | 44 |
44 GraphicsContext& context() { return *m_context; } | 45 GraphicsContext& context() { return *m_context; } |
45 | 46 |
46 // Returns a picture capturing all drawing performed on the builder's context | 47 // Returns a picture capturing all drawing performed on the builder's context |
47 // since construction. | 48 // since construction. |
48 sk_sp<SkPicture> endRecording(); | 49 sk_sp<PaintRecord> endRecording(); |
49 | 50 |
50 // DisplayItemClient methods | 51 // DisplayItemClient methods |
51 String debugName() const final { return "SkPictureBuilder"; } | 52 String debugName() const final { return "SkPictureBuilder"; } |
52 LayoutRect visualRect() const final { return LayoutRect(); } | 53 LayoutRect visualRect() const final { return LayoutRect(); } |
53 | 54 |
54 private: | 55 private: |
55 PaintController* m_paintController; | 56 PaintController* m_paintController; |
56 std::unique_ptr<PaintController> m_paintControllerPtr; | 57 std::unique_ptr<PaintController> m_paintControllerPtr; |
57 std::unique_ptr<GraphicsContext> m_context; | 58 std::unique_ptr<GraphicsContext> m_context; |
58 FloatRect m_bounds; | 59 FloatRect m_bounds; |
59 }; | 60 }; |
60 | 61 |
61 } // namespace blink | 62 } // namespace blink |
62 | 63 |
63 #endif // SkPictureBuilder_h | 64 #endif // SkPictureBuilder_h |
OLD | NEW |