Commit 32d01db2 authored by Cody Peterson's avatar Cody Peterson Committed by Commit Bot

[chromecast] Update Display Rotation Transform

The primary display rotation transforms for 90, 180, and 270 degree
rotations have been updated so that located events are properly
transformed to the new correct location after being subjected to the
inverse root transform. The inverse root transform is used to take the
(x, y) reported for a given located event and transform it to a new (x',
y') to align properly with the transformation applied to the display
graphics.

Take the case of a display with the following characteristics:
Height = 720
Width = 1280

Under the current case, the inverse root transforms are as follows:
90deg = [0, 1, 0, 0; -1, 0, 0, 720; 0, 0, 1, 0; 0, 0, 0, 1]
180deg = [-1, 0, 0, 720; 0, -1, 0, 1280; 0, 0, 1, 0; 0, 0, 0, 1]
270deg = [0, -1, 0, 1280; 1, 0, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1]

With the applied change, the inverse root transforms become:
90deg = [0, 1, 0, 0; -1, 0, 0, 719; 0, 0, 1, 0; 0, 0, 0, 1]
180deg = [-1, 0, 0, 719; 0, -1, 0, 1279; 0, 0, 1, 0; 0, 0, 0, 1]
270deg = [0, -1, 0, 1279; 1, 0, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1]

To see that these new transformations are correct, take the 270 degree
rotation case and consider the corner points of the display. The corner
point transformations under the old and updated transforms are:

Old
(0,0)-->(1280,0)
(719,0)-->(1280,719)
(0,1279)-->(1,0)
(719,1279)-->(1,719)

New
(0,0)-->(1279,0)
(719,0)-->(1279,719)
(0,1279)-->(0,0)
(719,1279)-->(0,719)

The old transformations take the corner points and incorrectly update
them, even outside of bounds for events at (0,0) and (719,0). The new
transformations properly map all corner points.

The same behavior can be observed for 90 and 180 degree rotations as
well.


BUG=None
TEST=Check on devices with 90, 180, and 270 degree rotations

Change-Id: I2d56cf1a4e871d3a08a886bc218fff7262157b73
Reviewed-on: https://chromium-review.googlesource.com/982373Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Cody Peterson <crpeterson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551372}
parent a0ecfbe5
......@@ -30,15 +30,16 @@ gfx::Transform GetPrimaryDisplayRotationTransform() {
case display::Display::ROTATE_0:
break;
case display::Display::ROTATE_90:
rotation.Translate(display.bounds().height(), 0);
rotation.Translate(display.bounds().height() - 1, 0);
rotation.Rotate(90);
break;
case display::Display::ROTATE_180:
rotation.Translate(display.bounds().width(), display.bounds().height());
rotation.Translate(display.bounds().width() - 1,
display.bounds().height() - 1);
rotation.Rotate(180);
break;
case display::Display::ROTATE_270:
rotation.Translate(0, display.bounds().width());
rotation.Translate(0, display.bounds().width() - 1);
rotation.Rotate(270);
break;
}
......
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