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

Side by Side Diff: ui/events/gesture_detection/gesture_event_data_packet.cc

Issue 403173004: Avoid heap allocations with GestureEventDataPacket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win build Created 6 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 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/gesture_detection/gesture_event_data_packet.h" 5 #include "ui/events/gesture_detection/gesture_event_data_packet.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/events/gesture_detection/motion_event.h" 8 #include "ui/events/gesture_detection/motion_event.h"
9 9
10 namespace ui { 10 namespace ui {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 timestamp_ = other.timestamp_; 65 timestamp_ = other.timestamp_;
66 gesture_source_ = other.gesture_source_; 66 gesture_source_ = other.gesture_source_;
67 touch_location_ = other.touch_location_; 67 touch_location_ = other.touch_location_;
68 raw_touch_location_ = other.raw_touch_location_; 68 raw_touch_location_ = other.raw_touch_location_;
69 gestures_ = other.gestures_; 69 gestures_ = other.gestures_;
70 return *this; 70 return *this;
71 } 71 }
72 72
73 void GestureEventDataPacket::Push(const GestureEventData& gesture) { 73 void GestureEventDataPacket::Push(const GestureEventData& gesture) {
74 DCHECK_NE(ET_UNKNOWN, gesture.type()); 74 DCHECK_NE(ET_UNKNOWN, gesture.type());
75 gestures_.push_back(gesture); 75 gestures_->push_back(gesture);
76 } 76 }
77 77
78 GestureEventDataPacket GestureEventDataPacket::FromTouch( 78 GestureEventDataPacket GestureEventDataPacket::FromTouch(
79 const ui::MotionEvent& touch) { 79 const ui::MotionEvent& touch) {
80 return GestureEventDataPacket(touch.GetEventTime(), 80 return GestureEventDataPacket(touch.GetEventTime(),
81 ToGestureSource(touch), 81 ToGestureSource(touch),
82 gfx::PointF(touch.GetX(), touch.GetY()), 82 gfx::PointF(touch.GetX(), touch.GetY()),
83 gfx::PointF(touch.GetRawX(), touch.GetRawY())); 83 gfx::PointF(touch.GetRawX(), touch.GetRawY()));
84 } 84 }
85 85
86 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout( 86 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout(
87 const GestureEventData& gesture) { 87 const GestureEventData& gesture) {
88 GestureEventDataPacket packet(gesture.time, 88 GestureEventDataPacket packet(gesture.time,
89 TOUCH_TIMEOUT, 89 TOUCH_TIMEOUT,
90 gfx::PointF(gesture.x, gesture.y), 90 gfx::PointF(gesture.x, gesture.y),
91 gfx::PointF(gesture.raw_x, gesture.raw_y)); 91 gfx::PointF(gesture.raw_x, gesture.raw_y));
92 packet.Push(gesture); 92 packet.Push(gesture);
93 return packet; 93 return packet;
94 } 94 }
95 95
96 } // namespace ui 96 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698