| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/chromeos/point_transformer.h" | 5 #include "remoting/host/chromeos/point_transformer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ui/aura/window_tree_host.h" | 8 #include "ui/aura/window_tree_host.h" |
| 9 #include "ui/compositor/dip_util.h" | 9 #include "ui/compositor/dip_util.h" |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // Use GetTargetTransform() instead of transform() as the layer may be | 30 // Use GetTargetTransform() instead of transform() as the layer may be |
| 31 // animating. GetTargetTransform() returns a transform comprising a rotation | 31 // animating. GetTargetTransform() returns a transform comprising a rotation |
| 32 // and a translation, but in DIPs, so we need to switch device pixels to DIPs, | 32 // and a translation, but in DIPs, so we need to switch device pixels to DIPs, |
| 33 // apply it, then switch from DIPs back to device pixels. | 33 // apply it, then switch from DIPs back to device pixels. |
| 34 gfx::Transform rotation = layer->GetTargetTransform(); | 34 gfx::Transform rotation = layer->GetTargetTransform(); |
| 35 gfx::Transform inverse_rotation; | 35 gfx::Transform inverse_rotation; |
| 36 gfx::Transform to_device_pixels; | 36 gfx::Transform to_device_pixels; |
| 37 gfx::Transform to_dip; | 37 gfx::Transform to_dip; |
| 38 | 38 |
| 39 CHECK(rotation.GetInverse(&inverse_rotation)) | 39 // Cannot inverse the root transform.|rotation.ToString()|. |
| 40 << "Cannot inverse the root transform." << rotation.ToString(); | 40 CHECK(rotation.GetInverse(&inverse_rotation)); |
| 41 | 41 |
| 42 to_device_pixels.Scale(scale, scale); | 42 to_device_pixels.Scale(scale, scale); |
| 43 to_dip.Scale(1 / scale, 1 / scale); | 43 to_dip.Scale(1 / scale, 1 / scale); |
| 44 | 44 |
| 45 // Matrix transformations are applied from right to left. See annotations. | 45 // Matrix transformations are applied from right to left. See annotations. |
| 46 // (3) (2) (1) | 46 // (3) (2) (1) |
| 47 root_to_screen_ = to_device_pixels * rotation * to_dip; | 47 root_to_screen_ = to_device_pixels * rotation * to_dip; |
| 48 screen_to_root_ = to_device_pixels * inverse_rotation * to_dip; | 48 screen_to_root_ = to_device_pixels * inverse_rotation * to_dip; |
| 49 } | 49 } |
| 50 | 50 |
| 51 gfx::PointF PointTransformer::ToScreenCoordinates( | 51 gfx::PointF PointTransformer::ToScreenCoordinates( |
| 52 const gfx::PointF& root_location) { | 52 const gfx::PointF& root_location) { |
| 53 gfx::Point3F screen_location(root_location); | 53 gfx::Point3F screen_location(root_location); |
| 54 root_to_screen_.TransformPoint(&screen_location); | 54 root_to_screen_.TransformPoint(&screen_location); |
| 55 return screen_location.AsPointF(); | 55 return screen_location.AsPointF(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 gfx::PointF PointTransformer::FromScreenCoordinates( | 58 gfx::PointF PointTransformer::FromScreenCoordinates( |
| 59 const gfx::PointF& screen_location) { | 59 const gfx::PointF& screen_location) { |
| 60 gfx::Point3F root_location(screen_location); | 60 gfx::Point3F root_location(screen_location); |
| 61 screen_to_root_.TransformPoint(&root_location); | 61 screen_to_root_.TransformPoint(&root_location); |
| 62 return root_location.AsPointF(); | 62 return root_location.AsPointF(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace remoting | 65 } // namespace remoting |
| OLD | NEW |