1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_H_ |
6 | #define FLUTTER_LIB_UI_PAINTING_PICTURE_H_ |
7 | |
8 | #include "flutter/flow/skia_gpu_object.h" |
9 | #include "flutter/lib/ui/dart_wrapper.h" |
10 | #include "flutter/lib/ui/painting/image.h" |
11 | #include "flutter/lib/ui/ui_dart_state.h" |
12 | #include "third_party/skia/include/core/SkPicture.h" |
13 | |
14 | namespace tonic { |
15 | class DartLibraryNatives; |
16 | } // namespace tonic |
17 | |
18 | namespace flutter { |
19 | class Canvas; |
20 | |
21 | class Picture : public RefCountedDartWrappable<Picture> { |
22 | DEFINE_WRAPPERTYPEINFO(); |
23 | FML_FRIEND_MAKE_REF_COUNTED(Picture); |
24 | |
25 | public: |
26 | ~Picture() override; |
27 | static fml::RefPtr<Picture> Create(Dart_Handle dart_handle, |
28 | flutter::SkiaGPUObject<SkPicture> picture, |
29 | size_t external_allocation_size); |
30 | |
31 | sk_sp<SkPicture> picture() const { return picture_.get(); } |
32 | |
33 | Dart_Handle toImage(uint32_t width, |
34 | uint32_t height, |
35 | Dart_Handle raw_image_callback); |
36 | |
37 | void dispose(); |
38 | |
39 | size_t GetAllocationSize() const override; |
40 | |
41 | static void RegisterNatives(tonic::DartLibraryNatives* natives); |
42 | |
43 | static Dart_Handle RasterizeToImage(sk_sp<SkPicture> picture, |
44 | uint32_t width, |
45 | uint32_t height, |
46 | Dart_Handle raw_image_callback); |
47 | |
48 | size_t external_allocation_size() const { return external_allocation_size_; } |
49 | |
50 | private: |
51 | Picture(flutter::SkiaGPUObject<SkPicture> picture, |
52 | size_t external_allocation_size_); |
53 | |
54 | flutter::SkiaGPUObject<SkPicture> picture_; |
55 | size_t external_allocation_size_; |
56 | }; |
57 | |
58 | } // namespace flutter |
59 | |
60 | #endif // FLUTTER_LIB_UI_PAINTING_PICTURE_H_ |
61 |