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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.h

Issue 2762003002: Refactor GVR controller gamepad API integration (Closed)
Patch Set: Rebase, no changes Created 3 years, 9 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/android/jni_weak_ref.h" 12 #include "base/android/jni_weak_ref.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "chrome/browser/android/vr_shell/ui_interface.h" 17 #include "chrome/browser/android/vr_shell/ui_interface.h"
18 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
19 #include "device/vr/android/gvr/gvr_delegate.h" 19 #include "device/vr/android/gvr/gvr_delegate.h"
20 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
20 #include "device/vr/vr_service.mojom.h" 21 #include "device/vr/vr_service.mojom.h"
21 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h" 22 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h"
22 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" 23 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
23 24
24 namespace base { 25 namespace base {
25 class ListValue; 26 class ListValue;
26 } 27 }
27 28
28 namespace blink { 29 namespace blink {
29 class WebInputEvent; 30 class WebInputEvent;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 SET_CONTENT_PAUSED, 65 SET_CONTENT_PAUSED,
65 SHOW_TAB, 66 SHOW_TAB,
66 OPEN_NEW_TAB, 67 OPEN_NEW_TAB,
67 KEY_EVENT, 68 KEY_EVENT,
68 }; 69 };
69 70
70 class VrMetricsHelper; 71 class VrMetricsHelper;
71 72
72 // The native instance of the Java VrShell. This class is not threadsafe and 73 // The native instance of the Java VrShell. This class is not threadsafe and
73 // must only be used on the UI thread. 74 // must only be used on the UI thread.
74 class VrShell : public device::GvrDelegate, content::WebContentsObserver { 75 class VrShell : public device::GvrDelegate,
76 content::WebContentsObserver,
77 device::GvrGamepadDataProvider {
75 public: 78 public:
76 VrShell(JNIEnv* env, 79 VrShell(JNIEnv* env,
77 jobject obj, 80 jobject obj,
78 ui::WindowAndroid* content_window, 81 ui::WindowAndroid* content_window,
79 content::WebContents* ui_contents, 82 content::WebContents* ui_contents,
80 ui::WindowAndroid* ui_window, 83 ui::WindowAndroid* ui_window,
81 bool for_web_vr, 84 bool for_web_vr,
82 VrShellDelegate* delegate, 85 VrShellDelegate* delegate,
83 gvr_context* gvr_api, 86 gvr_context* gvr_api,
84 bool reprojected_rendering); 87 bool reprojected_rendering);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void SetContentCssSize(float width, float height, float dpr); 171 void SetContentCssSize(float width, float height, float dpr);
169 void SetUiCssSize(float width, float height, float dpr); 172 void SetUiCssSize(float width, float height, float dpr);
170 173
171 void ContentFrameWasResized(bool width_changed); 174 void ContentFrameWasResized(bool width_changed);
172 175
173 void ForceExitVr(); 176 void ForceExitVr();
174 177
175 void ProcessUIGesture(std::unique_ptr<blink::WebInputEvent> event); 178 void ProcessUIGesture(std::unique_ptr<blink::WebInputEvent> event);
176 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event); 179 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event);
177 180
181 // device::GvrGamepadDataProvider implementation.
182 void UpdateGamepadData(device::GvrGamepadData) override;
183 void RegisterGamepadDataFetcher(device::GvrGamepadDataFetcher*) override;
184
178 // TODO(mthiesse): Find a better place for these functions to live. 185 // TODO(mthiesse): Find a better place for these functions to live.
179 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat); 186 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat);
180 static gvr::Sizei GetRecommendedWebVrSize(gvr::GvrApi* gvr_api); 187 static gvr::Sizei GetRecommendedWebVrSize(gvr::GvrApi* gvr_api);
181 static device::mojom::VRDisplayInfoPtr CreateVRDisplayInfo( 188 static device::mojom::VRDisplayInfoPtr CreateVRDisplayInfo(
182 gvr::GvrApi* gvr_api, 189 gvr::GvrApi* gvr_api,
183 gvr::Sizei recommended_size, 190 gvr::Sizei recommended_size,
184 uint32_t device_id); 191 uint32_t device_id);
185 192
186 private: 193 private:
187 ~VrShell() override; 194 ~VrShell() override;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 248 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
242 std::unique_ptr<VrGLThread> gl_thread_; 249 std::unique_ptr<VrGLThread> gl_thread_;
243 bool reprojected_rendering_; 250 bool reprojected_rendering_;
244 251
245 jobject content_surface_ = nullptr; 252 jobject content_surface_ = nullptr;
246 253
247 // TODO(mthiesse): Remove the need for this to be stored here. 254 // TODO(mthiesse): Remove the need for this to be stored here.
248 // crbug.com/674594 255 // crbug.com/674594
249 gvr_context* gvr_api_; 256 gvr_context* gvr_api_;
250 257
258 // Are we currently providing a gamepad factory to the gamepad manager?
259 bool gamepad_source_active_ = false;
260 // Registered fetcher, must remain alive for UpdateGamepadData calls.
261 // That's ok since the fetcher is only destroyed from VrShell's destructor.
262 device::GvrGamepadDataFetcher* gamepad_data_fetcher_ = nullptr;
263
251 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 264 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
252 265
253 DISALLOW_COPY_AND_ASSIGN(VrShell); 266 DISALLOW_COPY_AND_ASSIGN(VrShell);
254 }; 267 };
255 268
256 bool RegisterVrShell(JNIEnv* env); 269 bool RegisterVrShell(JNIEnv* env);
257 270
258 } // namespace vr_shell 271 } // namespace vr_shell
259 272
260 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 273 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_controller.cc ('k') | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698