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

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

Issue 2624243002: VrShell: Allow native control of UI element opacity. (Closed)
Patch Set: for (auto nit : nits) nit.fix(); Created 3 years, 11 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
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_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
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->IsHitTestable())
491 continue; 491 continue;
492 } 492
493 float distance_to_plane = plane->GetRayDistance(kOrigin, eye_to_target); 493 float distance_to_plane = plane->GetRayDistance(kOrigin, eye_to_target);
494 gvr::Vec3f plane_intersection_point = 494 gvr::Vec3f plane_intersection_point =
495 GetRayPoint(kOrigin, eye_to_target, distance_to_plane); 495 GetRayPoint(kOrigin, eye_to_target, distance_to_plane);
496 496
497 gvr::Vec3f rect_2d_point = 497 gvr::Vec3f rect_2d_point =
498 MatrixVectorMul(plane->transform.from_world, plane_intersection_point); 498 MatrixVectorMul(plane->transform.from_world, plane_intersection_point);
499 if (distance_to_plane > 0 && distance_to_plane < closest_element_distance) { 499 if (distance_to_plane > 0 && distance_to_plane < closest_element_distance) {
500 float x = rect_2d_point.x + 0.5f; 500 float x = rect_2d_point.x + 0.5f;
501 float y = 0.5f - rect_2d_point.y; 501 float y = 0.5f - rect_2d_point.y;
502 bool is_inside = x >= 0.0f && x < 1.0f && y >= 0.0f && y < 1.0f; 502 bool is_inside = x >= 0.0f && x < 1.0f && y >= 0.0f && y < 1.0f;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 ScheduleNextDrawFrame(); 694 ScheduleNextDrawFrame();
695 } 695 }
696 } 696 }
697 697
698 void VrShellGl::DrawVrShell(const gvr::Mat4f& head_pose, 698 void VrShellGl::DrawVrShell(const gvr::Mat4f& head_pose,
699 gvr::Frame &frame) { 699 gvr::Frame &frame) {
700 TRACE_EVENT0("gpu", "VrShellGl::DrawVrShell"); 700 TRACE_EVENT0("gpu", "VrShellGl::DrawVrShell");
701 std::vector<const ContentRectangle*> head_locked_elements; 701 std::vector<const ContentRectangle*> head_locked_elements;
702 std::vector<const ContentRectangle*> world_elements; 702 std::vector<const ContentRectangle*> world_elements;
703 for (const auto& rect : scene_->GetUiElements()) { 703 for (const auto& rect : scene_->GetUiElements()) {
704 if (!rect->visible) { 704 if (!rect->IsVisible())
705 continue; 705 continue;
706 }
707 if (rect->lock_to_fov) { 706 if (rect->lock_to_fov) {
708 head_locked_elements.push_back(rect.get()); 707 head_locked_elements.push_back(rect.get());
709 } else { 708 } else {
710 world_elements.push_back(rect.get()); 709 world_elements.push_back(rect.get());
711 } 710 }
712 } 711 }
713 712
714 if (web_vr_mode_) { 713 if (web_vr_mode_) {
715 // WebVR is incompatible with 3D world compositing since the 714 // WebVR is incompatible with 3D world compositing since the
716 // depth buffer was already populated with unknown scaling - the 715 // depth buffer was already populated with unknown scaling - the
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_css_width_; 805 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_; 806 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) / 807 copy_rect.width = static_cast<float>(rect->copy_rect.width) /
809 ui_tex_css_width_; 808 ui_tex_css_width_;
810 copy_rect.height = static_cast<float>(rect->copy_rect.height) / 809 copy_rect.height = static_cast<float>(rect->copy_rect.height) /
811 ui_tex_css_height_; 810 ui_tex_css_height_;
812 texture_handle = ui_texture_id_; 811 texture_handle = ui_texture_id_;
813 } 812 }
814 gvr::Mat4f transform = MatrixMul(render_matrix, rect->transform.to_world); 813 gvr::Mat4f transform = MatrixMul(render_matrix, rect->transform.to_world);
815 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( 814 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw(
816 texture_handle, transform, copy_rect); 815 texture_handle, transform, copy_rect, rect->computed_opacity);
817 } 816 }
818 } 817 }
819 818
820 void VrShellGl::DrawCursor(const gvr::Mat4f& render_matrix) { 819 void VrShellGl::DrawCursor(const gvr::Mat4f& render_matrix) {
821 gvr::Mat4f mat; 820 gvr::Mat4f mat;
822 SetIdentityM(mat); 821 SetIdentityM(mat);
823 822
824 // Draw the reticle. 823 // Draw the reticle.
825 824
826 // Scale the pointer to have a fixed FOV size at any distance. 825 // Scale the pointer to have a fixed FOV size at any distance.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 void VrShellGl::ForceExitVr() { 996 void VrShellGl::ForceExitVr() {
998 main_thread_task_runner_->PostTask( 997 main_thread_task_runner_->PostTask(
999 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); 998 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_));
1000 } 999 }
1001 1000
1002 void VrShellGl::UpdateScene(std::unique_ptr<base::ListValue> commands) { 1001 void VrShellGl::UpdateScene(std::unique_ptr<base::ListValue> commands) {
1003 scene_->HandleCommands(std::move(commands), TimeInMicroseconds()); 1002 scene_->HandleCommands(std::move(commands), TimeInMicroseconds());
1004 } 1003 }
1005 1004
1006 } // namespace vr_shell 1005 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_unittest.cc ('k') | chrome/browser/android/vr_shell/vr_shell_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698