Commit 2a4b44cc authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

ash: Remove root window argument from CreateRootWindowTransformerForDisplay

Move the pixel to DIP conversion into root_window_bounds_transform. Also
rename CreateInsetsAndScaleTransform to CreateInsetsTransform because UI
scale in the transform is no longer supported.

Moving the DIP conversion avoids flooring the bounds twice (during DIP
conversion, and after rotation & insets).

Bug: 1019015

Change-Id: Ia065b1f8f6892a193e7f545475e7c7ddbcd76f66

Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899835Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712759}
parent 59e488fb
...@@ -33,7 +33,6 @@ namespace { ...@@ -33,7 +33,6 @@ namespace {
// call |CreateRotationTransform()|, the |old_rotation| will implicitly be // call |CreateRotationTransform()|, the |old_rotation| will implicitly be
// |display::Display::ROTATE_0|. // |display::Display::ROTATE_0|.
gfx::Transform CreateRootWindowRotationTransform( gfx::Transform CreateRootWindowRotationTransform(
aura::Window* root_window,
const display::Display& display) { const display::Display& display) {
display::ManagedDisplayInfo info = display::ManagedDisplayInfo info =
Shell::Get()->display_manager()->GetDisplayInfo(display.id()); Shell::Get()->display_manager()->GetDisplayInfo(display.id());
...@@ -46,7 +45,7 @@ gfx::Transform CreateRootWindowRotationTransform( ...@@ -46,7 +45,7 @@ gfx::Transform CreateRootWindowRotationTransform(
info.GetLogicalActiveRotation(), size); info.GetLogicalActiveRotation(), size);
} }
gfx::Transform CreateInsetsAndScaleTransform(const gfx::Insets& insets, gfx::Transform CreateInsetsTransform(const gfx::Insets& insets,
float device_scale_factor) { float device_scale_factor) {
gfx::Transform transform; gfx::Transform transform;
if (insets.top() != 0 || insets.left() != 0) { if (insets.top() != 0 || insets.left() != 0) {
...@@ -98,16 +97,14 @@ gfx::Transform CreateReverseRotatedInsetsTransform( ...@@ -98,16 +97,14 @@ gfx::Transform CreateReverseRotatedInsetsTransform(
// RootWindowTransformer for ash environment. // RootWindowTransformer for ash environment.
class AshRootWindowTransformer : public RootWindowTransformer { class AshRootWindowTransformer : public RootWindowTransformer {
public: public:
AshRootWindowTransformer(aura::Window* root, const display::Display& display) AshRootWindowTransformer(const display::Display& display) {
: root_window_(root) {
display::DisplayManager* display_manager = Shell::Get()->display_manager(); display::DisplayManager* display_manager = Shell::Get()->display_manager();
display::ManagedDisplayInfo info = display::ManagedDisplayInfo info =
display_manager->GetDisplayInfo(display.id()); display_manager->GetDisplayInfo(display.id());
host_insets_ = info.GetOverscanInsetsInPixel(); host_insets_ = info.GetOverscanInsetsInPixel();
root_window_bounds_transform_ = root_window_bounds_transform_ =
CreateInsetsAndScaleTransform(host_insets_, CreateInsetsTransform(host_insets_, display.device_scale_factor()) *
display.device_scale_factor()) * CreateRootWindowRotationTransform(display);
CreateRootWindowRotationTransform(root, display);
transform_ = root_window_bounds_transform_; transform_ = root_window_bounds_transform_;
insets_and_scale_transform_ = CreateReverseRotatedInsetsTransform( insets_and_scale_transform_ = CreateReverseRotatedInsetsTransform(
info.GetLogicalActiveRotation(), host_insets_, info.GetLogicalActiveRotation(), host_insets_,
...@@ -121,6 +118,9 @@ class AshRootWindowTransformer : public RootWindowTransformer { ...@@ -121,6 +118,9 @@ class AshRootWindowTransformer : public RootWindowTransformer {
} }
CHECK(transform_.GetInverse(&invert_transform_)); CHECK(transform_.GetInverse(&invert_transform_));
root_window_bounds_transform_.Scale(1.f / display.device_scale_factor(),
1.f / display.device_scale_factor());
} }
// aura::RootWindowTransformer overrides: // aura::RootWindowTransformer overrides:
...@@ -129,10 +129,8 @@ class AshRootWindowTransformer : public RootWindowTransformer { ...@@ -129,10 +129,8 @@ class AshRootWindowTransformer : public RootWindowTransformer {
return invert_transform_; return invert_transform_;
} }
gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override { gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override {
gfx::Rect bounds(host_size); gfx::RectF new_bounds = gfx::RectF(gfx::SizeF(host_size));
bounds.Inset(host_insets_); new_bounds.Inset(host_insets_);
bounds = ui::ConvertRectToDIP(root_window_->layer(), bounds);
gfx::RectF new_bounds(bounds);
root_window_bounds_transform_.TransformRect(&new_bounds); root_window_bounds_transform_.TransformRect(&new_bounds);
// Ignore the origin because RootWindow's insets are handled by // Ignore the origin because RootWindow's insets are handled by
// the transform. // the transform.
...@@ -150,7 +148,6 @@ class AshRootWindowTransformer : public RootWindowTransformer { ...@@ -150,7 +148,6 @@ class AshRootWindowTransformer : public RootWindowTransformer {
private: private:
~AshRootWindowTransformer() override = default; ~AshRootWindowTransformer() override = default;
aura::Window* root_window_;
gfx::Transform transform_; gfx::Transform transform_;
// The accurate representation of the inverse of the |transform_|. // The accurate representation of the inverse of the |transform_|.
...@@ -323,9 +320,8 @@ class PartialBoundsRootWindowTransformer : public RootWindowTransformer { ...@@ -323,9 +320,8 @@ class PartialBoundsRootWindowTransformer : public RootWindowTransformer {
} // namespace } // namespace
RootWindowTransformer* CreateRootWindowTransformerForDisplay( RootWindowTransformer* CreateRootWindowTransformerForDisplay(
aura::Window* root,
const display::Display& display) { const display::Display& display) {
return new AshRootWindowTransformer(root, display); return new AshRootWindowTransformer(display);
} }
RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay(
......
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
namespace aura {
class Window;
}
namespace display { namespace display {
class Display; class Display;
class ManagedDisplayInfo; class ManagedDisplayInfo;
...@@ -24,7 +20,6 @@ namespace ash { ...@@ -24,7 +20,6 @@ namespace ash {
class RootWindowTransformer; class RootWindowTransformer;
ASH_EXPORT RootWindowTransformer* CreateRootWindowTransformerForDisplay( ASH_EXPORT RootWindowTransformer* CreateRootWindowTransformerForDisplay(
aura::Window* root,
const display::Display& display); const display::Display& display);
// Creates a RootWindowTransformers for mirror root window. // Creates a RootWindowTransformers for mirror root window.
......
...@@ -82,7 +82,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, ...@@ -82,7 +82,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host,
aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
ash_host->SetCursorConfig(display, effective_rotation); ash_host->SetCursorConfig(display, effective_rotation);
std::unique_ptr<RootWindowTransformer> transformer( std::unique_ptr<RootWindowTransformer> transformer(
CreateRootWindowTransformerForDisplay(host->window(), display)); CreateRootWindowTransformerForDisplay(display));
ash_host->SetRootWindowTransformer(std::move(transformer)); ash_host->SetRootWindowTransformer(std::move(transformer));
host->SetDisplayTransformHint( host->SetDisplayTransformHint(
......
...@@ -636,7 +636,7 @@ bool MagnificationController::RedrawDIP(const gfx::PointF& position_in_dip, ...@@ -636,7 +636,7 @@ bool MagnificationController::RedrawDIP(const gfx::PointF& position_in_dip,
display::Display display = display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(root_window_); display::Screen::GetScreen()->GetDisplayNearestWindow(root_window_);
std::unique_ptr<RootWindowTransformer> transformer( std::unique_ptr<RootWindowTransformer> transformer(
CreateRootWindowTransformerForDisplay(root_window_, display)); CreateRootWindowTransformerForDisplay(display));
// Inverse the transformation on the keyboard container so the keyboard will // Inverse the transformation on the keyboard container so the keyboard will
// remain zoomed out. Apply the same animation settings to it. // remain zoomed out. Apply the same animation settings to it.
......
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