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

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

Issue 2301073002: Optimization: avoid making 4 JNI calls to get touch device attributes. (Closed)
Patch Set: Correct a spelling mistake. 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
« ui/base/touch/touch_device.cc ('K') | « ui/base/touch/touch_device_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/touch/touch_device_win.cc
diff --git a/ui/base/touch/touch_device_win.cc b/ui/base/touch/touch_device_win.cc
index 26554862ef7e8b376699486f02d5bbc5ae5bd427..303d6d4a9066d21cece0d275395194e1c0d05404 100644
--- a/ui/base/touch/touch_device_win.cc
+++ b/ui/base/touch/touch_device_win.cc
@@ -17,6 +17,28 @@ bool IsTouchDevicePresent() {
((value & NID_INTEGRATED_TOUCH) || (value & NID_EXTERNAL_TOUCH));
}
+PointerType GetPrimaryPointerType(int available_pointer_types) {
+ if (available_pointer_types & POINTER_TYPE_FINE)
+ return POINTER_TYPE_FINE;
+ if (available_pointer_types & POINTER_TYPE_COARSE)
+ return POINTER_TYPE_COARSE;
+ DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE);
+ return POINTER_TYPE_NONE;
+}
+
+int GetAvailableHoverTypes() {
+ int available_hover_types = 0;
+ if (IsTouchDevicePresent())
+ available_hover_types |= HOVER_TYPE_ON_DEMAND;
+ if (GetSystemMetrics(SM_MOUSEPRESENT) != 0)
+ available_hover_types |= HOVER_TYPE_HOVER;
+
+ if (available_hover_types == 0)
+ available_hover_types = HOVER_TYPE_NONE;
+
+ return available_hover_types;
+}
+
} // namespace
TouchScreensAvailability GetTouchScreensAvailability() {
@@ -33,6 +55,10 @@ int MaxTouchPoints() {
return GetSystemMetrics(SM_MAXIMUMTOUCHES);
}
+std::pair<int, int> GetAvailablePointerAndHoverTypes() {
+ return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes());
+}
+
int GetAvailablePointerTypes() {
int available_pointer_types = 0;
if (IsTouchDevicePresent())
@@ -47,31 +73,7 @@ int GetAvailablePointerTypes() {
return available_pointer_types;
}
-PointerType GetPrimaryPointerType() {
- int available_pointer_types = GetAvailablePointerTypes();
- if (available_pointer_types & POINTER_TYPE_FINE)
- return POINTER_TYPE_FINE;
- if (available_pointer_types & POINTER_TYPE_COARSE)
- return POINTER_TYPE_COARSE;
- DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE);
- return POINTER_TYPE_NONE;
-}
-
-int GetAvailableHoverTypes() {
- int available_hover_types = 0;
- if (IsTouchDevicePresent())
- available_hover_types |= HOVER_TYPE_ON_DEMAND;
- if (GetSystemMetrics(SM_MOUSEPRESENT) != 0)
- available_hover_types |= HOVER_TYPE_HOVER;
-
- if (available_hover_types == 0)
- available_hover_types = HOVER_TYPE_NONE;
-
- 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)
« ui/base/touch/touch_device.cc ('K') | « ui/base/touch/touch_device_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698