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

Unified Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2343023002: Switch WebVR to handle GvrApi management through VrShellDelegate (Closed)
Patch Set: Rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index 57ec87c91077ef94eff8c77a98ee358cf9343c96..84a2b0e0d84951baa498938afd4ffb0679304ade 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/android/vr_shell/vr_gl_util.h"
#include "chrome/browser/android/vr_shell/vr_math.h"
+#include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
#include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
#include "jni/VrShell_jni.h"
#include "ui/gl/gl_bindings.h"
@@ -37,7 +38,8 @@ namespace vr_shell {
VrShell::VrShell(JNIEnv* env, jobject obj)
: desktop_screen_tilt_(kDesktopScreenTiltDefault),
desktop_height_(kDesktopHeightDefault),
- desktop_position_(kDesktopPositionDefault) {
+ desktop_position_(kDesktopPositionDefault),
+ delegate_(nullptr) {
j_vr_shell_.Reset(env, obj);
ui_rects_.emplace_back(new ContentRectangle());
desktop_plane_ = ui_rects_.back().get();
@@ -63,7 +65,12 @@ bool RegisterVrShell(JNIEnv* env) {
}
VrShell::~VrShell() {
- device::GvrDelegateManager::GetInstance()->Shutdown();
+}
+
+void VrShell::SetDelegate(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ jlong native_delegate) {
+ delegate_ = reinterpret_cast<VrShellDelegate*>(native_delegate);
}
void VrShell::GvrInit(JNIEnv* env,
@@ -72,7 +79,8 @@ void VrShell::GvrInit(JNIEnv* env,
gvr_api_ =
gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(native_gvr_api));
- device::GvrDelegateManager::GetInstance()->Initialize(this);
+ if (delegate_)
+ delegate_->OnVrShellReady(this);
}
void VrShell::InitializeGl(JNIEnv* env,
@@ -251,12 +259,10 @@ void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) {
gvr_api_->ResumeTracking();
}
-void VrShell::RequestWebVRPresent() {
- webvr_mode_ = true;
-}
-
-void VrShell::ExitWebVRPresent() {
- webvr_mode_ = false;
+void VrShell::SetWebVrMode(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ bool enabled) {
+ webvr_mode_ = enabled;
}
void VrShell::SubmitWebVRFrame() {

Powered by Google App Engine
This is Rietveld 408576698