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 #ifndef UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ | 5 #ifndef UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ |
6 #define UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ | 6 #define UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | |
9 #include <memory> | |
10 #include <vector> | |
11 | |
8 #include "base/macros.h" | 12 #include "base/macros.h" |
9 #include "ui/display/manager/display_manager_export.h" | 13 #include "ui/display/manager/display_manager_export.h" |
10 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
11 #include "ui/gfx/geometry/size_f.h" | 15 #include "ui/gfx/geometry/size_f.h" |
12 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
13 | 17 |
14 namespace ui { | 18 namespace ui { |
15 struct TouchscreenDevice; | 19 struct TouchscreenDevice; |
16 } | 20 } |
17 | 21 |
18 namespace display { | 22 namespace display { |
19 | 23 |
20 class DisplayConfigurator; | 24 class DisplayConfigurator; |
21 class DisplayManager; | 25 class DisplayManager; |
22 class ManagedDisplayInfo; | 26 class ManagedDisplayInfo; |
27 class TouchTransformSetter; | |
28 | |
29 struct TouchDeviceTransform; | |
23 | 30 |
24 namespace test { | 31 namespace test { |
25 class TouchTransformControllerTest; | 32 class TouchTransformControllerTest; |
26 } | 33 } |
27 | 34 |
28 // TouchTransformController matches touchscreen displays with touch | 35 // TouchTransformController matches touchscreen displays with touch |
29 // input-devices and computes the coordinate transforms between display space | 36 // input-devices and computes the coordinate transforms between display space |
30 // and input-device space. | 37 // and input-device space. |
31 class DISPLAY_MANAGER_EXPORT TouchTransformController { | 38 class DISPLAY_MANAGER_EXPORT TouchTransformController { |
32 public: | 39 public: |
33 TouchTransformController(DisplayConfigurator* display_configurator, | 40 TouchTransformController(DisplayConfigurator* display_configurator, |
34 DisplayManager* display_manager); | 41 DisplayManager* display_manager, |
42 std::unique_ptr<TouchTransformSetter> setter); | |
35 ~TouchTransformController(); | 43 ~TouchTransformController(); |
36 | 44 |
37 // Updates the transform for touch input-devices and pushes the new transforms | 45 // Updates the transform for touch input-devices and pushes the new transforms |
38 // into device manager. | 46 // into device manager. |
39 void UpdateTouchTransforms() const; | 47 void UpdateTouchTransforms() const; |
40 | 48 |
41 // During touch calibration we remove the previous transform and update touch | 49 // During touch calibration we remove the previous transform and update touch |
42 // transformer until calibration is complete. | 50 // transformer until calibration is complete. |
43 void SetForCalibration(bool is_calibrating); | 51 void SetForCalibration(bool is_calibrating); |
44 | 52 |
45 private: | 53 private: |
46 friend class test::TouchTransformControllerTest; | 54 friend class test::TouchTransformControllerTest; |
47 | 55 |
56 // Contains the data that is passed to TouchTransformSetter. | |
57 struct UpdateData { | |
58 UpdateData(); | |
59 ~UpdateData(); | |
60 | |
61 std::map<int32_t, double> device_to_scale; | |
62 std::vector<TouchDeviceTransform> touch_device_transforms; | |
63 }; | |
64 | |
65 void UpdateTouchTransforms(UpdateData* data) const; | |
66 | |
48 // Returns a transform that will be used to change an event's location from | 67 // Returns a transform that will be used to change an event's location from |
49 // the touchscreen's coordinate system into |display|'s coordinate system. | 68 // the touchscreen's coordinate system into |display|'s coordinate system. |
50 // The transform is also responsible for properly scaling the display if the | 69 // The transform is also responsible for properly scaling the display if the |
51 // display supports panel fitting. | 70 // display supports panel fitting. |
52 // | 71 // |
53 // On X11 events are reported in framebuffer coordinate space, so the | 72 // On X11 events are reported in framebuffer coordinate space, so the |
54 // |framebuffer_size| is used for scaling. | 73 // |framebuffer_size| is used for scaling. |
55 // On Ozone events are reported in the touchscreen's resolution, so | 74 // On Ozone events are reported in the touchscreen's resolution, so |
56 // |touch_display| is used to determine the size and scale the event. | 75 // |touch_display| is used to determine the size and scale the event. |
57 gfx::Transform GetTouchTransform(const ManagedDisplayInfo& display, | 76 gfx::Transform GetTouchTransform(const ManagedDisplayInfo& display, |
58 const ManagedDisplayInfo& touch_display, | 77 const ManagedDisplayInfo& touch_display, |
59 const ui::TouchscreenDevice& touchscreen, | 78 const ui::TouchscreenDevice& touchscreen, |
60 const gfx::Size& framebuffer_size) const; | 79 const gfx::Size& framebuffer_size) const; |
61 | 80 |
62 // Returns the scaling factor for the touch radius such that it scales the | 81 // Returns the scaling factor for the touch radius such that it scales the |
63 // radius from |touch_device|'s coordinate system to the |touch_display|'s | 82 // radius from |touch_device|'s coordinate system to the |touch_display|'s |
64 // coordinate system. | 83 // coordinate system. |
65 double GetTouchResolutionScale( | 84 double GetTouchResolutionScale( |
66 const ManagedDisplayInfo& touch_display, | 85 const ManagedDisplayInfo& touch_display, |
67 const ui::TouchscreenDevice& touch_device) const; | 86 const ui::TouchscreenDevice& touch_device) const; |
68 | 87 |
69 // For the provided |display| update the touch radius mapping. | 88 // For the provided |display| update the touch radius mapping. |
oshima
2017/05/19 23:54:00
nit: update the comment
sky
2017/05/21 14:42:41
Done.
| |
70 void UpdateTouchRadius(const ManagedDisplayInfo& display) const; | 89 void UpdateTouchRadius(const ManagedDisplayInfo& display, |
90 UpdateData* update_data) const; | |
71 | 91 |
72 // For a given |target_display| and |target_display_id| update the touch | 92 // For a given |target_display| and |target_display_id| update the touch |
73 // transformation based on the touchscreen associated with |touch_display|. | 93 // transformation based on the touchscreen associated with |touch_display|. |
74 // |target_display_id| is the display id whose root window will receive the | 94 // |target_display_id| is the display id whose root window will receive the |
75 // touch events. | 95 // touch events. |
76 // |touch_display| is the physical display that has the touchscreen | 96 // |touch_display| is the physical display that has the touchscreen |
77 // from which the events arrive. | 97 // from which the events arrive. |
78 // |target_display| provides the dimensions to which the touch event will be | 98 // |target_display| provides the dimensions to which the touch event will be |
79 // transformed. | 99 // transformed. |
oshima
2017/05/19 23:54:00
ditto
sky
2017/05/21 14:42:41
Done.
| |
80 void UpdateTouchTransform(int64_t target_display_id, | 100 void UpdateTouchTransform(int64_t target_display_id, |
81 const ManagedDisplayInfo& touch_display, | 101 const ManagedDisplayInfo& touch_display, |
82 const ManagedDisplayInfo& target_display) const; | 102 const ManagedDisplayInfo& target_display, |
103 UpdateData* update_data) const; | |
83 | 104 |
84 // Both |display_configurator_| and |display_manager_| are not owned and must | 105 // Both |display_configurator_| and |display_manager_| are not owned and must |
85 // outlive TouchTransformController. | 106 // outlive TouchTransformController. |
86 DisplayConfigurator* display_configurator_; | 107 DisplayConfigurator* display_configurator_; |
87 DisplayManager* display_manager_; | 108 DisplayManager* display_manager_; |
88 | 109 |
89 bool is_calibrating_ = false; | 110 bool is_calibrating_ = false; |
90 | 111 |
112 std::unique_ptr<TouchTransformSetter> setter_; | |
113 | |
91 DISALLOW_COPY_AND_ASSIGN(TouchTransformController); | 114 DISALLOW_COPY_AND_ASSIGN(TouchTransformController); |
92 }; | 115 }; |
93 | 116 |
94 } // namespace display | 117 } // namespace display |
95 | 118 |
96 #endif // UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ | 119 #endif // UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ |
OLD | NEW |