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

chromeos: make sure fallback surface is applied *after* primary surface

As remote clients trigger setting the primary surface we have to cache the
fallback until the primary is available.

BUG=863083
TEST=none

Change-Id: I3af87f1397bfa4f42f8ab3bb569ef115737f0e91
Reviewed-on: https://chromium-review.googlesource.com/1135524Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574920}
parent 85f40d18
...@@ -47,8 +47,6 @@ component("lib") { ...@@ -47,8 +47,6 @@ component("lib") {
"user_activity_monitor.cc", "user_activity_monitor.cc",
"user_activity_monitor.h", "user_activity_monitor.h",
"window_delegate_impl.cc", "window_delegate_impl.cc",
"window_host_frame_sink_client.cc",
"window_host_frame_sink_client.h",
"window_properties.cc", "window_properties.cc",
"window_service.cc", "window_service.cc",
"window_service_delegate.cc", "window_service_delegate.cc",
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
#include "services/ui/ws2/client_root.h" #include "services/ui/ws2/client_root.h"
#include "components/viz/common/surfaces/surface_info.h"
#include "components/viz/host/host_frame_sink_manager.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/server_window.h" #include "services/ui/ws2/server_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_tree.h" #include "services/ui/ws2/window_tree.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -49,18 +49,13 @@ ClientRoot::~ClientRoot() { ...@@ -49,18 +49,13 @@ ClientRoot::~ClientRoot() {
void ClientRoot::RegisterVizEmbeddingSupport() { void ClientRoot::RegisterVizEmbeddingSupport() {
// This function should only be called once. // This function should only be called once.
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 = viz::HostFrameSinkManager* host_frame_sink_manager =
aura::Env::GetInstance() aura::Env::GetInstance()
->context_factory_private() ->context_factory_private()
->GetHostFrameSinkManager(); ->GetHostFrameSinkManager();
viz::FrameSinkId frame_sink_id = viz::FrameSinkId frame_sink_id =
ServerWindow::GetMayBeNull(window_)->frame_sink_id(); ServerWindow::GetMayBeNull(window_)->frame_sink_id();
host_frame_sink_manager->RegisterFrameSinkId( host_frame_sink_manager->RegisterFrameSinkId(frame_sink_id, this);
frame_sink_id, window_host_frame_sink_client_.get());
window_->SetEmbedFrameSinkId(frame_sink_id); window_->SetEmbedFrameSinkId(frame_sink_id);
UpdatePrimarySurfaceId(); UpdatePrimarySurfaceId();
...@@ -101,6 +96,10 @@ void ClientRoot::UpdatePrimarySurfaceId() { ...@@ -101,6 +96,10 @@ void ClientRoot::UpdatePrimarySurfaceId() {
if (server_window->local_surface_id().has_value()) { if (server_window->local_surface_id().has_value()) {
client_surface_embedder_->SetPrimarySurfaceId(viz::SurfaceId( client_surface_embedder_->SetPrimarySurfaceId(viz::SurfaceId(
window_->GetFrameSinkId(), *server_window->local_surface_id())); window_->GetFrameSinkId(), *server_window->local_surface_id()));
if (fallback_surface_info_) {
client_surface_embedder_->SetFallbackSurfaceInfo(*fallback_surface_info_);
fallback_surface_info_.reset();
}
} }
} }
...@@ -140,5 +139,21 @@ void ClientRoot::OnWindowBoundsChanged(aura::Window* window, ...@@ -140,5 +139,21 @@ void ClientRoot::OnWindowBoundsChanged(aura::Window* window,
ServerWindow::GetMayBeNull(window_)->local_surface_id()); ServerWindow::GetMayBeNull(window_)->local_surface_id());
} }
void ClientRoot::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window_);
if (server_window->local_surface_id().has_value()) {
DCHECK(!fallback_surface_info_);
client_surface_embedder_->SetFallbackSurfaceInfo(surface_info);
} else {
fallback_surface_info_ = std::make_unique<viz::SurfaceInfo>(surface_info);
}
}
void ClientRoot::OnFrameTokenChanged(uint32_t frame_token) {
// TODO: this needs to call through to WindowTreeClient.
// https://crbug.com/848022.
}
} // namespace ws2 } // namespace ws2
} // namespace ui } // namespace ui
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "components/viz/common/surfaces/local_surface_id.h" #include "components/viz/common/surfaces/local_surface_id.h"
#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 "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -19,10 +20,13 @@ class ClientSurfaceEmbedder; ...@@ -19,10 +20,13 @@ class ClientSurfaceEmbedder;
class Window; class Window;
} // namespace aura } // namespace aura
namespace viz {
class SurfaceInfo;
}
namespace ui { namespace ui {
namespace ws2 { namespace ws2 {
class WindowHostFrameSinkClient;
class WindowTree; class WindowTree;
// WindowTree creates a ClientRoot for each window the client is embedded in. A // WindowTree creates a ClientRoot for each window the client is embedded in. A
...@@ -31,7 +35,8 @@ class WindowTree; ...@@ -31,7 +35,8 @@ class WindowTree;
// maintaining state associated with the root, as well as notifying the client // maintaining state associated with the root, as well as notifying the client
// of any changes to the root Window. // of any changes to the root Window.
class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
: public aura::WindowObserver { : public aura::WindowObserver,
public viz::HostFrameSinkClient {
public: public:
ClientRoot(WindowTree* window_tree, aura::Window* window, bool is_top_level); ClientRoot(WindowTree* window_tree, aura::Window* window, bool is_top_level);
~ClientRoot() override; ~ClientRoot() override;
...@@ -62,6 +67,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot ...@@ -62,6 +67,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
const gfx::Rect& new_bounds, const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override; ui::PropertyChangeReason reason) override;
// viz::HostFrameSinkClient:
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
void OnFrameTokenChanged(uint32_t frame_token) override;
WindowTree* window_tree_; WindowTree* window_tree_;
aura::Window* window_; aura::Window* window_;
const bool is_top_level_; const bool is_top_level_;
...@@ -74,9 +83,11 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot ...@@ -74,9 +83,11 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_; viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
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. // If non-null then the fallback SurfaceInfo was supplied before the primary
std::unique_ptr<WindowHostFrameSinkClient> window_host_frame_sink_client_; // surface. This will be pushed to the Layer once the primary surface is
// supplied.
std::unique_ptr<viz::SurfaceInfo> fallback_surface_info_;
DISALLOW_COPY_AND_ASSIGN(ClientRoot); DISALLOW_COPY_AND_ASSIGN(ClientRoot);
}; };
......
// Copyright 2018 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 "services/ui/ws2/window_host_frame_sink_client.h"
#include "base/logging.h"
#include "ui/aura/mus/client_surface_embedder.h"
namespace ui {
namespace ws2 {
WindowHostFrameSinkClient::WindowHostFrameSinkClient(
aura::ClientSurfaceEmbedder* client_surface_embedder)
: client_surface_embedder_(client_surface_embedder) {}
WindowHostFrameSinkClient::~WindowHostFrameSinkClient() {}
void WindowHostFrameSinkClient::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) {
client_surface_embedder_->SetFallbackSurfaceInfo(surface_info);
}
void WindowHostFrameSinkClient::OnFrameTokenChanged(uint32_t frame_token) {
// TODO: this needs to call through to WindowTreeClient.
// https://crbug.com/848022.
}
} // namespace ws2
} // namespace ui
// Copyright 2018 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.
#ifndef SERVICES_UI_WS2_WINDOW_HOST_FRAME_SINK_CLIENT_H_
#define SERVICES_UI_WS2_WINDOW_HOST_FRAME_SINK_CLIENT_H_
#include "base/component_export.h"
#include "base/macros.h"
#include "components/viz/common/surfaces/local_surface_id.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/host/host_frame_sink_client.h"
namespace aura {
class ClientSurfaceEmbedder;
}
namespace ui {
namespace ws2 {
// HostFrameSinkClient implementation used by WindowService. This is owned
// by WindowData.
class COMPONENT_EXPORT(WINDOW_SERVICE) WindowHostFrameSinkClient
: public viz::HostFrameSinkClient {
public:
explicit WindowHostFrameSinkClient(
aura::ClientSurfaceEmbedder* client_surface_embedder);
~WindowHostFrameSinkClient() override;
// viz::HostFrameSinkClient:
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
void OnFrameTokenChanged(uint32_t frame_token) override;
private:
aura::ClientSurfaceEmbedder* client_surface_embedder_;
DISALLOW_COPY_AND_ASSIGN(WindowHostFrameSinkClient);
};
} // namespace ws2
} // namespace ui
#endif // SERVICES_UI_WS2_WINDOW_HOST_FRAME_SINK_CLIENT_H_
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