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 #ifndef UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ |
| 6 #define UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "ui/display/manager/display_manager_export.h" |
| 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/gfx/geometry/size_f.h" |
| 12 #include "ui/gfx/transform.h" |
| 13 |
| 14 namespace ui { |
| 15 struct TouchscreenDevice; |
| 16 } |
| 17 |
| 18 namespace display { |
| 19 |
| 20 class DisplayConfigurator; |
| 21 class DisplayManager; |
| 22 class ManagedDisplayInfo; |
| 23 |
| 24 namespace test { |
| 25 class TouchTransformControllerTest; |
| 26 } |
| 27 |
| 28 // TouchTransformController matches touchscreen displays with touch |
| 29 // input-devices and computes the coordinate transforms between display space |
| 30 // and input-device space. |
| 31 class DISPLAY_MANAGER_EXPORT TouchTransformController { |
| 32 public: |
| 33 TouchTransformController(DisplayConfigurator* display_configurator, |
| 34 DisplayManager* display_manager); |
| 35 ~TouchTransformController(); |
| 36 |
| 37 // Updates the TouchTransformer for touch device and pushes the new |
| 38 // TouchTransformer into device manager. |
| 39 void UpdateTouchTransforms() const; |
| 40 |
| 41 private: |
| 42 friend class test::TouchTransformControllerTest; |
| 43 |
| 44 // Returns a transform that will be used to change an event's location from |
| 45 // the touchscreen's coordinate system into |display|'s coordinate system. |
| 46 // The transform is also responsible for properly scaling the display if the |
| 47 // display supports panel fitting. |
| 48 // |
| 49 // On X11 events are reported in framebuffer coordinate space, so the |
| 50 // |framebuffer_size| is used for scaling. |
| 51 // On Ozone events are reported in the touchscreen's resolution, so |
| 52 // |touch_display| is used to determine the size and scale the event. |
| 53 gfx::Transform GetTouchTransform(const ManagedDisplayInfo& display, |
| 54 const ManagedDisplayInfo& touch_display, |
| 55 const ui::TouchscreenDevice& touchscreen, |
| 56 const gfx::Size& framebuffer_size) const; |
| 57 |
| 58 // Returns the scaling factor for the touch radius such that it scales the |
| 59 // radius from |touch_device|'s coordinate system to the |touch_display|'s |
| 60 // coordinate system. |
| 61 double GetTouchResolutionScale( |
| 62 const ManagedDisplayInfo& touch_display, |
| 63 const ui::TouchscreenDevice& touch_device) const; |
| 64 |
| 65 // For the provided |display| update the touch radius mapping. |
| 66 void UpdateTouchRadius(const ManagedDisplayInfo& display) const; |
| 67 |
| 68 // For a given |target_display| and |target_display_id| update the touch |
| 69 // transformation based on the touchscreen associated with |touch_display|. |
| 70 // |target_display_id| is the display id whose root window will receive the |
| 71 // touch events. |
| 72 // |touch_display| is the physical display that has the touchscreen |
| 73 // from which the events arrive. |
| 74 // |target_display| provides the dimensions to which the touch event will be |
| 75 // transformed. |
| 76 void UpdateTouchTransform(int64_t target_display_id, |
| 77 const ManagedDisplayInfo& touch_display, |
| 78 const ManagedDisplayInfo& target_display) const; |
| 79 |
| 80 // Both |display_configurator_| and |display_manager_| are not owned and must |
| 81 // outlive TouchTransformController. |
| 82 DisplayConfigurator* display_configurator_; |
| 83 DisplayManager* display_manager_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(TouchTransformController); |
| 86 }; |
| 87 |
| 88 } // namespace display |
| 89 |
| 90 #endif // UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_ |
OLD | NEW |