Commit d04afb74 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

mus/aura: Fix setting up LayerTreeFrameSink for a window.

Make sure the LayerTreeFrameSink has the LocalSurfaceId correctly set,
even if the LocalSurfaceId is generated before a LayerTreeFrameSink is
created.

BUG=786453

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I768f06ab84ede54218afd2f9c3dbaf8bbb27296a
Reviewed-on: https://chromium-review.googlesource.com/817632
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523206}
parent 69a11d9f
......@@ -75,6 +75,8 @@ class VIZ_CLIENT_EXPORT ClientLayerTreeFrameSink
return hit_test_data_provider_.get();
}
const LocalSurfaceId& local_surface_id() const { return local_surface_id_; }
// cc::LayerTreeFrameSink implementation.
bool BindToClient(cc::LayerTreeFrameSinkClient* client) override;
void DetachFromClient() override;
......
......@@ -364,6 +364,7 @@ test("aura_unittests") {
"mus/os_exchange_data_provider_mus_unittest.cc",
"mus/property_converter_unittest.cc",
"mus/user_activity_forwarder_unittest.cc",
"mus/window_port_mus_unittest.cc",
"mus/window_tree_client_unittest.cc",
"mus/window_tree_host_mus_unittest.cc",
"test/run_all_unittests.cc",
......
......@@ -301,14 +301,12 @@ void WindowPortMus::SetFrameSinkIdFromServer(
const viz::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
const gfx::Size& surface_size_in_pixels) {
if (last_surface_size_in_pixels_ == surface_size_in_pixels &&
local_surface_id_.is_valid()) {
return local_surface_id_;
if (last_surface_size_in_pixels_ != surface_size_in_pixels ||
!local_surface_id_.is_valid()) {
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
last_surface_size_in_pixels_ = surface_size_in_pixels;
}
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
last_surface_size_in_pixels_ = surface_size_in_pixels;
// If the FrameSinkId is available, then immediately embed the SurfaceId.
// The newly generated frame by the embedder will block in the display
// compositor until the child submits a corresponding CompositorFrame or a
......
......@@ -37,7 +37,7 @@ namespace aura {
class ClientSurfaceEmbedder;
class PropertyConverter;
class Window;
class WindowPortMusTestApi;
class WindowPortMusTest;
class WindowTreeClient;
class WindowTreeClientPrivate;
class WindowTreeHostMus;
......@@ -99,7 +99,7 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
viz::FrameSinkId GetFrameSinkId() const override;
private:
friend class WindowPortMusTestApi;
friend class WindowPortMusTest;
friend class WindowTreeClient;
friend class WindowTreeClientPrivate;
friend class WindowTreeHostMus;
......
// 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.
#include "ui/aura/mus/window_port_mus.h"
#include "components/viz/client/client_layer_tree_frame_sink.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h"
namespace aura {
class WindowPortMusTest : public test::AuraTestBase {
public:
WindowPortMusTest() { EnableMusWithTestWindowTree(); }
~WindowPortMusTest() override = default;
base::WeakPtr<viz::ClientLayerTreeFrameSink> GetFrameSinkFor(Window* window) {
auto* window_mus = WindowPortMus::Get(window);
return window_mus->local_layer_tree_frame_sink_;
}
private:
DISALLOW_COPY_AND_ASSIGN(WindowPortMusTest);
};
TEST_F(WindowPortMusTest, LayerTreeFrameSinkGetsCorrectLocalSurfaceId) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
window.SetBounds(gfx::Rect(300, 300));
// Notify the window that it will embed an external client, so that it
// correctly generates LocalSurfaceId.
window.set_embed_frame_sink_id(viz::FrameSinkId(0, 1));
viz::LocalSurfaceId local_surface_id = window.GetLocalSurfaceId();
ASSERT_TRUE(local_surface_id.is_valid());
std::unique_ptr<cc::LayerTreeFrameSink> frame_sink(
window.CreateLayerTreeFrameSink());
EXPECT_TRUE(frame_sink.get());
auto mus_frame_sink = GetFrameSinkFor(&window);
ASSERT_TRUE(mus_frame_sink);
EXPECT_TRUE(mus_frame_sink->local_surface_id().is_valid());
EXPECT_EQ(mus_frame_sink->local_surface_id(), local_surface_id);
}
} // 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