Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/platform/fuchsia/flutter/compositor_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ CompositorContext::CompositorContext(
std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fit::closure session_error_callback,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle)
: debug_label_(std::move(debug_label)),
session_connection_(debug_label_,
std::move(view_token),
std::move(session),
std::move(session_error_callback),
session_error_callback,
vsync_event_handle) {}

void CompositorContext::OnSessionMetricsDidChange(
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/compositor_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CompositorContext final : public flutter::CompositorContext {
CompositorContext(std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fit::closure session_error_callback,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle);

~CompositorContext() override;
Expand Down
53 changes: 28 additions & 25 deletions shell/platform/fuchsia/flutter/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Engine::Engine(Delegate& delegate,
// This handles the fidl error callback when the Session connection is
// broken. The SessionListener interface also has an OnError method, which is
// invoked on the platform thread (in PlatformView).
fit::closure on_session_error_callback =
fml::closure on_session_error_callback =
[dispatcher = async_get_default_dispatcher(),
weak = weak_factory_.GetWeakPtr()]() {
async::PostTask(dispatcher, [weak]() {
Expand All @@ -144,30 +144,6 @@ Engine::Engine(Delegate& delegate,
});
};

// Create the compositor context from the scenic pointer to create the
// rasterizer.
std::unique_ptr<flutter::CompositorContext> compositor_context;
{
TRACE_EVENT0("flutter", "CreateCompositorContext");
compositor_context = std::make_unique<flutter_runner::CompositorContext>(
thread_label_, // debug label
std::move(view_token), // scenic view we attach our tree to
std::move(session), // scenic session
std::move(on_session_error_callback), // session did encounter error
vsync_event_.get() // vsync event handle
);
}

// Setup the callback that will instantiate the rasterizer.
flutter::Shell::CreateCallback<flutter::Rasterizer> on_create_rasterizer =
fml::MakeCopyable([compositor_context = std::move(compositor_context)](
flutter::Shell& shell) mutable {
return std::make_unique<flutter::Rasterizer>(
shell.GetTaskRunners(), // task runners
std::move(compositor_context) // compositor context
);
});

// Get the task runners from the managed threads. The current thread will be
// used as the "platform" thread.
const flutter::TaskRunners task_runners(
Expand All @@ -178,6 +154,33 @@ Engine::Engine(Delegate& delegate,
CreateFMLTaskRunner(threads_[2]->dispatcher()) // io
);

// Setup the callback that will instantiate the rasterizer.
flutter::Shell::CreateCallback<flutter::Rasterizer> on_create_rasterizer =
fml::MakeCopyable([thread_label = thread_label_, //
view_token = std::move(view_token), //
session = std::move(session), //
on_session_error_callback, //
vsync_event = vsync_event_.get() //
](flutter::Shell& shell) mutable {
std::unique_ptr<flutter_runner::CompositorContext> compositor_context;
{
TRACE_DURATION("flutter", "CreateCompositorContext");
compositor_context =
std::make_unique<flutter_runner::CompositorContext>(
thread_label, // debug label
std::move(view_token), // scenic view we attach our tree to
std::move(session), // scenic session
on_session_error_callback, // session did encounter error
vsync_event // vsync event handle
);
}

return std::make_unique<flutter::Rasterizer>(
shell.GetTaskRunners(), // task runners
std::move(compositor_context) // compositor context
);
});

UpdateNativeThreadLabelNames(thread_label_, task_runners);

settings_.verbose_logging = true;
Expand Down
6 changes: 2 additions & 4 deletions shell/platform/fuchsia/flutter/session_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SessionConnection::SessionConnection(
std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fit::closure session_error_callback,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle)
: debug_label_(std::move(debug_label)),
session_wrapper_(session.Bind(), nullptr),
Expand All @@ -27,9 +27,7 @@ SessionConnection::SessionConnection(
scene_update_context_(&session_wrapper_, surface_producer_.get()),
vsync_event_handle_(vsync_event_handle) {
session_wrapper_.set_error_handler(
[callback = std::move(session_error_callback)](zx_status_t status) {
callback();
});
[callback = session_error_callback](zx_status_t status) { callback(); });

session_wrapper_.SetDebugName(debug_label_);

Expand Down
4 changes: 3 additions & 1 deletion shell/platform/fuchsia/flutter/session_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "flutter/flow/compositor_context.h"
#include "flutter/flow/scene_update_context.h"
#include "flutter/fml/closure.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/trace_event.h"
#include "vulkan_surface_producer.h"
Expand All @@ -29,7 +30,7 @@ class SessionConnection final {
SessionConnection(std::string debug_label,
fuchsia::ui::views::ViewToken view_token,
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
fit::closure session_error_callback,
fml::closure session_error_callback,
zx_handle_t vsync_event_handle);

~SessionConnection();
Expand Down Expand Up @@ -68,6 +69,7 @@ class SessionConnection final {

std::unique_ptr<VulkanSurfaceProducer> surface_producer_;
flutter::SceneUpdateContext scene_update_context_;

zx_handle_t vsync_event_handle_;

// A flow event trace id for following |Session::Present| calls into
Expand Down