OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_hud_debug.h" | 5 #include "ash/touch/touch_hud_debug.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return static_cast<int>(tracking_id); | 86 return static_cast<int>(tracking_id); |
87 } | 87 } |
88 #endif | 88 #endif |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 // A TouchPointLog represents a single touch-event of a touch point. | 92 // A TouchPointLog represents a single touch-event of a touch point. |
93 struct TouchPointLog { | 93 struct TouchPointLog { |
94 public: | 94 public: |
95 explicit TouchPointLog(const ui::TouchEvent& touch) | 95 explicit TouchPointLog(const ui::TouchEvent& touch) |
96 : id(touch.touch_id()), | 96 : id(touch.pointer_details().id), |
97 type(touch.type()), | 97 type(touch.type()), |
98 location(touch.root_location()), | 98 location(touch.root_location()), |
99 timestamp((touch.time_stamp() - base::TimeTicks()).InMillisecondsF()), | 99 timestamp((touch.time_stamp() - base::TimeTicks()).InMillisecondsF()), |
100 radius_x(touch.pointer_details().radius_x), | 100 radius_x(touch.pointer_details().radius_x), |
101 radius_y(touch.pointer_details().radius_y), | 101 radius_y(touch.pointer_details().radius_y), |
102 pressure(touch.pointer_details().force), | 102 pressure(touch.pointer_details().force), |
103 tracking_id(GetTrackingId(touch)), | 103 tracking_id(GetTrackingId(touch)), |
104 source_device(touch.source_device_id()) {} | 104 source_device(touch.source_device_id()) {} |
105 | 105 |
106 // Populates a dictionary value with all the information about the touch | 106 // Populates a dictionary value with all the information about the touch |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 private: | 206 private: |
207 void StartTrace(const ui::TouchEvent& touch) { | 207 void StartTrace(const ui::TouchEvent& touch) { |
208 // Find the first inactive spot; otherwise, overwrite the one | 208 // Find the first inactive spot; otherwise, overwrite the one |
209 // |next_trace_index_| is pointing to. | 209 // |next_trace_index_| is pointing to. |
210 int old_trace_index = next_trace_index_; | 210 int old_trace_index = next_trace_index_; |
211 do { | 211 do { |
212 if (!traces_[next_trace_index_].active()) | 212 if (!traces_[next_trace_index_].active()) |
213 break; | 213 break; |
214 next_trace_index_ = (next_trace_index_ + 1) % kMaxPaths; | 214 next_trace_index_ = (next_trace_index_ + 1) % kMaxPaths; |
215 } while (next_trace_index_ != old_trace_index); | 215 } while (next_trace_index_ != old_trace_index); |
216 int touch_id = touch.touch_id(); | 216 int touch_id = touch.pointer_details().id; |
217 traces_[next_trace_index_].Reset(); | 217 traces_[next_trace_index_].Reset(); |
218 touch_id_to_trace_index_[touch_id] = next_trace_index_; | 218 touch_id_to_trace_index_[touch_id] = next_trace_index_; |
219 next_trace_index_ = (next_trace_index_ + 1) % kMaxPaths; | 219 next_trace_index_ = (next_trace_index_ + 1) % kMaxPaths; |
220 } | 220 } |
221 | 221 |
222 void AddToTrace(const ui::TouchEvent& touch) { | 222 void AddToTrace(const ui::TouchEvent& touch) { |
223 int touch_id = touch.touch_id(); | 223 int touch_id = touch.pointer_details().id; |
224 int trace_index = touch_id_to_trace_index_[touch_id]; | 224 int trace_index = touch_id_to_trace_index_[touch_id]; |
225 traces_[trace_index].AddTouchPoint(touch); | 225 traces_[trace_index].AddTouchPoint(touch); |
226 } | 226 } |
227 | 227 |
228 TouchTrace traces_[kMaxPaths]; | 228 TouchTrace traces_[kMaxPaths]; |
229 int next_trace_index_; | 229 int next_trace_index_; |
230 | 230 |
231 std::map<int, int> touch_id_to_trace_index_; | 231 std::map<int, int> touch_id_to_trace_index_; |
232 | 232 |
233 DISALLOW_COPY_AND_ASSIGN(TouchLog); | 233 DISALLOW_COPY_AND_ASSIGN(TouchLog); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 DCHECK(point != trace.log().rend()); | 432 DCHECK(point != trace.log().rend()); |
433 gfx::Point touch_position = point->location; | 433 gfx::Point touch_position = point->location; |
434 | 434 |
435 std::string string = base::StringPrintf( | 435 std::string string = base::StringPrintf( |
436 "%2d: %s %s (%.4f)", index, GetTouchEventLabel(touch_status), | 436 "%2d: %s %s (%.4f)", index, GetTouchEventLabel(touch_status), |
437 touch_position.ToString().c_str(), touch_radius); | 437 touch_position.ToString().c_str(), touch_radius); |
438 touch_labels_[index]->SetText(base::UTF8ToUTF16(string)); | 438 touch_labels_[index]->SetText(base::UTF8ToUTF16(string)); |
439 } | 439 } |
440 | 440 |
441 void TouchHudDebug::OnTouchEvent(ui::TouchEvent* event) { | 441 void TouchHudDebug::OnTouchEvent(ui::TouchEvent* event) { |
442 if (event->touch_id() >= kMaxTouchPoints) | 442 if (static_cast<int>(event->pointer_details().id) >= kMaxTouchPoints) |
443 return; | 443 return; |
444 | 444 |
445 touch_log_->AddTouchPoint(*event); | 445 touch_log_->AddTouchPoint(*event); |
446 canvas_->TouchPointAdded(event->touch_id()); | 446 canvas_->TouchPointAdded(event->pointer_details().id); |
447 UpdateTouchPointLabel(event->touch_id()); | 447 UpdateTouchPointLabel(event->pointer_details().id); |
448 label_container_->SetSize(label_container_->GetPreferredSize()); | 448 label_container_->SetSize(label_container_->GetPreferredSize()); |
449 } | 449 } |
450 | 450 |
451 void TouchHudDebug::OnDisplayMetricsChanged(const display::Display& display, | 451 void TouchHudDebug::OnDisplayMetricsChanged(const display::Display& display, |
452 uint32_t metrics) { | 452 uint32_t metrics) { |
453 TouchObserverHUD::OnDisplayMetricsChanged(display, metrics); | 453 TouchObserverHUD::OnDisplayMetricsChanged(display, metrics); |
454 | 454 |
455 if (display.id() != display_id() || !(metrics & DISPLAY_METRIC_BOUNDS)) | 455 if (display.id() != display_id() || !(metrics & DISPLAY_METRIC_BOUNDS)) |
456 return; | 456 return; |
457 const gfx::Size& size = display.size(); | 457 const gfx::Size& size = display.size(); |
458 canvas_->SetSize(size); | 458 canvas_->SetSize(size); |
459 label_container_->SetY(size.height() / kReducedScale); | 459 label_container_->SetY(size.height() / kReducedScale); |
460 } | 460 } |
461 | 461 |
462 void TouchHudDebug::SetHudForRootWindowController( | 462 void TouchHudDebug::SetHudForRootWindowController( |
463 RootWindowController* controller) { | 463 RootWindowController* controller) { |
464 controller->set_touch_hud_debug(this); | 464 controller->set_touch_hud_debug(this); |
465 } | 465 } |
466 | 466 |
467 void TouchHudDebug::UnsetHudForRootWindowController( | 467 void TouchHudDebug::UnsetHudForRootWindowController( |
468 RootWindowController* controller) { | 468 RootWindowController* controller) { |
469 controller->set_touch_hud_debug(NULL); | 469 controller->set_touch_hud_debug(NULL); |
470 } | 470 } |
471 | 471 |
472 } // namespace ash | 472 } // namespace ash |
OLD | NEW |