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

Side by Side Diff: ui/events/event.cc

Issue 785753002: Don't refcount tracking id -> slot id mapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address sadrul's comments. Created 5 years, 10 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 (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 "ui/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/keysym.h> 9 #include <X11/keysym.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 // TouchEvent 519 // TouchEvent
520 520
521 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 521 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
522 : LocatedEvent(native_event), 522 : LocatedEvent(native_event),
523 touch_id_(GetTouchId(native_event)), 523 touch_id_(GetTouchId(native_event)),
524 unique_event_id_(get_next_touch_event_id()), 524 unique_event_id_(get_next_touch_event_id()),
525 radius_x_(GetTouchRadiusX(native_event)), 525 radius_x_(GetTouchRadiusX(native_event)),
526 radius_y_(GetTouchRadiusY(native_event)), 526 radius_y_(GetTouchRadiusY(native_event)),
527 rotation_angle_(GetTouchAngle(native_event)), 527 rotation_angle_(GetTouchAngle(native_event)),
528 force_(GetTouchForce(native_event)), 528 force_(GetTouchForce(native_event)),
529 may_cause_scrolling_(false) { 529 should_remove_native_touch_id_mapping_(false) {
530 latency()->AddLatencyNumberWithTimestamp( 530 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
531 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 531 should_remove_native_touch_id_mapping_ = true;
532 0,
533 0,
534 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
535 1);
536 532
537 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 533 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
538 fixRotationAngle(); 534 FixRotationAngle();
539 535
540 if (type() == ET_TOUCH_PRESSED) 536 latency()->AddLatencyNumberWithTimestamp(
541 IncrementTouchIdRefCount(native_event); 537 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
538 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
539 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
542 } 540 }
543 541
544 TouchEvent::TouchEvent(EventType type, 542 TouchEvent::TouchEvent(EventType type,
545 const gfx::PointF& location, 543 const gfx::PointF& location,
546 int touch_id, 544 int touch_id,
547 base::TimeDelta time_stamp) 545 base::TimeDelta time_stamp)
548 : LocatedEvent(type, location, location, time_stamp, 0), 546 : LocatedEvent(type, location, location, time_stamp, 0),
549 touch_id_(touch_id), 547 touch_id_(touch_id),
550 unique_event_id_(get_next_touch_event_id()), 548 unique_event_id_(get_next_touch_event_id()),
551 radius_x_(0.0f), 549 radius_x_(0.0f),
552 radius_y_(0.0f), 550 radius_y_(0.0f),
553 rotation_angle_(0.0f), 551 rotation_angle_(0.0f),
554 force_(0.0f), 552 force_(0.0f),
555 may_cause_scrolling_(false) { 553 should_remove_native_touch_id_mapping_(false) {
556 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 554 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
557 } 555 }
558 556
559 TouchEvent::TouchEvent(EventType type, 557 TouchEvent::TouchEvent(EventType type,
560 const gfx::PointF& location, 558 const gfx::PointF& location,
561 int flags, 559 int flags,
562 int touch_id, 560 int touch_id,
563 base::TimeDelta time_stamp, 561 base::TimeDelta time_stamp,
564 float radius_x, 562 float radius_x,
565 float radius_y, 563 float radius_y,
566 float angle, 564 float angle,
567 float force) 565 float force)
568 : LocatedEvent(type, location, location, time_stamp, flags), 566 : LocatedEvent(type, location, location, time_stamp, flags),
569 touch_id_(touch_id), 567 touch_id_(touch_id),
570 unique_event_id_(get_next_touch_event_id()), 568 unique_event_id_(get_next_touch_event_id()),
571 radius_x_(radius_x), 569 radius_x_(radius_x),
572 radius_y_(radius_y), 570 radius_y_(radius_y),
573 rotation_angle_(angle), 571 rotation_angle_(angle),
574 force_(force), 572 force_(force),
575 may_cause_scrolling_(false) { 573 should_remove_native_touch_id_mapping_(false) {
576 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 574 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
577 fixRotationAngle(); 575 FixRotationAngle();
578 } 576 }
579 577
580 TouchEvent::~TouchEvent() { 578 TouchEvent::~TouchEvent() {
581 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 579 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
582 // platform setups the tracking_id to slot mapping. So in dtor here, 580 // platform setups the tracking_id to slot mapping. So in dtor here,
583 // if this touch event is a release event, we clear the mapping accordingly. 581 // if this touch event is a release event, we clear the mapping accordingly.
584 if (HasNativeEvent()) 582 if (should_remove_native_touch_id_mapping_) {
585 ClearTouchIdIfReleased(native_event()); 583 DCHECK(type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED);
584 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
585 ClearTouchIdIfReleased(native_event());
586 }
586 } 587 }
587 588
588 void TouchEvent::UpdateForRootTransform( 589 void TouchEvent::UpdateForRootTransform(
589 const gfx::Transform& inverted_root_transform) { 590 const gfx::Transform& inverted_root_transform) {
590 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 591 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
591 gfx::DecomposedTransform decomp; 592 gfx::DecomposedTransform decomp;
592 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 593 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
593 DCHECK(success); 594 DCHECK(success);
594 if (decomp.scale[0]) 595 if (decomp.scale[0])
595 radius_x_ *= decomp.scale[0]; 596 radius_x_ *= decomp.scale[0];
596 if (decomp.scale[1]) 597 if (decomp.scale[1])
597 radius_y_ *= decomp.scale[1]; 598 radius_y_ *= decomp.scale[1];
598 } 599 }
599 600
600 void TouchEvent::DisableSynchronousHandling() { 601 void TouchEvent::DisableSynchronousHandling() {
601 DispatcherApi dispatcher_api(this); 602 DispatcherApi dispatcher_api(this);
602 dispatcher_api.set_result( 603 dispatcher_api.set_result(
603 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING)); 604 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING));
604 } 605 }
605 606
606 void TouchEvent::fixRotationAngle() { 607 void TouchEvent::FixRotationAngle() {
607 while (rotation_angle_ < 0) 608 while (rotation_angle_ < 0)
608 rotation_angle_ += 180; 609 rotation_angle_ += 180;
609 while (rotation_angle_ >= 180) 610 while (rotation_angle_ >= 180)
610 rotation_angle_ -= 180; 611 rotation_angle_ -= 180;
611 } 612 }
612 613
613 //////////////////////////////////////////////////////////////////////////////// 614 ////////////////////////////////////////////////////////////////////////////////
614 // KeyEvent 615 // KeyEvent
615 616
616 // static 617 // static
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 gfx::PointF(x, y), 974 gfx::PointF(x, y),
974 time_stamp, 975 time_stamp,
975 flags | EF_FROM_TOUCH), 976 flags | EF_FROM_TOUCH),
976 details_(details) { 977 details_(details) {
977 } 978 }
978 979
979 GestureEvent::~GestureEvent() { 980 GestureEvent::~GestureEvent() {
980 } 981 }
981 982
982 } // namespace ui 983 } // namespace ui
OLDNEW
« ui/events/event.h ('K') | « ui/events/event.h ('k') | ui/events/event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698