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 "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" | 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
13 | 13 |
14 using blink::WebGestureEvent; | 14 using blink::WebGestureEvent; |
15 using blink::WebInputEvent; | 15 using blink::WebInputEvent; |
16 using blink::WebMouseEvent; | 16 using blink::WebMouseEvent; |
17 using blink::WebMouseWheelEvent; | 17 using blink::WebMouseWheelEvent; |
18 using blink::WebTouchEvent; | 18 using blink::WebTouchEvent; |
19 using ui::LatencyInfo; | 19 using ui::LatencyInfo; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 namespace { | 22 namespace { |
23 | 23 |
24 void UpdateLatencyCoordinatesImpl(const blink::WebTouchEvent& touch, | 24 void UpdateLatencyCoordinatesImpl(const blink::WebTouchEvent& touch, |
25 LatencyInfo* latency, | 25 LatencyInfo* latency, |
26 float device_scale_factor) { | 26 float device_scale_factor) { |
27 for (uint32_t i = 0; i < touch.touchesLength; ++i) { | 27 for (uint32_t i = 0; i < touch.touchesLength; ++i) { |
28 LatencyInfo::InputCoordinate coordinate( | 28 gfx::PointF coordinate(touch.touches[i].position.x * device_scale_factor, |
29 touch.touches[i].position.x * device_scale_factor, | 29 touch.touches[i].position.y * device_scale_factor); |
30 touch.touches[i].position.y * device_scale_factor); | |
31 if (!latency->AddInputCoordinate(coordinate)) | 30 if (!latency->AddInputCoordinate(coordinate)) |
32 break; | 31 break; |
33 } | 32 } |
34 } | 33 } |
35 | 34 |
36 void UpdateLatencyCoordinatesImpl(const WebGestureEvent& gesture, | 35 void UpdateLatencyCoordinatesImpl(const WebGestureEvent& gesture, |
37 LatencyInfo* latency, | 36 LatencyInfo* latency, |
38 float device_scale_factor) { | 37 float device_scale_factor) { |
39 latency->AddInputCoordinate( | 38 latency->AddInputCoordinate(gfx::PointF(gesture.x * device_scale_factor, |
40 LatencyInfo::InputCoordinate(gesture.x * device_scale_factor, | 39 gesture.y * device_scale_factor)); |
41 gesture.y * device_scale_factor)); | |
42 } | 40 } |
43 | 41 |
44 void UpdateLatencyCoordinatesImpl(const WebMouseEvent& mouse, | 42 void UpdateLatencyCoordinatesImpl(const WebMouseEvent& mouse, |
45 LatencyInfo* latency, | 43 LatencyInfo* latency, |
46 float device_scale_factor) { | 44 float device_scale_factor) { |
47 latency->AddInputCoordinate( | 45 latency->AddInputCoordinate(gfx::PointF(mouse.x * device_scale_factor, |
48 LatencyInfo::InputCoordinate(mouse.x * device_scale_factor, | 46 mouse.y * device_scale_factor)); |
49 mouse.y * device_scale_factor)); | |
50 } | 47 } |
51 | 48 |
52 void UpdateLatencyCoordinatesImpl(const WebMouseWheelEvent& wheel, | 49 void UpdateLatencyCoordinatesImpl(const WebMouseWheelEvent& wheel, |
53 LatencyInfo* latency, | 50 LatencyInfo* latency, |
54 float device_scale_factor) { | 51 float device_scale_factor) { |
55 latency->AddInputCoordinate( | 52 latency->AddInputCoordinate(gfx::PointF(wheel.x * device_scale_factor, |
56 LatencyInfo::InputCoordinate(wheel.x * device_scale_factor, | 53 wheel.y * device_scale_factor)); |
57 wheel.y * device_scale_factor)); | |
58 } | 54 } |
59 | 55 |
60 void UpdateLatencyCoordinates(const WebInputEvent& event, | 56 void UpdateLatencyCoordinates(const WebInputEvent& event, |
61 float device_scale_factor, | 57 float device_scale_factor, |
62 LatencyInfo* latency) { | 58 LatencyInfo* latency) { |
63 if (WebInputEvent::isMouseEventType(event.type)) { | 59 if (WebInputEvent::isMouseEventType(event.type)) { |
64 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseEvent&>(event), | 60 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseEvent&>(event), |
65 latency, device_scale_factor); | 61 latency, device_scale_factor); |
66 } else if (WebInputEvent::isGestureEventType(event.type)) { | 62 } else if (WebInputEvent::isGestureEventType(event.type)) { |
67 UpdateLatencyCoordinatesImpl(static_cast<const WebGestureEvent&>(event), | 63 UpdateLatencyCoordinatesImpl(static_cast<const WebGestureEvent&>(event), |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 latency_component_id_, nullptr)) { | 499 latency_component_id_, nullptr)) { |
504 return; | 500 return; |
505 } | 501 } |
506 | 502 |
507 ComputeScrollLatencyHistograms(gpu_swap_begin_component, | 503 ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
508 gpu_swap_end_component, latency_component_id_, | 504 gpu_swap_end_component, latency_component_id_, |
509 latency); | 505 latency); |
510 } | 506 } |
511 | 507 |
512 } // namespace content | 508 } // namespace content |
OLD | NEW |