Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/host/chromeos/display_transform_util.h" | |
| 6 | |
| 7 #include "ash/shell.h" | |
| 8 #include "ui/aura/window_tree_host.h" | |
| 9 #include "ui/compositor/dip_util.h" | |
| 10 | |
| 11 namespace remoting { | |
| 12 | |
| 13 gfx::Transform GetRootTransform(bool inverse) { | |
|
Wez
2014/12/04 01:28:25
This needs to be static, or in an anonymous namesp
kelvinp
2014/12/05 03:17:28
No longer applied.
| |
| 14 ui::Layer* layer = ash::Shell::GetPrimaryRootWindow()->layer(); | |
| 15 float scale = ui::GetDeviceScaleFactor(layer); | |
|
Wez
2014/12/04 01:28:25
nit: Blank line after this, before the comment, to
kelvinp
2014/12/05 03:17:27
Done.
| |
| 16 // When the display is rotated by 90 deg, the display rotation transform | |
| 17 // involves a rotation around the origin and then a translation of |h| pixels | |
| 18 // along the y-axis, where |h| is the height of the display in device | |
| 19 // independent pixels. Since event.x() and event.y() are expressed in device | |
| 20 // pixels, we need to divide it by the scale factor before applying the | |
| 21 // rotation transform. | |
|
Wez
2014/12/04 01:28:25
This paragraph isn't very helpful; it's not clear
kelvinp
2014/12/05 03:17:27
Done.
| |
| 22 gfx::Transform rotation = layer->transform(); | |
| 23 | |
| 24 if (inverse) { | |
| 25 gfx::Transform inverse; | |
| 26 ignore_result(rotation.GetInverse(&inverse)); | |
| 27 rotation = inverse; | |
| 28 } | |
| 29 | |
| 30 gfx::Transform transform; | |
| 31 transform.Scale(scale, scale); // Converts back to device pixels. | |
| 32 transform *= rotation; // Display rotation. | |
| 33 transform.Scale(1/scale, 1/scale); // Converts to device independent pixels. | |
|
Wez
2014/12/04 01:28:25
As I commented previously, you need to explain *wh
kelvinp
2014/12/05 03:17:27
Done.
| |
| 34 return transform; | |
| 35 } | |
| 36 | |
| 37 gfx::PointF ConvertPointToNativeScreen(const gfx::PointF& location) { | |
| 38 gfx::Point3F screen_location(location); | |
| 39 gfx::Transform transform = GetRootTransform(false); | |
| 40 transform.TransformPoint(&screen_location); | |
| 41 return screen_location.AsPointF(); | |
|
Wez
2014/12/04 01:28:25
It seems expensive to keep fetching the root layer
kelvinp
2014/12/05 03:17:28
Done
| |
| 42 } | |
| 43 | |
| 44 gfx::PointF ConvertPointFromNativeScreen(const gfx::PointF& location) { | |
| 45 gfx::Point3F host_location(location); | |
| 46 gfx::Transform transform = GetRootTransform(true); | |
| 47 transform.TransformPoint(&host_location); | |
| 48 return host_location.AsPointF(); | |
| 49 } | |
| 50 | |
| 51 } // namespace remoting | |
| OLD | NEW |