Commit a6a160b7 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

chromecast: Fix rounding of aura root window size with rotation

When a rotation is set, a very tiny error is introduced in the root
window transform due to use of trig functions in computing the transform.

This small error is later turned into a full pixel error when the root
window updates its transform.

Avoid trig functions in the display rotation transform. Use of a scale
factor can still cause similar problems, but this should fix most
problems at 1x scale.

Bug: b/78781894
Test: cast_graphics_unittests with new test in next patch

Change-Id: I1ac5d50ef56a1627f2698a47f5d4a2692446332f
Reviewed-on: https://chromium-review.googlesource.com/1087805Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Commit-Queue: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564739}
parent 36e326fd
...@@ -24,26 +24,32 @@ namespace chromecast { ...@@ -24,26 +24,32 @@ namespace chromecast {
namespace { namespace {
gfx::Transform GetPrimaryDisplayRotationTransform() { gfx::Transform GetPrimaryDisplayRotationTransform() {
gfx::Transform rotation; // NB: Using gfx::Transform::Rotate() introduces very small errors here
// which are later exacerbated by use of gfx::EnclosingRect() in
// WindowTreeHost::GetTransformedRootWindowBoundsInPixels().
const gfx::Transform rotate_90(0.f, -1.f, 0.f, 0.f, //
1.f, 0.f, 0.f, 0.f, //
0.f, 0.f, 1.f, 0.f, //
0.f, 0.f, 0.f, 1.f);
const gfx::Transform rotate_180 = rotate_90 * rotate_90;
const gfx::Transform rotate_270 = rotate_180 * rotate_90;
gfx::Transform translation;
display::Display display(display::Screen::GetScreen()->GetPrimaryDisplay()); display::Display display(display::Screen::GetScreen()->GetPrimaryDisplay());
switch (display.rotation()) { switch (display.rotation()) {
case display::Display::ROTATE_0: case display::Display::ROTATE_0:
break; return translation;
case display::Display::ROTATE_90: case display::Display::ROTATE_90:
rotation.Translate(display.bounds().height(), 0); translation.Translate(display.bounds().height(), 0);
rotation.Rotate(90); return translation * rotate_90;
break;
case display::Display::ROTATE_180: case display::Display::ROTATE_180:
rotation.Translate(display.bounds().width(), display.bounds().height()); translation.Translate(display.bounds().width(),
rotation.Rotate(180); display.bounds().height());
break; return translation * rotate_180;
case display::Display::ROTATE_270: case display::Display::ROTATE_270:
rotation.Translate(0, display.bounds().width()); translation.Translate(0, display.bounds().width());
rotation.Rotate(270); return translation * rotate_270;
break;
} }
return rotation;
} }
gfx::Rect GetPrimaryDisplayHostBounds() { gfx::Rect GetPrimaryDisplayHostBounds() {
......
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