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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_delegate.cc

Issue 2562733002: Implement our own GLThread for VR Shell. (Closed)
Patch Set: sigh Created 4 years 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 #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 "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "chrome/browser/android/vr_shell/vr_shell.h" 8 #include "chrome/browser/android/vr_shell/vr_shell.h"
9 #include "device/vr/android/gvr/gvr_device_provider.h" 9 #include "device/vr/android/gvr/gvr_device_provider.h"
10 #include "jni/VrShellDelegate_jni.h" 10 #include "jni/VrShellDelegate_jni.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 VrShellDelegate::~VrShellDelegate() { 52 VrShellDelegate::~VrShellDelegate() {
53 GvrDelegateProvider::SetInstance(nullptr); 53 GvrDelegateProvider::SetInstance(nullptr);
54 } 54 }
55 55
56 VrShellDelegate* VrShellDelegate::GetNativeDelegate( 56 VrShellDelegate* VrShellDelegate::GetNativeDelegate(
57 JNIEnv* env, jobject jdelegate) { 57 JNIEnv* env, jobject jdelegate) {
58 long native_delegate = Java_VrShellDelegate_getNativePointer(env, jdelegate); 58 long native_delegate = Java_VrShellDelegate_getNativePointer(env, jdelegate);
59 return reinterpret_cast<VrShellDelegate*>(native_delegate); 59 return reinterpret_cast<VrShellDelegate*>(native_delegate);
60 } 60 }
61 61
62 base::WeakPtr<device::GvrDeviceProvider> VrShellDelegate::GetDeviceProvider() { 62 void VrShellDelegate::SetDelegate(
63 return device_provider_; 63 const base::WeakPtr<device::GvrDelegate>& delegate) {
64 // TODO(mthiesse): There's no reason for this delegate to be a WeakPtr
65 // anymore.
66 delegate_ = delegate;
67 if (device_provider_.get()) {
68 device_provider_->OnGvrDelegateReady(delegate_);
69 }
70 }
71
72 void VrShellDelegate::RemoveDelegate() {
73 delegate_.reset();
74 if (device_provider_.get()) {
75 device_provider_->OnGvrDelegateRemoved();
76 }
64 } 77 }
65 78
66 void VrShellDelegate::SetPresentResult(JNIEnv* env, jobject obj, 79 void VrShellDelegate::SetPresentResult(JNIEnv* env, jobject obj,
67 jboolean result) { 80 jboolean result) {
68 CHECK(!present_callback_.is_null()); 81 CHECK(!present_callback_.is_null());
69 present_callback_.Run(result); 82 present_callback_.Run(result);
70 present_callback_.Reset(); 83 present_callback_.Reset();
71 } 84 }
72 85
73 void VrShellDelegate::DisplayActivate(JNIEnv* env, jobject obj) { 86 void VrShellDelegate::DisplayActivate(JNIEnv* env, jobject obj) {
74 if (device_provider_) { 87 if (device_provider_) {
75 device_provider_->OnDisplayActivate(); 88 device_provider_->OnDisplayActivate();
76 } 89 }
77 } 90 }
78 91
79 void VrShellDelegate::SetDeviceProvider( 92 void VrShellDelegate::SetDeviceProvider(
80 base::WeakPtr<device::GvrDeviceProvider> device_provider) { 93 base::WeakPtr<device::GvrDeviceProvider> device_provider) {
81 device_provider_ = device_provider; 94 device_provider_ = device_provider;
95 if (delegate_.get()) {
96 device_provider_->OnGvrDelegateReady(delegate_);
97 }
82 } 98 }
83 99
84 void VrShellDelegate::RequestWebVRPresent( 100 void VrShellDelegate::RequestWebVRPresent(
85 const base::Callback<void(bool)>& callback) { 101 const base::Callback<void(bool)>& callback) {
86 if (!present_callback_.is_null()) { 102 if (!present_callback_.is_null()) {
87 // Can only handle one request at a time. This is also extremely unlikely to 103 // Can only handle one request at a time. This is also extremely unlikely to
88 // happen in practice. 104 // happen in practice.
89 callback.Run(false); 105 callback.Run(false);
90 return; 106 return;
91 } 107 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 160
145 bool RegisterVrShellDelegate(JNIEnv* env) { 161 bool RegisterVrShellDelegate(JNIEnv* env) {
146 return RegisterNativesImpl(env); 162 return RegisterNativesImpl(env);
147 } 163 }
148 164
149 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 165 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
150 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); 166 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj));
151 } 167 }
152 168
153 } // namespace vr_shell 169 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_delegate.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698