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

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: 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
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..ae31ea06d7685b332bd4b5454d0e7a177242e926 100644
--- a/ui/base/touch/touch_device_linux.cc
+++ b/ui/base/touch/touch_device_linux.cc
@@ -37,6 +37,10 @@ int MaxTouchPoints() {
return max_touch;
}
+std::pair<int, int> GetAvailablePointerAndHoverTypes() {
+ return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes());
+}
+
// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634
int GetAvailablePointerTypes() {
// Assume a mouse is there
@@ -48,8 +52,7 @@ int GetAvailablePointerTypes() {
return available_pointer_types;
}
-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,6 +61,10 @@ PointerType GetPrimaryPointerType() {
return POINTER_TYPE_NONE;
}
+PointerType GetPrimaryPointerType() {
+ return GetPrimaryPointerType(GetAvailablePointerTypes());
+}
+
// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634
int GetAvailableHoverTypes() {
// Assume a mouse is there
@@ -69,8 +76,7 @@ int GetAvailableHoverTypes() {
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)
@@ -79,4 +85,8 @@ HoverType GetPrimaryHoverType() {
return HOVER_TYPE_NONE;
}
+HoverType GetPrimaryHoverType() {
+ return GetPrimaryHoverType(GetAvailableHoverTypes());
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698