runtime_controller.h 2.2 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
#define FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
7 8

#include <memory>
9

10
#include "flutter/flow/layers/layer_tree.h"
11
#include "flutter/lib/ui/ui_dart_state.h"
12
#include "flutter/lib/ui/window/pointer_data_packet.h"
13
#include "flutter/lib/ui/window/window.h"
14
#include "flutter/services/engine/sky_engine.mojom.h"
15
#include "lib/ftl/macros.h"
16 17

namespace blink {
18
class DartController;
19
class DartLibraryProvider;
20
class Scene;
21
class RuntimeDelegate;
22
class View;
23
class Window;
24

25
class RuntimeController : public WindowClient, public IsolateClient {
26
 public:
27 28 29 30 31
  static std::unique_ptr<RuntimeController> Create(RuntimeDelegate* client);
  ~RuntimeController();

  void CreateDartController(const std::string& script_uri);
  DartController* dart_controller() const { return dart_controller_.get(); }
32

33
  void SetViewportMetrics(const sky::ViewportMetricsPtr& metrics);
34
  void SetLocale(const std::string& language_code,
A
Adam Barth 已提交
35
                 const std::string& country_code);
36
  void SetSemanticsEnabled(bool enabled);
A
Adam Barth 已提交
37 38
  void PushRoute(const std::string& route);
  void PopRoute();
39

A
Adam Barth 已提交
40
  void BeginFrame(ftl::TimePoint frame_time);
41

42 43
  void DispatchPointerDataPacket(const PointerDataPacket& packet);
  void DispatchSemanticsAction(int32_t id, SemanticsAction action);
44

45 46
  void OnAppLifecycleStateChanged(sky::AppLifecycleState state);

47 48
  Dart_Port GetMainPort();

49 50
  std::string GetIsolateName();

51
 private:
52
  explicit RuntimeController(RuntimeDelegate* client);
53

54 55 56 57
  Window* GetWindow();

  void ScheduleFrame() override;
  void Render(Scene* scene) override;
58
  void UpdateSemantics(SemanticsUpdate* update) override;
A
Adam Barth 已提交
59

60 61
  void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;

62
  RuntimeDelegate* client_;
63
  sky::ViewportMetricsPtr viewport_metrics_;
64 65
  std::string language_code_;
  std::string country_code_;
66
  bool semantics_enabled_ = false;
67
  std::unique_ptr<DartController> dart_controller_;
A
Adam Barth 已提交
68

69
  FTL_DISALLOW_COPY_AND_ASSIGN(RuntimeController);
70 71
};

A
Adam Barth 已提交
72
}  // namespace blink
73

74
#endif  // FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_