Commit 06123085 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: fixs bugs in wiring up viz

This moves data structures that are needed at embed points to ClientRoot.

BUG=837684
TEST=none

Change-Id: I9c404a3e5d076df39d96777b21e858818f93a7c0
Reviewed-on: https://chromium-review.googlesource.com/1066916
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560184}
parent 7bac98f5
...@@ -4,14 +4,18 @@ ...@@ -4,14 +4,18 @@
#include "services/ui/ws2/client_root.h" #include "services/ui/ws2/client_root.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "services/ui/ws2/client_change.h" #include "services/ui/ws2/client_change.h"
#include "services/ui/ws2/client_change_tracker.h" #include "services/ui/ws2/client_change_tracker.h"
#include "services/ui/ws2/client_window.h" #include "services/ui/ws2/client_window.h"
#include "services/ui/ws2/window_host_frame_sink_client.h"
#include "services/ui/ws2/window_service.h" #include "services/ui/ws2/window_service.h"
#include "services/ui/ws2/window_service_client.h" #include "services/ui/ws2/window_service_client.h"
#include "ui/aura/env.h"
#include "ui/aura/mus/client_surface_embedder.h" #include "ui/aura/mus/client_surface_embedder.h"
#include "ui/aura/mus/property_converter.h" #include "ui/aura/mus/property_converter.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/dip_util.h" #include "ui/compositor/dip_util.h"
namespace ui { namespace ui {
...@@ -38,14 +42,34 @@ ClientRoot::ClientRoot(WindowServiceClient* window_service_client, ...@@ -38,14 +42,34 @@ ClientRoot::ClientRoot(WindowServiceClient* window_service_client,
} }
ClientRoot::~ClientRoot() { ClientRoot::~ClientRoot() {
ClientWindow::GetMayBeNull(window_)->set_embedded_window_service_client( ClientWindow* client_window = ClientWindow::GetMayBeNull(window_);
nullptr); client_window->set_embedded_window_service_client(nullptr);
window_->RemoveObserver(this); window_->RemoveObserver(this);
viz::HostFrameSinkManager* host_frame_sink_manager =
aura::Env::GetInstance()
->context_factory_private()
->GetHostFrameSinkManager();
host_frame_sink_manager->InvalidateFrameSinkId(
client_window->frame_sink_id());
} }
void ClientRoot::FrameSinkIdChanged() { void ClientRoot::RegisterVizEmbeddingSupport() {
window_->SetEmbedFrameSinkId( // This function should only be called once.
ClientWindow::GetMayBeNull(window_)->frame_sink_id()); DCHECK(!window_host_frame_sink_client_);
window_host_frame_sink_client_ = std::make_unique<WindowHostFrameSinkClient>(
client_surface_embedder_.get());
viz::HostFrameSinkManager* host_frame_sink_manager =
aura::Env::GetInstance()
->context_factory_private()
->GetHostFrameSinkManager();
viz::FrameSinkId frame_sink_id =
ClientWindow::GetMayBeNull(window_)->frame_sink_id();
host_frame_sink_manager->RegisterFrameSinkId(
frame_sink_id, window_host_frame_sink_client_.get());
window_->SetEmbedFrameSinkId(frame_sink_id);
UpdatePrimarySurfaceId(); UpdatePrimarySurfaceId();
} }
...@@ -96,7 +120,7 @@ void ClientRoot::OnWindowBoundsChanged(aura::Window* window, ...@@ -96,7 +120,7 @@ void ClientRoot::OnWindowBoundsChanged(aura::Window* window,
ui::PropertyChangeReason reason) { ui::PropertyChangeReason reason) {
UpdatePrimarySurfaceId(); UpdatePrimarySurfaceId();
client_surface_embedder_->UpdateSizeAndGutters(); client_surface_embedder_->UpdateSizeAndGutters();
base::Optional<viz::LocalSurfaceId> surface_id = local_surface_id_; base::Optional<viz::LocalSurfaceId> surface_id = GetLocalSurfaceId();
// See comments in WindowServiceClient::SetWindowBoundsImpl() for details on // See comments in WindowServiceClient::SetWindowBoundsImpl() for details on
// why this always notifies the client. // why this always notifies the client.
window_service_client_->window_tree_client_->OnWindowBoundsChanged( window_service_client_->window_tree_client_->OnWindowBoundsChanged(
......
...@@ -22,6 +22,7 @@ class Window; ...@@ -22,6 +22,7 @@ class Window;
namespace ui { namespace ui {
namespace ws2 { namespace ws2 {
class WindowHostFrameSinkClient;
class WindowServiceClient; class WindowServiceClient;
// WindowServiceClient creates a ClientRoot for each window the client is // WindowServiceClient creates a ClientRoot for each window the client is
...@@ -37,8 +38,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot ...@@ -37,8 +38,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
bool is_top_level); bool is_top_level);
~ClientRoot() override; ~ClientRoot() override;
// Called when the FrameSinkId associated with the window changes. // Registers the necessary state needed for embedding in viz.
void FrameSinkIdChanged(); void RegisterVizEmbeddingSupport();
aura::Window* window() { return window_; } aura::Window* window() { return window_; }
...@@ -65,8 +66,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot ...@@ -65,8 +66,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
gfx::Size last_surface_size_in_pixels_; gfx::Size last_surface_size_in_pixels_;
viz::LocalSurfaceId local_surface_id_; viz::LocalSurfaceId local_surface_id_;
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_; viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
// TODO: it may make more sense for this to be owned by WindowData.
std::unique_ptr<aura::ClientSurfaceEmbedder> client_surface_embedder_; std::unique_ptr<aura::ClientSurfaceEmbedder> client_surface_embedder_;
// viz::HostFrameSinkClient registered with the HostFrameSinkManager for the
// window.
std::unique_ptr<WindowHostFrameSinkClient> window_host_frame_sink_client_;
DISALLOW_COPY_AND_ASSIGN(ClientRoot); DISALLOW_COPY_AND_ASSIGN(ClientRoot);
}; };
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "services/ui/ws2/client_window.h" #include "services/ui/ws2/client_window.h"
#include "components/viz/host/host_frame_sink_manager.h" #include "components/viz/host/host_frame_sink_manager.h"
#include "services/ui/ws2/window_host_frame_sink_client.h"
#include "services/ui/ws2/window_service_client.h" #include "services/ui/ws2/window_service_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -222,29 +221,6 @@ const ClientWindow* ClientWindow::GetMayBeNull(const aura::Window* window) { ...@@ -222,29 +221,6 @@ const ClientWindow* ClientWindow::GetMayBeNull(const aura::Window* window) {
return window ? window->GetProperty(kClientWindowKey) : nullptr; return window ? window->GetProperty(kClientWindowKey) : nullptr;
} }
void ClientWindow::SetFrameSinkId(const viz::FrameSinkId& frame_sink_id) {
frame_sink_id_ = frame_sink_id;
viz::HostFrameSinkManager* host_frame_sink_manager =
aura::Env::GetInstance()
->context_factory_private()
->GetHostFrameSinkManager();
if (!window_host_frame_sink_client_) {
window_host_frame_sink_client_ =
std::make_unique<WindowHostFrameSinkClient>();
host_frame_sink_manager->RegisterFrameSinkId(
frame_sink_id_, window_host_frame_sink_client_.get());
// TODO: need to unregister, and update on changes.
// TODO: figure what parts of the ancestors (and descendants) need to be
// registered.
}
host_frame_sink_manager->InvalidateFrameSinkId(frame_sink_id_);
host_frame_sink_manager->RegisterFrameSinkId(
frame_sink_id, window_host_frame_sink_client_.get());
window_->SetEmbedFrameSinkId(frame_sink_id_);
window_host_frame_sink_client_->OnFrameSinkIdChanged();
}
void ClientWindow::SetClientArea( void ClientWindow::SetClientArea(
const gfx::Insets& insets, const gfx::Insets& insets,
const std::vector<gfx::Rect>& additional_client_areas) { const std::vector<gfx::Rect>& additional_client_areas) {
......
...@@ -25,7 +25,6 @@ class EventHandler; ...@@ -25,7 +25,6 @@ class EventHandler;
namespace ws2 { namespace ws2 {
class WindowHostFrameSinkClient;
class WindowServiceClient; class WindowServiceClient;
// Tracks any state associated with an aura::Window for the WindowService. // Tracks any state associated with an aura::Window for the WindowService.
...@@ -69,7 +68,9 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientWindow { ...@@ -69,7 +68,9 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientWindow {
return embedded_window_service_client_; return embedded_window_service_client_;
} }
void SetFrameSinkId(const viz::FrameSinkId& frame_sink_id); void set_frame_sink_id(const viz::FrameSinkId& frame_sink_id) {
frame_sink_id_ = frame_sink_id;
}
const viz::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } const viz::FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
const std::vector<gfx::Rect>& additional_client_areas() const { const std::vector<gfx::Rect>& additional_client_areas() const {
...@@ -113,20 +114,14 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientWindow { ...@@ -113,20 +114,14 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientWindow {
// |embedded_window_service_client_| is set appropriately. // |embedded_window_service_client_| is set appropriately.
WindowServiceClient* embedded_window_service_client_ = nullptr; WindowServiceClient* embedded_window_service_client_ = nullptr;
// TODO(sky): wire this up, see ServerWindow::UpdateFrameSinkId(). This is // This is initially the id supplied by the client (for locally created
// initially the id supplied by the client (for locally created windows it is // windows it is kWindowServerClientId for the high part and low part an ever
// kWindowServerClientId for the high part and low part an ever increasing // increasing number). If the window is used as the embed root, then it
// number). If the window is used as the embed root, then it changes to high // changes to high part = id of client being embedded in and low part 0. If
// part = id of client being embedded in and low part 0. If used as a // used as a top-level, it's changed to the id passed by the client
// top-level, it's changed to the id passed by the client requesting the // requesting the top-level.
// top-level.
// TODO(sky): this likely needs to plug into values in aura::Window.
viz::FrameSinkId frame_sink_id_; viz::FrameSinkId frame_sink_id_;
// viz::HostFrameSinkClient registered with the HostFrameSinkManager for the
// window.
std::unique_ptr<WindowHostFrameSinkClient> window_host_frame_sink_client_;
// Together |client_area_| and |additional_client_areas_| are used to specify // Together |client_area_| and |additional_client_areas_| are used to specify
// the client area. See SetClientArea() in mojom for details. // the client area. See SetClientArea() in mojom for details.
gfx::Insets client_area_; gfx::Insets client_area_;
......
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
namespace ui { namespace ui {
namespace ws2 { namespace ws2 {
WindowHostFrameSinkClient::WindowHostFrameSinkClient() = default; WindowHostFrameSinkClient::WindowHostFrameSinkClient(
aura::ClientSurfaceEmbedder* client_surface_embedder)
: client_surface_embedder_(client_surface_embedder) {}
WindowHostFrameSinkClient::~WindowHostFrameSinkClient() {} WindowHostFrameSinkClient::~WindowHostFrameSinkClient() {}
void WindowHostFrameSinkClient::OnFrameSinkIdChanged() {}
void WindowHostFrameSinkClient::OnFirstSurfaceActivation( void WindowHostFrameSinkClient::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) { const viz::SurfaceInfo& surface_info) {
NOTIMPLEMENTED(); client_surface_embedder_->SetFallbackSurfaceInfo(surface_info);
} }
void WindowHostFrameSinkClient::OnFrameTokenChanged(uint32_t frame_token) { void WindowHostFrameSinkClient::OnFrameTokenChanged(uint32_t frame_token) {
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h" #include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/host/host_frame_sink_client.h" #include "components/viz/host/host_frame_sink_client.h"
namespace aura {
class ClientSurfaceEmbedder;
}
namespace ui { namespace ui {
namespace ws2 { namespace ws2 {
...@@ -19,17 +23,17 @@ namespace ws2 { ...@@ -19,17 +23,17 @@ namespace ws2 {
class COMPONENT_EXPORT(WINDOW_SERVICE) WindowHostFrameSinkClient class COMPONENT_EXPORT(WINDOW_SERVICE) WindowHostFrameSinkClient
: public viz::HostFrameSinkClient { : public viz::HostFrameSinkClient {
public: public:
WindowHostFrameSinkClient(); explicit WindowHostFrameSinkClient(
aura::ClientSurfaceEmbedder* client_surface_embedder);
~WindowHostFrameSinkClient() override; ~WindowHostFrameSinkClient() override;
// Called when the FrameSinkId of the window this is associated with changes.
void OnFrameSinkIdChanged();
// viz::HostFrameSinkClient: // viz::HostFrameSinkClient:
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override; void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
void OnFrameTokenChanged(uint32_t frame_token) override; void OnFrameTokenChanged(uint32_t frame_token) override;
private: private:
aura::ClientSurfaceEmbedder* client_surface_embedder_;
DISALLOW_COPY_AND_ASSIGN(WindowHostFrameSinkClient); DISALLOW_COPY_AND_ASSIGN(WindowHostFrameSinkClient);
}; };
......
...@@ -139,11 +139,10 @@ ClientRoot* WindowServiceClient::CreateClientRoot( ...@@ -139,11 +139,10 @@ ClientRoot* WindowServiceClient::CreateClientRoot(
// Reset the frame sink id locally (after calling OnEmbed()). This is // Reset the frame sink id locally (after calling OnEmbed()). This is
// needed so that the id used by the client matches the id used locally. // needed so that the id used by the client matches the id used locally.
client_window->SetFrameSinkId(ClientWindowId(client_id_, 0)); client_window->set_frame_sink_id(ClientWindowId(client_id_, 0));
} }
// TODO(sky): centralize FrameSinkId management. client_root->RegisterVizEmbeddingSupport();
client_root->FrameSinkIdChanged();
// Requests for top-levels don't get OnFrameSinkIdAllocated(). // Requests for top-levels don't get OnFrameSinkIdAllocated().
if (!is_top_level) { if (!is_top_level) {
...@@ -894,7 +893,7 @@ void WindowServiceClient::NewTopLevelWindow( ...@@ -894,7 +893,7 @@ void WindowServiceClient::NewTopLevelWindow(
const bool is_top_level = true; const bool is_top_level = true;
aura::Window* top_level = AddClientCreatedWindow( aura::Window* top_level = AddClientCreatedWindow(
client_window_id, is_top_level, std::move(top_level_ptr)); client_window_id, is_top_level, std::move(top_level_ptr));
ClientWindow::GetMayBeNull(top_level)->SetFrameSinkId(client_window_id); ClientWindow::GetMayBeNull(top_level)->set_frame_sink_id(client_window_id);
const int64_t display_id = const int64_t display_id =
display::Screen::GetScreen()->GetDisplayNearestWindow(top_level).id(); display::Screen::GetScreen()->GetDisplayNearestWindow(top_level).id();
// This passes null for the mojom::WindowTreePtr because the client has // This passes null for the mojom::WindowTreePtr because the client has
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment