| OLD | NEW |
| 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 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h" | 10 #include "chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // If/When VRShell is ready for use it will call SetPresentResult. | 158 // If/When VRShell is ready for use it will call SetPresentResult. |
| 159 JNIEnv* env = AttachCurrentThread(); | 159 JNIEnv* env = AttachCurrentThread(); |
| 160 Java_VrShellDelegate_presentRequested(env, j_vr_shell_delegate_.obj()); | 160 Java_VrShellDelegate_presentRequested(env, j_vr_shell_delegate_.obj()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void VrShellDelegate::ExitWebVRPresent() { | 163 void VrShellDelegate::ExitWebVRPresent() { |
| 164 // VRShell is no longer needed by WebVR, allow it to shut down if it's not | 164 // VRShell is no longer needed by WebVR, allow it to shut down if it's not |
| 165 // being used elsewhere. | 165 // being used elsewhere. |
| 166 JNIEnv* env = AttachCurrentThread(); | 166 JNIEnv* env = AttachCurrentThread(); |
| 167 Java_VrShellDelegate_exitWebVR(env, j_vr_shell_delegate_.obj()); | 167 if (Java_VrShellDelegate_exitWebVRPresent(env, j_vr_shell_delegate_.obj())) { |
| 168 device_provider_->Device()->OnExitPresent(); |
| 169 } |
| 168 } | 170 } |
| 169 | 171 |
| 170 void VrShellDelegate::CreateNonPresentingDelegate() { | 172 void VrShellDelegate::CreateNonPresentingDelegate() { |
| 171 JNIEnv* env = AttachCurrentThread(); | 173 JNIEnv* env = AttachCurrentThread(); |
| 172 gvr_context* context = reinterpret_cast<gvr_context*>( | 174 gvr_context* context = reinterpret_cast<gvr_context*>( |
| 173 Java_VrShellDelegate_createNonPresentingNativeContext( | 175 Java_VrShellDelegate_createNonPresentingNativeContext( |
| 174 env, j_vr_shell_delegate_.obj())); | 176 env, j_vr_shell_delegate_.obj())); |
| 175 non_presenting_delegate_ = | 177 non_presenting_delegate_ = |
| 176 base::MakeUnique<NonPresentingGvrDelegate>(context); | 178 base::MakeUnique<NonPresentingGvrDelegate>(context); |
| 177 non_presenting_delegate_->UpdateVSyncInterval(timebase_nanos_, | 179 non_presenting_delegate_->UpdateVSyncInterval(timebase_nanos_, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 201 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 203 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 202 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); | 204 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); |
| 203 } | 205 } |
| 204 | 206 |
| 205 static void OnLibraryAvailable(JNIEnv* env, const JavaParamRef<jclass>& clazz) { | 207 static void OnLibraryAvailable(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 206 device::GvrDelegateProvider::SetInstance( | 208 device::GvrDelegateProvider::SetInstance( |
| 207 base::Bind(&VrShellDelegate::CreateVrShellDelegate)); | 209 base::Bind(&VrShellDelegate::CreateVrShellDelegate)); |
| 208 } | 210 } |
| 209 | 211 |
| 210 } // namespace vr_shell | 212 } // namespace vr_shell |
| OLD | NEW |