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

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

Issue 922843002: Fix software mirror mode on Ozone part 2/2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 #include "ui/events/devices/device_data_manager.h" 5 #include "ui/events/devices/device_data_manager.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/events/devices/input_device_event_observer.h" 10 #include "ui/events/devices/input_device_event_observer.h"
(...skipping 15 matching lines...) Expand all
26 26
27 DeviceDataManager::DeviceDataManager() { 27 DeviceDataManager::DeviceDataManager() {
28 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager"; 28 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager";
29 instance_ = this; 29 instance_ = this;
30 30
31 base::AtExitManager::RegisterTask( 31 base::AtExitManager::RegisterTask(
32 base::Bind(&base::DeletePointer<DeviceDataManager>, this)); 32 base::Bind(&base::DeletePointer<DeviceDataManager>, this));
33 33
34 for (int i = 0; i < kMaxDeviceNum; ++i) { 34 for (int i = 0; i < kMaxDeviceNum; ++i) {
35 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID; 35 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
36 touch_device_to_destination_display_map_[i] =
37 gfx::Display::kInvalidDisplayID;
36 touch_radius_scale_map_[i] = 1.0; 38 touch_radius_scale_map_[i] = 1.0;
37 } 39 }
38 } 40 }
39 41
40 DeviceDataManager::~DeviceDataManager() { 42 DeviceDataManager::~DeviceDataManager() {
41 CHECK_EQ(this, instance_); 43 CHECK_EQ(this, instance_);
42 instance_ = NULL; 44 instance_ = NULL;
43 } 45 }
44 46
45 // static 47 // static
(...skipping 21 matching lines...) Expand all
67 void DeviceDataManager::ClearTouchTransformerRecord() { 69 void DeviceDataManager::ClearTouchTransformerRecord() {
68 for (int i = 0; i < kMaxDeviceNum; i++) { 70 for (int i = 0; i < kMaxDeviceNum; i++) {
69 touch_device_transformer_map_[i] = gfx::Transform(); 71 touch_device_transformer_map_[i] = gfx::Transform();
70 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID; 72 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
71 touch_radius_scale_map_[i] = 1.0; 73 touch_radius_scale_map_[i] = 1.0;
72 } 74 }
73 } 75 }
74 76
75 bool DeviceDataManager::IsTouchDeviceIdValid( 77 bool DeviceDataManager::IsTouchDeviceIdValid(
76 unsigned int touch_device_id) const { 78 unsigned int touch_device_id) const {
77 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); 79 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum);
oshima 2015/02/27 02:37:43 optional: it may be safer to reset the table entry
pkotwicz 2015/02/27 02:47:06 My understanding is that there is no table entry i
oshima 2015/02/27 20:45:31 this is just a array, not map right? anyway, if th
pkotwicz 2015/03/01 16:04:00 I don't think I understand your concern We check
78 } 80 }
79 81
80 void DeviceDataManager::UpdateTouchInfoForDisplay( 82 void DeviceDataManager::UpdateTouchInfoForDisplay(
81 int64_t display_id, 83 int64_t display_id,
82 unsigned int touch_device_id, 84 unsigned int touch_device_id,
83 const gfx::Transform& touch_transformer) { 85 const gfx::Transform& touch_transformer) {
84 if (IsTouchDeviceIdValid(touch_device_id)) { 86 if (IsTouchDeviceIdValid(touch_device_id)) {
85 touch_device_to_display_map_[touch_device_id] = display_id; 87 touch_device_to_display_map_[touch_device_id] = display_id;
86 touch_device_transformer_map_[touch_device_id] = touch_transformer; 88 touch_device_transformer_map_[touch_device_id] = touch_transformer;
87 } 89 }
(...skipping 24 matching lines...) Expand all
112 } 114 }
113 } 115 }
114 116
115 int64_t DeviceDataManager::GetDisplayForTouchDevice( 117 int64_t DeviceDataManager::GetDisplayForTouchDevice(
116 unsigned int touch_device_id) const { 118 unsigned int touch_device_id) const {
117 if (IsTouchDeviceIdValid(touch_device_id)) 119 if (IsTouchDeviceIdValid(touch_device_id))
118 return touch_device_to_display_map_[touch_device_id]; 120 return touch_device_to_display_map_[touch_device_id];
119 return gfx::Display::kInvalidDisplayID; 121 return gfx::Display::kInvalidDisplayID;
120 } 122 }
121 123
124 void DeviceDataManager::SetDestinationDisplayForTouchDevice(
125 unsigned int touch_device_id,
126 int64_t destination_display_id) {
127 if (IsTouchDeviceIdValid(touch_device_id)) {
128 touch_device_to_destination_display_map_[touch_device_id] =
129 destination_display_id;
130 }
131 }
132
133 int64_t DeviceDataManager::GetDestinationDisplayForTouchDevice(
134 unsigned int touch_device_id) {
135 if (IsTouchDeviceIdValid(touch_device_id))
136 return touch_device_to_destination_display_map_[touch_device_id];
137 return gfx::Display::kInvalidDisplayID;
138 }
139
122 void DeviceDataManager::OnTouchscreenDevicesUpdated( 140 void DeviceDataManager::OnTouchscreenDevicesUpdated(
123 const std::vector<TouchscreenDevice>& devices) { 141 const std::vector<TouchscreenDevice>& devices) {
124 if (devices.size() == touchscreen_devices_.size() && 142 if (devices.size() == touchscreen_devices_.size() &&
125 std::equal(devices.begin(), 143 std::equal(devices.begin(),
126 devices.end(), 144 devices.end(),
127 touchscreen_devices_.begin(), 145 touchscreen_devices_.begin(),
128 InputDeviceEquals)) { 146 InputDeviceEquals)) {
129 return; 147 return;
130 } 148 }
131 touchscreen_devices_ = devices; 149 touchscreen_devices_ = devices;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 183
166 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { 184 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) {
167 observers_.AddObserver(observer); 185 observers_.AddObserver(observer);
168 } 186 }
169 187
170 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { 188 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) {
171 observers_.RemoveObserver(observer); 189 observers_.RemoveObserver(observer);
172 } 190 }
173 191
174 } // namespace ui 192 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698