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

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

Issue 2398103002: Enable magic window mode with new Gvr (Closed)
Patch Set: reviews Created 4 years, 2 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_delegate.h ('k') | content/public/android/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell_delegate.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_delegate.cc b/chrome/browser/android/vr_shell/vr_shell_delegate.cc
index 606a641702abb96ca529c98b09e560d021e38e8e..af69ba1a03620671880aa90cf4f915f72e35e64e 100644
--- a/chrome/browser/android/vr_shell/vr_shell_delegate.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_delegate.cc
@@ -13,6 +13,32 @@ using base::android::AttachCurrentThread;
namespace vr_shell {
+// A non presenting delegate for magic window mode.
+class GvrNonPresentingDelegate : public device::GvrDelegate {
+ public:
+ explicit GvrNonPresentingDelegate(jlong context) {
+ gvr_api_ =
+ gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(context));
+ }
+
+ virtual ~GvrNonPresentingDelegate() = default;
+
+ // GvrDelegate implementation
+ void SetWebVRSecureOrigin(bool secure_origin) override {}
+ void SubmitWebVRFrame() override {}
+ void UpdateWebVRTextureBounds(int eye,
+ float left,
+ float top,
+ float width,
+ float height) override {}
+ void SetGvrPoseForWebVr(const gvr::Mat4f& pose,
+ uint32_t pose_index) override {}
+ gvr::GvrApi* gvr_api() override { return gvr_api_.get(); }
+
+ private:
+ std::unique_ptr<gvr::GvrApi> gvr_api_;
+};
+
VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj)
: device_provider_(nullptr) {
j_vr_shell_delegate_.Reset(env, obj);
@@ -62,6 +88,26 @@ void VrShellDelegate::ExitWebVRPresent() {
Java_VrShellDelegate_exitWebVR(env, j_vr_shell_delegate_.obj());
}
+device::GvrDelegate* VrShellDelegate::GetNonPresentingDelegate() {
+ if (!non_presenting_delegate_) {
+ JNIEnv* env = AttachCurrentThread();
+ jlong context = Java_VrShellDelegate_createNonPresentingNativeContext(
+ env, j_vr_shell_delegate_.obj());
+ if (!context)
+ return nullptr;
+
+ non_presenting_delegate_.reset(new GvrNonPresentingDelegate(context));
+ }
+ return non_presenting_delegate_.get();
+}
+
+void VrShellDelegate::DestroyNonPresentingDelegate() {
+ non_presenting_delegate_.reset(nullptr);
+ JNIEnv* env = AttachCurrentThread();
+ Java_VrShellDelegate_shutdownNonPresentingNativeContext(
+ env, j_vr_shell_delegate_.obj());
+}
+
void VrShellDelegate::OnVrShellReady(VrShell* vr_shell) {
if (device_provider_)
device_provider_->OnGvrDelegateReady(vr_shell);
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_delegate.h ('k') | content/public/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698