OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/touch/touch_uma.h" | 5 #include "ash/touch/touch_uma.h" |
6 | 6 |
7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const int bucket_size_x = std::max(1, | 101 const int bucket_size_x = std::max(1, |
102 bounds.width() / kBucketCountForLocation); | 102 bounds.width() / kBucketCountForLocation); |
103 const int bucket_size_y = std::max(1, | 103 const int bucket_size_y = std::max(1, |
104 bounds.height() / kBucketCountForLocation); | 104 bounds.height() / kBucketCountForLocation); |
105 | 105 |
106 gfx::Point position = event.root_location(); | 106 gfx::Point position = event.root_location(); |
107 | 107 |
108 // Prefer raw event location (when available) over calibrated location. | 108 // Prefer raw event location (when available) over calibrated location. |
109 if (event.HasNativeEvent()) { | 109 if (event.HasNativeEvent()) { |
110 position = ui::EventLocationFromNative(event.native_event()); | 110 position = ui::EventLocationFromNative(event.native_event()); |
111 position = gfx::ToFlooredPoint( | 111 position = gfx::ScaleToFlooredPoint( |
112 gfx::ScalePoint(position, 1. / target->layer()->device_scale_factor())); | 112 position, 1.f / target->layer()->device_scale_factor()); |
113 } | 113 } |
114 | 114 |
115 position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); | 115 position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); |
116 position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); | 116 position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); |
117 | 117 |
118 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionX", | 118 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionX", |
119 position.x() / bucket_size_x, | 119 position.x() / bucket_size_x, |
120 0, kBucketCountForLocation, kBucketCountForLocation + 1); | 120 0, kBucketCountForLocation, kBucketCountForLocation + 1); |
121 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionY", | 121 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionY", |
122 position.y() / bucket_size_y, | 122 position.y() / bucket_size_y, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 return GESTURE_OMNIBOX_SCROLL; | 299 return GESTURE_OMNIBOX_SCROLL; |
300 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) | 300 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) |
301 return GESTURE_OMNIBOX_PINCH; | 301 return GESTURE_OMNIBOX_PINCH; |
302 return GESTURE_UNKNOWN; | 302 return GESTURE_UNKNOWN; |
303 } | 303 } |
304 | 304 |
305 return GESTURE_UNKNOWN; | 305 return GESTURE_UNKNOWN; |
306 } | 306 } |
307 | 307 |
308 } // namespace ash | 308 } // namespace ash |
OLD | NEW |