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.
5 #ifndef REMOTING_HOST_CHROMEOS_POINT_TRANSFORMER_H_
6 #define REMOTING_HOST_CHROMEOS_POINT_TRANSFORMER_H_
8 #include "ui/aura/window_observer.h"
9 #include "ui/gfx/geometry/point_f.h"
10 #include "ui/gfx/transform.h"
18 // A class that performs coordinate transformations between the root window
19 // coordinates and the native screen coordinates, according to the current
20 // display rotation settings.
22 // Root window coordinates are expressed relative to the top left corner of the
23 // root window whereas native screen coordinates are expressed relative to the
24 // top left corner of the frame buffer, which may not match the root window
25 // either in origin nor orientation. Both coordinate systems are always in
28 // For example, when the display is rotated by 90 deg, the pixel at root window
29 // coordinates (x, y) will have native screen coordinates (height - y, x).
30 class PointTransformer
: public aura::WindowObserver
{
33 ~PointTransformer() override
;
35 // Converts from root window coordinates to native screen coordinates.
36 gfx::PointF
ToScreenCoordinates(const gfx::PointF
& window_location
);
38 // Converts from native screen coordinates to root window coordinates.
39 gfx::PointF
FromScreenCoordinates(const gfx::PointF
& screen_location
);
42 // aura::WindowObserver interface.
43 void OnWindowTransformed(aura::Window
* window
) override
;
45 aura::Window
* root_window_
;
46 gfx::Transform root_to_screen_
;
47 gfx::Transform screen_to_root_
;
49 DISALLOW_COPY_AND_ASSIGN(PointTransformer
);
52 } // namespace remoting
54 #endif // REMOTING_HOST_CHROMEOS_POINT_TRANSFORMER_H_