| 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 "skia/ext/cdl_common.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 // When slimming paint ships we can remove this CdlPicture 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 | 29 // Constructs a new builder with the given bounds for the resulting recorded |
| 30 // picture. If |metadata| is specified, that metadata is propagated to the | 30 // picture. If |metadata| is specified, that metadata is propagated to the |
| 31 // builder's internal canvas. If |containingContext| is specified, the device | 31 // builder's internal canvas. If |containingContext| is specified, the device |
| 32 // scale factor, printing, and disabled state are propagated to the builder's | 32 // scale factor, printing, and disabled state are propagated to the builder's |
| 33 // internal context. | 33 // internal context. |
| 34 // If a PaintController is passed, it is used as the PaintController for | 34 // 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 | 35 // 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 | 36 // PaintController is used for the duration of the picture building, which |
| 37 // therefore has no caching. | 37 // therefore has no caching. |
| 38 SkPictureBuilder(const FloatRect& bounds, | 38 SkPictureBuilder(const FloatRect& bounds, |
| 39 SkMetaData* = nullptr, | 39 SkMetaData* = nullptr, |
| 40 GraphicsContext* containingContext = nullptr, | 40 GraphicsContext* containingContext = nullptr, |
| 41 PaintController* = nullptr); | 41 PaintController* = nullptr); |
| 42 ~SkPictureBuilder(); | 42 ~SkPictureBuilder(); |
| 43 | 43 |
| 44 GraphicsContext& context() { return *m_context; } | 44 GraphicsContext& context() { return *m_context; } |
| 45 | 45 |
| 46 // Returns a picture capturing all drawing performed on the builder's context | 46 // Returns a picture capturing all drawing performed on the builder's context |
| 47 // since construction. | 47 // since construction. |
| 48 sk_sp<SkPicture> endRecording(); | 48 sk_sp<CdlPicture> endRecording(); |
| 49 | 49 |
| 50 // DisplayItemClient methods | 50 // DisplayItemClient methods |
| 51 String debugName() const final { return "SkPictureBuilder"; } | 51 String debugName() const final { return "SkPictureBuilder"; } |
| 52 LayoutRect visualRect() const final { return LayoutRect(); } | 52 LayoutRect visualRect() const final { return LayoutRect(); } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 PaintController* m_paintController; | 55 PaintController* m_paintController; |
| 56 std::unique_ptr<PaintController> m_paintControllerPtr; | 56 std::unique_ptr<PaintController> m_paintControllerPtr; |
| 57 std::unique_ptr<GraphicsContext> m_context; | 57 std::unique_ptr<GraphicsContext> m_context; |
| 58 FloatRect m_bounds; | 58 FloatRect m_bounds; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace blink | 61 } // namespace blink |
| 62 | 62 |
| 63 #endif // SkPictureBuilder_h | 63 #endif // SkPictureBuilder_h |
| OLD | NEW |