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_ENGINE_LAYER_H_ |
6 | #define FLUTTER_LIB_UI_PAINTING_ENGINE_LAYER_H_ |
7 | |
8 | #include "flutter/lib/ui/dart_wrapper.h" |
9 | |
10 | #include "flutter/flow/layers/container_layer.h" |
11 | |
12 | namespace tonic { |
13 | class DartLibraryNatives; |
14 | } // namespace tonic |
15 | |
16 | namespace flutter { |
17 | |
18 | class EngineLayer; |
19 | |
20 | class EngineLayer : public RefCountedDartWrappable<EngineLayer> { |
21 | DEFINE_WRAPPERTYPEINFO(); |
22 | |
23 | public: |
24 | ~EngineLayer() override; |
25 | |
26 | size_t GetAllocationSize() const override; |
27 | |
28 | static fml::RefPtr<EngineLayer> MakeRetained( |
29 | std::shared_ptr<flutter::ContainerLayer> layer) { |
30 | return fml::MakeRefCounted<EngineLayer>(layer); |
31 | } |
32 | |
33 | static void MakeRetained(Dart_Handle dart_handle, |
34 | std::shared_ptr<flutter::ContainerLayer> layer) { |
35 | auto engine_layer = fml::MakeRefCounted<EngineLayer>(layer); |
36 | engine_layer->AssociateWithDartWrapper(dart_handle); |
37 | } |
38 | |
39 | static void RegisterNatives(tonic::DartLibraryNatives* natives); |
40 | |
41 | std::shared_ptr<flutter::ContainerLayer> Layer() const { return layer_; } |
42 | |
43 | private: |
44 | explicit EngineLayer(std::shared_ptr<flutter::ContainerLayer> layer); |
45 | std::shared_ptr<flutter::ContainerLayer> layer_; |
46 | |
47 | FML_FRIEND_MAKE_REF_COUNTED(EngineLayer); |
48 | }; |
49 | |
50 | } // namespace flutter |
51 | |
52 | #endif // FLUTTER_LIB_UI_PAINTING_ENGINE_LAYER_H_ |
53 |