Rename SkyView to RuntimeController (flutter/engine#2924)
Also, rename SkyViewClient to RuntimeDelegate. These names are more sensible. This patch also cleans up the RuntimeDelegate a bit, for example by removing support for flushing real-time events, which aren't used.
This commit is contained in:
@@ -172,15 +172,12 @@ class Window {
|
||||
/// graphical operations, call the [endRecording] function on the
|
||||
/// [PictureRecorder] to obtain the final [Picture] that represents
|
||||
/// the issued graphical operations.
|
||||
///
|
||||
///
|
||||
/// Next, create a [SceneBuilder], and add the [Picture] to it using
|
||||
/// [SceneBuilder.addPicture]. With the [SceneBuilder.build] method
|
||||
/// you can then obtain a [Scene] object, which you can display to
|
||||
/// the user via this [render] function.
|
||||
void render(Scene scene) native "Window_render";
|
||||
|
||||
/// Flushes pending real-time events, executing their callbacks.
|
||||
void flushRealTimeEvents() native "Scheduler_FlushRealTimeEvents";
|
||||
}
|
||||
|
||||
/// The [Window] singleton. This object exposes the size of the display, the
|
||||
|
||||
@@ -33,10 +33,6 @@ void Render(Dart_NativeArguments args) {
|
||||
UIDartState::Current()->window()->client()->Render(scene);
|
||||
}
|
||||
|
||||
void FlushRealTimeEvents(Dart_NativeArguments args) {
|
||||
UIDartState::Current()->window()->client()->FlushRealTimeEvents();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
WindowClient::~WindowClient() {}
|
||||
@@ -154,7 +150,6 @@ void Window::RegisterNatives(tonic::DartLibraryNatives* natives) {
|
||||
natives->Register({
|
||||
{"Window_scheduleFrame", ScheduleFrame, 1, true},
|
||||
{"Window_render", Render, 2, true},
|
||||
{"Scheduler_FlushRealTimeEvents", FlushRealTimeEvents, 1, true},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ class Scene;
|
||||
class WindowClient {
|
||||
public:
|
||||
virtual void ScheduleFrame() = 0;
|
||||
virtual void FlushRealTimeEvents() = 0;
|
||||
virtual void Render(Scene* scene) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -46,10 +46,10 @@ source_set("runtime") {
|
||||
"dart_service_isolate.h",
|
||||
"embedder_resources.cc",
|
||||
"embedder_resources.h",
|
||||
"sky_view.cc",
|
||||
"sky_view_client.cc",
|
||||
"sky_view_client.h",
|
||||
"sky_view.h",
|
||||
"runtime_controller.cc",
|
||||
"runtime_controller.h",
|
||||
"runtime_delegate.cc",
|
||||
"runtime_delegate.h",
|
||||
"start_up.cc",
|
||||
"start_up.h",
|
||||
]
|
||||
|
||||
@@ -2,61 +2,37 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/runtime/sky_view.h"
|
||||
#include "flutter/runtime/runtime_controller.h"
|
||||
|
||||
#include "flutter/glue/trace_event.h"
|
||||
#include "flutter/lib/ui/compositing/scene.h"
|
||||
#include "flutter/lib/ui/ui_dart_state.h"
|
||||
#include "flutter/lib/ui/window/window.h"
|
||||
#include "flutter/runtime/dart_controller.h"
|
||||
#include "flutter/runtime/sky_view_client.h"
|
||||
#include "flutter/runtime/runtime_delegate.h"
|
||||
|
||||
using tonic::DartState;
|
||||
|
||||
namespace blink {
|
||||
|
||||
std::unique_ptr<SkyView> SkyView::Create(SkyViewClient* client) {
|
||||
return std::unique_ptr<SkyView>(new SkyView(client));
|
||||
std::unique_ptr<RuntimeController> RuntimeController::Create(
|
||||
RuntimeDelegate* client) {
|
||||
return std::unique_ptr<RuntimeController>(new RuntimeController(client));
|
||||
}
|
||||
|
||||
SkyView::SkyView(SkyViewClient* client) : client_(client) {}
|
||||
RuntimeController::RuntimeController(RuntimeDelegate* client)
|
||||
: client_(client) {}
|
||||
|
||||
SkyView::~SkyView() {}
|
||||
RuntimeController::~RuntimeController() {}
|
||||
|
||||
void SkyView::SetViewportMetrics(const sky::ViewportMetricsPtr& metrics) {
|
||||
if (metrics) {
|
||||
viewport_metrics_ = metrics->Clone();
|
||||
GetWindow()->UpdateWindowMetrics(viewport_metrics_);
|
||||
} else {
|
||||
viewport_metrics_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SkyView::SetLocale(const std::string& language_code,
|
||||
const std::string& country_code) {
|
||||
if (language_code_ == language_code && country_code_ == country_code)
|
||||
return;
|
||||
|
||||
language_code_ = language_code;
|
||||
country_code_ = country_code;
|
||||
GetWindow()->UpdateLocale(language_code_, country_code_);
|
||||
}
|
||||
|
||||
void SkyView::PushRoute(const std::string& route) {
|
||||
GetWindow()->PushRoute(route);
|
||||
}
|
||||
|
||||
void SkyView::PopRoute() {
|
||||
GetWindow()->PopRoute();
|
||||
}
|
||||
|
||||
void SkyView::CreateView(const std::string& script_uri) {
|
||||
void RuntimeController::CreateDartController(const std::string& script_uri) {
|
||||
FTL_DCHECK(!dart_controller_);
|
||||
|
||||
dart_controller_.reset(new DartController());
|
||||
std::unique_ptr<Window> window(new Window(this));
|
||||
dart_controller_->CreateIsolateFor(script_uri, std::unique_ptr<UIDartState>(
|
||||
new UIDartState(this, std::move(window))));
|
||||
dart_controller_->CreateIsolateFor(
|
||||
script_uri,
|
||||
std::unique_ptr<UIDartState>(new UIDartState(this, std::move(window))));
|
||||
|
||||
UIDartState* dart_state = dart_controller_->dart_state();
|
||||
DartState::Scope scope(dart_state);
|
||||
@@ -68,40 +44,66 @@ void SkyView::CreateView(const std::string& script_uri) {
|
||||
GetWindow()->UpdateLocale(language_code_, country_code_);
|
||||
}
|
||||
|
||||
void SkyView::BeginFrame(ftl::TimePoint frame_time) {
|
||||
void RuntimeController::SetViewportMetrics(
|
||||
const sky::ViewportMetricsPtr& metrics) {
|
||||
if (metrics) {
|
||||
viewport_metrics_ = metrics->Clone();
|
||||
GetWindow()->UpdateWindowMetrics(viewport_metrics_);
|
||||
} else {
|
||||
viewport_metrics_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeController::SetLocale(const std::string& language_code,
|
||||
const std::string& country_code) {
|
||||
if (language_code_ == language_code && country_code_ == country_code)
|
||||
return;
|
||||
|
||||
language_code_ = language_code;
|
||||
country_code_ = country_code;
|
||||
GetWindow()->UpdateLocale(language_code_, country_code_);
|
||||
}
|
||||
|
||||
void RuntimeController::PushRoute(const std::string& route) {
|
||||
GetWindow()->PushRoute(route);
|
||||
}
|
||||
|
||||
void RuntimeController::PopRoute() {
|
||||
GetWindow()->PopRoute();
|
||||
}
|
||||
|
||||
void RuntimeController::BeginFrame(ftl::TimePoint frame_time) {
|
||||
GetWindow()->BeginFrame(frame_time);
|
||||
}
|
||||
|
||||
void SkyView::HandlePointerPacket(const pointer::PointerPacketPtr& packet) {
|
||||
TRACE_EVENT0("input", "SkyView::HandlePointerPacket");
|
||||
void RuntimeController::HandlePointerPacket(
|
||||
const pointer::PointerPacketPtr& packet) {
|
||||
TRACE_EVENT0("input", "RuntimeController::HandlePointerPacket");
|
||||
GetWindow()->DispatchPointerPacket(packet);
|
||||
}
|
||||
|
||||
Window* SkyView::GetWindow() {
|
||||
Window* RuntimeController::GetWindow() {
|
||||
return dart_controller_->dart_state()->window();
|
||||
}
|
||||
|
||||
void SkyView::ScheduleFrame() {
|
||||
void RuntimeController::ScheduleFrame() {
|
||||
client_->ScheduleFrame();
|
||||
}
|
||||
|
||||
void SkyView::FlushRealTimeEvents() {
|
||||
client_->FlushRealTimeEvents();
|
||||
}
|
||||
|
||||
void SkyView::Render(Scene* scene) {
|
||||
void RuntimeController::Render(Scene* scene) {
|
||||
client_->Render(scene->takeLayerTree());
|
||||
}
|
||||
|
||||
void SkyView::DidCreateSecondaryIsolate(Dart_Isolate isolate) {
|
||||
void RuntimeController::DidCreateSecondaryIsolate(Dart_Isolate isolate) {
|
||||
client_->DidCreateSecondaryIsolate(isolate);
|
||||
}
|
||||
|
||||
void SkyView::OnAppLifecycleStateChanged(sky::AppLifecycleState state) {
|
||||
void RuntimeController::OnAppLifecycleStateChanged(
|
||||
sky::AppLifecycleState state) {
|
||||
GetWindow()->OnAppLifecycleStateChanged(state);
|
||||
}
|
||||
|
||||
Dart_Port SkyView::GetMainPort() {
|
||||
Dart_Port RuntimeController::GetMainPort() {
|
||||
if (!dart_controller_) {
|
||||
return ILLEGAL_PORT;
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_RUNTIME_SKY_VIEW_H_
|
||||
#define FLUTTER_RUNTIME_SKY_VIEW_H_
|
||||
#ifndef FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
|
||||
#define FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -18,14 +18,17 @@ namespace blink {
|
||||
class DartController;
|
||||
class DartLibraryProvider;
|
||||
class Scene;
|
||||
class SkyViewClient;
|
||||
class RuntimeDelegate;
|
||||
class View;
|
||||
class Window;
|
||||
|
||||
class SkyView : public WindowClient, public IsolateClient {
|
||||
class RuntimeController : public WindowClient, public IsolateClient {
|
||||
public:
|
||||
static std::unique_ptr<SkyView> Create(SkyViewClient* client);
|
||||
~SkyView();
|
||||
static std::unique_ptr<RuntimeController> Create(RuntimeDelegate* client);
|
||||
~RuntimeController();
|
||||
|
||||
void CreateDartController(const std::string& script_uri);
|
||||
DartController* dart_controller() const { return dart_controller_.get(); }
|
||||
|
||||
void SetViewportMetrics(const sky::ViewportMetricsPtr& metrics);
|
||||
void SetLocale(const std::string& language_code,
|
||||
@@ -35,9 +38,6 @@ class SkyView : public WindowClient, public IsolateClient {
|
||||
|
||||
void BeginFrame(ftl::TimePoint frame_time);
|
||||
|
||||
void CreateView(const std::string& script_uri);
|
||||
DartController* dart_controller() const { return dart_controller_.get(); }
|
||||
|
||||
void HandlePointerPacket(const pointer::PointerPacketPtr& packet);
|
||||
|
||||
void OnAppLifecycleStateChanged(sky::AppLifecycleState state);
|
||||
@@ -45,25 +45,24 @@ class SkyView : public WindowClient, public IsolateClient {
|
||||
Dart_Port GetMainPort();
|
||||
|
||||
private:
|
||||
explicit SkyView(SkyViewClient* client);
|
||||
explicit RuntimeController(RuntimeDelegate* client);
|
||||
|
||||
Window* GetWindow();
|
||||
|
||||
void ScheduleFrame() override;
|
||||
void FlushRealTimeEvents() override;
|
||||
void Render(Scene* scene) override;
|
||||
|
||||
void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;
|
||||
|
||||
SkyViewClient* client_;
|
||||
RuntimeDelegate* client_;
|
||||
sky::ViewportMetricsPtr viewport_metrics_;
|
||||
std::string language_code_;
|
||||
std::string country_code_;
|
||||
std::unique_ptr<DartController> dart_controller_;
|
||||
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(SkyView);
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(RuntimeController);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_RUNTIME_SKY_VIEW_H_
|
||||
#endif // FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
|
||||
15
engine/src/flutter/runtime/runtime_delegate.cc
Normal file
15
engine/src/flutter/runtime/runtime_delegate.cc
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
#include "flutter/runtime/runtime_delegate.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
RuntimeDelegate::~RuntimeDelegate() {}
|
||||
|
||||
void RuntimeDelegate::DidCreateMainIsolate(Dart_Isolate isolate) {}
|
||||
|
||||
void RuntimeDelegate::DidCreateSecondaryIsolate(Dart_Isolate isolate) {}
|
||||
|
||||
} // namespace blink
|
||||
@@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_RUNTIME_SKY_VIEW_CLIENT_H_
|
||||
#define FLUTTER_RUNTIME_SKY_VIEW_CLIENT_H_
|
||||
#ifndef FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
|
||||
#define FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -12,19 +12,18 @@
|
||||
|
||||
namespace blink {
|
||||
|
||||
class SkyViewClient {
|
||||
class RuntimeDelegate {
|
||||
public:
|
||||
virtual void ScheduleFrame() = 0;
|
||||
virtual void FlushRealTimeEvents() = 0;
|
||||
virtual void Render(std::unique_ptr<flow::LayerTree> layer_tree) = 0;
|
||||
|
||||
virtual void DidCreateMainIsolate(Dart_Isolate isolate) = 0;
|
||||
virtual void DidCreateSecondaryIsolate(Dart_Isolate isolate) = 0;
|
||||
virtual void DidCreateMainIsolate(Dart_Isolate isolate);
|
||||
virtual void DidCreateSecondaryIsolate(Dart_Isolate isolate);
|
||||
|
||||
protected:
|
||||
virtual ~SkyViewClient();
|
||||
virtual ~RuntimeDelegate();
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // FLUTTER_RUNTIME_SKY_VIEW_CLIENT_H_
|
||||
#endif // FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
|
||||
@@ -1,11 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "flutter/runtime/sky_view_client.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
SkyViewClient::~SkyViewClient() {}
|
||||
|
||||
} // namespace blink
|
||||
Reference in New Issue
Block a user