| OLD | NEW |
| 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/device_data_manager.h" | 5 #include "ui/events/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/gfx/display.h" | 10 #include "ui/gfx/display.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 new DeviceDataManager(); | 42 new DeviceDataManager(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 DeviceDataManager* DeviceDataManager::GetInstance() { | 46 DeviceDataManager* DeviceDataManager::GetInstance() { |
| 47 CHECK(instance_) << "DeviceDataManager was not created."; | 47 CHECK(instance_) << "DeviceDataManager was not created."; |
| 48 return instance_; | 48 return instance_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static |
| 52 bool DeviceDataManager::HasInstance() { |
| 53 return instance_ != NULL; |
| 54 } |
| 55 |
| 51 void DeviceDataManager::ClearTouchTransformerRecord() { | 56 void DeviceDataManager::ClearTouchTransformerRecord() { |
| 52 for (int i = 0; i < kMaxDeviceNum; i++) { | 57 for (int i = 0; i < kMaxDeviceNum; i++) { |
| 53 touch_device_transformer_map_[i] = gfx::Transform(); | 58 touch_device_transformer_map_[i] = gfx::Transform(); |
| 54 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID; | 59 touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID; |
| 55 } | 60 } |
| 56 } | 61 } |
| 57 | 62 |
| 58 bool DeviceDataManager::IsTouchDeviceIdValid(int touch_device_id) const { | 63 bool DeviceDataManager::IsTouchDeviceIdValid(int touch_device_id) const { |
| 59 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); | 64 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); |
| 60 } | 65 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 82 } | 87 } |
| 83 } | 88 } |
| 84 | 89 |
| 85 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const { | 90 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const { |
| 86 if (IsTouchDeviceIdValid(touch_device_id)) | 91 if (IsTouchDeviceIdValid(touch_device_id)) |
| 87 return touch_device_to_display_map_[touch_device_id]; | 92 return touch_device_to_display_map_[touch_device_id]; |
| 88 return gfx::Display::kInvalidDisplayID; | 93 return gfx::Display::kInvalidDisplayID; |
| 89 } | 94 } |
| 90 | 95 |
| 91 } // namespace ui | 96 } // namespace ui |
| OLD | NEW |