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 1a43be9b47ace59b6a423f32964855552595b391..9a79b1c688cd9b16a71440467a5b99e372884d51 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell.cc |
@@ -36,6 +36,7 @@ |
#include "content/public/common/referrer.h" |
#include "device/vr/android/gvr/gvr_device.h" |
#include "device/vr/android/gvr/gvr_device_provider.h" |
+#include "gpu/command_buffer/common/mailbox.h" |
#include "jni/VrShellImpl_jni.h" |
#include "third_party/WebKit/public/platform/WebInputEvent.h" |
#include "ui/android/view_android.h" |
@@ -170,6 +171,7 @@ bool RegisterVrShell(JNIEnv* env) { |
} |
VrShell::~VrShell() { |
+ delegate_provider_->RemoveDelegate(); |
{ |
// 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 |
@@ -185,7 +187,6 @@ VrShell::~VrShell() { |
base::ThreadRestrictions::ScopedAllowIO allow_io; |
gl_thread_.reset(); |
} |
- delegate_provider_->RemoveDelegate(); |
g_instance = nullptr; |
} |
@@ -271,6 +272,7 @@ void VrShell::SetWebVrMode(JNIEnv* env, |
metrics_helper_->SetWebVREnabled(enabled); |
PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetWebVrMode, |
gl_thread_->GetVrShellGl(), enabled)); |
+ |
html_interface_->SetMode(enabled ? UiInterface::Mode::WEB_VR |
: UiInterface::Mode::STANDARD); |
} |
@@ -324,14 +326,22 @@ void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
html_interface_->SetWebVRSecureOrigin(secure_origin); |
} |
-void VrShell::SubmitWebVRFrame() {} |
+void VrShell::SubmitWebVRFrame(int16_t frame_index, |
+ const gpu::MailboxHolder& mailbox) { |
+ TRACE_EVENT1("gpu", "SubmitWebVRFrame", "frame", frame_index); |
+ |
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SubmitWebVRFrame, |
+ gl_thread_->GetVrShellGl(), frame_index, |
+ mailbox)); |
+} |
void VrShell::UpdateWebVRTextureBounds(int16_t frame_index, |
const gvr::Rectf& left_bounds, |
- const gvr::Rectf& right_bounds) { |
+ const gvr::Rectf& right_bounds, |
+ const gvr::Sizei& source_size) { |
PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, |
gl_thread_->GetVrShellGl(), frame_index, |
- left_bounds, right_bounds)); |
+ left_bounds, right_bounds, source_size)); |
} |
bool VrShell::SupportsPresentation() { |
@@ -378,6 +388,10 @@ void VrShell::ContentSurfaceChanged(jobject surface) { |
} |
void VrShell::GvrDelegateReady() { |
+ PostToGlThreadWhenReady(base::Bind( |
+ &VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(), |
+ base::Passed( |
+ delegate_provider_->TakeSubmitFrameClient().PassInterface()))); |
delegate_provider_->SetDelegate(this, gvr_api_); |
} |
@@ -625,7 +639,7 @@ device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) { |
device::mojom::VRDisplayInfoPtr VrShell::CreateVRDisplayInfo( |
gvr::GvrApi* gvr_api, |
- gvr::Sizei compositor_size, |
+ gvr::Sizei recommended_size, |
uint32_t device_id) { |
TRACE_EVENT0("input", "GvrDevice::GetVRDevice"); |
@@ -654,8 +668,8 @@ device::mojom::VRDisplayInfoPtr VrShell::CreateVRDisplayInfo( |
(eye == GVR_LEFT_EYE) ? device->leftEye : device->rightEye; |
eye_params->fieldOfView = device::mojom::VRFieldOfView::New(); |
eye_params->offset.resize(3); |
- eye_params->renderWidth = compositor_size.width / 2; |
- eye_params->renderHeight = compositor_size.height; |
+ eye_params->renderWidth = recommended_size.width / 2; |
+ eye_params->renderHeight = recommended_size.height; |
gvr::BufferViewport eye_viewport = gvr_api->CreateBufferViewport(); |
gvr_buffer_viewports.GetBufferViewport(eye, &eye_viewport); |