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

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

Issue 2567233002: Use GVR async reprojection video surface for fullscreen in VR shell
Patch Set: Refactor using new interface and manager, also rebased 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/android/video_surface_provider.h"
17 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
18 #include "device/vr/android/gvr/gvr_delegate.h" 19 #include "device/vr/android/gvr/gvr_delegate.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"
22 #include "ui/gfx/geometry/size.h"
23 #include "ui/gl/android/scoped_java_surface.h"
21 24
22 namespace base { 25 namespace base {
23 class ListValue; 26 class ListValue;
24 class Thread; 27 class Thread;
25 } 28 }
26 29
27 namespace content { 30 namespace content {
28 class WebContents; 31 class WebContents;
29 } 32 }
30 33
(...skipping 16 matching lines...) Expand all
47 RELOAD, 50 RELOAD,
48 ZOOM_OUT, 51 ZOOM_OUT,
49 ZOOM_IN, 52 ZOOM_IN,
50 RELOAD_UI 53 RELOAD_UI
51 }; 54 };
52 55
53 class VrMetricsHelper; 56 class VrMetricsHelper;
54 57
55 // The native instance of the Java VrShell. This class is not threadsafe and 58 // The native instance of the Java VrShell. This class is not threadsafe and
56 // must only be used on the UI thread. 59 // must only be used on the UI thread.
57 class VrShell : public device::GvrDelegate, content::WebContentsObserver { 60 class VrShell : public device::GvrDelegate, content::WebContentsObserver,
61 content::VideoSurfaceProvider {
58 public: 62 public:
59 VrShell(JNIEnv* env, jobject obj, 63 VrShell(JNIEnv* env, jobject obj,
60 content::WebContents* main_contents, 64 content::WebContents* main_contents,
61 ui::WindowAndroid* content_window, 65 ui::WindowAndroid* content_window,
62 content::WebContents* ui_contents, 66 content::WebContents* ui_contents,
63 ui::WindowAndroid* ui_window, 67 ui::WindowAndroid* ui_window,
64 bool for_web_vr, 68 bool for_web_vr,
65 VrShellDelegate* delegate, 69 VrShellDelegate* delegate,
66 gvr_context* gvr_api, 70 gvr_context* gvr_api,
67 bool reprojected_rendering); 71 bool reprojected_rendering);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void UpdateScene(const base::ListValue* args); 128 void UpdateScene(const base::ListValue* args);
125 129
126 // Perform a UI action triggered by the javascript API. 130 // Perform a UI action triggered by the javascript API.
127 void DoUiAction(const UiAction action); 131 void DoUiAction(const UiAction action);
128 132
129 void SetContentCssSize(float width, float height, float dpr); 133 void SetContentCssSize(float width, float height, float dpr);
130 void SetUiCssSize(float width, float height, float dpr); 134 void SetUiCssSize(float width, float height, float dpr);
131 135
132 void ContentFrameWasResized(bool width_changed); 136 void ContentFrameWasResized(bool width_changed);
133 137
138 // Called by the Java class when the video surface changes.
139 void SetVideoSurface(JNIEnv* env,
140 const base::android::JavaParamRef<jobject>& obj,
141 const base::android::JavaParamRef<jobject>& surface);
142
143
134 void ForceExitVr(); 144 void ForceExitVr();
135 145
136 private: 146 private:
137 ~VrShell() override; 147 ~VrShell() override;
138 void SetShowingOverscrollGlow(bool showing_glow); 148 void SetShowingOverscrollGlow(bool showing_glow);
139 void PostToGlThreadWhenReady(const base::Closure& task); 149 void PostToGlThreadWhenReady(const base::Closure& task);
140 150
141 // content::WebContentsObserver implementation. All called on UI thread. 151 // content::WebContentsObserver implementation. All called on UI thread.
142 void RenderViewHostChanged(content::RenderViewHost* old_host, 152 void RenderViewHostChanged(content::RenderViewHost* old_host,
143 content::RenderViewHost* new_host) override; 153 content::RenderViewHost* new_host) override;
144 void MainFrameWasResized(bool width_changed) override; 154 void MainFrameWasResized(bool width_changed) override;
145 void WebContentsDestroyed() override; 155 void WebContentsDestroyed() override;
146 156
157 // content::VideoSurfaceProvider implementation. (not sure what thread).
158 void OnVideoSizeChanged(int width, int height) override;
159 void CreateVideoSurface(content::VideoSurfaceProvider::Client* client,
160 const gfx::Size& video_natural_size) override;
161 content::VideoSurfaceProvider::Client* client_;
162
147 std::unique_ptr<UiInterface> html_interface_; 163 std::unique_ptr<UiInterface> html_interface_;
148 164
149 content::WebContents* main_contents_; 165 content::WebContents* main_contents_;
150 std::unique_ptr<VrCompositor> content_compositor_; 166 std::unique_ptr<VrCompositor> content_compositor_;
151 content::WebContents* ui_contents_; 167 content::WebContents* ui_contents_;
152 std::unique_ptr<VrCompositor> ui_compositor_; 168 std::unique_ptr<VrCompositor> ui_compositor_;
153 169
154 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_; 170 std::unique_ptr<VrWebContentsObserver> vr_web_contents_observer_;
155 171
156 VrShellDelegate* delegate_ = nullptr; 172 VrShellDelegate* delegate_ = nullptr;
(...skipping 10 matching lines...) Expand all
167 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 183 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
168 184
169 DISALLOW_COPY_AND_ASSIGN(VrShell); 185 DISALLOW_COPY_AND_ASSIGN(VrShell);
170 }; 186 };
171 187
172 bool RegisterVrShell(JNIEnv* env); 188 bool RegisterVrShell(JNIEnv* env);
173 189
174 } // namespace vr_shell 190 } // namespace vr_shell
175 191
176 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 192 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698