Index: chrome/browser/android/vr_shell/vr_shell.cc |
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc |
index f931b2d7a787195537d5f243747cf12b08942cb0..34a56b680ce34badb5e253fd40afb576ec65c3e4 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell.cc |
@@ -24,6 +24,8 @@ |
#include "content/public/browser/web_contents.h" |
#include "content/public/common/referrer.h" |
#include "device/vr/android/gvr/gvr_device_provider.h" |
+#include "gpu/ipc/common/gpu_surface_tracker.h" |
+#include "gpu/ipc/common/surface_handle.h" |
#include "jni/VrShellImpl_jni.h" |
#include "ui/android/view_android.h" |
#include "ui/android/window_android.h" |
@@ -31,6 +33,9 @@ |
#include "ui/display/display.h" |
#include "ui/display/screen.h" |
+#include <android/native_window.h> |
+#include <android/native_window_jni.h> |
+ |
using base::android::JavaParamRef; |
using base::android::JavaRef; |
@@ -161,6 +166,7 @@ bool RegisterVrShell(JNIEnv* env) { |
} |
VrShell::~VrShell() { |
+ VLOG(1) << __FUNCTION__ << ": Destructor for presenting delegate and its gvr_api"; |
{ |
// The GvrLayout is, and must always be, used only on the UI thread, and the |
// GvrApi used for rendering should only be used from the GL thread as it's |
@@ -238,6 +244,7 @@ void VrShell::OnDomContentsLoaded() { |
void VrShell::SetWebVrMode(JNIEnv* env, |
const base::android::JavaParamRef<jobject>& obj, |
bool enabled) { |
+ VLOG(1) << __FUNCTION__ << ": enabled=" << enabled; |
metrics_helper_->SetWebVREnabled(enabled); |
GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
PostToGlThreadWhenReady( |
@@ -249,40 +256,48 @@ void VrShell::SetWebVrMode(JNIEnv* env, |
} |
} |
-void VrShell::SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) { |
+void VrShell::SetWebVRGvrPose(const gvr::Mat4f& pose, uint32_t pose_num, int64_t pose_time_nanos) { |
GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
if (thread->IsRunning()) { |
thread->task_runner()->PostTask( |
- FROM_HERE, base::Bind(&VrShellGl::SetGvrPoseForWebVr, |
- thread->GetVrShellGl(), pose, pose_num)); |
+ FROM_HERE, base::Bind(&VrShellGl::SetWebVRGvrPose, |
+ thread->GetVrShellGl(), pose, pose_num, pose_time_nanos)); |
} |
} |
-void VrShell::SetWebVRRenderSurfaceSize(int width, int height) { |
- // TODO(klausw,crbug.com/655722): Change the GVR render size and set the WebVR |
- // render surface size. |
-} |
- |
-gvr::Sizei VrShell::GetWebVRCompositorSurfaceSize() { |
- const gfx::Size& size = content_compositor_->GetWindowBounds(); |
- return {size.width(), size.height()}; |
-} |
- |
void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
// TODO(cjgrant): Align this state with the logic that drives the omnibox. |
html_interface_->SetWebVRSecureOrigin(secure_origin); |
} |
-void VrShell::SubmitWebVRFrame() {} |
+void VrShell::SubmitWebVRFrame(int32_t surface_handle, device::mojom::VRPosePtr pose) { |
+ GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SubmitWebVRFrame, |
+ thread->GetVrShellGl(), |
+ surface_handle, |
+ std::move(pose))); |
+} |
-void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
+void VrShell::UpdateWebVRTextureBounds(uint32_t for_pose_index, |
+ const gvr::Rectf& left_bounds, |
const gvr::Rectf& right_bounds) { |
GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, |
- thread->GetVrShellGl(), left_bounds, |
+ thread->GetVrShellGl(), |
+ for_pose_index, |
+ left_bounds, |
right_bounds)); |
} |
+void VrShell::GetWebVRSurfaceHandle(int width, int height, const device::mojom::VRDisplay::GetSurfaceHandleCallback& callback) { |
+ GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::GetWebVRSurfaceHandle, |
+ thread->GetVrShellGl(), |
+ width, |
+ height, |
+ std::move(callback))); |
+} |
+ |
// TODO(mthiesse): Do not expose GVR API outside of GL thread. |
// It's not thread-safe. |
gvr::GvrApi* VrShell::gvr_api() { |
@@ -303,6 +318,10 @@ void VrShell::GvrDelegateReady() { |
delegate_->SetDelegate(this); |
} |
+void VrShell::OnWebVRFrameSubmitted(int32_t surface_handle, uint32_t frame_index, double elapsed) { |
+ delegate_->device_provider()->OnFrameSubmitted(surface_handle, frame_index, elapsed); |
+} |
+ |
void VrShell::AppButtonPressed() { |
#if defined(ENABLE_VR_SHELL) |
html_interface_->SetMenuMode(!html_interface_->GetMenuMode()); |