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

Unified Diff: ui/base/touch/touch_device_linux.cc

Issue 2301073002: Optimization: avoid making 4 JNI calls to get touch device attributes. (Closed)
Patch Set: Fix windows compile issues Created 4 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
« no previous file with comments | « ui/base/touch/touch_device_android.cc ('k') | ui/base/touch/touch_device_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/touch/touch_device_linux.cc
diff --git a/ui/base/touch/touch_device_linux.cc b/ui/base/touch/touch_device_linux.cc
index 5767fb82ac5823776343abbbb62a1501d1d4b6d8..6b5460d8daaebcb0cf69253d15096bc7dcbd91e7 100644
--- a/ui/base/touch/touch_device_linux.cc
+++ b/ui/base/touch/touch_device_linux.cc
@@ -15,6 +15,28 @@ bool IsTouchDevicePresent() {
return !InputDeviceManager::GetInstance()->GetTouchscreenDevices().empty();
}
+// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634
+int GetAvailablePointerTypes() {
+ // Assume a mouse is there
+ int available_pointer_types = POINTER_TYPE_FINE;
+ if (IsTouchDevicePresent())
+ available_pointer_types |= POINTER_TYPE_COARSE;
+
+ DCHECK(available_pointer_types);
+ return available_pointer_types;
+}
+
+// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634
+int GetAvailableHoverTypes() {
+ // Assume a mouse is there
+ int available_hover_types = HOVER_TYPE_HOVER;
+ if (IsTouchDevicePresent())
+ available_hover_types |= HOVER_TYPE_ON_DEMAND;
+
+ DCHECK(available_hover_types);
+ return available_hover_types;
+}
+
} // namespace
TouchScreensAvailability GetTouchScreensAvailability() {
@@ -37,19 +59,11 @@ int MaxTouchPoints() {
return max_touch;
}
-// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634
-int GetAvailablePointerTypes() {
- // Assume a mouse is there
- int available_pointer_types = POINTER_TYPE_FINE;
- if (IsTouchDevicePresent())
- available_pointer_types |= POINTER_TYPE_COARSE;
-
- DCHECK(available_pointer_types);
- return available_pointer_types;
+std::pair<int, int> GetAvailablePointerAndHoverTypes() {
+ return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes());
}
-PointerType GetPrimaryPointerType() {
- int available_pointer_types = GetAvailablePointerTypes();
+PointerType GetPrimaryPointerType(int available_pointer_types) {
if (available_pointer_types & POINTER_TYPE_FINE)
return POINTER_TYPE_FINE;
if (available_pointer_types & POINTER_TYPE_COARSE)
@@ -58,19 +72,7 @@ PointerType GetPrimaryPointerType() {
return POINTER_TYPE_NONE;
}
-// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634
-int GetAvailableHoverTypes() {
- // Assume a mouse is there
- int available_hover_types = HOVER_TYPE_HOVER;
- if (IsTouchDevicePresent())
- available_hover_types |= HOVER_TYPE_ON_DEMAND;
-
- DCHECK(available_hover_types);
- return available_hover_types;
-}
-
-HoverType GetPrimaryHoverType() {
- int available_hover_types = GetAvailableHoverTypes();
+HoverType GetPrimaryHoverType(int available_hover_types) {
if (available_hover_types & HOVER_TYPE_HOVER)
return HOVER_TYPE_HOVER;
if (available_hover_types & HOVER_TYPE_ON_DEMAND)
« no previous file with comments | « ui/base/touch/touch_device_android.cc ('k') | ui/base/touch/touch_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698