Files
engine/content_handler/session_connection.h
T
Chinmay Garde 5b5d920746 Use interface handles for transferring ownership of channels across threads. (#5107)
* Scenic is used on the GPU thread and is owned by the session connection held by the rasterizer.
* The view container is used to initialize the mozart bindings on the UI thread.
* Accessibility bridge is used on the platform thread.
2018-04-26 18:40:53 -07:00

65 lines
1.9 KiB
C++

// Copyright 2017 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.
#pragma once
#include <zx/eventpair.h>
#include "flutter/flow/compositor_context.h"
#include "flutter/flow/scene_update_context.h"
#include "lib/fidl/cpp/interface_handle.h"
#include "lib/fxl/functional/closure.h"
#include "lib/fxl/macros.h"
#include "lib/ui/scenic/client/resources.h"
#include "lib/ui/scenic/client/session.h"
#include "vulkan_surface_producer.h"
namespace flutter {
using OnMetricsUpdate = std::function<void(double /* device pixel ratio */)>;
// The component residing on the GPU thread that is responsible for
// maintaining the Scenic session connection and presenting node updates.
class SessionConnection final {
public:
SessionConnection(fidl::InterfaceHandle<ui::Scenic> scenic,
std::string debug_label,
zx::eventpair import_token,
OnMetricsUpdate session_metrics_did_change_callback,
fxl::Closure session_error_callback);
~SessionConnection();
bool has_metrics() const { return scene_update_context_.has_metrics(); }
const gfx::MetricsPtr& metrics() const {
return scene_update_context_.metrics();
}
flow::SceneUpdateContext& scene_update_context() {
return scene_update_context_;
}
scenic_lib::ImportNode& root_node() { return root_node_; }
void Present(flow::CompositorContext::ScopedFrame& frame);
private:
const std::string debug_label_;
ui::ScenicPtr scenic_;
scenic_lib::Session session_;
scenic_lib::ImportNode root_node_;
std::unique_ptr<VulkanSurfaceProducer> surface_producer_;
flow::SceneUpdateContext scene_update_context_;
OnMetricsUpdate metrics_changed_callback_;
void OnSessionEvents(fidl::VectorPtr<ui::Event> events);
void EnqueueClearOps();
FXL_DISALLOW_COPY_AND_ASSIGN(SessionConnection);
};
} // namespace flutter