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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/vr_shell/vr_shell.h" 5 #include "chrome/browser/android/vr_shell/vr_shell.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "chrome/browser/android/vr_shell/ui_elements.h" 8 #include "chrome/browser/android/vr_shell/ui_elements.h"
9 #include "chrome/browser/android/vr_shell/ui_scene.h" 9 #include "chrome/browser/android/vr_shell/ui_scene.h"
10 #include "chrome/browser/android/vr_shell/vr_compositor.h" 10 #include "chrome/browser/android/vr_shell/vr_compositor.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 CHECK(gl::GetGLImplementation() != gl::kGLImplementationNone || 238 CHECK(gl::GetGLImplementation() != gl::kGLImplementationNone ||
239 gl::init::InitializeGLOneOff()); 239 gl::init::InitializeGLOneOff());
240 240
241 content_texture_id_ = content_texture_handle; 241 content_texture_id_ = content_texture_handle;
242 ui_texture_id_ = ui_texture_handle; 242 ui_texture_id_ = ui_texture_handle;
243 243
244 gvr_api_->InitializeGl(); 244 gvr_api_->InitializeGl();
245 std::vector<gvr::BufferSpec> specs; 245 std::vector<gvr::BufferSpec> specs;
246 specs.push_back(gvr_api_->CreateBufferSpec()); 246 specs.push_back(gvr_api_->CreateBufferSpec());
247 render_size_ = specs[0].GetSize(); 247 render_size_ = specs[0].GetSize();
248
249 // For WebVR content
250 specs.push_back(gvr_api_->CreateBufferSpec());
251
248 swap_chain_.reset(new gvr::SwapChain(gvr_api_->CreateSwapChain(specs))); 252 swap_chain_.reset(new gvr::SwapChain(gvr_api_->CreateSwapChain(specs)));
249 253
250 vr_shell_renderer_.reset(new VrShellRenderer()); 254 vr_shell_renderer_.reset(new VrShellRenderer());
251 buffer_viewport_list_.reset( 255 buffer_viewport_list_.reset(
252 new gvr::BufferViewportList(gvr_api_->CreateEmptyBufferViewportList())); 256 new gvr::BufferViewportList(gvr_api_->CreateEmptyBufferViewportList()));
257 buffer_viewport_list_->SetToRecommendedBufferViewports();
258
253 buffer_viewport_.reset( 259 buffer_viewport_.reset(
254 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); 260 new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
261
262 overlay_left_viewport_.reset(
263 new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
264 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE,
265 overlay_left_viewport_.get());
266 overlay_left_viewport_->SetSourceBufferIndex(1);
267 overlay_left_viewport_->SetReprojection(GVR_REPROJECTION_NONE);
268
269 overlay_right_viewport_.reset(
270 new gvr::BufferViewport(gvr_api_->CreateBufferViewport()));
271 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE,
272 overlay_right_viewport_.get());
273 overlay_right_viewport_->SetSourceBufferIndex(1);
274 overlay_right_viewport_->SetReprojection(GVR_REPROJECTION_NONE);
255 } 275 }
256 276
257 void VrShell::UpdateController(const gvr::Vec3f& forward_vector) { 277 void VrShell::UpdateController(const gvr::Vec3f& forward_vector) {
258 controller_->UpdateState(); 278 controller_->UpdateState();
259 std::unique_ptr<VrGesture> gesture = controller_->DetectGesture(); 279 std::unique_ptr<VrGesture> gesture = controller_->DetectGesture();
260 280
261 // TODO(asimjour) for now, scroll is sent to the main content. 281 // TODO(asimjour) for now, scroll is sent to the main content.
262 if (gesture->type == WebInputEvent::GestureScrollBegin || 282 if (gesture->type == WebInputEvent::GestureScrollBegin ||
263 gesture->type == WebInputEvent::GestureScrollUpdate || 283 gesture->type == WebInputEvent::GestureScrollUpdate ||
264 gesture->type == WebInputEvent::GestureScrollEnd) { 284 gesture->type == WebInputEvent::GestureScrollEnd) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // it. For now, removing it seems working fine. 435 // it. For now, removing it seems working fine.
416 gvr_api_->ApplyNeckModel(head_pose, 1.0f); 436 gvr_api_->ApplyNeckModel(head_pose, 1.0f);
417 } 437 }
418 438
419 // Bind back to the default framebuffer. 439 // Bind back to the default framebuffer.
420 frame.BindBuffer(0); 440 frame.BindBuffer(0);
421 441
422 if (webvr_mode_) { 442 if (webvr_mode_) {
423 DrawWebVr(); 443 DrawWebVr();
424 if (!webvr_secure_origin_) { 444 if (!webvr_secure_origin_) {
445 buffer_viewport_list_->SetBufferViewport(buffer_viewport_list_->GetSize(),
446 *overlay_left_viewport_);
447 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
448 *overlay_right_viewport_);
449
450 // 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
451 frame.BindBuffer(1);
425 DrawWebVrOverlay(target_time.monotonic_system_time_nanos); 452 DrawWebVrOverlay(target_time.monotonic_system_time_nanos);
426 } 453 }
427 454
428 // When using async reprojection, we need to know which pose was used in 455 // When using async reprojection, we need to know which pose was used in
429 // the WebVR app for drawing this frame. Due to unknown amounts of 456 // the WebVR app for drawing this frame. Due to unknown amounts of
430 // buffering in the compositor and SurfaceTexture, we read the pose number 457 // buffering in the compositor and SurfaceTexture, we read the pose number
431 // from a corner pixel. There's no point in doing this for legacy 458 // from a corner pixel. There's no point in doing this for legacy
432 // distortion rendering since that doesn't need a pose, and reading back 459 // distortion rendering since that doesn't need a pose, and reading back
433 // pixels is an expensive operation. TODO(klausw): stop doing this once we 460 // pixels is an expensive operation. TODO(klausw): stop doing this once we
434 // have working no-compositor rendering for WebVR. 461 // have working no-compositor rendering for WebVR.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 void VrShell::DrawWebVrOverlay(int64_t present_time_nanos) { 659 void VrShell::DrawWebVrOverlay(int64_t present_time_nanos) {
633 // Draw WebVR security warning overlays for each eye. This uses the 660 // Draw WebVR security warning overlays for each eye. This uses the
634 // eye-from-head matrices but not the pose, goal is to place the icons in an 661 // eye-from-head matrices but not the pose, goal is to place the icons in an
635 // eye-relative position so that they follow along with head rotations. 662 // eye-relative position so that they follow along with head rotations.
636 663
637 gvr::Mat4f left_eye_view_matrix = 664 gvr::Mat4f left_eye_view_matrix =
638 gvr_api_->GetEyeFromHeadMatrix(GVR_LEFT_EYE); 665 gvr_api_->GetEyeFromHeadMatrix(GVR_LEFT_EYE);
639 gvr::Mat4f right_eye_view_matrix = 666 gvr::Mat4f right_eye_view_matrix =
640 gvr_api_->GetEyeFromHeadMatrix(GVR_RIGHT_EYE); 667 gvr_api_->GetEyeFromHeadMatrix(GVR_RIGHT_EYE);
641 668
669 // 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
670 glClear(GL_COLOR_BUFFER_BIT);
671
642 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, 672 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE,
643 buffer_viewport_.get()); 673 buffer_viewport_.get());
644 DrawWebVrEye(left_eye_view_matrix, *buffer_viewport_, present_time_nanos); 674 DrawWebVrEye(left_eye_view_matrix, *buffer_viewport_, present_time_nanos);
645 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, 675 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE,
646 buffer_viewport_.get()); 676 buffer_viewport_.get());
647 DrawWebVrEye(right_eye_view_matrix, *buffer_viewport_, present_time_nanos); 677 DrawWebVrEye(right_eye_view_matrix, *buffer_viewport_, present_time_nanos);
648 } 678 }
649 679
650 void VrShell::DrawWebVrEye(const gvr::Mat4f& view_matrix, 680 void VrShell::DrawWebVrEye(const gvr::Mat4f& view_matrix,
651 const gvr::BufferViewport& params, 681 const gvr::BufferViewport& params,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 const JavaParamRef<jobject>& ui_web_contents, 897 const JavaParamRef<jobject>& ui_web_contents,
868 jlong ui_window_android) { 898 jlong ui_window_android) {
869 return reinterpret_cast<intptr_t>(new VrShell( 899 return reinterpret_cast<intptr_t>(new VrShell(
870 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 900 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
871 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 901 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
872 content::WebContents::FromJavaWebContents(ui_web_contents), 902 content::WebContents::FromJavaWebContents(ui_web_contents),
873 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); 903 reinterpret_cast<ui::WindowAndroid*>(ui_window_android)));
874 } 904 }
875 905
876 } // namespace vr_shell 906 } // namespace vr_shell
OLDNEW
« 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