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

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

Issue 886593004: Reland "Don't refcount tracking id -> slot id mapping." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix terrible merge. 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
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 may_cause_scrolling_(false),
530 should_remove_native_touch_id_mapping_(false) {
530 latency()->AddLatencyNumberWithTimestamp( 531 latency()->AddLatencyNumberWithTimestamp(
531 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 532 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
532 0, 533 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
533 0, 534 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
534 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
535 1);
536 535
537 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 536 FixRotationAngle();
538 fixRotationAngle(); 537 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
539 538 should_remove_native_touch_id_mapping_ = true;
540 if (type() == ET_TOUCH_PRESSED)
541 IncrementTouchIdRefCount(native_event);
542 } 539 }
543 540
544 TouchEvent::TouchEvent(EventType type, 541 TouchEvent::TouchEvent(EventType type,
545 const gfx::PointF& location, 542 const gfx::PointF& location,
546 int touch_id, 543 int touch_id,
547 base::TimeDelta time_stamp) 544 base::TimeDelta time_stamp)
548 : LocatedEvent(type, location, location, time_stamp, 0), 545 : LocatedEvent(type, location, location, time_stamp, 0),
549 touch_id_(touch_id), 546 touch_id_(touch_id),
550 unique_event_id_(get_next_touch_event_id()), 547 unique_event_id_(get_next_touch_event_id()),
551 radius_x_(0.0f), 548 radius_x_(0.0f),
552 radius_y_(0.0f), 549 radius_y_(0.0f),
553 rotation_angle_(0.0f), 550 rotation_angle_(0.0f),
554 force_(0.0f), 551 force_(0.0f),
555 may_cause_scrolling_(false) { 552 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 may_cause_scrolling_(false),
574 should_remove_native_touch_id_mapping_(false) {
576 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 575 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
577 fixRotationAngle(); 576 FixRotationAngle();
578 } 577 }
579 578
580 TouchEvent::~TouchEvent() { 579 TouchEvent::~TouchEvent() {
581 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 580 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
582 // platform setups the tracking_id to slot mapping. So in dtor here, 581 // 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. 582 // if this touch event is a release event, we clear the mapping accordingly.
584 if (HasNativeEvent()) 583 if (should_remove_native_touch_id_mapping_) {
585 ClearTouchIdIfReleased(native_event()); 584 DCHECK(type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED);
585 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
586 ClearTouchIdIfReleased(native_event());
587 }
586 } 588 }
587 589
588 void TouchEvent::UpdateForRootTransform( 590 void TouchEvent::UpdateForRootTransform(
589 const gfx::Transform& inverted_root_transform) { 591 const gfx::Transform& inverted_root_transform) {
590 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 592 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
591 gfx::DecomposedTransform decomp; 593 gfx::DecomposedTransform decomp;
592 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 594 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
593 DCHECK(success); 595 DCHECK(success);
594 if (decomp.scale[0]) 596 if (decomp.scale[0])
595 radius_x_ *= decomp.scale[0]; 597 radius_x_ *= decomp.scale[0];
596 if (decomp.scale[1]) 598 if (decomp.scale[1])
597 radius_y_ *= decomp.scale[1]; 599 radius_y_ *= decomp.scale[1];
598 } 600 }
599 601
600 void TouchEvent::DisableSynchronousHandling() { 602 void TouchEvent::DisableSynchronousHandling() {
601 DispatcherApi dispatcher_api(this); 603 DispatcherApi dispatcher_api(this);
602 dispatcher_api.set_result( 604 dispatcher_api.set_result(
603 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING)); 605 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING));
604 } 606 }
605 607
606 void TouchEvent::fixRotationAngle() { 608 void TouchEvent::FixRotationAngle() {
607 while (rotation_angle_ < 0) 609 while (rotation_angle_ < 0)
608 rotation_angle_ += 180; 610 rotation_angle_ += 180;
609 while (rotation_angle_ >= 180) 611 while (rotation_angle_ >= 180)
610 rotation_angle_ -= 180; 612 rotation_angle_ -= 180;
611 } 613 }
612 614
613 //////////////////////////////////////////////////////////////////////////////// 615 ////////////////////////////////////////////////////////////////////////////////
614 // KeyEvent 616 // KeyEvent
615 617
616 // static 618 // static
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 gfx::PointF(x, y), 975 gfx::PointF(x, y),
974 time_stamp, 976 time_stamp,
975 flags | EF_FROM_TOUCH), 977 flags | EF_FROM_TOUCH),
976 details_(details) { 978 details_(details) {
977 } 979 }
978 980
979 GestureEvent::~GestureEvent() { 981 GestureEvent::~GestureEvent() {
980 } 982 }
981 983
982 } // namespace ui 984 } // namespace ui
OLDNEW
« no previous file with comments | « 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