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

Unified Diff: chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h

Issue 2624633002: Remove Sync GetPose VRService call, implement VRVSyncProvider (Closed)
Patch Set: nits 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/non_presenting_gvr_delegate.h
diff --git a/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h b/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..f4b044564220225522c039d40e061df08cfe6868
--- /dev/null
+++ b/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_
+#define CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_
+
+#include <jni.h>
+
+#include "base/cancelable_callback.h"
+#include "base/macros.h"
+#include "device/vr/android/gvr/gvr_delegate.h"
+#include "device/vr/vr_service.mojom.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+namespace vr_shell {
+
+// A non presenting delegate for magic window mode.
+class NonPresentingGvrDelegate : public device::GvrDelegate,
+ public device::mojom::VRVSyncProvider {
+ public:
+ explicit NonPresentingGvrDelegate(long context);
+
+ ~NonPresentingGvrDelegate();
+
+ // 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 SetWebVRRenderSurfaceSize(int width, int height) override {}
+ gvr::Sizei GetWebVRCompositorSurfaceSize() override {
+ return device::kInvalidRenderTargetSize; }
+ gvr::GvrApi* gvr_api() override { return gvr_api_.get(); }
+ void OnVRVsyncProviderRequest(
+ device::mojom::VRVSyncProviderRequest request) override;
+ void UpdateVSyncInterval(long timebase_nanos,
+ double interval_seconds) override;
+
+ void Pause();
+ void Resume();
+ device::mojom::VRVSyncProviderRequest OnSwitchToPresentingDelegate();
+
+ private:
+ void StopVSyncLoop();
+ void StartVSyncLoop();
+ void OnVSync();
+ void GetVSync(const GetVSyncCallback& callback);
+ device::mojom::VRPosePtr GetPose();
+
+ std::unique_ptr<gvr::GvrApi> gvr_api_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ base::CancelableClosure vsync_task_;
+ base::TimeTicks vsync_timebase_;
+ base::TimeDelta vsync_interval_;
+
+ bool paused_ = false;
+ base::TimeDelta pending_time_;
+ bool pending_vsync_ = false;
+ GetVSyncCallback callback_;
+ bool received_frame_ = false;
+ uint32_t pose_index_ = 1;
+ mojo::Binding<device::mojom::VRVSyncProvider> binding_;
+ base::WeakPtrFactory<NonPresentingGvrDelegate> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(NonPresentingGvrDelegate);
+};
+
+} // namespace vr_shell
+
+#endif // CHROME_BROWSER_ANDROID_VR_SHELL_NON_PRESENTING_GVR_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698