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

Unified Diff: views/touchui/touch_factory.cc

Issue 7927001: touchui: Convert XI2 MT tracking id to slot id for gesture recognizer (Closed) Base URL: nhu@powerbuilder.sh.intel.com:/home/www-data/git-repos/chromium/chromium.git@trunk
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« views/touchui/touch_factory.h ('K') | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/touchui/touch_factory.cc
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc
index 84db3ebd7340d95e07183e2902fa42e1f9c7b14c..f11b2463801b3b3675dcb693426f5ae100c1b1ff 100644
--- a/views/touchui/touch_factory.cc
+++ b/views/touchui/touch_factory.cc
@@ -129,10 +129,11 @@ TouchFactory::TouchFactory()
keep_mouse_cursor_(false),
cursor_timer_(),
pointer_device_lookup_(),
+ touch_device_list_(),
#if defined(USE_XI2_MT)
- touch_device_list_() {
+ slots_used_(),
sadrul 2011/09/19 16:13:36 slots_used_ is used even when USE_XI2_MT is not se
ningxin.hu 2011/09/20 16:08:49 Yes.
+ tracking_id_map_() {
#else
- touch_device_list_(),
slots_used_() {
#endif
#if defined(TOUCH_UI)
@@ -319,7 +320,32 @@ bool TouchFactory::IsTouchDevice(unsigned deviceid) const {
touch_device_lookup_[deviceid] : false;
}
-#if !defined(USE_XI2_MT)
+#if defined(USE_XI2_MT)
+int TouchFactory::AllocateSlotIdForTrackingId(uint32 tracking_id) {
+ TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
+ if (itr != tracking_id_map_.end())
+ return itr->second;
+
+ // Find the lowest available slot, assume kMaxTouchPoints is less than 32
+ int slot = ffs(~(slots_used_.to_ulong())) - 1;
sadrul 2011/09/19 16:13:36 I think we can spare a few cycles here and do a lo
ningxin.hu 2011/09/20 16:08:49 OK. Will implement it.
+ if (slot == -1) {
+ LOG(ERROR) << "Could not find available slot for touch point";
+ return 0;
+ }
+ SetSlotUsed(slot, true);
+ tracking_id_map_.insert(std::make_pair(tracking_id, slot));
+ return slot;
+}
+
+void TouchFactory::ReleaseSlotIdForTrackingId(uint32 tracking_id) {
+ TrackingIdMap::iterator itr = tracking_id_map_.find(tracking_id);
+ if (itr != tracking_id_map_.end()) {
+ SetSlotUsed(itr->second, false);
+ tracking_id_map_.erase(itr);
+ }
sadrul 2011/09/19 16:13:36 Add a NOTREACHED or DCHECK on else
ningxin.hu 2011/09/20 16:08:49 Will add. Thanks for comment.
+}
+#endif
+
bool TouchFactory::IsSlotUsed(int slot) const {
CHECK_LT(slot, kMaxTouchPoints);
return slots_used_[slot];
@@ -329,7 +355,6 @@ void TouchFactory::SetSlotUsed(int slot, bool used) {
CHECK_LT(slot, kMaxTouchPoints);
slots_used_[slot] = used;
}
-#endif
bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
#if defined(TOUCH_UI)
« views/touchui/touch_factory.h ('K') | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698