Chromium Code Reviews| 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.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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 static constexpr float kReticleOffset = 0.99f; | 66 static constexpr float kReticleOffset = 0.99f; |
| 67 | 67 |
| 68 // Limit the rendering distance of the reticle to the distance to a corner of | 68 // Limit the rendering distance of the reticle to the distance to a corner of |
| 69 // the content quad, times this value. This lets the rendering distance | 69 // the content quad, times this value. This lets the rendering distance |
| 70 // adjust according to content quad placement. | 70 // adjust according to content quad placement. |
| 71 static constexpr float kReticleDistanceMultiplier = 1.5f; | 71 static constexpr float kReticleDistanceMultiplier = 1.5f; |
| 72 | 72 |
| 73 // UI element 0 is the browser content rectangle. | 73 // UI element 0 is the browser content rectangle. |
| 74 static constexpr int kBrowserUiElementId = 0; | 74 static constexpr int kBrowserUiElementId = 0; |
| 75 | 75 |
| 76 // Positions and sizes of statically placed UI elements in the UI texture. | |
| 77 // TODO(klausw): replace the hardcoded positions with JS position/offset | |
| 78 // retrieval once the infrastructure for that is hooked up. | |
| 79 // | |
| 80 // UI is designed with 1 pixel = 1mm at 1m distance. It's rescaled to | |
| 81 // maintain the same angular resolution if placed closer or further. | |
| 82 // The warning overlays should be fairly close since they cut holes | |
| 83 // into geometry (they ignore the Z buffer), leading to odd effects | |
| 84 // if they are far away. | |
| 85 static constexpr vr_shell::Recti kWebVrWarningTransientRect = { | |
| 86 0, 128, 512, 250}; | |
| 87 static constexpr vr_shell::Recti kWebVrWarningPermanentRect = {0, 0, 512, 128}; | |
| 88 static constexpr float kWebVrWarningDistance = 0.7f; // meters | |
| 89 static constexpr float kWebVrWarningPermanentAngle = 16.3f; // degrees up | |
| 90 // How long the transient warning needs to be displayed. | |
| 91 static constexpr int64_t kWebVrWarningSeconds = 30; | |
| 92 | |
| 93 static constexpr int kFramePrimaryBuffer = 0; | 76 static constexpr int kFramePrimaryBuffer = 0; |
| 94 static constexpr int kFrameHeadlockedBuffer = 1; | 77 static constexpr int kFrameHeadlockedBuffer = 1; |
| 95 | 78 |
| 96 vr_shell::VrShell* g_instance; | 79 vr_shell::VrShell* g_instance; |
| 97 | 80 |
| 98 static const char kVrShellUIURL[] = "chrome://vr-shell-ui"; | 81 static const char kVrShellUIURL[] = "chrome://vr-shell-ui"; |
| 99 | 82 |
| 100 float Distance(const gvr::Vec3f& vec1, const gvr::Vec3f& vec2) { | 83 float Distance(const gvr::Vec3f& vec1, const gvr::Vec3f& vec2) { |
| 101 float xdiff = (vec1.x - vec2.x); | 84 float xdiff = (vec1.x - vec2.x); |
| 102 float ydiff = (vec1.y - vec2.y); | 85 float ydiff = (vec1.y - vec2.y); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 // The head pose has redundant data. Assume we're only using the | 420 // The head pose has redundant data. Assume we're only using the |
| 438 // object_from_reference_matrix, we're not updating position_external. | 421 // object_from_reference_matrix, we're not updating position_external. |
| 439 // TODO: Not sure what object_from_reference_matrix is. The new api removed | 422 // TODO: Not sure what object_from_reference_matrix is. The new api removed |
| 440 // it. For now, removing it seems working fine. | 423 // it. For now, removing it seems working fine. |
| 441 gvr_api_->ApplyNeckModel(head_pose, 1.0f); | 424 gvr_api_->ApplyNeckModel(head_pose, 1.0f); |
| 442 } | 425 } |
| 443 | 426 |
| 444 // Bind the primary framebuffer. | 427 // Bind the primary framebuffer. |
| 445 frame.BindBuffer(kFramePrimaryBuffer); | 428 frame.BindBuffer(kFramePrimaryBuffer); |
| 446 | 429 |
| 430 HandleQueuedTasks(); | |
| 431 | |
| 432 // Update the render position of all UI elements (including desktop). | |
| 433 float screen_tilt = desktop_screen_tilt_ * M_PI / 180.0f; | |
| 434 scene_->UpdateTransforms(screen_tilt, UiScene::TimeInMicroseconds()); | |
| 435 | |
| 447 if (webvr_mode_) { | 436 if (webvr_mode_) { |
| 448 DrawWebVr(); | 437 DrawWebVr(); |
| 449 // Wait for the DOM contents to be loaded before rendering to avoid drawing | |
| 450 // white rectangles with no content. | |
| 451 if (!webvr_secure_origin_ && IsUiTextureReady()) { | |
| 452 size_t last_viewport = buffer_viewport_list_->GetSize(); | |
| 453 buffer_viewport_list_->SetBufferViewport(last_viewport++, | |
| 454 *headlocked_left_viewport_); | |
| 455 buffer_viewport_list_->SetBufferViewport(last_viewport++, | |
| 456 *headlocked_right_viewport_); | |
| 457 | 438 |
| 458 // Bind the headlocked framebuffer. | 439 size_t last_viewport = buffer_viewport_list_->GetSize(); |
| 459 frame.BindBuffer(kFrameHeadlockedBuffer); | 440 buffer_viewport_list_->SetBufferViewport(last_viewport++, |
| 460 DrawWebVrOverlay(target_time.monotonic_system_time_nanos); | 441 *headlocked_left_viewport_); |
| 461 } | 442 buffer_viewport_list_->SetBufferViewport(last_viewport++, |
| 443 *headlocked_right_viewport_); | |
| 444 | |
| 445 // Bind the headlocked framebuffer. | |
| 446 frame.BindBuffer(kFrameHeadlockedBuffer); | |
|
bajones
2016/10/24 21:12:27
I don't know how much of a perf hit this introduce
cjgrant
2016/10/24 21:34:57
On determining if there's anything to draw: Yes,
cjgrant
2016/10/25 20:09:07
So this refactor was a little bigger than I expect
| |
| 462 | 447 |
| 463 // When using async reprojection, we need to know which pose was used in | 448 // When using async reprojection, we need to know which pose was used in |
| 464 // the WebVR app for drawing this frame. Due to unknown amounts of | 449 // the WebVR app for drawing this frame. Due to unknown amounts of |
| 465 // buffering in the compositor and SurfaceTexture, we read the pose number | 450 // buffering in the compositor and SurfaceTexture, we read the pose number |
| 466 // from a corner pixel. There's no point in doing this for legacy | 451 // from a corner pixel. There's no point in doing this for legacy |
| 467 // distortion rendering since that doesn't need a pose, and reading back | 452 // distortion rendering since that doesn't need a pose, and reading back |
| 468 // pixels is an expensive operation. TODO(klausw): stop doing this once we | 453 // pixels is an expensive operation. TODO(klausw): stop doing this once we |
| 469 // have working no-compositor rendering for WebVR. | 454 // have working no-compositor rendering for WebVR. |
| 470 if (gvr_api_->GetAsyncReprojectionEnabled()) { | 455 if (gvr_api_->GetAsyncReprojectionEnabled()) { |
| 471 uint32_t webvr_pose_frame = GetPixelEncodedPoseIndex(); | 456 uint32_t webvr_pose_frame = GetPixelEncodedPoseIndex(); |
| 472 head_pose = webvr_head_pose_[webvr_pose_frame % kPoseRingBufferSize]; | 457 head_pose = webvr_head_pose_[webvr_pose_frame % kPoseRingBufferSize]; |
| 473 } | 458 } |
| 474 } else { | 459 } else { |
| 475 DrawVrShell(head_pose); | 460 UpdateController(GetForwardVector(head_pose)); |
| 476 } | 461 } |
| 477 | 462 |
| 463 DrawVrShell(head_pose); | |
| 464 | |
| 478 frame.Unbind(); | 465 frame.Unbind(); |
| 479 frame.Submit(*buffer_viewport_list_, head_pose); | 466 frame.Submit(*buffer_viewport_list_, head_pose); |
| 480 } | 467 } |
| 481 | 468 |
| 482 void VrShell::DrawVrShell(const gvr::Mat4f& head_pose) { | 469 void VrShell::DrawVrShell(const gvr::Mat4f& head_pose) { |
| 483 float screen_tilt = desktop_screen_tilt_ * M_PI / 180.0f; | 470 if (!webvr_mode_) { |
| 484 | 471 glEnable(GL_CULL_FACE); |
|
cjgrant
2016/10/24 20:05:09
Brandon, in this CL, I try to leave the sequence o
bajones
2016/10/24 21:12:27
Sure, let's grab a moment to chat. Stick something
| |
| 485 HandleQueuedTasks(); | 472 glEnable(GL_DEPTH_TEST); |
| 486 | 473 glEnable(GL_SCISSOR_TEST); |
| 487 // Update the render position of all UI elements (including desktop). | 474 glClearColor(0.1f, 0.1f, 0.1f, 1.0f); |
| 488 scene_->UpdateTransforms(screen_tilt, UiScene::TimeInMicroseconds()); | 475 } else { |
| 489 | 476 glClear(GL_COLOR_BUFFER_BIT); |
| 490 UpdateController(GetForwardVector(head_pose)); | 477 } |
| 491 | |
| 492 // Use culling to remove back faces. | |
| 493 glEnable(GL_CULL_FACE); | |
| 494 | |
| 495 // Enable depth testing. | |
| 496 glEnable(GL_DEPTH_TEST); | |
| 497 glEnable(GL_SCISSOR_TEST); | |
| 498 | |
| 499 glClearColor(0.1f, 0.1f, 0.1f, 1.0f); | |
| 500 | 478 |
| 501 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, | 479 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, |
| 502 buffer_viewport_.get()); | 480 buffer_viewport_.get()); |
| 503 DrawEye(GVR_LEFT_EYE, head_pose, *buffer_viewport_); | 481 DrawEye(GVR_LEFT_EYE, head_pose, *buffer_viewport_); |
| 504 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, | 482 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, |
| 505 buffer_viewport_.get()); | 483 buffer_viewport_.get()); |
| 506 DrawEye(GVR_RIGHT_EYE, head_pose, *buffer_viewport_); | 484 DrawEye(GVR_RIGHT_EYE, head_pose, *buffer_viewport_); |
| 507 } | 485 } |
| 508 | 486 |
| 509 void VrShell::DrawEye(gvr::Eye eye, | 487 void VrShell::DrawEye(gvr::Eye eye, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 521 pixel_rect.right - pixel_rect.left, | 499 pixel_rect.right - pixel_rect.left, |
| 522 pixel_rect.top - pixel_rect.bottom); | 500 pixel_rect.top - pixel_rect.bottom); |
| 523 | 501 |
| 524 const gvr::Mat4f fov_render_matrix = MatrixMul( | 502 const gvr::Mat4f fov_render_matrix = MatrixMul( |
| 525 PerspectiveMatrixFromView(params.GetSourceFov(), kZNear, kZFar), | 503 PerspectiveMatrixFromView(params.GetSourceFov(), kZNear, kZFar), |
| 526 eye_matrix); | 504 eye_matrix); |
| 527 const gvr::Mat4f world_render_matrix = MatrixMul( | 505 const gvr::Mat4f world_render_matrix = MatrixMul( |
| 528 PerspectiveMatrixFromView(params.GetSourceFov(), kZNear, kZFar), | 506 PerspectiveMatrixFromView(params.GetSourceFov(), kZNear, kZFar), |
| 529 view_matrix); | 507 view_matrix); |
| 530 | 508 |
| 531 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 509 if (!webvr_mode_) { |
| 510 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
| 511 } | |
| 532 | 512 |
| 533 // TODO(mthiesse): Draw order for transparency. | 513 // TODO(mthiesse): Draw order for transparency. |
| 534 DrawUI(world_render_matrix, fov_render_matrix); | 514 DrawUI(world_render_matrix, fov_render_matrix); |
| 535 DrawCursor(world_render_matrix); | 515 if (!webvr_mode_) { |
| 536 } | 516 DrawCursor(world_render_matrix); |
| 537 | 517 } |
| 538 bool VrShell::IsUiTextureReady() { | |
| 539 return ui_tex_width_ > 0 && ui_tex_height_ > 0 && dom_contents_loaded_; | |
| 540 } | |
| 541 | |
| 542 Rectf VrShell::MakeUiGlCopyRect(Recti pixel_rect) { | |
| 543 CHECK(IsUiTextureReady()); | |
| 544 return Rectf({ | |
| 545 static_cast<float>(pixel_rect.x) / ui_tex_width_, | |
| 546 static_cast<float>(pixel_rect.y) / ui_tex_height_, | |
| 547 static_cast<float>(pixel_rect.width) / ui_tex_width_, | |
| 548 static_cast<float>(pixel_rect.height) / ui_tex_height_}); | |
| 549 } | 518 } |
| 550 | 519 |
| 551 void VrShell::DrawUI(const gvr::Mat4f& world_matrix, | 520 void VrShell::DrawUI(const gvr::Mat4f& world_matrix, |
| 552 const gvr::Mat4f& fov_matrix) { | 521 const gvr::Mat4f& fov_matrix) { |
| 553 for (const auto& rect : scene_->GetUiElements()) { | 522 for (const auto& rect : scene_->GetUiElements()) { |
| 554 if (!rect->visible) { | 523 if (!rect->visible) { |
| 555 continue; | 524 continue; |
| 556 } | 525 } |
| 526 if (webvr_mode_ && rect->id == kBrowserUiElementId) { | |
| 527 continue; | |
| 528 } | |
| 557 | 529 |
| 558 Rectf copy_rect; | 530 Rectf copy_rect; |
| 559 jint texture_handle; | 531 jint texture_handle; |
| 560 if (rect->id == kBrowserUiElementId) { | 532 if (rect->id == kBrowserUiElementId) { |
| 561 copy_rect = {0, 0, 1, 1}; | 533 copy_rect = {0, 0, 1, 1}; |
| 562 texture_handle = content_texture_id_; | 534 texture_handle = content_texture_id_; |
| 563 } else { | 535 } else { |
| 564 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_width_; | 536 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_width_; |
| 565 copy_rect.y = static_cast<float>(rect->copy_rect.y) / ui_tex_height_; | 537 copy_rect.y = static_cast<float>(rect->copy_rect.y) / ui_tex_height_; |
| 566 copy_rect.width = static_cast<float>(rect->copy_rect.width) / | 538 copy_rect.width = static_cast<float>(rect->copy_rect.width) / |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 661 glDisable(GL_BLEND); | 633 glDisable(GL_BLEND); |
| 662 glDisable(GL_POLYGON_OFFSET_FILL); | 634 glDisable(GL_POLYGON_OFFSET_FILL); |
| 663 | 635 |
| 664 // Don't need to clear, since we're drawing over the entire render target. | 636 // Don't need to clear, since we're drawing over the entire render target. |
| 665 glClear(GL_COLOR_BUFFER_BIT); | 637 glClear(GL_COLOR_BUFFER_BIT); |
| 666 | 638 |
| 667 glViewport(0, 0, render_size_.width, render_size_.height); | 639 glViewport(0, 0, render_size_.width, render_size_.height); |
| 668 vr_shell_renderer_->GetWebVrRenderer()->Draw(content_texture_id_); | 640 vr_shell_renderer_->GetWebVrRenderer()->Draw(content_texture_id_); |
| 669 } | 641 } |
| 670 | 642 |
| 671 void VrShell::DrawWebVrOverlay(int64_t present_time_nanos) { | |
| 672 // Draw WebVR security warning overlays for each eye. This uses the | |
| 673 // eye-from-head matrices but not the pose, goal is to place the icons in an | |
| 674 // eye-relative position so that they follow along with head rotations. | |
| 675 | |
| 676 gvr::Mat4f left_eye_view_matrix = | |
| 677 gvr_api_->GetEyeFromHeadMatrix(GVR_LEFT_EYE); | |
| 678 gvr::Mat4f right_eye_view_matrix = | |
| 679 gvr_api_->GetEyeFromHeadMatrix(GVR_RIGHT_EYE); | |
| 680 | |
| 681 glClear(GL_COLOR_BUFFER_BIT); | |
| 682 | |
| 683 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, | |
| 684 buffer_viewport_.get()); | |
| 685 DrawWebVrEye(left_eye_view_matrix, *buffer_viewport_, present_time_nanos); | |
| 686 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, | |
| 687 buffer_viewport_.get()); | |
| 688 DrawWebVrEye(right_eye_view_matrix, *buffer_viewport_, present_time_nanos); | |
| 689 } | |
| 690 | |
| 691 void VrShell::DrawWebVrEye(const gvr::Mat4f& view_matrix, | |
| 692 const gvr::BufferViewport& params, | |
| 693 int64_t present_time_nanos) { | |
| 694 gvr::Recti pixel_rect = | |
| 695 CalculatePixelSpaceRect(render_size_, params.GetSourceUv()); | |
| 696 glViewport(pixel_rect.left, pixel_rect.bottom, | |
| 697 pixel_rect.right - pixel_rect.left, | |
| 698 pixel_rect.top - pixel_rect.bottom); | |
| 699 glScissor(pixel_rect.left, pixel_rect.bottom, | |
| 700 pixel_rect.right - pixel_rect.left, | |
| 701 pixel_rect.top - pixel_rect.bottom); | |
| 702 | |
| 703 gvr::Mat4f projection_matrix = | |
| 704 PerspectiveMatrixFromView(params.GetSourceFov(), kZNear, kZFar); | |
| 705 | |
| 706 if (!IsUiTextureReady()) { | |
| 707 // If the UI texture hasn't been initialized yet, we can't draw the overlay. | |
| 708 return; | |
| 709 } | |
| 710 | |
| 711 // Show IDS_WEBSITE_SETTINGS_INSECURE_WEBVR_CONTENT_PERMANENT text. | |
| 712 gvr::Mat4f icon_pos; | |
| 713 SetIdentityM(icon_pos); | |
| 714 // The UI is designed in pixels with the assumption that 1px = 1mm at 1m | |
| 715 // distance. Scale mm-to-m and adjust to keep the same angular size if the | |
| 716 // distance changes. | |
| 717 const float small_icon_width = | |
| 718 kWebVrWarningPermanentRect.width / 1000.f * kWebVrWarningDistance; | |
| 719 const float small_icon_height = | |
| 720 kWebVrWarningPermanentRect.height / 1000.f * kWebVrWarningDistance; | |
| 721 const float small_icon_angle = | |
| 722 kWebVrWarningPermanentAngle * M_PI / 180.f; // Degrees to radians. | |
| 723 ScaleM(icon_pos, icon_pos, small_icon_width, small_icon_height, 1.0f); | |
| 724 TranslateM(icon_pos, icon_pos, 0.0f, 0.0f, -kWebVrWarningDistance); | |
| 725 icon_pos = MatrixMul( | |
| 726 QuatToMatrix(QuatFromAxisAngle({1.f, 0.f, 0.f}, small_icon_angle)), | |
| 727 icon_pos); | |
| 728 gvr::Mat4f combined = MatrixMul(projection_matrix, | |
| 729 MatrixMul(view_matrix, icon_pos)); | |
| 730 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( | |
| 731 ui_texture_id_, combined, MakeUiGlCopyRect(kWebVrWarningPermanentRect)); | |
| 732 | |
| 733 // Check if we also need to show the transient warning. | |
| 734 if (present_time_nanos > webvr_warning_end_nanos_) { | |
| 735 return; | |
| 736 } | |
| 737 | |
| 738 // Show IDS_WEBSITE_SETTINGS_INSECURE_WEBVR_CONTENT_TRANSIENT text. | |
| 739 SetIdentityM(icon_pos); | |
| 740 const float large_icon_width = | |
| 741 kWebVrWarningTransientRect.width / 1000.f * kWebVrWarningDistance; | |
| 742 const float large_icon_height = | |
| 743 kWebVrWarningTransientRect.height / 1000.f * kWebVrWarningDistance; | |
| 744 ScaleM(icon_pos, icon_pos, large_icon_width, large_icon_height, 1.0f); | |
| 745 TranslateM(icon_pos, icon_pos, 0.0f, 0.0f, -kWebVrWarningDistance); | |
| 746 combined = MatrixMul(projection_matrix, | |
| 747 MatrixMul(view_matrix, icon_pos)); | |
| 748 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( | |
| 749 ui_texture_id_, combined, MakeUiGlCopyRect(kWebVrWarningTransientRect)); | |
| 750 | |
| 751 } | |
| 752 | |
| 753 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 643 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 754 // Set a flag to handle this on the render thread at the next frame. | 644 // Set a flag to handle this on the render thread at the next frame. |
| 755 touch_pending_ = true; | 645 touch_pending_ = true; |
| 756 } | 646 } |
| 757 | 647 |
| 758 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 648 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 759 if (gvr_api_ == nullptr) | 649 if (gvr_api_ == nullptr) |
| 760 return; | 650 return; |
| 761 controller_->OnPause(); | 651 controller_->OnPause(); |
| 762 gvr_api_->PauseTracking(); | 652 gvr_api_->PauseTracking(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 792 SK_ColorTRANSPARENT); | 682 SK_ColorTRANSPARENT); |
| 793 html_interface_->OnDomContentsLoaded(); | 683 html_interface_->OnDomContentsLoaded(); |
| 794 dom_contents_loaded_ = true; | 684 dom_contents_loaded_ = true; |
| 795 } | 685 } |
| 796 | 686 |
| 797 void VrShell::SetWebVrMode(JNIEnv* env, | 687 void VrShell::SetWebVrMode(JNIEnv* env, |
| 798 const base::android::JavaParamRef<jobject>& obj, | 688 const base::android::JavaParamRef<jobject>& obj, |
| 799 bool enabled) { | 689 bool enabled) { |
| 800 webvr_mode_ = enabled; | 690 webvr_mode_ = enabled; |
| 801 if (enabled) { | 691 if (enabled) { |
| 802 int64_t now = gvr::GvrApi::GetTimePointNow().monotonic_system_time_nanos; | |
| 803 constexpr int64_t seconds_to_nanos = 1000 * 1000 * 1000; | |
| 804 webvr_warning_end_nanos_ = now + kWebVrWarningSeconds * seconds_to_nanos; | |
| 805 html_interface_->SetMode(UiInterface::Mode::WEB_VR); | 692 html_interface_->SetMode(UiInterface::Mode::WEB_VR); |
| 806 } else { | 693 } else { |
| 807 webvr_warning_end_nanos_ = 0; | |
| 808 html_interface_->SetMode(UiInterface::Mode::STANDARD); | 694 html_interface_->SetMode(UiInterface::Mode::STANDARD); |
| 809 } | 695 } |
| 810 } | 696 } |
| 811 | 697 |
| 812 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { | 698 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
| 813 webvr_secure_origin_ = secure_origin; | 699 html_interface_->SetSecureOrigin(secure_origin); |
| 814 } | 700 } |
| 815 | 701 |
| 816 void VrShell::SubmitWebVRFrame() { | 702 void VrShell::SubmitWebVRFrame() { |
| 817 } | 703 } |
| 818 | 704 |
| 819 void VrShell::UpdateWebVRTextureBounds( | 705 void VrShell::UpdateWebVRTextureBounds( |
| 820 int eye, float left, float top, float width, float height) { | 706 int eye, float left, float top, float width, float height) { |
| 821 gvr::Rectf bounds = { left, top, width, height }; | 707 gvr::Rectf bounds = { left, top, width, height }; |
| 822 vr_shell_renderer_->GetWebVrRenderer()->UpdateTextureBounds(eye, bounds); | 708 vr_shell_renderer_->GetWebVrRenderer()->UpdateTextureBounds(eye, bounds); |
| 823 } | 709 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 const JavaParamRef<jobject>& ui_web_contents, | 802 const JavaParamRef<jobject>& ui_web_contents, |
| 917 jlong ui_window_android) { | 803 jlong ui_window_android) { |
| 918 return reinterpret_cast<intptr_t>(new VrShell( | 804 return reinterpret_cast<intptr_t>(new VrShell( |
| 919 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 805 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 920 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 806 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 921 content::WebContents::FromJavaWebContents(ui_web_contents), | 807 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 922 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); | 808 reinterpret_cast<ui::WindowAndroid*>(ui_window_android))); |
| 923 } | 809 } |
| 924 | 810 |
| 925 } // namespace vr_shell | 811 } // namespace vr_shell |
| OLD | NEW |