OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_WIN_DIRECT_MANIPULATION_H_ | 5 #ifndef UI_GFX_WIN_DIRECT_MANIPULATION_H_ |
6 #define UI_GFX_WIN_DIRECT_MANIPULATION_H_ | 6 #define UI_GFX_WIN_DIRECT_MANIPULATION_H_ |
7 | 7 |
8 #include <directmanipulation.h> | 8 #include <directmanipulation.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/win/scoped_comptr.h" | 13 #include "base/win/scoped_comptr.h" |
13 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/gfx_export.h" | 15 #include "ui/gfx/gfx_export.h" |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 namespace win { | 18 namespace win { |
18 | 19 |
19 // Windows 10 provides a new API called Direct Manipulation which generates | 20 // Windows 10 provides a new API called Direct Manipulation which generates |
20 // smooth scroll events via WM_MOUSEWHEEL messages with predictable deltas | 21 // smooth scroll events via WM_MOUSEWHEEL messages with predictable deltas |
21 // on high precision touch pads. This basically requires the application window | 22 // on high precision touch pads. This basically requires the application window |
(...skipping 13 matching lines...) Expand all Loading... |
35 // Our approach for addressing this is to do the absolute minimum to | 36 // Our approach for addressing this is to do the absolute minimum to |
36 // register our window as a Direct Manipulation consumer. This class | 37 // register our window as a Direct Manipulation consumer. This class |
37 // provides the necessary functionality to register the passed in HWND as a | 38 // provides the necessary functionality to register the passed in HWND as a |
38 // Direct Manipulation consumer. We don't rely on Direct manipulation | 39 // Direct Manipulation consumer. We don't rely on Direct manipulation |
39 // to do the smooth scrolling in the background thread as documented on | 40 // to do the smooth scrolling in the background thread as documented on |
40 // msdn. | 41 // msdn. |
41 class GFX_EXPORT DirectManipulationHelper { | 42 class GFX_EXPORT DirectManipulationHelper { |
42 public: | 43 public: |
43 // Creates an instance of this class if Direct Manipulation is enabled on | 44 // Creates an instance of this class if Direct Manipulation is enabled on |
44 // the platform. If not returns NULL. | 45 // the platform. If not returns NULL. |
45 static scoped_ptr<DirectManipulationHelper> CreateInstance(); | 46 static std::unique_ptr<DirectManipulationHelper> CreateInstance(); |
46 | 47 |
47 // This function instantiates Direct Manipulation and creates a viewport for | 48 // This function instantiates Direct Manipulation and creates a viewport for |
48 // the passed in |window|. | 49 // the passed in |window|. |
49 // consumer. Most of the code is boiler plate and is based on the sample. | 50 // consumer. Most of the code is boiler plate and is based on the sample. |
50 void Initialize(HWND window); | 51 void Initialize(HWND window); |
51 | 52 |
52 // Sets the bounds of the fake Direct manipulation viewport to match those | 53 // Sets the bounds of the fake Direct manipulation viewport to match those |
53 // of the legacy window. | 54 // of the legacy window. |
54 void SetBounds(const gfx::Rect& bounds); | 55 void SetBounds(const gfx::Rect& bounds); |
55 | 56 |
(...skipping 20 matching lines...) Expand all Loading... |
76 base::win::ScopedComPtr<IDirectManipulationFrameInfoProvider> frame_info_; | 77 base::win::ScopedComPtr<IDirectManipulationFrameInfoProvider> frame_info_; |
77 base::win::ScopedComPtr<IDirectManipulationViewport2> view_port_outer_; | 78 base::win::ScopedComPtr<IDirectManipulationViewport2> view_port_outer_; |
78 | 79 |
79 DISALLOW_COPY_AND_ASSIGN(DirectManipulationHelper); | 80 DISALLOW_COPY_AND_ASSIGN(DirectManipulationHelper); |
80 }; | 81 }; |
81 | 82 |
82 } // namespace win | 83 } // namespace win |
83 } // namespace gfx | 84 } // namespace gfx |
84 | 85 |
85 #endif // UI_GFX_WIN_DIRECT_MANIPULATION_H_ | 86 #endif // UI_GFX_WIN_DIRECT_MANIPULATION_H_ |
OLD | NEW |