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

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

Issue 508303002: Move touchscreen device caching to DeviceDataManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove PlatformEventObserver Created 6 years, 3 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_EVENTS_DEVICE_DATA_MANAGER_H_ 5 #ifndef UI_EVENTS_DEVICE_DATA_MANAGER_H_
6 #define UI_EVENTS_DEVICE_DATA_MANAGER_H_ 6 #define UI_EVENTS_DEVICE_DATA_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h"
15 #include "ui/events/device_hotplug_event_observer.h"
12 #include "ui/events/events_base_export.h" 16 #include "ui/events/events_base_export.h"
17 #include "ui/events/touchscreen_device.h"
13 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
14 19
15 namespace ui { 20 namespace ui {
16 21
22 class InputDeviceEventObserver;
23
17 // Keeps track of device mappings and event transformations. 24 // Keeps track of device mappings and event transformations.
18 class EVENTS_BASE_EXPORT DeviceDataManager { 25 class EVENTS_BASE_EXPORT DeviceDataManager : public DeviceHotplugEventObserver {
19 public: 26 public:
20 virtual ~DeviceDataManager(); 27 virtual ~DeviceDataManager();
21 28
22 static void CreateInstance(); 29 static void CreateInstance();
23 static DeviceDataManager* GetInstance(); 30 static DeviceDataManager* GetInstance();
24 static bool HasInstance(); 31 static bool HasInstance();
25 32
26 void ClearTouchTransformerRecord(); 33 void ClearTouchTransformerRecord();
27 void UpdateTouchInfoForDisplay(int64_t display_id, 34 void UpdateTouchInfoForDisplay(int64_t display_id,
28 int touch_device_id, 35 int touch_device_id,
29 const gfx::Transform& touch_transformer); 36 const gfx::Transform& touch_transformer);
30 void ApplyTouchTransformer(int touch_device_id, float* x, float* y); 37 void ApplyTouchTransformer(int touch_device_id, float* x, float* y);
31 int64_t GetDisplayForTouchDevice(int touch_device_id) const; 38 int64_t GetDisplayForTouchDevice(int touch_device_id) const;
32 39
33 void UpdateTouchRadiusScale(int touch_device_id, double scale); 40 void UpdateTouchRadiusScale(int touch_device_id, double scale);
34 void ApplyTouchRadiusScale(int touch_device_id, double* radius); 41 void ApplyTouchRadiusScale(int touch_device_id, double* radius);
35 42
43 std::vector<TouchscreenDevice> GetTouchscreenDevices() const;
Daniel Erat 2014/09/10 16:51:25 can this instead be a simple inlined accessor that
dnicoara 2014/09/10 18:05:36 Done.
44
45 void AddObserver(InputDeviceEventObserver* observer);
46 void RemoveObserver(InputDeviceEventObserver* observer);
47
36 protected: 48 protected:
37 DeviceDataManager(); 49 DeviceDataManager();
38 50
39 static DeviceDataManager* instance(); 51 static DeviceDataManager* instance();
40 52
41 static const int kMaxDeviceNum = 128; 53 static const int kMaxDeviceNum = 128;
42 54
43 private: 55 private:
44 static DeviceDataManager* instance_; 56 static DeviceDataManager* instance_;
45 57
46 bool IsTouchDeviceIdValid(int touch_device_id) const; 58 bool IsTouchDeviceIdValid(int touch_device_id) const;
47 59
60 // DeviceHotplugEventObserver:
61 virtual void OnTouchscreenDevices(
62 const std::vector<TouchscreenDevice>& devices) OVERRIDE;
63
48 double touch_radius_scale_map_[kMaxDeviceNum]; 64 double touch_radius_scale_map_[kMaxDeviceNum];
49 65
50 // Table to keep track of which display id is mapped to which touch device. 66 // Table to keep track of which display id is mapped to which touch device.
51 int64_t touch_device_to_display_map_[kMaxDeviceNum]; 67 int64_t touch_device_to_display_map_[kMaxDeviceNum];
52 // Index table to find the TouchTransformer for a touch device. 68 // Index table to find the TouchTransformer for a touch device.
53 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; 69 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum];
54 70
71 std::vector<TouchscreenDevice> touchscreen_devices_;
72
73 ObserverList<InputDeviceEventObserver> observers_;
74
55 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); 75 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager);
56 }; 76 };
57 77
58 } // namespace ui 78 } // namespace ui
59 79
60 #endif // UI_EVENTS_DEVICE_DATA_MANAGER_H_ 80 #endif // UI_EVENTS_DEVICE_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698