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