runtime_controller.h 2.1 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 29 30
  static std::unique_ptr<RuntimeController> Create(RuntimeDelegate* client);
  ~RuntimeController();

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

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

A
Adam Barth 已提交
37
  void BeginFrame(ftl::TimePoint frame_time);
38

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

43 44
  Dart_Port GetMainPort();

45 46
  std::string GetIsolateName();

47
 private:
48
  explicit RuntimeController(RuntimeDelegate* client);
49

50 51 52 53
  Window* GetWindow();

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

57 58
  void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;

59
  RuntimeDelegate* client_;
60
  ViewportMetrics viewport_metrics_;
61 62
  std::string language_code_;
  std::string country_code_;
63
  bool semantics_enabled_ = false;
64
  std::unique_ptr<DartController> dart_controller_;
A
Adam Barth 已提交
65

66
  FTL_DISALLOW_COPY_AND_ASSIGN(RuntimeController);
67 68
};

A
Adam Barth 已提交
69
}  // namespace blink
70

71
#endif  // FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_