blob: 5759fad255f0223ef5efd9651f7893add538735b [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_EMBEDDER_FLATLAND_VIEW_PROVIDER_H_
#define SRC_EMBEDDER_FLATLAND_VIEW_PROVIDER_H_
#include <fuchsia/ui/app/cpp/fidl.h>
#include <lib/syslog/global.h>
#include <lib/ui/scenic/cpp/view_identity.h>
#include "src/embedder/flatland_connection.h"
#include "src/embedder/flatland_ids.h"
#include "src/embedder/logging.h"
namespace embedder {
/// Implements ViewProvider by using Flatland to create a view.
class FlatlandViewProvider final : public fuchsia::ui::app::ViewProvider {
public:
FlatlandViewProvider(FlatlandConnection* flatland_connection)
: flatland_connection_(flatland_connection) {}
~FlatlandViewProvider() override {}
FlatlandViewProvider(const FlatlandViewProvider&) = delete;
FlatlandViewProvider& operator=(const FlatlandViewProvider&) = delete;
void CreateView(zx::eventpair token,
fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services) override {
FX_LOG(ERROR, kLogTag, "ViewProvider::CreateView not implemented.");
}
void CreateViewWithViewRef(zx::eventpair view_token,
fuchsia::ui::views::ViewRefControl control_ref,
fuchsia::ui::views::ViewRef view_ref) override {
FX_LOG(ERROR, kLogTag, "ViewProvider::CreateViewWithViewRef not implemented.");
}
void CreateView2(fuchsia::ui::app::CreateView2Args view_args) override {
auto* flatland = flatland_connection_->flatland();
flatland->CreateView2(std::move(*view_args.mutable_view_creation_token()),
scenic::NewViewIdentityOnCreation(), {} /* protocols */,
parent_viewport_watcher_.NewRequest());
flatland->CreateTransform({kRootTransformId});
flatland->SetRootTransform({kRootTransformId});
}
FlatlandConnection* flatland_connection_;
fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher_;
};
} // namespace embedder
#endif // SRC_EMBEDDER_FLATLAND_VIEW_PROVIDER_H_