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

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

Issue 2624633002: Remove Sync GetPose VRService call, implement VRVSyncProvider (Closed)
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
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 9a3dd570bc4e6ea2eb74f82c67d127d30e489ed8..83837e7299d14013045ef6f355d1a491a3870162 100644
--- a/chrome/browser/android/vr_shell/vr_shell_delegate.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_delegate.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
#include "base/android/jni_android.h"
-#include "chrome/browser/android/vr_shell/vr_shell.h"
+#include "chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h"
#include "device/vr/android/gvr/gvr_device_provider.h"
#include "jni/VrShellDelegate_jni.h"
@@ -14,31 +14,6 @@ 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(const gvr::Rectf& left_bounds,
- const gvr::Rectf& right_bounds) override {}
- void SetGvrPoseForWebVr(const gvr::Mat4f& pose,
- uint32_t pose_index) override {}
- void SetWebVRRenderSurfaceSize(int width, int height) override {}
- gvr::Sizei GetWebVRCompositorSurfaceSize() override {
- return device::kInvalidRenderTargetSize; }
- gvr::GvrApi* gvr_api() override { return gvr_api_.get(); }
- private:
- std::unique_ptr<gvr::GvrApi> gvr_api_;
-};
-
VrShellDelegate::VrShellDelegate(JNIEnv* env, jobject obj) {
j_vr_shell_delegate_.Reset(env, obj);
GvrDelegateProvider::SetInstance(this);
@@ -58,12 +33,11 @@ VrShellDelegate* VrShellDelegate::GetNativeDelegate(
}
void VrShellDelegate::SetDelegate(device::GvrDelegate* delegate) {
- // TODO(mthiesse): There's no reason for this delegate to be a WeakPtr
- // anymore.
delegate_ = delegate;
if (device_provider_) {
device_provider_->OnGvrDelegateReady(delegate_);
}
+ delegate_->UpdateVSyncInterval(timebase_nanos_, interval_seconds_);
}
void VrShellDelegate::RemoveDelegate() {
@@ -73,19 +47,54 @@ void VrShellDelegate::RemoveDelegate() {
delegate_ = nullptr;
}
-void VrShellDelegate::SetPresentResult(JNIEnv* env, jobject obj,
+void VrShellDelegate::SetPresentResult(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
jboolean result) {
CHECK(!present_callback_.is_null());
+ if (result && non_presenting_delegate_) {
+ non_presenting_delegate_->OnSwitchToPresentingDelegate();
+ }
present_callback_.Run(result);
present_callback_.Reset();
}
-void VrShellDelegate::DisplayActivate(JNIEnv* env, jobject obj) {
+void VrShellDelegate::DisplayActivate(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
if (device_provider_) {
device_provider_->OnDisplayActivate();
}
}
+void VrShellDelegate::UpdateVSyncInterval(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jlong timebase_nanos,
+ jdouble interval_seconds) {
+ timebase_nanos_ = timebase_nanos;
+ interval_seconds_ = interval_seconds;
+ if (delegate_) {
+ delegate_->UpdateVSyncInterval(timebase_nanos_,
+ interval_seconds_);
+ }
+ if (non_presenting_delegate_) {
+ non_presenting_delegate_->UpdateVSyncInterval(timebase_nanos_,
+ interval_seconds_);
+ }
+}
+
+void VrShellDelegate::OnPause(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
+ if (non_presenting_delegate_) {
+ non_presenting_delegate_->Pause();
+ }
+}
+
+void VrShellDelegate::OnResume(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
+ if (non_presenting_delegate_) {
+ non_presenting_delegate_->Resume();
+ }
+}
+
void VrShellDelegate::SetDeviceProvider(
device::GvrDeviceProvider* device_provider) {
device_provider_ = device_provider;
@@ -130,9 +139,11 @@ device::GvrDelegate* VrShellDelegate::GetNonPresentingDelegate() {
if (!context)
return nullptr;
- non_presenting_delegate_.reset(new GvrNonPresentingDelegate(context));
+ non_presenting_delegate_.reset(new NonPresentingGvrDelegate(context));
}
- return static_cast<GvrNonPresentingDelegate*>(non_presenting_delegate_.get());
+ non_presenting_delegate_->UpdateVSyncInterval(timebase_nanos_,
+ interval_seconds_);
+ return non_presenting_delegate_.get();
}
void VrShellDelegate::DestroyNonPresentingDelegate() {

Powered by Google App Engine
This is Rietveld 408576698