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

Side by Side Diff: ui/events/gestures/gesture_provider_aura.cc

Issue 309823002: Pass ui::LatencyInfo correct with unified gesture detector on Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix int to unsigned int comparison. Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gestures/gesture_provider_aura.h" 5 #include "ui/events/gestures/gesture_provider_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/gesture_detection/gesture_config_helper.h" 10 #include "ui/events/gesture_detection/gesture_config_helper.h"
11 #include "ui/events/gesture_detection/gesture_event_data.h" 11 #include "ui/events/gesture_detection/gesture_event_data.h"
12 #include "ui/events/gestures/gesture_configuration.h" 12 #include "ui/events/gestures/gesture_configuration.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) 16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client)
17 : client_(client), 17 : client_(client),
18 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this), 18 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this),
19 handling_event_(false) { 19 handling_event_(false) {
20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); 20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false);
21 } 21 }
22 22
23 GestureProviderAura::~GestureProviderAura() {} 23 GestureProviderAura::~GestureProviderAura() {}
24 24
25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { 25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) {
26 last_touch_event_flags_ = event.flags();
27 bool pointer_id_is_active = false; 26 bool pointer_id_is_active = false;
28 for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) { 27 for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) {
29 if (event.touch_id() != pointer_state_.GetPointerId(i)) 28 if (event.touch_id() != pointer_state_.GetPointerId(i))
30 continue; 29 continue;
31 pointer_id_is_active = true; 30 pointer_id_is_active = true;
32 break; 31 break;
33 } 32 }
34 33
35 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { 34 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
36 // Ignore touch press events if we already believe the pointer is down. 35 // Ignore touch press events if we already believe the pointer is down.
37 return false; 36 return false;
38 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { 37 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
39 // We could have an active touch stream transfered to us, resulting in touch 38 // We could have an active touch stream transfered to us, resulting in touch
40 // move or touch up events without associated touch down events. Ignore 39 // move or touch up events without associated touch down events. Ignore
41 // them. 40 // them.
42 return false; 41 return false;
43 } 42 }
44 43
44 last_touch_event_flags_ = event.flags();
45 last_touch_event_latency_info_ = *event.latency();
45 pointer_state_.OnTouch(event); 46 pointer_state_.OnTouch(event);
46 47
47 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); 48 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
48 pointer_state_.CleanupRemovedTouchPoints(event); 49 pointer_state_.CleanupRemovedTouchPoints(event);
49 return result; 50 return result;
50 } 51 }
51 52
52 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { 53 void GestureProviderAura::OnTouchEventAck(bool event_consumed) {
53 DCHECK(pending_gestures_.empty()); 54 DCHECK(pending_gestures_.empty());
54 DCHECK(!handling_event_); 55 DCHECK(!handling_event_);
55 base::AutoReset<bool> handling_event(&handling_event_, true); 56 base::AutoReset<bool> handling_event(&handling_event_, true);
56 filtered_gesture_provider_.OnTouchEventAck(event_consumed); 57 filtered_gesture_provider_.OnTouchEventAck(event_consumed);
58 last_touch_event_latency_info_.Clear();
57 } 59 }
58 60
59 void GestureProviderAura::OnGestureEvent( 61 void GestureProviderAura::OnGestureEvent(
60 const GestureEventData& gesture) { 62 const GestureEventData& gesture) {
61 GestureEventDetails details = gesture.details; 63 GestureEventDetails details = gesture.details;
62 64
63 if (gesture.type == ET_GESTURE_TAP) { 65 if (gesture.type == ET_GESTURE_TAP) {
64 int tap_count = 1; 66 int tap_count = 1;
65 if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture)) 67 if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture))
66 tap_count = 1 + (previous_tap_->details.tap_count() % 3); 68 tap_count = 1 + (previous_tap_->details.tap_count() % 3);
(...skipping 13 matching lines...) Expand all
80 gesture.y, 82 gesture.y,
81 last_touch_event_flags_, 83 last_touch_event_flags_,
82 gesture.time - base::TimeTicks(), 84 gesture.time - base::TimeTicks(),
83 details, 85 details,
84 // ui::GestureEvent stores a bitfield indicating the 86 // ui::GestureEvent stores a bitfield indicating the
85 // ids of active touch points. This is currently only 87 // ids of active touch points. This is currently only
86 // used when one finger is down, and will eventually 88 // used when one finger is down, and will eventually
87 // be cleaned up. See crbug.com/366707. 89 // be cleaned up. See crbug.com/366707.
88 1 << gesture.motion_event_id)); 90 1 << gesture.motion_event_id));
89 91
92
93 ui::LatencyInfo* gesture_latency = event->latency();
94
95 gesture_latency->CopyLatencyFrom(
96 last_touch_event_latency_info_,
97 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
98 gesture_latency->CopyLatencyFrom(
99 last_touch_event_latency_info_,
100 ui::INPUT_EVENT_LATENCY_UI_COMPONENT);
101 gesture_latency->CopyLatencyFrom(
102 last_touch_event_latency_info_,
103 ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT);
104
90 if (!handling_event_) { 105 if (!handling_event_) {
91 // Dispatching event caused by timer. 106 // Dispatching event caused by timer.
92 client_->OnGestureEvent(event.get()); 107 client_->OnGestureEvent(event.get());
93 } else { 108 } else {
94 // Memory managed by ScopedVector pending_gestures_. 109 // Memory managed by ScopedVector pending_gestures_.
95 pending_gestures_.push_back(event.release()); 110 pending_gestures_.push_back(event.release());
96 } 111 }
97 } 112 }
98 113
99 ScopedVector<GestureEvent>* GestureProviderAura::GetAndResetPendingGestures() { 114 ScopedVector<GestureEvent>* GestureProviderAura::GetAndResetPendingGestures() {
(...skipping 18 matching lines...) Expand all
118 133
119 double double_tap_slop_square = 134 double double_tap_slop_square =
120 GestureConfiguration::max_distance_between_taps_for_double_tap(); 135 GestureConfiguration::max_distance_between_taps_for_double_tap();
121 double_tap_slop_square *= double_tap_slop_square; 136 double_tap_slop_square *= double_tap_slop_square;
122 const float delta_x = previous_tap.x - current_tap.x; 137 const float delta_x = previous_tap.x - current_tap.x;
123 const float delta_y = previous_tap.y - current_tap.y; 138 const float delta_y = previous_tap.y - current_tap.y;
124 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); 139 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square);
125 } 140 }
126 141
127 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698