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

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

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 #include "ui/gfx/win/direct_manipulation.h"
6
7 #include "base/basictypes.h"
8 #include "base/win/windows_version.h"
9
10 namespace gfx {
11 namespace win {
12
13 // static
14 scoped_ptr<DirectManipulationHelper>
15 DirectManipulationHelper::CreateInstance() {
16 scoped_ptr<DirectManipulationHelper> instance;
17
18 if (base::win::GetVersion() >= base::win::VERSION_WIN10)
19 instance.reset(new DirectManipulationHelper);
20
21 return instance.Pass();
22 }
23
24 DirectManipulationHelper::DirectManipulationHelper() {}
25
26 void DirectManipulationHelper::Initialize(HWND window) {
27 DCHECK(::IsWindow(window));
28
29 // TODO(ananta)
30 // Remove the CHECK statements here and below and replace them with logs
31 // when this code stabilizes.
32 HRESULT hr = manager_.CreateInstance(CLSID_DirectManipulationManager,
33 nullptr, CLSCTX_INPROC_SERVER);
34 CHECK(SUCCEEDED(hr));
35
36 hr = compositor_.CreateInstance(CLSID_DCompManipulationCompositor,
37 nullptr, CLSCTX_INPROC_SERVER);
38 CHECK(SUCCEEDED(hr));
39
40 hr = manager_->GetUpdateManager(IID_PPV_ARGS(update_manager_.Receive()));
41 CHECK(SUCCEEDED(hr));
42
43 hr = compositor_->SetUpdateManager(update_manager_.get());
44 CHECK(SUCCEEDED(hr));
45
46 hr = frame_info_.QueryFrom(compositor_.get());
47 CHECK(SUCCEEDED(hr));
48
49 hr = manager_->CreateViewport(frame_info_.get(), window,
50 IID_PPV_ARGS(view_port_outer_.Receive()));
51 CHECK(SUCCEEDED(hr));
52
53 //
54 // Enable the desired configuration for each viewport.
55 //
56 DIRECTMANIPULATION_CONFIGURATION configuration =
57 DIRECTMANIPULATION_CONFIGURATION_INTERACTION
58 | DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_X
59 | DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_Y
60 | DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA
61 | DIRECTMANIPULATION_CONFIGURATION_RAILS_X
62 | DIRECTMANIPULATION_CONFIGURATION_RAILS_Y
63 | DIRECTMANIPULATION_CONFIGURATION_SCALING
64 | DIRECTMANIPULATION_CONFIGURATION_SCALING_INERTIA;
65
66 hr = view_port_outer_->ActivateConfiguration(configuration);
67 CHECK(SUCCEEDED(hr));
68 }
69
70 void DirectManipulationHelper::SetBounds(const gfx::Rect& bounds) {
71 base::win::ScopedComPtr<IDirectManipulationPrimaryContent>
72 primary_content_outer;
73 HRESULT hr = view_port_outer_->GetPrimaryContent(
74 IID_PPV_ARGS(primary_content_outer.Receive()));
75 CHECK(SUCCEEDED(hr));
76
77 base::win::ScopedComPtr<IDirectManipulationContent> content_outer;
78 hr = content_outer.QueryFrom(primary_content_outer.get());
79 CHECK(SUCCEEDED(hr));
80
81 RECT rect = bounds.ToRECT();
82
83 hr = view_port_outer_->SetViewportRect(&rect);
84 CHECK(SUCCEEDED(hr));
85
86 hr = content_outer->SetContentRect(&rect);
87 CHECK(SUCCEEDED(hr));
88 }
89
90 void DirectManipulationHelper::Activate(HWND window) {
91 DCHECK(::IsWindow(window));
92 HRESULT hr = manager_->Activate(window);
93 CHECK(SUCCEEDED(hr));
94 }
95
96 void DirectManipulationHelper:: HandleMouseWheel(HWND window, UINT message,
97 WPARAM w_param, LPARAM l_param) {
98 MSG msg = { window, message, w_param, l_param};
99
100 HRESULT hr = view_port_outer_->SetContact(DIRECTMANIPULATION_MOUSEFOCUS);
101 if (SUCCEEDED(hr)) {
102 BOOL handled = FALSE;
103 manager_->ProcessInput(&msg, &handled);
104 view_port_outer_->ReleaseContact(DIRECTMANIPULATION_MOUSEFOCUS);
105 }
106 }
107
108 } // namespace win.
109 } // namespace gfx.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698