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

Side by Side Diff: content/common/input/event_with_latency_info.cc

Issue 2162143002: Don't use PostTask queueing between compositor and main thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't ack mouse move right away send them unthrottled Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/input/event_with_latency_info.h" 5 #include "content/common/input/event_with_latency_info.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <limits> 8 #include <limits>
9 #include "content/common/input/web_input_event_traits.h"
9 10
10 using blink::WebGestureEvent; 11 using blink::WebGestureEvent;
11 using blink::WebInputEvent; 12 using blink::WebInputEvent;
12 using blink::WebKeyboardEvent; 13 using blink::WebKeyboardEvent;
13 using blink::WebMouseEvent; 14 using blink::WebMouseEvent;
14 using blink::WebMouseWheelEvent; 15 using blink::WebMouseWheelEvent;
15 using blink::WebTouchEvent; 16 using blink::WebTouchEvent;
16 using std::numeric_limits; 17 using std::numeric_limits;
17 18
18 namespace content { 19 namespace content {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale; 188 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale;
188 // Ensure the scale remains bounded above 0 and below Infinity so that 189 // Ensure the scale remains bounded above 0 and below Infinity so that
189 // we can reliably perform operations like log on the values. 190 // we can reliably perform operations like log on the values.
190 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) 191 if (event->data.pinchUpdate.scale < numeric_limits<float>::min())
191 event->data.pinchUpdate.scale = numeric_limits<float>::min(); 192 event->data.pinchUpdate.scale = numeric_limits<float>::min();
192 else if (event->data.pinchUpdate.scale > numeric_limits<float>::max()) 193 else if (event->data.pinchUpdate.scale > numeric_limits<float>::max())
193 event->data.pinchUpdate.scale = numeric_limits<float>::max(); 194 event->data.pinchUpdate.scale = numeric_limits<float>::max();
194 } 195 }
195 } 196 }
196 197
198 bool CanCoalesce(const blink::WebInputEvent& event_to_coalesce,
199 const blink::WebInputEvent& event) {
200 if (blink::WebInputEvent::isGestureEventType(event_to_coalesce.type) &&
201 blink::WebInputEvent::isGestureEventType(event.type)) {
202 return CanCoalesce(
203 static_cast<const blink::WebGestureEvent&>(event_to_coalesce),
204 static_cast<const blink::WebGestureEvent&>(event));
205 }
206 if (blink::WebInputEvent::isMouseEventType(event_to_coalesce.type) &&
207 blink::WebInputEvent::isMouseEventType(event.type)) {
208 return CanCoalesce(
209 static_cast<const blink::WebMouseEvent&>(event_to_coalesce),
210 static_cast<const blink::WebMouseEvent&>(event));
211 }
212 if (blink::WebInputEvent::isTouchEventType(event_to_coalesce.type) &&
213 blink::WebInputEvent::isTouchEventType(event.type)) {
214 return CanCoalesce(
215 static_cast<const blink::WebTouchEvent&>(event_to_coalesce),
216 static_cast<const blink::WebTouchEvent&>(event));
217 }
218 if (event_to_coalesce.type == blink::WebInputEvent::MouseWheel &&
219 event.type == blink::WebInputEvent::MouseWheel) {
220 return CanCoalesce(
221 static_cast<const blink::WebMouseWheelEvent&>(event_to_coalesce),
222 static_cast<const blink::WebMouseWheelEvent&>(event));
223 }
224 return false;
225 }
226
227 void Coalesce(const blink::WebInputEvent& event_to_coalesce,
228 blink::WebInputEvent* event) {
229 if (blink::WebInputEvent::isGestureEventType(event_to_coalesce.type) &&
230 blink::WebInputEvent::isGestureEventType(event->type)) {
231 Coalesce(static_cast<const blink::WebGestureEvent&>(event_to_coalesce),
232 static_cast<blink::WebGestureEvent*>(event));
233 return;
234 }
235 if (blink::WebInputEvent::isMouseEventType(event_to_coalesce.type) &&
236 blink::WebInputEvent::isMouseEventType(event->type)) {
237 Coalesce(static_cast<const blink::WebMouseEvent&>(event_to_coalesce),
238 static_cast<blink::WebMouseEvent*>(event));
239 return;
240 }
241 if (blink::WebInputEvent::isTouchEventType(event_to_coalesce.type) &&
242 blink::WebInputEvent::isTouchEventType(event->type)) {
243 Coalesce(static_cast<const blink::WebTouchEvent&>(event_to_coalesce),
244 static_cast<blink::WebTouchEvent*>(event));
245 return;
246 }
247 if (event_to_coalesce.type == blink::WebInputEvent::MouseWheel &&
248 event->type == blink::WebInputEvent::MouseWheel) {
249 Coalesce(static_cast<const blink::WebMouseWheelEvent&>(event_to_coalesce),
250 static_cast<blink::WebMouseWheelEvent*>(event));
251 }
252 }
253
197 } // namespace internal 254 } // namespace internal
255
256 ScopedWebInputEventWithLatencyInfo::ScopedWebInputEventWithLatencyInfo(
257 const WebInputEvent& e,
258 const ui::LatencyInfo& l)
259 : event_(WebInputEventTraits::Clone(e)), latency_(l) {}
260
261 ScopedWebInputEventWithLatencyInfo::~ScopedWebInputEventWithLatencyInfo() {}
262
263 bool ScopedWebInputEventWithLatencyInfo::CanCoalesceWith(
264 const ScopedWebInputEventWithLatencyInfo& other) const {
265 return internal::CanCoalesce(other.event(), event());
266 }
267
268 void ScopedWebInputEventWithLatencyInfo::CoalesceWith(
269 const ScopedWebInputEventWithLatencyInfo& other) {
270 // |other| should be a newer event than |this|.
271 if (other.latency_.trace_id() >= 0 && latency_.trace_id() >= 0)
272 DCHECK_GT(other.latency_.trace_id(), latency_.trace_id());
273
274 // New events get coalesced into older events, and the newer timestamp
275 // should always be preserved.
276 const double time_stamp_seconds = other.event().timeStampSeconds;
277 internal::Coalesce(other.event(), event_.get());
278 event_->timeStampSeconds = time_stamp_seconds;
279
280 // When coalescing two input events, we keep the oldest LatencyInfo
281 // for Telemetry latency tests, since it will represent the longest
tdresser 2016/07/20 20:52:27 While you're here, we shouldn't really say "for Te
dtapuska 2016/07/27 05:29:00 Done.
282 // latency.
283 other.latency_ = latency_;
284 other.latency_.set_coalesced();
285 }
286
287 const blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() const {
288 return *event_;
289 }
290
291 blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() {
292 return *event_;
293 }
294
198 } // namespace content 295 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698