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

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

Issue 2430543002: Draw WebVR security overlay with a non-reprojected viewport (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9f1bb69260ffe0abdcdd3bbe6189d19fcd743a16..89e6a0082881c75849c1acc03141ea0491e63546 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -245,13 +245,33 @@ void VrShell::InitializeGl(JNIEnv* env,
std::vector<gvr::BufferSpec> specs;
specs.push_back(gvr_api_->CreateBufferSpec());
render_size_ = specs[0].GetSize();
+
+ // For WebVR content
+ specs.push_back(gvr_api_->CreateBufferSpec());
+
swap_chain_.reset(new gvr::SwapChain(gvr_api_->CreateSwapChain(specs)));
vr_shell_renderer_.reset(new VrShellRenderer());
buffer_viewport_list_.reset(
new gvr::BufferViewportList(gvr_api_->CreateEmptyBufferViewportList()));
+ buffer_viewport_list_->SetToRecommendedBufferViewports();
+
buffer_viewport_.reset(
new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
+
+ overlay_left_viewport_.reset(
+ new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
+ buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE,
+ overlay_left_viewport_.get());
+ overlay_left_viewport_->SetSourceBufferIndex(1);
+ overlay_left_viewport_->SetReprojection(GVR_REPROJECTION_NONE);
+
+ overlay_right_viewport_.reset(
+ new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
+ buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE,
+ overlay_right_viewport_.get());
+ overlay_right_viewport_->SetSourceBufferIndex(1);
+ overlay_right_viewport_->SetReprojection(GVR_REPROJECTION_NONE);
}
void VrShell::UpdateController(const gvr::Vec3f& forward_vector) {
@@ -422,6 +442,13 @@ void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) {
if (webvr_mode_) {
DrawWebVr();
if (!webvr_secure_origin_) {
+ buffer_viewport_list_->SetBufferViewport(buffer_viewport_list_->GetSize(),
+ *overlay_left_viewport_);
+ buffer_viewport_list_->SetBufferViewport(buffer_viewport_list_->GetSize(),
klausw (use chromium instead) 2016/10/17 23:03:18 Using GetSize() twice seems weird. Does the SetToR
+ *overlay_right_viewport_);
+
+ // Bind back to the second default framebuffer.
klausw (use chromium instead) 2016/10/17 23:03:18 These comments are confusing. Can you rephrase thi
+ frame.BindBuffer(1);
DrawWebVrOverlay(target_time.monotonic_system_time_nanos);
}
@@ -639,6 +666,9 @@ void VrShell::DrawWebVrOverlay(int64_t present_time_nanos) {
gvr::Mat4f right_eye_view_matrix =
gvr_api_->GetEyeFromHeadMatrix(GVR_RIGHT_EYE);
+ // Don't need to clear, since we're drawing over the entire render target.
klausw (use chromium instead) 2016/10/17 23:03:18 Please delete this comment, it conflicts with the
+ glClear(GL_COLOR_BUFFER_BIT);
+
buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE,
buffer_viewport_.get());
DrawWebVrEye(left_eye_view_matrix, *buffer_viewport_, present_time_nanos);
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698