Commit 95fa24b1 authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

VR: Fix broken hover in testapp

This makes the testapp rendering code more closely match vr_shell_gl,
alleviating the annoying hover issue (a button may stay hovered even
when the reticle had moved away).

BUG=
R=ymalik

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I6b1bd7006c9ff319c177d721a309d82906a69153
Reviewed-on: https://chromium-review.googlesource.com/998740Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548761}
parent ea41ab27
......@@ -127,22 +127,24 @@ void VrTestContext::DrawFrame() {
RenderInfo render_info = GetRenderInfo();
UpdateController(render_info);
// Update the render position of all UI elements (including desktop).
ui_->scene()->OnBeginFrame(current_time, head_pose_);
ui_->OnProjMatrixChanged(render_info.left_eye_model.proj_matrix);
if (web_vr_mode_ && ui_->ShouldRenderWebVr() && webvr_frames_received_) {
ui_->ui_renderer()->DrawWebVrOverlayForeground(render_info);
} else {
ui_->ui_renderer()->Draw(render_info);
}
UpdateController(render_info, current_time);
ui_->scene()->UpdateTextures();
auto load_progress = (current_time - page_load_start_).InMilliseconds() /
kPageLoadTimeMilliseconds;
ui_->SetLoading(load_progress < 1.0f);
ui_->SetLoadProgress(std::min(load_progress, 1.0f));
if (web_vr_mode_ && ui_->ShouldRenderWebVr() && webvr_frames_received_) {
ui_->ui_renderer()->DrawWebVrOverlayForeground(render_info);
} else {
ui_->ui_renderer()->Draw(render_info);
}
}
void VrTestContext::HandleInput(ui::Event* event) {
......@@ -297,10 +299,10 @@ void VrTestContext::HandleInput(ui::Event* event) {
head_pose_.RotateAboutYAxis(-head_angle_y_degrees_);
last_mouse_point_ = gfx::Point(mouse_event->x(), mouse_event->y());
last_controller_model_ = UpdateController(GetRenderInfo());
}
ControllerModel VrTestContext::UpdateController(const RenderInfo& render_info) {
ControllerModel VrTestContext::UpdateController(const RenderInfo& render_info,
base::TimeTicks current_time) {
// We could map mouse position to controller position, and skip this logic,
// but it will make targeting elements with a mouse feel strange and not
// mouse-like. Instead, we make the reticle track the mouse position linearly
......@@ -348,9 +350,8 @@ ControllerModel VrTestContext::UpdateController(const RenderInfo& render_info) {
// Hit testing is done in terms of this synthesized controller model.
GestureList gesture_list;
ReticleModel reticle_model;
ui_->input_manager()->HandleInput(base::TimeTicks::Now(), render_info,
controller_model, &reticle_model,
&gesture_list);
ui_->input_manager()->HandleInput(current_time, render_info, controller_model,
&reticle_model, &gesture_list);
// Now that we have accurate hit information, we use this to construct a
// controller model for display.
......
......@@ -72,7 +72,8 @@ class VrTestContext : public vr::UiBrowserInterface {
RenderInfo GetRenderInfo() const;
gfx::Transform ProjectionMatrix() const;
gfx::Transform ViewProjectionMatrix() const;
ControllerModel UpdateController(const RenderInfo& render_info);
ControllerModel UpdateController(const RenderInfo& render_info,
base::TimeTicks current_time);
gfx::Point3F LaserOrigin() const;
void LoadAssets();
......@@ -102,8 +103,6 @@ class VrTestContext : public vr::UiBrowserInterface {
bool touching_touchpad_ = false;
base::TimeTicks page_load_start_;
ControllerModel last_controller_model_;
std::unique_ptr<TextInputDelegate> text_input_delegate_;
std::unique_ptr<TestKeyboardDelegate> keyboard_delegate_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment