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

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

Issue 2584343002: WIP: working copy-no-compositor path
Patch Set: StatTracker destructor, delete old magic numbers, mojo export 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 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
6 #include "device/vr/android/gvr/gvr_delegate.h"
6 7
7 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
8 #include "chrome/browser/android/vr_shell/vr_shell.h" 9 #include "chrome/browser/android/vr_shell/vr_shell.h"
9 #include "device/vr/android/gvr/gvr_device_provider.h" 10 #include "device/vr/android/gvr/gvr_device_provider.h"
10 #include "jni/VrShellDelegate_jni.h" 11 #include "jni/VrShellDelegate_jni.h"
11 12
12 using base::android::JavaParamRef; 13 using base::android::JavaParamRef;
13 using base::android::AttachCurrentThread; 14 using base::android::AttachCurrentThread;
14 15
15 namespace vr_shell { 16 namespace vr_shell {
16 17
17 // A non presenting delegate for magic window mode. 18 // A non presenting delegate for magic window mode.
18 class GvrNonPresentingDelegate : public device::GvrDelegate { 19 class GvrNonPresentingDelegate : public device::GvrDelegate {
19 public: 20 public:
20 explicit GvrNonPresentingDelegate(jlong context) { 21 explicit GvrNonPresentingDelegate(jlong context) {
22 VLOG(1) << __FUNCTION__ << ": Instantiate gvr_api for non-presenting delegat e";
21 gvr_api_ = 23 gvr_api_ =
22 gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(context)); 24 gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(context));
23 } 25 }
24 26
25 virtual ~GvrNonPresentingDelegate() = default; 27 virtual ~GvrNonPresentingDelegate() {
28 VLOG(1) << __FUNCTION__ << ": Destructor for non-presenting delegate and its gvr_api)";
29 };
26 30
27 // GvrDelegate implementation 31 // GvrDelegate implementation
28 void SetWebVRSecureOrigin(bool secure_origin) override {} 32 void SetWebVRSecureOrigin(bool secure_origin) override {}
29 void SubmitWebVRFrame() override {} 33 void SubmitWebVRFrame(int32_t surface_handle, device::mojom::VRPosePtr pose) o verride {}
30 void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 34 void UpdateWebVRTextureBounds(uint32_t for_pose_index,
35 const gvr::Rectf& left_bounds,
31 const gvr::Rectf& right_bounds) override {} 36 const gvr::Rectf& right_bounds) override {}
32 void SetGvrPoseForWebVr(const gvr::Mat4f& pose, 37 void SetWebVRGvrPose(const gvr::Mat4f& pose,
33 uint32_t pose_index) override {} 38 uint32_t pose_index, int64_t pose_time_nanos) override {}
34 void SetWebVRRenderSurfaceSize(int width, int height) override {} 39 void GetWebVRSurfaceHandle(int width, int height, const device::mojom::VRDispl ay::GetSurfaceHandleCallback& callback) override { callback.Run(0); }
35 gvr::Sizei GetWebVRCompositorSurfaceSize() override {
36 return device::kInvalidRenderTargetSize; }
37 gvr::GvrApi* gvr_api() override { return gvr_api_.get(); } 40 gvr::GvrApi* gvr_api() override { return gvr_api_.get(); }
38 private: 41 private:
39 std::unique_ptr<gvr::GvrApi> gvr_api_; 42 std::unique_ptr<gvr::GvrApi> gvr_api_;
40 }; 43 };
41 44
42 VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj) { 45 VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj) {
43 j_vr_shell_delegate_.Reset(env, obj); 46 j_vr_shell_delegate_.Reset(env, obj);
44 GvrDelegateProvider::SetInstance(this); 47 GvrDelegateProvider::SetInstance(this);
45 } 48 }
46 49
(...skipping 27 matching lines...) Expand all
74 } 77 }
75 78
76 void VrShellDelegate::SetPresentResult(JNIEnv* env, jobject obj, 79 void VrShellDelegate::SetPresentResult(JNIEnv* env, jobject obj,
77 jboolean result) { 80 jboolean result) {
78 CHECK(!present_callback_.is_null()); 81 CHECK(!present_callback_.is_null());
79 present_callback_.Run(result); 82 present_callback_.Run(result);
80 present_callback_.Reset(); 83 present_callback_.Reset();
81 } 84 }
82 85
83 void VrShellDelegate::DisplayActivate(JNIEnv* env, jobject obj) { 86 void VrShellDelegate::DisplayActivate(JNIEnv* env, jobject obj) {
87 VLOG(1) << __FUNCTION__ << ": device_provider_=" << device_provider_;
84 if (device_provider_) { 88 if (device_provider_) {
85 device_provider_->OnDisplayActivate(); 89 device_provider_->OnDisplayActivate();
86 } 90 }
87 } 91 }
88 92
89 void VrShellDelegate::SetDeviceProvider( 93 void VrShellDelegate::SetDeviceProvider(
90 device::GvrDeviceProvider* device_provider) { 94 device::GvrDeviceProvider* device_provider) {
91 device_provider_ = device_provider; 95 device_provider_ = device_provider;
92 if (device_provider_ && delegate_) { 96 if (device_provider_ && delegate_) {
93 device_provider_->OnGvrDelegateReady(delegate_); 97 device_provider_->OnGvrDelegateReady(delegate_);
(...skipping 24 matching lines...) Expand all
118 } 122 }
119 123
120 void VrShellDelegate::ForceExitVr() { 124 void VrShellDelegate::ForceExitVr() {
121 JNIEnv* env = AttachCurrentThread(); 125 JNIEnv* env = AttachCurrentThread();
122 Java_VrShellDelegate_forceExitVr(env, j_vr_shell_delegate_.obj()); 126 Java_VrShellDelegate_forceExitVr(env, j_vr_shell_delegate_.obj());
123 } 127 }
124 128
125 device::GvrDelegate* VrShellDelegate::GetNonPresentingDelegate() { 129 device::GvrDelegate* VrShellDelegate::GetNonPresentingDelegate() {
126 if (!non_presenting_delegate_) { 130 if (!non_presenting_delegate_) {
127 JNIEnv* env = AttachCurrentThread(); 131 JNIEnv* env = AttachCurrentThread();
132 VLOG(1) << __FUNCTION__;
128 jlong context = Java_VrShellDelegate_createNonPresentingNativeContext( 133 jlong context = Java_VrShellDelegate_createNonPresentingNativeContext(
129 env, j_vr_shell_delegate_.obj()); 134 env, j_vr_shell_delegate_.obj());
130 if (!context) 135 if (!context)
131 return nullptr; 136 return nullptr;
132 137
133 non_presenting_delegate_.reset(new GvrNonPresentingDelegate(context)); 138 non_presenting_delegate_.reset(new GvrNonPresentingDelegate(context));
134 } 139 }
135 return static_cast<GvrNonPresentingDelegate*>(non_presenting_delegate_.get()); 140 return static_cast<GvrNonPresentingDelegate*>(non_presenting_delegate_.get());
136 } 141 }
137 142
138 void VrShellDelegate::DestroyNonPresentingDelegate() { 143 void VrShellDelegate::DestroyNonPresentingDelegate() {
139 if (non_presenting_delegate_) { 144 if (non_presenting_delegate_) {
145 VLOG(1) << __FUNCTION__;
140 non_presenting_delegate_.reset(nullptr); 146 non_presenting_delegate_.reset(nullptr);
141 JNIEnv* env = AttachCurrentThread(); 147 JNIEnv* env = AttachCurrentThread();
142 Java_VrShellDelegate_shutdownNonPresentingNativeContext( 148 Java_VrShellDelegate_shutdownNonPresentingNativeContext(
143 env, j_vr_shell_delegate_.obj()); 149 env, j_vr_shell_delegate_.obj());
144 } 150 }
145 } 151 }
146 152
147 void VrShellDelegate::SetListeningForActivate(bool listening) { 153 void VrShellDelegate::SetListeningForActivate(bool listening) {
148 JNIEnv* env = AttachCurrentThread(); 154 JNIEnv* env = AttachCurrentThread();
155 VLOG(1) << __FUNCTION__;
149 Java_VrShellDelegate_setListeningForWebVrActivate( 156 Java_VrShellDelegate_setListeningForWebVrActivate(
150 env, j_vr_shell_delegate_.obj(), listening); 157 env, j_vr_shell_delegate_.obj(), listening);
151 } 158 }
152 159
153 // ---------------------------------------------------------------------------- 160 // ----------------------------------------------------------------------------
154 // Native JNI methods 161 // Native JNI methods
155 // ---------------------------------------------------------------------------- 162 // ----------------------------------------------------------------------------
156 163
157 bool RegisterVrShellDelegate(JNIEnv* env) { 164 bool RegisterVrShellDelegate(JNIEnv* env) {
158 return RegisterNativesImpl(env); 165 return RegisterNativesImpl(env);
159 } 166 }
160 167
161 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 168 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
162 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); 169 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj));
163 } 170 }
164 171
165 } // namespace vr_shell 172 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698