Commit 7bad1708 authored by tdresser@chromium.org's avatar tdresser@chromium.org

Allow any number of gestures to be constructed per touch.

BUG=395168

Review URL: https://codereview.chromium.org/407563002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284222 0039d316-1c4b-4281-b951-d872f2087c98
parent a5e4afa7
...@@ -33,7 +33,7 @@ GestureEventDataPacket::GestureSource ToGestureSource( ...@@ -33,7 +33,7 @@ GestureEventDataPacket::GestureSource ToGestureSource(
} // namespace } // namespace
GestureEventDataPacket::GestureEventDataPacket() GestureEventDataPacket::GestureEventDataPacket()
: gesture_count_(0), gesture_source_(UNDEFINED) { : gesture_source_(UNDEFINED) {
} }
GestureEventDataPacket::GestureEventDataPacket( GestureEventDataPacket::GestureEventDataPacket(
...@@ -42,7 +42,6 @@ GestureEventDataPacket::GestureEventDataPacket( ...@@ -42,7 +42,6 @@ GestureEventDataPacket::GestureEventDataPacket(
const gfx::PointF& touch_location, const gfx::PointF& touch_location,
const gfx::PointF& raw_touch_location) const gfx::PointF& raw_touch_location)
: timestamp_(timestamp), : timestamp_(timestamp),
gesture_count_(0),
touch_location_(touch_location), touch_location_(touch_location),
raw_touch_location_(raw_touch_location), raw_touch_location_(raw_touch_location),
gesture_source_(source) { gesture_source_(source) {
...@@ -52,11 +51,10 @@ GestureEventDataPacket::GestureEventDataPacket( ...@@ -52,11 +51,10 @@ GestureEventDataPacket::GestureEventDataPacket(
GestureEventDataPacket::GestureEventDataPacket( GestureEventDataPacket::GestureEventDataPacket(
const GestureEventDataPacket& other) const GestureEventDataPacket& other)
: timestamp_(other.timestamp_), : timestamp_(other.timestamp_),
gesture_count_(other.gesture_count_), gestures_(other.gestures_),
touch_location_(other.touch_location_), touch_location_(other.touch_location_),
raw_touch_location_(other.raw_touch_location_), raw_touch_location_(other.raw_touch_location_),
gesture_source_(other.gesture_source_) { gesture_source_(other.gesture_source_) {
std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_);
} }
GestureEventDataPacket::~GestureEventDataPacket() { GestureEventDataPacket::~GestureEventDataPacket() {
...@@ -65,18 +63,16 @@ GestureEventDataPacket::~GestureEventDataPacket() { ...@@ -65,18 +63,16 @@ GestureEventDataPacket::~GestureEventDataPacket() {
GestureEventDataPacket& GestureEventDataPacket::operator=( GestureEventDataPacket& GestureEventDataPacket::operator=(
const GestureEventDataPacket& other) { const GestureEventDataPacket& other) {
timestamp_ = other.timestamp_; timestamp_ = other.timestamp_;
gesture_count_ = other.gesture_count_;
gesture_source_ = other.gesture_source_; gesture_source_ = other.gesture_source_;
touch_location_ = other.touch_location_; touch_location_ = other.touch_location_;
raw_touch_location_ = other.raw_touch_location_; raw_touch_location_ = other.raw_touch_location_;
std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); gestures_ = other.gestures_;
return *this; return *this;
} }
void GestureEventDataPacket::Push(const GestureEventData& gesture) { void GestureEventDataPacket::Push(const GestureEventData& gesture) {
DCHECK_NE(ET_UNKNOWN, gesture.type()); DCHECK_NE(ET_UNKNOWN, gesture.type());
CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch)); gestures_.push_back(gesture);
gestures_[gesture_count_++] = gesture;
} }
GestureEventDataPacket GestureEventDataPacket::FromTouch( GestureEventDataPacket GestureEventDataPacket::FromTouch(
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
#define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
#include <vector>
#include "ui/events/gesture_detection/gesture_detection_export.h" #include "ui/events/gesture_detection/gesture_detection_export.h"
#include "ui/events/gesture_detection/gesture_event_data.h" #include "ui/events/gesture_detection/gesture_event_data.h"
...@@ -42,7 +44,7 @@ class GESTURE_DETECTION_EXPORT GestureEventDataPacket { ...@@ -42,7 +44,7 @@ class GESTURE_DETECTION_EXPORT GestureEventDataPacket {
const base::TimeTicks& timestamp() const { return timestamp_; } const base::TimeTicks& timestamp() const { return timestamp_; }
const GestureEventData& gesture(size_t i) const { return gestures_[i]; } const GestureEventData& gesture(size_t i) const { return gestures_[i]; }
size_t gesture_count() const { return gesture_count_; } size_t gesture_count() const { return gestures_.size(); }
GestureSource gesture_source() const { return gesture_source_; } GestureSource gesture_source() const { return gesture_source_; }
const gfx::PointF& touch_location() const { return touch_location_; } const gfx::PointF& touch_location() const { return touch_location_; }
const gfx::PointF& raw_touch_location() const { return raw_touch_location_; } const gfx::PointF& raw_touch_location() const { return raw_touch_location_; }
...@@ -53,10 +55,9 @@ class GESTURE_DETECTION_EXPORT GestureEventDataPacket { ...@@ -53,10 +55,9 @@ class GESTURE_DETECTION_EXPORT GestureEventDataPacket {
const gfx::PointF& touch_location, const gfx::PointF& touch_location,
const gfx::PointF& raw_touch_location); const gfx::PointF& raw_touch_location);
enum { kMaxGesturesPerTouch = 5 };
base::TimeTicks timestamp_; base::TimeTicks timestamp_;
GestureEventData gestures_[kMaxGesturesPerTouch]; // TODO(jdduke): This vector is in general very short. Optimize?
size_t gesture_count_; std::vector<GestureEventData> gestures_;
gfx::PointF touch_location_; gfx::PointF touch_location_;
gfx::PointF raw_touch_location_; gfx::PointF raw_touch_location_;
GestureSource gesture_source_; GestureSource gesture_source_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment