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

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

Issue 2624633002: Remove Sync GetPose VRService call, implement VRVSyncProvider (Closed)
Patch Set: nits Created 3 years, 11 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 "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
18 #include "device/vr/android/gvr/gvr_delegate.h" 18 #include "device/vr/android/gvr/gvr_delegate.h"
19 #include "device/vr/vr_service.mojom.h"
19 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h" 20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h"
20 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" 21 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
21 22
22 namespace base { 23 namespace base {
23 class ListValue; 24 class ListValue;
24 class Thread;
25 } 25 }
26 26
27 namespace content { 27 namespace content {
28 class WebContents; 28 class WebContents;
29 } 29 }
30 30
31 namespace ui { 31 namespace ui {
32 class WindowAndroid; 32 class WindowAndroid;
33 } 33 }
34 34
35 namespace vr_shell { 35 namespace vr_shell {
36 36
37 class UiInterface; 37 class UiInterface;
38 class VrCompositor; 38 class VrCompositor;
39 class VrGLThread;
39 class VrInputManager; 40 class VrInputManager;
40 class VrMetricsHelper; 41 class VrMetricsHelper;
41 class VrShellDelegate; 42 class VrShellDelegate;
42 class VrWebContentsObserver; 43 class VrWebContentsObserver;
43 44
44 enum UiAction { 45 enum UiAction {
45 HISTORY_BACK = 0, 46 HISTORY_BACK = 0,
46 HISTORY_FORWARD, 47 HISTORY_FORWARD,
47 RELOAD, 48 RELOAD,
48 ZOOM_OUT, 49 ZOOM_OUT,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 void ContentWebContentsDestroyed(); 89 void ContentWebContentsDestroyed();
89 // Called when our WebContents have been hidden. Usually a sign that something 90 // Called when our WebContents have been hidden. Usually a sign that something
90 // like another tab placed in front of it. 91 // like another tab placed in front of it.
91 void ContentWasHidden(); 92 void ContentWasHidden();
92 93
93 // html/js UI hooks. 94 // html/js UI hooks.
94 static base::WeakPtr<VrShell> GetWeakPtr( 95 static base::WeakPtr<VrShell> GetWeakPtr(
95 const content::WebContents* web_contents); 96 const content::WebContents* web_contents);
96 97
97 // TODO(mthiesse): Clean up threading around UiInterface.
98 UiInterface* GetUiInterface(); 98 UiInterface* GetUiInterface();
99 void OnDomContentsLoaded(); 99 void OnDomContentsLoaded();
100 100
101 // device::GvrDelegate implementation
102 // TODO(mthiesse): Clean up threading around GVR API. These functions are
103 // called on the UI thread, but use GL thread objects in a non-threadsafe way.
104 void SetWebVRSecureOrigin(bool secure_origin) override;
105 void SubmitWebVRFrame() override;
106 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,
107 const gvr::Rectf& right_bounds) override;
108 gvr::GvrApi* gvr_api() override;
109 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) override;
110 void SetWebVRRenderSurfaceSize(int width, int height) override;
111 gvr::Sizei GetWebVRCompositorSurfaceSize() override;
112
113 void SurfacesChanged(jobject content_surface, jobject ui_surface); 101 void SurfacesChanged(jobject content_surface, jobject ui_surface);
114 void GvrDelegateReady(); 102 void GvrDelegateReady();
115 void AppButtonPressed(); 103 void AppButtonPressed();
116 104
117 void ContentPhysicalBoundsChanged( 105 void ContentPhysicalBoundsChanged(
118 JNIEnv* env, 106 JNIEnv* env,
119 const base::android::JavaParamRef<jobject>& object, 107 const base::android::JavaParamRef<jobject>& object,
120 jint width, jint height, jfloat dpr); 108 jint width, jint height, jfloat dpr);
121 109
122 void UIPhysicalBoundsChanged( 110 void UIPhysicalBoundsChanged(
123 JNIEnv* env, 111 JNIEnv* env,
124 const base::android::JavaParamRef<jobject>& object, 112 const base::android::JavaParamRef<jobject>& object,
125 jint width, jint height, jfloat dpr); 113 jint width, jint height, jfloat dpr);
126 114
127 void UpdateScene(const base::ListValue* args); 115 void UpdateScene(const base::ListValue* args);
128 116
129 // Perform a UI action triggered by the javascript API. 117 // Perform a UI action triggered by the javascript API.
130 void DoUiAction(const UiAction action); 118 void DoUiAction(const UiAction action);
131 119
132 void SetContentCssSize(float width, float height, float dpr); 120 void SetContentCssSize(float width, float height, float dpr);
133 void SetUiCssSize(float width, float height, float dpr); 121 void SetUiCssSize(float width, float height, float dpr);
134 122
135 void ContentFrameWasResized(bool width_changed); 123 void ContentFrameWasResized(bool width_changed);
136 124
137 void ForceExitVr(); 125 void ForceExitVr();
138 126
127 static device::mojom::VRPosePtr VRPosePtrFromGvrPose(gvr::Mat4f head_mat,
128 uint32_t pose_index);
129
139 private: 130 private:
140 ~VrShell() override; 131 virtual ~VrShell();
141 void SetShowingOverscrollGlow(bool showing_glow); 132 void SetShowingOverscrollGlow(bool showing_glow);
142 void PostToGlThreadWhenReady(const base::Closure& task); 133 void PostToGlThreadWhenReady(const base::Closure& task);
143 134
144 // content::WebContentsObserver implementation. All called on UI thread. 135 // content::WebContentsObserver implementation.
145 void RenderViewHostChanged(content::RenderViewHost* old_host, 136 void RenderViewHostChanged(content::RenderViewHost* old_host,
146 content::RenderViewHost* new_host) override; 137 content::RenderViewHost* new_host) override;
147 void MainFrameWasResized(bool width_changed) override; 138 void MainFrameWasResized(bool width_changed) override;
148 void WebContentsDestroyed() override; 139 void WebContentsDestroyed() override;
149 140
141 // device::GvrDelegate implementation
142 void SetWebVRSecureOrigin(bool secure_origin) override;
143 void SubmitWebVRFrame() override;
144 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,
145 const gvr::Rectf& right_bounds) override;
146 gvr::GvrApi* gvr_api() override;
147 void SetWebVRRenderSurfaceSize(int width, int height) override;
148 gvr::Sizei GetWebVRCompositorSurfaceSize() override;
149 void OnVRVsyncProviderRequest(
150 device::mojom::VRVSyncProviderRequest request) override;
151 void UpdateVSyncInterval(long timebase_nanos,
152 double interval_seconds) override;
153
150 std::unique_ptr<UiInterface> html_interface_; 154 std::unique_ptr<UiInterface> html_interface_;
151 155
152 content::WebContents* main_contents_; 156 content::WebContents* main_contents_;
153 std::unique_ptr<VrCompositor> content_compositor_; 157 std::unique_ptr<VrCompositor> content_compositor_;
154 content::WebContents* ui_contents_; 158 content::WebContents* ui_contents_;
155 std::unique_ptr<VrCompositor> ui_compositor_; 159 std::unique_ptr<VrCompositor> ui_compositor_;
156 160
157 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 161 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
158 162
159 VrShellDelegate* delegate_ = nullptr; 163 VrShellDelegate* delegate_provider_ = nullptr;
160 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 164 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
161 165
162 std::unique_ptr<VrInputManager> content_input_manager_; 166 std::unique_ptr<VrInputManager> content_input_manager_;
163 std::unique_ptr<VrInputManager> ui_input_manager_; 167 std::unique_ptr<VrInputManager> ui_input_manager_;
164 std::unique_ptr<VrMetricsHelper> metrics_helper_; 168 std::unique_ptr<VrMetricsHelper> metrics_helper_;
165 169
166 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 170 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
167 std::unique_ptr<base::Thread> gl_thread_; 171 std::unique_ptr<VrGLThread> gl_thread_;
168 bool reprojected_rendering_; 172 bool reprojected_rendering_;
169 173
170 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 174 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
171 175
172 DISALLOW_COPY_AND_ASSIGN(VrShell); 176 DISALLOW_COPY_AND_ASSIGN(VrShell);
173 }; 177 };
174 178
175 bool RegisterVrShell(JNIEnv* env); 179 bool RegisterVrShell(JNIEnv* env);
176 180
177 } // namespace vr_shell 181 } // namespace vr_shell
178 182
179 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 183 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698