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

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

Issue 2729523002: Re-land^2 WebVR compositor bypass via BrowserMain context + mailbox (Closed)
Patch Set: Revert FrameView.cpp change, re-enable typemap workaround. Created 3 years, 9 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.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index ab3b67ac4529a57e6708f2c6ea1ef9543128f90a..922ed31c66e7d3222b746490442dbfd12efbc6e3 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"
@@ -324,14 +325,58 @@ void VrShell::SetWebVRSecureOrigin(bool secure_origin) {
html_interface_->SetWebVRSecureOrigin(secure_origin);
}
-void VrShell::SubmitWebVRFrame() {}
+void VrShell::SubmitWebVRFrame(
+ int16_t frame_index,
+ const gpu::Mailbox& mailbox,
+ const gpu::SyncToken& sync_token,
+ device::mojom::VRSubmitFrameClientPtr submit_client) {
+ TRACE_EVENT1("gpu", "SubmitWebVRFrame", "frame", frame_index);
+
+ // Save the submit completion client for later, we'll call the
+ // next lifecycle stages on it later. Use extra boolean maps
+ // to track when they get called since they could potentially
+ // be out of order, do cleanup once both were called.
+ webvr_submit_clients_.insert(
+ std::make_pair(frame_index, std::move(submit_client)));
+ webvr_submit_client_transferring_.insert({frame_index, true});
+ webvr_submit_client_rendering_.insert({frame_index, true});
+
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SubmitWebVRFrame,
+ gl_thread_->GetVrShellGl(), frame_index,
+ mailbox, sync_token));
+}
+
+void VrShell::OnSubmitWebVRFrameTransferred(int frame_index) {
+ DCHECK(webvr_submit_clients_.find(frame_index) !=
+ webvr_submit_clients_.end());
+ webvr_submit_clients_[frame_index]->OnSubmitFrameTransferred();
+ webvr_submit_client_transferring_[frame_index] = false;
+ if (!webvr_submit_client_rendering_[frame_index]) {
+ webvr_submit_clients_.erase(frame_index);
+ webvr_submit_client_transferring_.erase(frame_index);
+ webvr_submit_client_rendering_.erase(frame_index);
+ }
+}
+
+void VrShell::OnSubmitWebVRFrameRendered(int frame_index) {
+ DCHECK(webvr_submit_clients_.find(frame_index) !=
+ webvr_submit_clients_.end());
+ webvr_submit_clients_[frame_index]->OnSubmitFrameRendered();
+ webvr_submit_client_rendering_[frame_index] = false;
+ if (!webvr_submit_client_transferring_[frame_index]) {
+ webvr_submit_clients_.erase(frame_index);
+ webvr_submit_client_transferring_.erase(frame_index);
+ webvr_submit_client_rendering_.erase(frame_index);
+ }
+}
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() {
@@ -623,7 +668,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");
@@ -652,8 +697,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);

Powered by Google App Engine
This is Rietveld 408576698