Commit 4fb46772 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

[Cleanup] Use display's property where possible

* The size and scale factor in Display and DisplayInfo could be different
 in the past, but they're now always the same, except for the unified
 desktop mode.

* panel_rotation() was added recently so use it instead of
DisplayInfo::GetLogicalActiveRotation();
 ImageCursor can get the panel's orientation from display and
   no need to create a fake display.

Bug: None
Test: No functional change. All tests passes.
Change-Id: I1a3dd26f96dd201eefcd58841e185eed6ab514ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994672Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Mitsuru Oshima (slow in TOK) <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737123}
parent 0455af94
......@@ -34,15 +34,13 @@ namespace {
// |display::Display::ROTATE_0|.
gfx::Transform CreateRootWindowRotationTransform(
const display::Display& display) {
display::ManagedDisplayInfo info =
Shell::Get()->display_manager()->GetDisplayInfo(display.id());
gfx::SizeF size(info.size_in_pixel());
gfx::SizeF size(display.GetSizeInPixel());
// Use SizeF so that the origin of translated layer will be
// aligned when scaled back at pixels.
size.Scale(1.f / display.device_scale_factor());
return CreateRotationTransform(display::Display::ROTATE_0,
info.GetLogicalActiveRotation(), size);
display.panel_rotation(), size);
}
gfx::Transform CreateInsetsTransform(const gfx::Insets& insets,
......@@ -108,8 +106,7 @@ class AshRootWindowTransformer : public RootWindowTransformer {
CreateRootWindowRotationTransform(display);
transform_ = insets_and_rotation_transform;
insets_and_scale_transform_ = CreateReverseRotatedInsetsTransform(
info.GetLogicalActiveRotation(), host_insets_,
display.device_scale_factor());
display.panel_rotation(), host_insets_, display.device_scale_factor());
MagnificationController* magnifier =
Shell::Get()->magnification_controller();
if (magnifier) {
......
......@@ -75,10 +75,8 @@ display::DisplayManager* GetDisplayManager() {
void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host,
const display::Display& display) {
display::ManagedDisplayInfo info =
GetDisplayManager()->GetDisplayInfo(display.id());
const display::Display::Rotation effective_rotation =
info.GetLogicalActiveRotation();
display.panel_rotation();
aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
ash_host->SetCursorConfig(display, effective_rotation);
std::unique_ptr<RootWindowTransformer> transformer(
......
......@@ -77,20 +77,13 @@ void NativeCursorManagerAsh::SetDisplay(
const display::Display& display,
::wm::NativeCursorManagerDelegate* delegate) {
DCHECK(display.is_valid());
auto managed_display_info =
Shell::Get()->display_manager()->GetDisplayInfo(display.id());
// Use the platform's device scale factor instead of the display's, which
// might have been adjusted for the UI scale.
const float original_scale = managed_display_info.device_scale_factor();
const float original_scale = display.device_scale_factor();
// And use the nearest resource scale factor.
const float cursor_scale =
ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale));
display::Display panel_adjusted(display);
panel_adjusted.set_rotation(managed_display_info.GetLogicalActiveRotation());
if (image_cursors_->SetDisplay(panel_adjusted, cursor_scale))
if (image_cursors_->SetDisplay(display, cursor_scale))
SetCursor(delegate->GetCursor(), delegate);
Shell::Get()
......
......@@ -94,12 +94,12 @@ bool ImageCursors::SetDisplay(const display::Display& display,
float scale_factor) {
if (!cursor_loader_) {
cursor_loader_.reset(CursorLoader::Create());
} else if (cursor_loader_->rotation() == display.rotation() &&
} else if (cursor_loader_->rotation() == display.panel_rotation() &&
cursor_loader_->scale() == scale_factor) {
return false;
}
cursor_loader_->set_rotation(display.rotation());
cursor_loader_->set_rotation(display.panel_rotation());
cursor_loader_->set_scale(scale_factor);
ReloadCursors();
return true;
......
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