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

Side by Side Diff: ui/events/device_data_manager.cc

Issue 289283015: Extract touchscreen device management into a generic manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/device_data_manager.h ('k') | ui/events/events.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "ui/events/device_data_manager.h"
6
7 #include "base/memory/singleton.h"
8 #include "ui/gfx/display.h"
9 #include "ui/gfx/geometry/point3_f.h"
10
11 namespace ui {
12
13 DeviceDataManager::DeviceDataManager() {
14 for (int i = 0; i < kMaxDeviceNum; ++i)
15 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
16 }
17
18 DeviceDataManager::~DeviceDataManager() {}
19
20 #if !defined(USE_X11)
21 // static
22 DeviceDataManager* DeviceDataManager::GetInstance() {
sadrul 2014/05/27 15:50:21 Can we change this to be more like how PlatformEve
23 return Singleton<DeviceDataManager>::get();
24 }
25 #endif
26
27 void DeviceDataManager::ClearTouchTransformerRecord() {
28 for (int i = 0; i < kMaxDeviceNum; i++) {
29 touch_device_transformer_map_[i] = gfx::Transform();
30 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
31 }
32 }
33
34 bool DeviceDataManager::IsTouchDeviceIdValid(int touch_device_id) const {
35 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum);
36 }
37
38 void DeviceDataManager::UpdateTouchInfoForDisplay(
39 int64_t display_id,
40 int touch_device_id,
41 const gfx::Transform& touch_transformer) {
42 if (IsTouchDeviceIdValid(touch_device_id)) {
43 touch_device_to_display_map_[touch_device_id] = display_id;
44 touch_device_transformer_map_[touch_device_id] = touch_transformer;
45 }
46 }
47
48 void DeviceDataManager::ApplyTouchTransformer(int touch_device_id,
49 float* x,
50 float* y) {
51 if (IsTouchDeviceIdValid(touch_device_id)) {
52 gfx::Point3F point(*x, *y, 0.0);
53 const gfx::Transform& trans =
54 touch_device_transformer_map_[touch_device_id];
55 trans.TransformPoint(&point);
56 *x = point.x();
57 *y = point.y();
58 }
59 }
60
61 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const {
62 if (IsTouchDeviceIdValid(touch_device_id))
63 return touch_device_to_display_map_[touch_device_id];
64 return gfx::Display::kInvalidDisplayID;
65 }
66
67 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/device_data_manager.h ('k') | ui/events/events.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698