Commit acc80585 authored by Daniel Nicoara's avatar Daniel Nicoara Committed by Commit Bot

Chromecast/EXO: Fix ManagedDisplayInfo initialization

* Add rotation information to the ManagedDisplayInfo. Allows clients to
  be aware of the display rotation and allocate buffers in the native
  orientation. Buffers in the native orientation can be overlayed by the
  compositor.
* Fix how the ManagedDisplayInfo bounds is updated. display::Display's
  bounds is in transformed space. ManagedDisplayInfo's bounds is in
  native display space. Need to un-transform the bounds to report the
  right information. EXO apps will use this to allocate buffers in the
  native display scanout orientation, allowing the compositor to skip
  composition and just overlay the buffer.

Bug: b/132813099, b/131769446
Test: Ran wayland_fullscreen_client on device with various orientations.
Change-Id: Ibef6e30bf9ce59a4004c1a179b8cefe8ab1866aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636029Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664437}
parent 9fdab7ed
......@@ -19,6 +19,25 @@
#include "ui/wm/public/activation_client.h"
namespace exo {
namespace {
// Returns the native location of the display. Removes any rotations and scales.
gfx::Rect GetNativeBounds(const display::Display& display) {
gfx::Point origin = gfx::ScaleToFlooredPoint(display.bounds().origin(),
display.device_scale_factor());
gfx::Size size_in_pixels = display.GetSizeInPixel();
switch (display.rotation()) {
case display::Display::ROTATE_0:
case display::Display::ROTATE_180:
return gfx::Rect(origin, size_in_pixels);
case display::Display::ROTATE_90:
case display::Display::ROTATE_270:
return gfx::Rect(
origin, gfx::Size(size_in_pixels.height(), size_in_pixels.width()));
}
}
} // namespace
WMHelperCastShell::WMHelperCastShell(
chromecast::CastWindowManagerAura* cast_window_manager_aura,
......@@ -179,7 +198,9 @@ void WMHelperCastShell::CastDisplayObserver::OnDidProcessDisplayChanges() {}
void WMHelperCastShell::CastDisplayObserver::OnDisplayAdded(
const display::Display& new_display) {
display::ManagedDisplayInfo md(new_display.id(), "CastDisplayInfo", true);
md.SetBounds(new_display.bounds());
md.SetRotation(new_display.rotation(),
display::Display::RotationSource::ACTIVE);
md.SetBounds(GetNativeBounds(new_display));
display_info_.emplace(new_display.id(), md);
}
......@@ -191,15 +212,12 @@ void WMHelperCastShell::CastDisplayObserver::OnDisplayRemoved(
void WMHelperCastShell::CastDisplayObserver::OnDisplayMetricsChanged(
const display::Display& display,
uint32_t changed_metrics) {
if (display_info_.find(display.id()) == display_info_.end()) {
display::ManagedDisplayInfo md(display.id(), "CastDisplayInfo", true);
md.SetBounds(display.bounds());
display_info_.emplace(display.id(), md);
}
if (display_info_.find(display.id()) == display_info_.end())
OnDisplayAdded(display);
// Currently only updates bounds
if ((DISPLAY_METRIC_BOUNDS & changed_metrics) == DISPLAY_METRIC_BOUNDS)
display_info_[display.id()].SetBounds(display.bounds());
display_info_[display.id()].SetBounds(GetNativeBounds(display));
}
const display::ManagedDisplayInfo&
......
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