Commit 7645e91f authored by James Cook's avatar James Cook Committed by Commit Bot

SingleProcessMash: Fix window size after display zoom

aura::TopLevelAllocator::NotifyServerOfLocalSurfaceId() needs to pass
bounds in DIPs, not pixels.

Also clarify dips vs. pixels in some function parameters and member
variables.

TBR=tsepez@chromium.org

Bug: 934180

Change-Id: I28b0331f9d430e195f37b9a73061fc831b40f44f
Reviewed-on: https://chromium-review.googlesource.com/c/1479889Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634388}
parent 735d9af4
......@@ -112,6 +112,7 @@ interface WindowTree {
// change the child-sequence number portion of the id. Supplying a different
// embed token results in failure, and changes to the parent sequence number
// are ignored.
// |bounds| are in DIPs.
SetWindowBounds(
uint32 change_id,
uint64 window_id,
......
......@@ -222,9 +222,10 @@ void TopLevelAllocator::DidGenerateLocalSurfaceIdAllocation(
}
void TopLevelAllocator::NotifyServerOfLocalSurfaceId() {
window_tree_client()->OnWindowTreeHostBoundsWillChange(
static_cast<WindowTreeHostMus*>(GetWindow()->GetHost()),
GetWindow()->GetHost()->GetBoundsInPixels());
WindowTreeHostMus* host =
static_cast<WindowTreeHostMus*>(GetWindow()->GetHost());
window_tree_client()->OnWindowTreeHostBoundsWillChange(host,
host->bounds_in_dip());
}
// EmbeddedAllocator -----------------------------------------------------------
......
......@@ -716,8 +716,8 @@ void WindowTreeClient::UpdateObservedEventTypes() {
void WindowTreeClient::ScheduleInFlightBoundsChange(
WindowMus* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
const gfx::Rect& old_bounds_in_dip,
const gfx::Rect& new_bounds_in_dip) {
base::Optional<viz::LocalSurfaceIdAllocation> local_surface_id_allocation =
window->GetLocalSurfaceIdAllocation();
if (!local_surface_id_allocation->IsValid()) {
......@@ -736,9 +736,9 @@ void WindowTreeClient::ScheduleInFlightBoundsChange(
}
const uint32_t change_id =
ScheduleInFlightChange(std::make_unique<InFlightBoundsChange>(
this, window, old_bounds, /* from_server */ false,
this, window, old_bounds_in_dip, /* from_server */ false,
local_surface_id_allocation));
tree_->SetWindowBounds(change_id, window->server_id(), new_bounds,
tree_->SetWindowBounds(change_id, window->server_id(), new_bounds_in_dip,
local_surface_id_allocation);
}
......
......@@ -356,8 +356,8 @@ class AURA_EXPORT WindowTreeClient
// Called from OnWindowMusBoundsChanged() and SetRootWindowBounds().
void ScheduleInFlightBoundsChange(WindowMus* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds);
const gfx::Rect& old_bounds_in_dip,
const gfx::Rect& new_bounds_in_dip);
// Following are called from WindowMus.
void OnWindowMusCreated(WindowMus* window);
......
......@@ -188,7 +188,7 @@ WindowTreeHostMus* WindowTreeHostMus::ForWindow(aura::Window* window) {
}
void WindowTreeHostMus::SetBounds(
const gfx::Rect& bounds,
const gfx::Rect& bounds_in_dip,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation) {
viz::LocalSurfaceIdAllocation actual_local_surface_id_allocation =
local_surface_id_allocation;
......@@ -199,8 +199,9 @@ void WindowTreeHostMus::SetBounds(
// Do not use ConvertRectToPixel, enclosing rects cause problems. In
// particular, ConvertRectToPixel's result varies based on the location.
const float dsf = ui::GetScaleFactorForNativeView(window());
const gfx::Rect pixel_bounds(gfx::ScaleToFlooredPoint(bounds.origin(), dsf),
gfx::ScaleToCeiledSize(bounds.size(), dsf));
const gfx::Rect pixel_bounds(
gfx::ScaleToFlooredPoint(bounds_in_dip.origin(), dsf),
gfx::ScaleToCeiledSize(bounds_in_dip.size(), dsf));
if (!in_set_bounds_from_server_) {
// Update the LocalSurfaceIdAllocation here, rather than in WindowTreeHost
// as WindowTreeClient (the delegate) needs that information before
......@@ -212,9 +213,9 @@ void WindowTreeHostMus::SetBounds(
actual_local_surface_id_allocation =
window()->GetLocalSurfaceIdAllocation();
}
delegate_->OnWindowTreeHostBoundsWillChange(this, bounds);
delegate_->OnWindowTreeHostBoundsWillChange(this, bounds_in_dip);
}
bounds_in_dip_ = bounds;
bounds_in_dip_ = bounds_in_dip;
WindowTreeHostPlatform::SetBoundsInPixels(pixel_bounds,
actual_local_surface_id_allocation);
}
......
......@@ -41,7 +41,7 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform,
static WindowTreeHostMus* ForWindow(aura::Window* window);
virtual void SetBounds(
const gfx::Rect& bounds,
const gfx::Rect& bounds_in_dip,
const viz::LocalSurfaceIdAllocation& local_surface_id_allocation);
void SetBoundsFromServer(
const gfx::Rect& bounds,
......
......@@ -57,7 +57,7 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(
std::unique_ptr<Window> window,
const char* trace_environment_name)
: WindowTreeHost(std::move(window)) {
bounds_ = properties.bounds;
bounds_in_pixels_ = properties.bounds;
CreateCompositor(viz::FrameSinkId(),
/* force_software_compositor */ false,
/* external_begin_frames_enabled */ nullptr,
......@@ -200,18 +200,20 @@ void WindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) {
void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) {
float current_scale = compositor()->device_scale_factor();
float new_scale = ui::GetScaleFactorForNativeView(window());
gfx::Rect old_bounds = bounds_;
bounds_ = new_bounds;
if (bounds_.origin() != old_bounds.origin())
OnHostMovedInPixels(bounds_.origin());
gfx::Rect old_bounds = bounds_in_pixels_;
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_.size() != old_bounds.size() || current_scale != new_scale) {
bounds_in_pixels_.size() != old_bounds.size() ||
current_scale != new_scale) {
viz::LocalSurfaceIdAllocation local_surface_id_allocation;
if (bounds_.size() == pending_size_)
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_.size(), local_surface_id_allocation);
OnHostResizedInPixels(bounds_in_pixels_.size(),
local_surface_id_allocation);
}
}
......
......@@ -94,7 +94,7 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
gfx::AcceleratedWidget widget_;
std::unique_ptr<ui::PlatformWindow> platform_window_;
gfx::NativeCursor current_cursor_;
gfx::Rect bounds_;
gfx::Rect bounds_in_pixels_;
std::unique_ptr<ui::KeyboardHook> keyboard_hook_;
......
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