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 ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_
6 #define ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "ash/display/display_controller.h"
10 #include "ui/gfx/transform.h"
13 struct TouchscreenDevice
;
18 // TouchTransformerController listens to display configuration change
19 // and updates the touch transformation for touch displays.
20 class ASH_EXPORT TouchTransformerController
21 : public DisplayController::Observer
{
23 TouchTransformerController();
24 virtual ~TouchTransformerController();
26 // Updates the TouchTransformer for touch device and pushes the new
27 // TouchTransformer into device manager.
28 void UpdateTouchTransformer() const;
30 // DisplayController::Observer:
31 virtual void OnDisplaysInitialized() override
;
32 virtual void OnDisplayConfigurationChanged() override
;
35 FRIEND_TEST_ALL_PREFIXES(TouchTransformerControllerTest
,
36 TouchTransformerMirrorModeLetterboxing
);
37 FRIEND_TEST_ALL_PREFIXES(TouchTransformerControllerTest
,
38 TouchTransformerMirrorModePillarboxing
);
39 FRIEND_TEST_ALL_PREFIXES(TouchTransformerControllerTest
,
40 TouchTransformerExtendedMode
);
41 FRIEND_TEST_ALL_PREFIXES(TouchTransformerControllerTest
,
44 // Returns a transform that will be used to change an event's location from
45 // the touchscreen's coordinate system into the display's coordinate system.
46 // The transform is also responsible for properly scaling the display if the
47 // display support panel fitting.
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 // |touchscreen| is used to determine the size and scale the event.
53 gfx::Transform
GetTouchTransform(
54 const DisplayInfo
& display
,
55 const ui::TouchscreenDevice
& touchscreen
,
56 const gfx::Size
& framebuffer_size
) const;
58 // Returns the scaling factor for the touch radius such that it scales the
59 // radius from |touch_device|'s coordiante system to the |touch_display|'s
61 double GetTouchResolutionScale(
62 const DisplayInfo
& touch_display
,
63 const ui::TouchscreenDevice
& touch_device
) const;
65 DISALLOW_COPY_AND_ASSIGN(TouchTransformerController
);
70 #endif // ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_