OLD | NEW |
---|---|
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_gl.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 | 480 |
481 // Determine which UI element (if any) intersects the line between the eyes | 481 // Determine which UI element (if any) intersects the line between the eyes |
482 // and the controller target position. | 482 // and the controller target position. |
483 float closest_element_distance = std::numeric_limits<float>::infinity(); | 483 float closest_element_distance = std::numeric_limits<float>::infinity(); |
484 int pixel_x = 0; | 484 int pixel_x = 0; |
485 int pixel_y = 0; | 485 int pixel_y = 0; |
486 target_element_ = nullptr; | 486 target_element_ = nullptr; |
487 InputTarget input_target = InputTarget::NONE; | 487 InputTarget input_target = InputTarget::NONE; |
488 | 488 |
489 for (const auto& plane : scene_->GetUiElements()) { | 489 for (const auto& plane : scene_->GetUiElements()) { |
490 if (!plane->visible || !plane->hit_testable) { | 490 if (!plane->visible || plane->computed_opacity == 0.0f || |
cjgrant
2017/01/11 16:45:47
Checking opacity here relieves the HTML UI of havi
mthiesse
2017/01/11 18:33:04
Maybe add a function IsVisible() to ContentRectang
cjgrant
2017/01/11 20:58:42
Done.
| |
491 !plane->hit_testable) { | |
491 continue; | 492 continue; |
492 } | 493 } |
493 float distance_to_plane = plane->GetRayDistance(kOrigin, eye_to_target); | 494 float distance_to_plane = plane->GetRayDistance(kOrigin, eye_to_target); |
494 gvr::Vec3f plane_intersection_point = | 495 gvr::Vec3f plane_intersection_point = |
495 GetRayPoint(kOrigin, eye_to_target, distance_to_plane); | 496 GetRayPoint(kOrigin, eye_to_target, distance_to_plane); |
496 | 497 |
497 gvr::Vec3f rect_2d_point = | 498 gvr::Vec3f rect_2d_point = |
498 MatrixVectorMul(plane->transform.from_world, plane_intersection_point); | 499 MatrixVectorMul(plane->transform.from_world, plane_intersection_point); |
499 if (distance_to_plane > 0 && distance_to_plane < closest_element_distance) { | 500 if (distance_to_plane > 0 && distance_to_plane < closest_element_distance) { |
500 float x = rect_2d_point.x + 0.5f; | 501 float x = rect_2d_point.x + 0.5f; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 ScheduleNextDrawFrame(); | 695 ScheduleNextDrawFrame(); |
695 } | 696 } |
696 } | 697 } |
697 | 698 |
698 void VrShellGl::DrawVrShell(const gvr::Mat4f& head_pose, | 699 void VrShellGl::DrawVrShell(const gvr::Mat4f& head_pose, |
699 gvr::Frame &frame) { | 700 gvr::Frame &frame) { |
700 TRACE_EVENT0("gpu", "VrShellGl::DrawVrShell"); | 701 TRACE_EVENT0("gpu", "VrShellGl::DrawVrShell"); |
701 std::vector<const ContentRectangle*> head_locked_elements; | 702 std::vector<const ContentRectangle*> head_locked_elements; |
702 std::vector<const ContentRectangle*> world_elements; | 703 std::vector<const ContentRectangle*> world_elements; |
703 for (const auto& rect : scene_->GetUiElements()) { | 704 for (const auto& rect : scene_->GetUiElements()) { |
704 if (!rect->visible) { | 705 if (!rect->visible || rect->computed_opacity == 0.0f) { |
705 continue; | 706 continue; |
706 } | 707 } |
707 if (rect->lock_to_fov) { | 708 if (rect->lock_to_fov) { |
708 head_locked_elements.push_back(rect.get()); | 709 head_locked_elements.push_back(rect.get()); |
709 } else { | 710 } else { |
710 world_elements.push_back(rect.get()); | 711 world_elements.push_back(rect.get()); |
711 } | 712 } |
712 } | 713 } |
713 | 714 |
714 if (web_vr_mode_) { | 715 if (web_vr_mode_) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_css_width_; | 807 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_css_width_; |
807 copy_rect.y = static_cast<float>(rect->copy_rect.y) / ui_tex_css_height_; | 808 copy_rect.y = static_cast<float>(rect->copy_rect.y) / ui_tex_css_height_; |
808 copy_rect.width = static_cast<float>(rect->copy_rect.width) / | 809 copy_rect.width = static_cast<float>(rect->copy_rect.width) / |
809 ui_tex_css_width_; | 810 ui_tex_css_width_; |
810 copy_rect.height = static_cast<float>(rect->copy_rect.height) / | 811 copy_rect.height = static_cast<float>(rect->copy_rect.height) / |
811 ui_tex_css_height_; | 812 ui_tex_css_height_; |
812 texture_handle = ui_texture_id_; | 813 texture_handle = ui_texture_id_; |
813 } | 814 } |
814 gvr::Mat4f transform = MatrixMul(render_matrix, rect->transform.to_world); | 815 gvr::Mat4f transform = MatrixMul(render_matrix, rect->transform.to_world); |
815 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( | 816 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( |
816 texture_handle, transform, copy_rect); | 817 texture_handle, transform, copy_rect, rect->computed_opacity); |
817 } | 818 } |
818 } | 819 } |
819 | 820 |
820 void VrShellGl::DrawCursor(const gvr::Mat4f& render_matrix) { | 821 void VrShellGl::DrawCursor(const gvr::Mat4f& render_matrix) { |
821 gvr::Mat4f mat; | 822 gvr::Mat4f mat; |
822 SetIdentityM(mat); | 823 SetIdentityM(mat); |
823 | 824 |
824 // Draw the reticle. | 825 // Draw the reticle. |
825 | 826 |
826 // Scale the pointer to have a fixed FOV size at any distance. | 827 // Scale the pointer to have a fixed FOV size at any distance. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
997 void VrShellGl::ForceExitVr() { | 998 void VrShellGl::ForceExitVr() { |
998 main_thread_task_runner_->PostTask( | 999 main_thread_task_runner_->PostTask( |
999 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); | 1000 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); |
1000 } | 1001 } |
1001 | 1002 |
1002 void VrShellGl::UpdateScene(std::unique_ptr<base::ListValue> commands) { | 1003 void VrShellGl::UpdateScene(std::unique_ptr<base::ListValue> commands) { |
1003 scene_->HandleCommands(std::move(commands), TimeInMicroseconds()); | 1004 scene_->HandleCommands(std::move(commands), TimeInMicroseconds()); |
1004 } | 1005 } |
1005 | 1006 |
1006 } // namespace vr_shell | 1007 } // namespace vr_shell |
OLD | NEW |