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

chromeos: don't allocate LocalSurfaceId if size doesnt change

If WindowTreeHostMus::SetBounds() is called with no LocalSurfaceIdAllocation
(as happens when views calls SetBounds()) and the size hasn't changed, then
the current LocalSurfaceId should be used.

BUG=931878
TEST=covered by test

Change-Id: I135dca75ce04220796c41dd9d49042127d5dcfc5
Reviewed-on: https://chromium-review.googlesource.com/c/1474252
Auto-Submit: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarJonathan Ross <jonross@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632394}
parent 1174e383
......@@ -208,6 +208,7 @@ void WindowTreeHostMus::SetBounds(
// OnWindowTreeHostBoundsWillChange().
if (!local_surface_id_allocation.IsValid() &&
ShouldAllocateLocalSurfaceIdOnResize()) {
if (pixel_bounds.size() != compositor()->size())
window()->AllocateLocalSurfaceId();
actual_local_surface_id_allocation =
window()->GetLocalSurfaceIdAllocation();
......
......@@ -4,23 +4,65 @@
#include "ui/aura/mus/window_tree_host_mus.h"
#include "components/viz/common/surfaces/local_surface_id_allocation.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/mus/window_tree_host_mus_init_params.h"
#include "ui/aura/test/aura_mus_test_base.h"
#include "ui/aura/test/mus/test_window_tree.h"
#include "ui/aura/window.h"
namespace aura {
using WindowTreeHostMusTest = aura::test::AuraMusClientTestBase;
using WindowTreeHostMusTest = test::AuraMusClientTestBase;
TEST_F(WindowTreeHostMusTest, UpdateClientArea) {
std::unique_ptr<WindowTreeHostMus> window_tree_host_mus =
std::make_unique<WindowTreeHostMus>(
aura::CreateInitParamsForTopLevel(window_tree_client_impl()));
CreateInitParamsForTopLevel(window_tree_client_impl()));
gfx::Insets new_insets(10, 11, 12, 13);
window_tree_host_mus->SetClientArea(new_insets, std::vector<gfx::Rect>());
EXPECT_EQ(new_insets, window_tree()->last_client_area());
}
TEST_F(WindowTreeHostMusTest, DontGenerateNewSurfaceIdOnMove) {
std::unique_ptr<WindowTreeHostMus> window_tree_host =
std::make_unique<WindowTreeHostMus>(
CreateInitParamsForTopLevel(window_tree_client_impl()));
window_tree_host->InitHost();
Window* window = window_tree_host->window();
ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = WindowMus::Get(window)->server_id();
data->visible = true;
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator;
parent_local_surface_id_allocator.GenerateId();
uint32_t change_id = 0;
ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
window_tree_client()->OnTopLevelCreated(
change_id, std::move(data), 1u, true,
parent_local_surface_id_allocator.GetCurrentLocalSurfaceIdAllocation());
window_tree_host->SetBounds(gfx::Rect(1, 2, 3, 4),
viz::LocalSurfaceIdAllocation());
window_tree()->AckAllChanges();
EXPECT_EQ(0u,
window_tree()->GetChangeCountForType(WindowTreeChangeType::BOUNDS));
const viz::LocalSurfaceIdAllocation lsia =
window_tree_host->compositor()->GetLocalSurfaceIdAllocation();
// Setting the bounds to the same size, but different location should not
// generate a new id.
window_tree_host->SetBounds(gfx::Rect(1, 21, 3, 4),
viz::LocalSurfaceIdAllocation());
EXPECT_EQ(lsia,
window_tree_host->compositor()->GetLocalSurfaceIdAllocation());
EXPECT_EQ(1u, window_tree()->number_of_changes());
EXPECT_EQ(1u,
window_tree()->GetChangeCountForType(WindowTreeChangeType::BOUNDS));
ASSERT_TRUE(window_tree()->last_local_surface_id());
EXPECT_EQ(lsia.local_surface_id(), window_tree()->last_local_surface_id());
window_tree()->AckAllChanges();
}
} // 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