Commit 5a727b54 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

mus: Embed the new surface in WindowPortMus::AllocateLocalSurfaceId

Seems like we don't embed the LocalSurfaceId allocated in
WindowPortMus::AllocateLocalSurfaceId with --mash. Embed it.

Bug: 807448
Change-Id: Id4c03c01d714de010a8306fc97bcd1a98dfaa3cb
Reviewed-on: https://chromium-review.googlesource.com/895926
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534176}
parent bc976225
...@@ -94,4 +94,9 @@ void ClientSurfaceEmbedder::UpdateSizeAndGutters() { ...@@ -94,4 +94,9 @@ void ClientSurfaceEmbedder::UpdateSizeAndGutters() {
window_->layer()->StackAtTop(surface_layer_.get()); window_->layer()->StackAtTop(surface_layer_.get());
} }
const viz::SurfaceId& ClientSurfaceEmbedder::GetPrimarySurfaceIdForTesting()
const {
return *surface_layer_->GetPrimarySurfaceId();
}
} // namespace aura } // namespace aura
...@@ -9,16 +9,14 @@ ...@@ -9,16 +9,14 @@
#include "base/macros.h" #include "base/macros.h"
#include "components/viz/common/surfaces/surface_info.h" #include "components/viz/common/surfaces/surface_info.h"
#include "ui/aura/aura_export.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
namespace gfx { namespace gfx {
class Insets; class Insets;
} }
namespace ui {
class Layer;
}
namespace aura { namespace aura {
class Window; class Window;
...@@ -26,7 +24,7 @@ class Window; ...@@ -26,7 +24,7 @@ class Window;
// Used by WindowPortMus when it is embedding a client. Responsible for setting // Used by WindowPortMus when it is embedding a client. Responsible for setting
// up layers containing content from the client, parenting them to the window's // up layers containing content from the client, parenting them to the window's
// layer, and updating them when the client submits new surfaces. // layer, and updating them when the client submits new surfaces.
class ClientSurfaceEmbedder { class AURA_EXPORT ClientSurfaceEmbedder {
public: public:
// TODO(fsamuel): Insets might differ when the window is maximized. We should // TODO(fsamuel): Insets might differ when the window is maximized. We should
// deal with that case as well. // deal with that case as well.
...@@ -51,6 +49,8 @@ class ClientSurfaceEmbedder { ...@@ -51,6 +49,8 @@ class ClientSurfaceEmbedder {
ui::Layer* BottomGutterForTesting() { return bottom_gutter_.get(); } ui::Layer* BottomGutterForTesting() { return bottom_gutter_.get(); }
const viz::SurfaceId& GetPrimarySurfaceIdForTesting() const;
private: private:
// The window which embeds the client. // The window which embeds the client.
Window* window_; Window* window_;
......
...@@ -403,6 +403,7 @@ WindowPortMus::ChangeSource WindowPortMus::OnTransientChildRemoved( ...@@ -403,6 +403,7 @@ WindowPortMus::ChangeSource WindowPortMus::OnTransientChildRemoved(
void WindowPortMus::AllocateLocalSurfaceId() { void WindowPortMus::AllocateLocalSurfaceId() {
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId(); local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
UpdatePrimarySurfaceId();
} }
const viz::LocalSurfaceId& WindowPortMus::GetLocalSurfaceId() { const viz::LocalSurfaceId& WindowPortMus::GetLocalSurfaceId() {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "components/viz/client/client_layer_tree_frame_sink.h" #include "components/viz/client/client_layer_tree_frame_sink.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/local/layer_tree_frame_sink_local.h" #include "ui/aura/local/layer_tree_frame_sink_local.h"
#include "ui/aura/mus/client_surface_embedder.h"
#include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/ui_base_switches_util.h" #include "ui/base/ui_base_switches_util.h"
...@@ -55,4 +56,24 @@ TEST_F(WindowPortMusTest, LayerTreeFrameSinkGetsCorrectLocalSurfaceId) { ...@@ -55,4 +56,24 @@ TEST_F(WindowPortMusTest, LayerTreeFrameSinkGetsCorrectLocalSurfaceId) {
EXPECT_EQ(frame_sink_local_surface_id, local_surface_id); EXPECT_EQ(frame_sink_local_surface_id, local_surface_id);
} }
TEST_F(WindowPortMusTest, ClientSurfaceEmbedderUpdatesLayer) {
// If mus is not hosting viz, we don't have ClientSurfaceEmbedder.
if (!switches::IsMusHostingViz())
return;
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
window.SetBounds(gfx::Rect(300, 300));
window.set_embed_frame_sink_id(viz::FrameSinkId(0, 1));
// Allocate a new LocalSurfaceId. The ui::Layer should be updated.
window.AllocateLocalSurfaceId();
auto* window_mus = WindowPortMus::Get(&window);
viz::LocalSurfaceId local_surface_id = window.GetLocalSurfaceId();
viz::SurfaceId primary_surface_id =
window_mus->client_surface_embedder()->GetPrimarySurfaceIdForTesting();
EXPECT_EQ(local_surface_id, primary_surface_id.local_surface_id());
}
} // namespace aura } // namespace aura
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