runtime_controller.h 2.3 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 14
#include "flutter/lib/ui/window/window.h"
#include "lib/ftl/macros.h"
15 16

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

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

R
Ryan Macnak 已提交
29 30 31
  void CreateDartController(const std::string& script_uri,
                            const uint8_t* isolate_snapshot_data,
                            const uint8_t* isolate_snapshot_instr);
32
  DartController* dart_controller() const { return dart_controller_.get(); }
33

34
  void SetViewportMetrics(const ViewportMetrics& metrics);
35
  void SetLocale(const std::string& language_code,
A
Adam Barth 已提交
36
                 const std::string& country_code);
37
  void SetSemanticsEnabled(bool enabled);
38

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

A
Adam Barth 已提交
41
  void DispatchPlatformMessage(ftl::RefPtr<PlatformMessage> message);
42 43
  void DispatchPointerDataPacket(const PointerDataPacket& packet);
  void DispatchSemanticsAction(int32_t id, SemanticsAction action);
44

45
  Dart_Port GetMainPort();
46
  std::string GetIsolateName();
47
  bool HasLivePorts();
48
  tonic::DartErrorHandleType GetLastError();
49

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

53 54 55 56
  Window* GetWindow();

  void ScheduleFrame() override;
  void Render(Scene* scene) override;
57
  void UpdateSemantics(SemanticsUpdate* update) override;
58
  void HandlePlatformMessage(ftl::RefPtr<PlatformMessage> message) override;
A
Adam Barth 已提交
59

60 61
  void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;

62
  RuntimeDelegate* client_;
63
  ViewportMetrics 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_