• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COMPOSITING_SCENE_HOST_H_
6 #define FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_
7 
8 #include <lib/ui/scenic/cpp/id.h>
9 #include <stdint.h>
10 #include <zircon/types.h>
11 
12 #include "dart-pkg/zircon/sdk_ext/handle.h"
13 #include "flutter/fml/memory/ref_counted.h"
14 #include "flutter/fml/task_runner.h"
15 #include "flutter/lib/ui/dart_wrapper.h"
16 
17 namespace flutter {
18 
19 class SceneHost : public RefCountedDartWrappable<SceneHost> {
20   DEFINE_WRAPPERTYPEINFO();
21   FML_FRIEND_MAKE_REF_COUNTED(SceneHost);
22 
23  public:
24   static void RegisterNatives(tonic::DartLibraryNatives* natives);
25   static fml::RefPtr<SceneHost> Create(
26       fml::RefPtr<zircon::dart::Handle> viewHolderToken,
27       Dart_Handle viewConnectedCallback,
28       Dart_Handle viewDisconnectedCallback,
29       Dart_Handle viewStateChangedCallback);
30   static void OnViewConnected(scenic::ResourceId id);
31   static void OnViewDisconnected(scenic::ResourceId id);
32   static void OnViewStateChanged(scenic::ResourceId id, bool state);
33 
34   SceneHost(fml::RefPtr<zircon::dart::Handle> viewHolderToken,
35             Dart_Handle viewConnectedCallback,
36             Dart_Handle viewDisconnectedCallback,
37             Dart_Handle viewStateChangedCallback);
38   ~SceneHost() override;
39 
id()40   zx_koid_t id() const { return koid_; }
41 
42   void dispose();
43   void setProperties(double width,
44                      double height,
45                      double insetTop,
46                      double insetRight,
47                      double insetBottom,
48                      double insetLeft,
49                      bool focusable);
50   void setOpacity(double opacity);
51 
52  private:
53   fml::RefPtr<fml::TaskRunner> gpu_task_runner_;
54   tonic::DartPersistentValue view_connected_callback_;
55   tonic::DartPersistentValue view_disconnected_callback_;
56   tonic::DartPersistentValue view_state_changed_callback_;
57   zx_koid_t koid_ = ZX_KOID_INVALID;
58 };
59 
60 }  // namespace flutter
61 
62 #endif  // FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_
63