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

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: Fix uninitialized memory issue. Created 6 years 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/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/keysym.h> 10 #include <X11/keysym.h>
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 510
511 //////////////////////////////////////////////////////////////////////////////// 511 ////////////////////////////////////////////////////////////////////////////////
512 // TouchEvent 512 // TouchEvent
513 513
514 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 514 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
515 : LocatedEvent(native_event), 515 : LocatedEvent(native_event),
516 touch_id_(GetTouchId(native_event)), 516 touch_id_(GetTouchId(native_event)),
517 radius_x_(GetTouchRadiusX(native_event)), 517 radius_x_(GetTouchRadiusX(native_event)),
518 radius_y_(GetTouchRadiusY(native_event)), 518 radius_y_(GetTouchRadiusY(native_event)),
519 rotation_angle_(GetTouchAngle(native_event)), 519 rotation_angle_(GetTouchAngle(native_event)),
520 force_(GetTouchForce(native_event)) { 520 force_(GetTouchForce(native_event)),
521 should_remove_native_touch_id_mapping_(false) {
521 latency()->AddLatencyNumberWithTimestamp( 522 latency()->AddLatencyNumberWithTimestamp(
522 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 523 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
523 0, 524 0,
524 0, 525 0,
525 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 526 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
526 1); 527 1);
528 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
529 should_remove_native_touch_id_mapping_ = true;
sadrul 2015/01/14 20:21:35 Do this before or after the latency block.
tdresser 2015/01/23 18:12:34 Done.
527 530
528 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 531 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
529
530 if (type() == ET_TOUCH_PRESSED)
531 IncrementTouchIdRefCount(native_event);
532 } 532 }
533 533
534 TouchEvent::TouchEvent(EventType type, 534 TouchEvent::TouchEvent(EventType type,
535 const gfx::PointF& location, 535 const gfx::PointF& location,
536 int touch_id, 536 int touch_id,
537 base::TimeDelta time_stamp) 537 base::TimeDelta time_stamp)
538 : LocatedEvent(type, location, location, time_stamp, 0), 538 : LocatedEvent(type, location, location, time_stamp, 0),
539 touch_id_(touch_id), 539 touch_id_(touch_id),
540 radius_x_(0.0f), 540 radius_x_(0.0f),
541 radius_y_(0.0f), 541 radius_y_(0.0f),
542 rotation_angle_(0.0f), 542 rotation_angle_(0.0f),
543 force_(0.0f) { 543 force_(0.0f),
544 should_remove_native_touch_id_mapping_(false) {
544 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 545 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
545 } 546 }
546 547
547 TouchEvent::TouchEvent(EventType type, 548 TouchEvent::TouchEvent(EventType type,
548 const gfx::PointF& location, 549 const gfx::PointF& location,
549 int flags, 550 int flags,
550 int touch_id, 551 int touch_id,
551 base::TimeDelta time_stamp, 552 base::TimeDelta time_stamp,
552 float radius_x, 553 float radius_x,
553 float radius_y, 554 float radius_y,
554 float angle, 555 float angle,
555 float force) 556 float force)
556 : LocatedEvent(type, location, location, time_stamp, flags), 557 : LocatedEvent(type, location, location, time_stamp, flags),
557 touch_id_(touch_id), 558 touch_id_(touch_id),
558 radius_x_(radius_x), 559 radius_x_(radius_x),
559 radius_y_(radius_y), 560 radius_y_(radius_y),
560 rotation_angle_(angle), 561 rotation_angle_(angle),
561 force_(force) { 562 force_(force),
563 should_remove_native_touch_id_mapping_(false) {
562 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 564 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
563 } 565 }
564 566
565 TouchEvent::~TouchEvent() { 567 TouchEvent::~TouchEvent() {
566 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 568 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
567 // platform setups the tracking_id to slot mapping. So in dtor here, 569 // platform setups the tracking_id to slot mapping. So in dtor here,
568 // if this touch event is a release event, we clear the mapping accordingly. 570 // if this touch event is a release event, we clear the mapping accordingly.
569 if (HasNativeEvent()) 571 if (should_remove_native_touch_id_mapping_) {
570 ClearTouchIdIfReleased(native_event()); 572 DCHECK(type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED);
573 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
574 ClearTouchIdIfReleased(native_event());
575 }
571 } 576 }
572 577
573 void TouchEvent::UpdateForRootTransform( 578 void TouchEvent::UpdateForRootTransform(
574 const gfx::Transform& inverted_root_transform) { 579 const gfx::Transform& inverted_root_transform) {
575 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 580 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
576 gfx::DecomposedTransform decomp; 581 gfx::DecomposedTransform decomp;
577 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 582 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
578 DCHECK(success); 583 DCHECK(success);
579 if (decomp.scale[0]) 584 if (decomp.scale[0])
580 radius_x_ *= decomp.scale[0]; 585 radius_x_ *= decomp.scale[0];
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 gfx::PointF(x, y), 984 gfx::PointF(x, y),
980 time_stamp, 985 time_stamp,
981 flags | EF_FROM_TOUCH), 986 flags | EF_FROM_TOUCH),
982 details_(details) { 987 details_(details) {
983 } 988 }
984 989
985 GestureEvent::~GestureEvent() { 990 GestureEvent::~GestureEvent() {
986 } 991 }
987 992
988 } // namespace ui 993 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698