Commit 56214d99 authored by jonross's avatar jonross Committed by Commit Bot

Removing External LocalSurfaceIdAllocation from WindowTreeHostPlatform

WindowTreeHostPlatform supported bounds changes where the source of
the LocalSurfaceIdAllocation was external. This was to support Mus,
where the Window Service would allocate new ids when triggering resizes.

On other Aura platforms there were DCHECKs that no other source was
setting these ids. As WindowTreeHostPlatform is intended to be the
root allocator.

With the removal of Mus this is no longer needed.

TEST=aura_unittests, manual testing of unified mode
Bug: 958239

Change-Id: I595a147cb38c454e3199e9cab9d180719adc9711
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625801Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663847}
parent 900c5542
......@@ -145,11 +145,8 @@ void AshWindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) {
SetTapToClickPaused(!show);
}
void AshWindowTreeHostPlatform::SetBoundsInPixels(
const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
WindowTreeHostPlatform::SetBoundsInPixels(bounds,
local_surface_id_allocation);
void AshWindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) {
WindowTreeHostPlatform::SetBoundsInPixels(bounds);
ConfineCursorToRootWindow();
}
......
......@@ -55,9 +55,7 @@ class ASH_EXPORT AshWindowTreeHostPlatform
gfx::Rect GetTransformedRootWindowBoundsInPixels(
const gfx::Size& host_size_in_pixels) const override;
void OnCursorVisibilityChangedNative(bool show) override;
void SetBoundsInPixels(const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation&
local_surface_id_allocation) override;
void SetBoundsInPixels(const gfx::Rect& bounds) override;
void DispatchEvent(ui::Event* event) override;
private:
......
......@@ -92,14 +92,6 @@ void AshWindowTreeHostUnified::RegisterMirroringHost(
mirroring_ash_host->AsWindowTreeHost()->window()->AddObserver(this);
}
void AshWindowTreeHostUnified::SetBoundsInPixels(
const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
AshWindowTreeHostPlatform::SetBoundsInPixels(bounds,
local_surface_id_allocation);
OnHostResizedInPixels(bounds.size());
}
void AshWindowTreeHostUnified::SetCursorNative(gfx::NativeCursor cursor) {
for (auto* host : mirroring_hosts_)
host->AsWindowTreeHost()->SetCursor(cursor);
......
......@@ -31,9 +31,6 @@ class AshWindowTreeHostUnified : public AshWindowTreeHostPlatform,
void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) override;
// aura::WindowTreeHost:
void SetBoundsInPixels(const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation&
local_surface_id_allocation) override;
void SetCursorNative(gfx::NativeCursor cursor) override;
void OnCursorVisibilityChangedNative(bool show) override;
......
......@@ -63,8 +63,7 @@ void HeadlessBrowserImpl::PlatformSetWebContentsBounds(
gfx::Rect new_host_bounds(
0, 0, std::max(old_host_bounds.width(), bounds.x() + bounds.width()),
std::max(old_host_bounds.height(), bounds.y() + bounds.height()));
web_contents->window_tree_host()->SetBoundsInPixels(
new_host_bounds, viz::LocalSurfaceIdAllocation());
web_contents->window_tree_host()->SetBoundsInPixels(new_host_bounds);
web_contents->window_tree_host()->window()->SetBounds(new_host_bounds);
gfx::NativeView native_view = web_contents->web_contents()->GetNativeView();
......
......@@ -55,16 +55,14 @@ gfx::Rect HeadlessWindowTreeHost::GetBoundsInPixels() const {
return bounds_;
}
void HeadlessWindowTreeHost::SetBoundsInPixels(
const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
void HeadlessWindowTreeHost::SetBoundsInPixels(const gfx::Rect& bounds) {
bool origin_changed = bounds_.origin() != bounds.origin();
bool size_changed = bounds_.size() != bounds.size();
bounds_ = bounds;
if (origin_changed)
OnHostMovedInPixels(bounds.origin());
if (size_changed)
OnHostResizedInPixels(bounds.size(), local_surface_id_allocation);
OnHostResizedInPixels(bounds.size());
}
void HeadlessWindowTreeHost::ShowImpl() {}
......
......@@ -47,9 +47,7 @@ class HeadlessWindowTreeHost : public aura::WindowTreeHost,
void ShowImpl() override;
void HideImpl() override;
gfx::Rect GetBoundsInPixels() const override;
void SetBoundsInPixels(const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation&
local_surface_id_allocation) override;
void SetBoundsInPixels(const gfx::Rect& bounds) override;
gfx::Point GetLocationOnScreenInPixels() const override;
void SetCapture() override;
void ReleaseCapture() override;
......
......@@ -441,25 +441,17 @@ void WindowTreeHost::OnHostMovedInPixels(
}
void WindowTreeHost::OnHostResizedInPixels(
const gfx::Size& new_size_in_pixels,
const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation) {
// TODO(jonross) Unify all OnHostResizedInPixels to have both
// viz::LocalSurfaceId and allocation time as optional parameters.
const gfx::Size& new_size_in_pixels) {
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(window());
device_scale_factor_ = display.device_scale_factor();
UpdateRootWindowSizeInPixels();
// Allocate a new LocalSurfaceId for the new state.
viz::LocalSurfaceIdAllocation local_surface_id_allocation(
new_local_surface_id_allocation);
if (!new_local_surface_id_allocation.IsValid()) {
window_->AllocateLocalSurfaceId();
local_surface_id_allocation = window_->GetLocalSurfaceIdAllocation();
}
ScopedLocalSurfaceIdValidator lsi_validator(window());
compositor_->SetScaleAndSize(device_scale_factor_, new_size_in_pixels,
local_surface_id_allocation);
window_->GetLocalSurfaceIdAllocation());
for (WindowTreeHostObserver& observer : observers_)
observer.OnHostResized(this);
......
......@@ -18,7 +18,6 @@
#include "base/optional.h"
#include "base/time/time.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/common/surfaces/local_surface_id.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/window.h"
#include "ui/base/cursor/cursor.h"
......@@ -201,12 +200,7 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
// the old bounds, because SetBoundsInPixels() can take effect asynchronously,
// depending on the platform. The |local_surface_id| takes effect when (and
// if) the new size is confirmed (potentially asynchronously) by the platform.
// If |local_surface_id| is invalid, then a new LocalSurfaceId is allocated
// when the size change takes effect.
virtual void SetBoundsInPixels(
const gfx::Rect& bounds_in_pixels,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation =
viz::LocalSurfaceIdAllocation()) = 0;
virtual void SetBoundsInPixels(const gfx::Rect& bounds_in_pixels) = 0;
virtual gfx::Rect GetBoundsInPixels() const = 0;
// Sets the OS capture to the root window.
......@@ -278,10 +272,7 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
virtual gfx::Point GetLocationOnScreenInPixels() const = 0;
void OnHostMovedInPixels(const gfx::Point& new_location_in_pixels);
void OnHostResizedInPixels(
const gfx::Size& new_size_in_pixels,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation =
viz::LocalSurfaceIdAllocation());
void OnHostResizedInPixels(const gfx::Size& new_size_in_pixels);
void OnHostWorkspaceChanged();
void OnHostDisplayChanged();
void OnHostCloseRequested();
......
......@@ -119,11 +119,8 @@ gfx::Rect WindowTreeHostPlatform::GetBoundsInPixels() const {
return platform_window_ ? platform_window_->GetBounds() : gfx::Rect();
}
void WindowTreeHostPlatform::SetBoundsInPixels(
const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
void WindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) {
pending_size_ = bounds.size();
pending_local_surface_id_allocation_ = local_surface_id_allocation;
platform_window_->SetBounds(bounds);
}
......@@ -211,16 +208,10 @@ void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) {
bounds_in_pixels_ = new_bounds;
if (bounds_in_pixels_.origin() != old_bounds.origin())
OnHostMovedInPixels(bounds_in_pixels_.origin());
if (pending_local_surface_id_allocation_.IsValid() ||
bounds_in_pixels_.size() != old_bounds.size() ||
if (bounds_in_pixels_.size() != old_bounds.size() ||
current_scale != new_scale) {
viz::LocalSurfaceIdAllocation local_surface_id_allocation;
if (bounds_in_pixels_.size() == pending_size_)
local_surface_id_allocation = pending_local_surface_id_allocation_;
pending_local_surface_id_allocation_ = viz::LocalSurfaceIdAllocation();
pending_size_ = gfx::Size();
OnHostResizedInPixels(bounds_in_pixels_.size(),
local_surface_id_allocation);
OnHostResizedInPixels(bounds_in_pixels_.size());
}
DCHECK_GT(on_bounds_changed_recursion_depth_, 0);
if (--on_bounds_changed_recursion_depth_ == 0) {
......
......@@ -42,9 +42,7 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
void ShowImpl() override;
void HideImpl() override;
gfx::Rect GetBoundsInPixels() const override;
void SetBoundsInPixels(const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation&
local_surface_id_allocation) override;
void SetBoundsInPixels(const gfx::Rect& bounds) override;
gfx::Point GetLocationOnScreenInPixels() const override;
void SetCapture() override;
void ReleaseCapture() override;
......@@ -98,12 +96,6 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
std::unique_ptr<ui::KeyboardHook> keyboard_hook_;
// |pending_local_surface_id_allocation_|, and |pending_size_| are set when
// the PlatformWindow instance is requested to adopt a new size (in
// SetBoundsInPixels()). When the platform confirms the new size (by way of
// OnBoundsChanged() callback), the LocalSurfaceIdAllocation is set on the
// compositor, by WindowTreeHost.
viz::LocalSurfaceIdAllocation pending_local_surface_id_allocation_;
gfx::Size pending_size_;
// Tracks how nested OnBoundsChanged() is. That is, on entering
......
......@@ -59,7 +59,7 @@ class TestWindowTreeHostObserver : public aura::WindowTreeHostObserver {
should_change_bounds_in_on_resized_ = false;
gfx::Rect bounds = platform_window_->GetBounds();
bounds.set_x(bounds.x() + 1);
host_->SetBoundsInPixels(bounds, viz::LocalSurfaceIdAllocation());
host_->SetBoundsInPixels(bounds);
}
void OnHostWillProcessBoundsChange(WindowTreeHost* host) override {
++on_host_will_process_bounds_change_count_;
......@@ -87,8 +87,7 @@ TEST_F(WindowTreeHostPlatformTest, HostWillProcessBoundsChangeRecursion) {
// WindowTreePlatform::OnBoundsChanged(). In such a scenario the observer
// should be notified only once (see comment in
// WindowTreeHostPlatform::OnBoundsChanged() for details).
host.SetBoundsInPixels(gfx::Rect(1, 2, 3, 4),
viz::LocalSurfaceIdAllocation());
host.SetBoundsInPixels(gfx::Rect(1, 2, 3, 4));
EXPECT_EQ(1, observer.on_host_did_process_bounds_change_count());
EXPECT_EQ(1, observer.on_host_will_process_bounds_change_count());
}
......
......@@ -533,14 +533,7 @@ gfx::Rect DesktopWindowTreeHostWin::GetBoundsInPixels() const {
return without_expansion;
}
void DesktopWindowTreeHostWin::SetBoundsInPixels(
const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
// On Windows, the callers of SetBoundsInPixels() shouldn't need to (or be
// able to) allocate LocalSurfaceId for the compositor. Aura itself should
// allocate the new ids as needed, instead.
DCHECK(!local_surface_id_allocation.IsValid());
void DesktopWindowTreeHostWin::SetBoundsInPixels(const gfx::Rect& bounds) {
// If the window bounds have to be expanded we need to subtract the
// window_expansion_top_left_delta_ from the origin and add the
// window_expansion_bottom_right_delta_ to the width and height
......
......@@ -132,10 +132,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
void ShowImpl() override;
void HideImpl() override;
gfx::Rect GetBoundsInPixels() const override;
void SetBoundsInPixels(
const gfx::Rect& bounds,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation =
viz::LocalSurfaceIdAllocation()) override;
void SetBoundsInPixels(const gfx::Rect& bounds) override;
gfx::Point GetLocationOnScreenInPixels() const override;
void SetCapture() override;
void ReleaseCapture() override;
......
......@@ -1240,13 +1240,7 @@ gfx::Rect DesktopWindowTreeHostX11::GetBoundsInPixels() const {
}
void DesktopWindowTreeHostX11::SetBoundsInPixels(
const gfx::Rect& requested_bounds_in_pixel,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
// On desktop-x11, the callers of SetBoundsInPixels() shouldn't need to (or be
// able to) allocate LocalSurfaceId for the compositor. Aura itself should
// allocate the new ids as needed, instead.
DCHECK(!local_surface_id_allocation.IsValid());
const gfx::Rect& requested_bounds_in_pixel) {
gfx::Rect bounds_in_pixels(requested_bounds_in_pixel.origin(),
AdjustSize(requested_bounds_in_pixel.size()));
bool origin_changed = bounds_in_pixels_.origin() != bounds_in_pixels.origin();
......@@ -1298,7 +1292,7 @@ void DesktopWindowTreeHostX11::SetBoundsInPixels(
if (origin_changed)
native_widget_delegate_->AsWidget()->OnNativeWidgetMove();
if (size_changed) {
OnHostResizedInPixels(bounds_in_pixels.size(), local_surface_id_allocation);
OnHostResizedInPixels(bounds_in_pixels.size());
ResetWindowRegion();
}
}
......
......@@ -165,10 +165,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
void ShowImpl() override;
void HideImpl() override;
gfx::Rect GetBoundsInPixels() const override;
void SetBoundsInPixels(
const gfx::Rect& requested_bounds_in_pixels,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation =
viz::LocalSurfaceIdAllocation()) override;
void SetBoundsInPixels(const gfx::Rect& requested_bounds_in_pixels) override;
gfx::Point GetLocationOnScreenInPixels() const override;
void SetCapture() override;
void ReleaseCapture() override;
......
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