Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: ui/display/manager/chromeos/touch_transform_controller.h

Issue 2887413004: chromeos: moves setting of touch state to a separate class (Closed)
Patch Set: feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 in
70 void UpdateTouchRadius(const ManagedDisplayInfo& display) const; 89 // |update_data|.
90 void UpdateTouchRadius(const ManagedDisplayInfo& display,
91 UpdateData* update_data) const;
71 92
72 // For a given |target_display| and |target_display_id| update the touch 93 // For a given |target_display| and |target_display_id| update the touch
73 // transformation based on the touchscreen associated with |touch_display|. 94 // transformation in |update_data| based on the touchscreen associated with
74 // |target_display_id| is the display id whose root window will receive the 95 // |touch_display|. |target_display_id| is the display id to update the
75 // touch events. 96 // transform for.
76 // |touch_display| is the physical display that has the touchscreen 97 // |touch_display| is the physical display that has the touchscreen
77 // from which the events arrive. 98 // from which the events arrive.
78 // |target_display| provides the dimensions to which the touch event will be 99 // |target_display| provides the dimensions to which the touch event will be
79 // transformed. 100 // transformed.
80 void UpdateTouchTransform(int64_t target_display_id, 101 void UpdateTouchTransform(int64_t target_display_id,
81 const ManagedDisplayInfo& touch_display, 102 const ManagedDisplayInfo& touch_display,
82 const ManagedDisplayInfo& target_display) const; 103 const ManagedDisplayInfo& target_display,
104 UpdateData* update_data) const;
83 105
84 // Both |display_configurator_| and |display_manager_| are not owned and must 106 // Both |display_configurator_| and |display_manager_| are not owned and must
85 // outlive TouchTransformController. 107 // outlive TouchTransformController.
86 DisplayConfigurator* display_configurator_; 108 DisplayConfigurator* display_configurator_;
87 DisplayManager* display_manager_; 109 DisplayManager* display_manager_;
88 110
89 bool is_calibrating_ = false; 111 bool is_calibrating_ = false;
90 112
113 std::unique_ptr<TouchTransformSetter> setter_;
114
91 DISALLOW_COPY_AND_ASSIGN(TouchTransformController); 115 DISALLOW_COPY_AND_ASSIGN(TouchTransformController);
92 }; 116 };
93 117
94 } // namespace display 118 } // namespace display
95 119
96 #endif // UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ 120 #endif // UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/display/manager/chromeos/touch_device_transform.cc ('k') | ui/display/manager/chromeos/touch_transform_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698