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

Side by Side Diff: ui/gfx/win/direct_manipulation.h

Issue 1283913002: Improve scroll performance on Windows 10 with high precision touchpads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 5 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_WIN_DIRECT_MANIPULATION_H_
6 #define UI_GFX_WIN_DIRECT_MANIPULATION_H_
7
8 #include <directmanipulation.h>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/win/scoped_comptr.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/gfx_export.h"
14
15 namespace gfx {
16 namespace win {
17
18 // Windows 10 provides a new API called Direct Manipulation which generates
19 // smooth scroll events via WM_MOUSEWHEEL messages with predictable deltas
20 // on high precision touch pads. This basically requires the application window
21 // to register as a Direct Manipulation consumer. The way mouse wheel messages
22 // are dispatched is
23 // 1. The foreground window is checked to see if it is a Direct Manipulation
24 // consumer.
25 // 2. If it is then Direct Manipulation takes over and sends the following
26 // messages. WM_POINTERACTIVATE, WM_POINTERDOWN and DM_POINTERHITTEST.
27 // 3. It then posts WM_MOUSEWHEEL messages with precision deltas which vary
28 // based on the amount of the scroll.
29 // 4. If the foreground window is not a Direct Manipulation consumer, it
30 // then takes a fallback route where it posts WM_MOUSEWHEEL messages
31 // with precision but varying deltas to the window. There is a also
32 // a slight delay in receiving the first set of mouse wheel messages.
33 // This causes scrolling to appear janky and jumpy.
34 // Our approach for addressing this is to do the absolute minimum to
35 // register our window as a Direct Manipulation consumer. This class
36 // provides the necessary functionality to register the passed in HWND as a
37 // Direct Manipulation consumer. We don't rely on Direct manipulation
38 // to do the smooth scrolling in the background thread as documented on
39 // msdn.
40 class GFX_EXPORT DirectManipulationHelper {
Reid Kleckner 2015/08/12 15:26:11 The Chromium style plugin wants this class to have
41 public:
42 // Creates an instance of this class if Direct Manipulation is enabled on
43 // the platform. If not returns NULL.
44 static scoped_ptr<DirectManipulationHelper> CreateInstance();
45
46 // This function instantiates Direct Manipulation and creates a viewport for
47 // the passed in |window|.
48 // consumer. Most of the code is boiler plate and is based on the sample.
49 void Initialize(HWND window);
50
51 // Sets the bounds of the fake Direct manipulation viewport to match those
52 // of the legacy window.
53 void SetBounds(const gfx::Rect& bounds);
54
55 // Registers the passed in |window| as a Direct Manipulation consumer.
56 void Activate(HWND window);
57
58 // Passes the WM_MOUSEWHEEL messages to Direct Manipulation. This is for
59 // logistics purposes.
60 void HandleMouseWheel(HWND window, UINT message, WPARAM w_param,
61 LPARAM l_param);
62
63 private:
64 DirectManipulationHelper();
65
66 base::win::ScopedComPtr<IDirectManipulationManager2> manager_;
67 base::win::ScopedComPtr<IDirectManipulationCompositor> compositor_;
68 base::win::ScopedComPtr<IDirectManipulationUpdateManager> update_manager_;
69 base::win::ScopedComPtr<IDirectManipulationFrameInfoProvider> frame_info_;
70 base::win::ScopedComPtr<IDirectManipulationViewport2> view_port_outer_;
71
72 DISALLOW_COPY_AND_ASSIGN(DirectManipulationHelper);
73 };
74
75 } // namespace win
76 } // namespace gfx
77
78 #endif // UI_GFX_WIN_DIRECT_MANIPULATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698