| 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.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 base::Passed(&controller_model))); | 76 base::Passed(&controller_model))); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 VrShell::VrShell(JNIEnv* env, | 82 VrShell::VrShell(JNIEnv* env, |
| 83 jobject obj, | 83 jobject obj, |
| 84 ui::WindowAndroid* window, | 84 ui::WindowAndroid* window, |
| 85 bool for_web_vr, | 85 bool for_web_vr, |
| 86 bool in_cct, |
| 86 VrShellDelegate* delegate, | 87 VrShellDelegate* delegate, |
| 87 gvr_context* gvr_api, | 88 gvr_context* gvr_api, |
| 88 bool reprojected_rendering) | 89 bool reprojected_rendering) |
| 89 : vr_shell_enabled_(base::FeatureList::IsEnabled(features::kVrShell)), | 90 : vr_shell_enabled_(base::FeatureList::IsEnabled(features::kVrShell)), |
| 90 window_(window), | 91 window_(window), |
| 91 compositor_(base::MakeUnique<VrCompositor>(window_)), | 92 compositor_(base::MakeUnique<VrCompositor>(window_)), |
| 92 delegate_provider_(delegate), | 93 delegate_provider_(delegate), |
| 93 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 94 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 94 reprojected_rendering_(reprojected_rendering), | 95 reprojected_rendering_(reprojected_rendering), |
| 95 gvr_api_(gvr_api), | 96 gvr_api_(gvr_api), |
| 96 weak_ptr_factory_(this) { | 97 weak_ptr_factory_(this) { |
| 97 DVLOG(1) << __FUNCTION__ << "=" << this; | 98 DVLOG(1) << __FUNCTION__ << "=" << this; |
| 98 DCHECK(g_instance == nullptr); | 99 DCHECK(g_instance == nullptr); |
| 99 g_instance = this; | 100 g_instance = this; |
| 100 j_vr_shell_.Reset(env, obj); | 101 j_vr_shell_.Reset(env, obj); |
| 101 | 102 |
| 102 gl_thread_ = base::MakeUnique<VrGLThread>(weak_ptr_factory_.GetWeakPtr(), | 103 gl_thread_ = base::MakeUnique<VrGLThread>( |
| 103 main_thread_task_runner_, gvr_api, | 104 weak_ptr_factory_.GetWeakPtr(), main_thread_task_runner_, gvr_api, |
| 104 for_web_vr, reprojected_rendering_); | 105 for_web_vr, in_cct, reprojected_rendering_); |
| 105 | 106 |
| 106 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); | 107 base::Thread::Options options(base::MessageLoop::TYPE_DEFAULT, 0); |
| 107 options.priority = base::ThreadPriority::DISPLAY; | 108 options.priority = base::ThreadPriority::DISPLAY; |
| 108 gl_thread_->StartWithOptions(options); | 109 gl_thread_->StartWithOptions(options); |
| 109 | 110 |
| 110 ui_ = base::MakeUnique<UiInterface>(for_web_vr ? UiInterface::Mode::WEB_VR | 111 ui_ = base::MakeUnique<UiInterface>(for_web_vr ? UiInterface::Mode::WEB_VR |
| 111 : UiInterface::Mode::STANDARD); | 112 : UiInterface::Mode::STANDARD); |
| 112 | 113 |
| 113 content::BrowserThread::PostTask( | 114 content::BrowserThread::PostTask( |
| 114 content::BrowserThread::FILE, FROM_HERE, | 115 content::BrowserThread::FILE, FROM_HERE, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 550 |
| 550 // ---------------------------------------------------------------------------- | 551 // ---------------------------------------------------------------------------- |
| 551 // Native JNI methods | 552 // Native JNI methods |
| 552 // ---------------------------------------------------------------------------- | 553 // ---------------------------------------------------------------------------- |
| 553 | 554 |
| 554 jlong Init(JNIEnv* env, | 555 jlong Init(JNIEnv* env, |
| 555 const JavaParamRef<jobject>& obj, | 556 const JavaParamRef<jobject>& obj, |
| 556 const JavaParamRef<jobject>& delegate, | 557 const JavaParamRef<jobject>& delegate, |
| 557 jlong window_android, | 558 jlong window_android, |
| 558 jboolean for_web_vr, | 559 jboolean for_web_vr, |
| 560 jboolean in_cct, |
| 559 jlong gvr_api, | 561 jlong gvr_api, |
| 560 jboolean reprojected_rendering) { | 562 jboolean reprojected_rendering) { |
| 561 return reinterpret_cast<intptr_t>(new VrShell( | 563 return reinterpret_cast<intptr_t>(new VrShell( |
| 562 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 564 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 563 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 565 for_web_vr, in_cct, |
| 566 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 564 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 567 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 565 } | 568 } |
| 566 | 569 |
| 567 } // namespace vr_shell | 570 } // namespace vr_shell |
| OLD | NEW |