Commit e275bddf authored by pliard's avatar pliard Committed by Commit Bot

Make surface scale set after construction immediately effective

In the attached bug launching some Android applications such as Adobe
Acrobat results in a flash where shadow bounds are twice larger than
they should be.

This is due to the shadow bounds being computed before the first commit
even though the pending scale is correctly set which results in the
default hard-coded scale (=1.0) being used.

The pending scale set via SetScale() only becomes effective after a
commit. Rather than implicitly relying on this commit for the scale to
be effective exo::Display now commits it explicitly right after setting
it.

Bug: b/118827262
Change-Id: I4bd6cf395ba186be2dfd4f4e3b42e6591bd5382d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612937Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Philippe Liard <pliard@google.com>
Auto-Submit: Philippe Liard <pliard@google.com>
Cr-Commit-Position: refs/heads/master@{#660659}
parent 50b12560
......@@ -427,6 +427,16 @@ void ClientControlledShellSurface::SetScale(double scale) {
pending_scale_ = scale;
}
void ClientControlledShellSurface::CommitPendingScale() {
if (pending_scale_ != scale_) {
gfx::Transform transform;
DCHECK_NE(pending_scale_, 0.0);
transform.Scale(1.0 / pending_scale_, 1.0 / pending_scale_);
host_window()->SetTransform(transform);
scale_ = pending_scale_;
}
}
void ClientControlledShellSurface::SetTopInset(int height) {
TRACE_EVENT1("exo", "ClientControlledShellSurface::SetTopInset", "height",
height);
......@@ -979,13 +989,7 @@ void ClientControlledShellSurface::OnPostWidgetCommit() {
}
// Update surface scale.
if (pending_scale_ != scale_) {
gfx::Transform transform;
DCHECK_NE(pending_scale_, 0.0);
transform.Scale(1.0 / pending_scale_, 1.0 / pending_scale_);
host_window()->SetTransform(transform);
scale_ = pending_scale_;
}
CommitPendingScale();
orientation_ = pending_orientation_;
if (expected_orientation_ == orientation_)
......
......@@ -135,8 +135,13 @@ class ClientControlledShellSurface
// Set shadow bounds in surface coordinates. Empty bounds disable the shadow.
void SetShadowBounds(const gfx::Rect& bounds);
// Set the pending scale.
void SetScale(double scale);
// Commit the pending scale if it was changed. The scale set by SetScale() is
// otherwise committed by OnPostWidgetCommit().
void CommitPendingScale();
// Set top inset for surface.
void SetTopInset(int height);
......@@ -225,6 +230,10 @@ class ClientControlledShellSurface
ash::WideFrameView* wide_frame_for_test() { return wide_frame_.get(); }
// Exposed for testing. Returns the effective scale as opposed to
// |pending_scale_|.
double scale() const { return scale_; }
private:
class ScopedSetBoundsLocally;
class ScopedLockedToRoot;
......
......@@ -174,6 +174,7 @@ Display::CreateClientControlledShellSurface(
container));
DCHECK_GE(default_device_scale_factor, 1.0);
shell_surface->SetScale(default_device_scale_factor);
shell_surface->CommitPendingScale();
return shell_surface;
}
......
......@@ -120,11 +120,12 @@ TEST_F(DisplayTest, CreateClientControlledShellSurface) {
ASSERT_TRUE(surface2);
// Create a remote shell surface for surface1.
std::unique_ptr<ShellSurfaceBase> shell_surface1 =
std::unique_ptr<ClientControlledShellSurface> shell_surface1 =
display->CreateClientControlledShellSurface(
surface1.get(), ash::kShellWindowId_SystemModalContainer,
2.0 /* default_scale_factor */);
EXPECT_TRUE(shell_surface1);
ASSERT_TRUE(shell_surface1);
EXPECT_EQ(shell_surface1->scale(), 2.0);
// Create a remote shell surface for surface2.
std::unique_ptr<ShellSurfaceBase> shell_surface2 =
......
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