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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2509483002: Fixed WebVR HTTP warning only rendering in the right eye (Closed)
Patch Set: Created 4 years, 1 month 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_interface.h" 9 #include "chrome/browser/android/vr_shell/ui_interface.h"
10 #include "chrome/browser/android/vr_shell/ui_scene.h" 10 #include "chrome/browser/android/vr_shell/ui_scene.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 558 }
559 if (rect->lock_to_fov) { 559 if (rect->lock_to_fov) {
560 head_locked_elements.push_back(rect.get()); 560 head_locked_elements.push_back(rect.get());
561 } else { 561 } else {
562 world_elements.push_back(rect.get()); 562 world_elements.push_back(rect.get());
563 } 563 }
564 } 564 }
565 565
566 bool not_web_vr = html_interface_->GetMode() != UiInterface::Mode::WEB_VR; 566 bool not_web_vr = html_interface_->GetMode() != UiInterface::Mode::WEB_VR;
567 567
568 glEnable(GL_CULL_FACE);
569 glEnable(GL_DEPTH_TEST);
570 glDepthMask(GL_TRUE);
571
568 if (not_web_vr) { 572 if (not_web_vr) {
569 glEnable(GL_CULL_FACE);
570 glEnable(GL_DEPTH_TEST);
571 glEnable(GL_SCISSOR_TEST);
572 glClearColor(0.1f, 0.1f, 0.1f, 1.0f); 573 glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
574 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
573 } 575 }
574 576
575 DrawUiView(&head_pose, world_elements, not_web_vr); 577 DrawUiView(&head_pose, world_elements);
576 578
577 if (!head_locked_elements.empty()) { 579 if (!head_locked_elements.empty()) {
578 // Switch to head-locked viewports. 580 // Switch to head-locked viewports.
579 size_t last_viewport = buffer_viewport_list_->GetSize(); 581 size_t last_viewport = buffer_viewport_list_->GetSize();
580 buffer_viewport_list_->SetBufferViewport(last_viewport++, 582 buffer_viewport_list_->SetBufferViewport(last_viewport++,
581 *headlocked_left_viewport_); 583 *headlocked_left_viewport_);
582 buffer_viewport_list_->SetBufferViewport(last_viewport++, 584 buffer_viewport_list_->SetBufferViewport(last_viewport++,
583 *headlocked_right_viewport_); 585 *headlocked_right_viewport_);
584 586
585 // Bind the headlocked framebuffer. 587 // Bind the headlocked framebuffer.
586 frame.BindBuffer(kFrameHeadlockedBuffer); 588 frame.BindBuffer(kFrameHeadlockedBuffer);
587 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 589 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
588 DrawUiView(nullptr, head_locked_elements, true); 590 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
591 DrawUiView(nullptr, head_locked_elements);
589 } 592 }
590 } 593 }
591 594
592 void VrShell::DrawUiView(const gvr::Mat4f* head_pose, 595 void VrShell::DrawUiView(const gvr::Mat4f* head_pose,
593 const std::vector<const ContentRectangle*>& elements, 596 const std::vector<const ContentRectangle*>& elements) {
594 bool clear) {
595 for (auto eye : {GVR_LEFT_EYE, GVR_RIGHT_EYE}) { 597 for (auto eye : {GVR_LEFT_EYE, GVR_RIGHT_EYE}) {
596 buffer_viewport_list_->GetBufferViewport(eye, buffer_viewport_.get()); 598 buffer_viewport_list_->GetBufferViewport(eye, buffer_viewport_.get());
597 599
598 gvr::Mat4f view_matrix = gvr_api_->GetEyeFromHeadMatrix(eye); 600 gvr::Mat4f view_matrix = gvr_api_->GetEyeFromHeadMatrix(eye);
599 if (head_pose != nullptr) { 601 if (head_pose != nullptr) {
600 view_matrix = MatrixMul(view_matrix, *head_pose); 602 view_matrix = MatrixMul(view_matrix, *head_pose);
601 } 603 }
602 604
603 gvr::Recti pixel_rect = 605 gvr::Recti pixel_rect =
604 CalculatePixelSpaceRect(render_size_, buffer_viewport_->GetSourceUv()); 606 CalculatePixelSpaceRect(render_size_, buffer_viewport_->GetSourceUv());
605 glViewport(pixel_rect.left, pixel_rect.bottom, 607 glViewport(pixel_rect.left, pixel_rect.bottom,
606 pixel_rect.right - pixel_rect.left, 608 pixel_rect.right - pixel_rect.left,
607 pixel_rect.top - pixel_rect.bottom); 609 pixel_rect.top - pixel_rect.bottom);
608 glScissor(pixel_rect.left, pixel_rect.bottom,
609 pixel_rect.right - pixel_rect.left,
610 pixel_rect.top - pixel_rect.bottom);
611
612 if (clear) {
613 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
614 }
615 610
616 const gvr::Mat4f render_matrix = MatrixMul( 611 const gvr::Mat4f render_matrix = MatrixMul(
617 PerspectiveMatrixFromView( 612 PerspectiveMatrixFromView(
618 buffer_viewport_->GetSourceFov(), kZNear, kZFar), 613 buffer_viewport_->GetSourceFov(), kZNear, kZFar),
619 view_matrix); 614 view_matrix);
620 615
621 DrawElements(render_matrix, elements); 616 DrawElements(render_matrix, elements);
622 if (head_pose != nullptr && 617 if (head_pose != nullptr &&
623 html_interface_->GetMode() != UiInterface::Mode::WEB_VR) { 618 html_interface_->GetMode() != UiInterface::Mode::WEB_VR) {
624 DrawCursor(render_matrix); 619 DrawCursor(render_matrix);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 const JavaParamRef<jobject>& ui_web_contents, 899 const JavaParamRef<jobject>& ui_web_contents,
905 jlong ui_window_android) { 900 jlong ui_window_android) {
906 return reinterpret_cast<intptr_t>(new VrShell( 901 return reinterpret_cast<intptr_t>(new VrShell(
907 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 902 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
908 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 903 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
909 content::WebContents::FromJavaWebContents(ui_web_contents), 904 content::WebContents::FromJavaWebContents(ui_web_contents),
910 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); 905 reinterpret_cast<ui::WindowAndroid*>(ui_window_android)));
911 } 906 }
912 907
913 } // namespace vr_shell 908 } // 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