Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui_scene_manager.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" |
| 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" | 11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" |
| 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" | 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" |
| 13 #include "chrome/browser/android/vr_shell/ui_elements/exclusive_screen_toast.h" | |
| 13 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" | 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" |
| 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" | 15 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" |
| 15 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" | 16 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
| 16 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" | 17 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" |
| 17 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" | 18 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" |
| 18 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" | 19 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" |
| 19 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 20 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| 20 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" | 21 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" |
| 21 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" | 22 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" |
| 22 #include "chrome/browser/android/vr_shell/ui_scene.h" | 23 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 | 74 |
| 74 static constexpr float kTransientUrlBarDistance = 1.4; | 75 static constexpr float kTransientUrlBarDistance = 1.4; |
| 75 static constexpr float kTransientUrlBarWidth = | 76 static constexpr float kTransientUrlBarWidth = |
| 76 kUrlBarWidthDMM * kTransientUrlBarDistance; | 77 kUrlBarWidthDMM * kTransientUrlBarDistance; |
| 77 static constexpr float kTransientUrlBarHeight = | 78 static constexpr float kTransientUrlBarHeight = |
| 78 kUrlBarHeightDMM * kTransientUrlBarDistance; | 79 kUrlBarHeightDMM * kTransientUrlBarDistance; |
| 79 static constexpr float kTransientUrlBarVerticalOffset = | 80 static constexpr float kTransientUrlBarVerticalOffset = |
| 80 -0.2 * kTransientUrlBarDistance; | 81 -0.2 * kTransientUrlBarDistance; |
| 81 static constexpr int kTransientUrlBarTimeoutSeconds = 6; | 82 static constexpr int kTransientUrlBarTimeoutSeconds = 6; |
| 82 | 83 |
| 83 static constexpr float kToastDistance = 1.4; | 84 static constexpr float kWebVrToastDistance = 1.0; |
| 84 static constexpr float kToastWidth = 0.512 * kToastDistance; | 85 static constexpr float kFullscreenToastDistance = kFullscreenDistance; |
| 85 static constexpr float kToastHeight = 0.16 * kToastDistance; | 86 static constexpr float kToastWidthDMM = 0.512; |
| 87 static constexpr float kToastHeightDMM = 0.064; | |
| 88 static constexpr float kToastOffsetDMM = 0.004; | |
| 89 // When changing the value here, make sure it doesn't collide with | |
| 90 // kWarningAngleRadians. | |
| 91 static constexpr float kWebVrAngleRadians = 9.88 * M_PI / 180.0; | |
| 86 static constexpr int kToastTimeoutSeconds = kTransientUrlBarTimeoutSeconds; | 92 static constexpr int kToastTimeoutSeconds = kTransientUrlBarTimeoutSeconds; |
| 87 | 93 |
| 88 static constexpr float kSplashScreenDistance = 1; | 94 static constexpr float kSplashScreenDistance = 1; |
| 89 static constexpr float kSplashScreenIconDMM = 0.12; | 95 static constexpr float kSplashScreenIconDMM = 0.12; |
| 90 static constexpr float kSplashScreenIconHeight = | 96 static constexpr float kSplashScreenIconHeight = |
| 91 kSplashScreenIconDMM * kSplashScreenDistance; | 97 kSplashScreenIconDMM * kSplashScreenDistance; |
| 92 static constexpr float kSplashScreenIconWidth = | 98 static constexpr float kSplashScreenIconWidth = |
| 93 kSplashScreenIconDMM * kSplashScreenDistance; | 99 kSplashScreenIconDMM * kSplashScreenDistance; |
| 94 static constexpr float kSplashScreenIconVerticalOffset = | 100 static constexpr float kSplashScreenIconVerticalOffset = |
| 95 0.2 * kSplashScreenDistance; | 101 0.2 * kSplashScreenDistance; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 content_elements_.push_back(element.get()); | 429 content_elements_.push_back(element.get()); |
| 424 scene_->AddUiElement(std::move(element)); | 430 scene_->AddUiElement(std::move(element)); |
| 425 } | 431 } |
| 426 | 432 |
| 427 void UiSceneManager::CreateToasts() { | 433 void UiSceneManager::CreateToasts() { |
| 428 std::unique_ptr<UiElement> element = | 434 std::unique_ptr<UiElement> element = |
| 429 base::MakeUnique<ExclusiveScreenToast>(512); | 435 base::MakeUnique<ExclusiveScreenToast>(512); |
| 430 element->set_debug_id(kExclusiveScreenToast); | 436 element->set_debug_id(kExclusiveScreenToast); |
| 431 element->set_id(AllocateId()); | 437 element->set_id(AllocateId()); |
| 432 element->set_fill(vr_shell::Fill::NONE); | 438 element->set_fill(vr_shell::Fill::NONE); |
| 433 element->set_size({kToastWidth, kToastHeight, 1}); | 439 element->set_size({kToastWidthDMM, kToastHeightDMM, 1}); |
|
amp
2017/06/28 16:47:21
Don't the DMM need to be multiplied by the distanc
bshe
2017/06/28 20:01:58
It is what set_scale does. It is unclear to me if
| |
| 434 element->set_translation({0, 0, -kToastDistance}); | |
| 435 element->set_visible(false); | 440 element->set_visible(false); |
| 436 element->set_hit_testable(false); | 441 element->set_hit_testable(false); |
| 437 element->set_lock_to_fov(true); | |
| 438 exclusive_screen_toast_ = element.get(); | 442 exclusive_screen_toast_ = element.get(); |
| 439 scene_->AddUiElement(std::move(element)); | 443 scene_->AddUiElement(std::move(element)); |
| 440 } | 444 } |
| 441 | 445 |
| 442 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { | 446 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
| 443 return weak_ptr_factory_.GetWeakPtr(); | 447 return weak_ptr_factory_.GetWeakPtr(); |
| 444 } | 448 } |
| 445 | 449 |
| 446 void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) { | 450 void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) { |
| 447 if (web_vr_mode_ == web_vr && web_vr_show_toast_ == show_toast) { | 451 if (web_vr_mode_ == web_vr && web_vr_show_toast_ == show_toast) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 {0, kContentVerticalOffset, -kContentDistance}); | 517 {0, kContentVerticalOffset, -kContentDistance}); |
| 514 main_content_->set_size({kContentWidth, kContentHeight, 1}); | 518 main_content_->set_size({kContentWidth, kContentHeight, 1}); |
| 515 | 519 |
| 516 close_button_->set_translation( | 520 close_button_->set_translation( |
| 517 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, | 521 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, |
| 518 -kCloseButtonDistance)); | 522 -kCloseButtonDistance)); |
| 519 close_button_->set_size( | 523 close_button_->set_size( |
| 520 gfx::Vector3dF(kCloseButtonWidth, kCloseButtonHeight, 1)); | 524 gfx::Vector3dF(kCloseButtonWidth, kCloseButtonHeight, 1)); |
| 521 } | 525 } |
| 522 | 526 |
| 527 if (fullscreen_ && !web_vr_mode_) { | |
|
cjgrant
2017/06/28 13:55:34
Why not put this block into ConfigureExclusiveScre
bshe
2017/06/28 20:01:58
I am trying to make rebase easier. Your refactor p
cjgrant
2017/06/28 20:24:50
Yes, it does, currently, but when there's this muc
bshe
2017/06/29 01:34:11
Done.
| |
| 528 // Do not set size again. The size might have been changed by the backing | |
| 529 // texture size in UpdateElementSize. | |
| 530 exclusive_screen_toast_->set_scale( | |
| 531 {kFullscreenToastDistance, kFullscreenToastDistance, 1}); | |
| 532 exclusive_screen_toast_->set_translation( | |
| 533 {0, | |
| 534 kFullscreenVerticalOffset + kFullscreenHeight / 2 + | |
| 535 (kToastOffsetDMM + kToastHeightDMM) * kFullscreenToastDistance, | |
| 536 -kFullscreenToastDistance}); | |
| 537 exclusive_screen_toast_->set_rotation( | |
| 538 gfx::Quaternion(gfx::Vector3dF(1, 0, 0), 0.0)); | |
| 539 exclusive_screen_toast_->set_lock_to_fov(false); | |
| 540 } else if (web_vr_mode_ && web_vr_show_toast_) { | |
| 541 exclusive_screen_toast_->set_scale( | |
| 542 {kWebVrToastDistance, kWebVrToastDistance, 1}); | |
| 543 exclusive_screen_toast_->set_translation( | |
| 544 gfx::Vector3dF(0, kWebVrToastDistance * sin(kWebVrAngleRadians), | |
| 545 -kWebVrToastDistance * cos(kWebVrAngleRadians))); | |
| 546 exclusive_screen_toast_->set_rotation( | |
| 547 gfx::Quaternion(gfx::Vector3dF(1, 0, 0), kWebVrAngleRadians)); | |
| 548 exclusive_screen_toast_->set_lock_to_fov(true); | |
| 549 } | |
| 550 | |
| 523 scene_->SetMode(mode()); | 551 scene_->SetMode(mode()); |
| 524 scene_->SetBackgroundDistance(main_content_->translation().z() * | 552 scene_->SetBackgroundDistance(main_content_->translation().z() * |
| 525 -kBackgroundDistanceMultiplier); | 553 -kBackgroundDistanceMultiplier); |
| 526 UpdateBackgroundColor(); | 554 UpdateBackgroundColor(); |
| 527 | 555 |
| 528 // Configure other subsystems here as well. Ultimately, it would be nice if we | 556 // Configure other subsystems here as well. Ultimately, it would be nice if we |
| 529 // could configure all elements through ConfigureScene(), as the exact | 557 // could configure all elements through ConfigureScene(), as the exact |
| 530 // conditions that control each element are getting complicated. More systems | 558 // conditions that control each element are getting complicated. More systems |
| 531 // should move in here, such that a single method call can update the entire | 559 // should move in here, such that a single method call can update the entire |
| 532 // scene. The drawback is slightly more overhead for individual scene | 560 // scene. The drawback is slightly more overhead for individual scene |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 if (fullscreen_) | 817 if (fullscreen_) |
| 790 return ColorScheme::kModeFullscreen; | 818 return ColorScheme::kModeFullscreen; |
| 791 return ColorScheme::kModeNormal; | 819 return ColorScheme::kModeNormal; |
| 792 } | 820 } |
| 793 | 821 |
| 794 const ColorScheme& UiSceneManager::color_scheme() const { | 822 const ColorScheme& UiSceneManager::color_scheme() const { |
| 795 return ColorScheme::GetColorScheme(mode()); | 823 return ColorScheme::GetColorScheme(mode()); |
| 796 } | 824 } |
| 797 | 825 |
| 798 } // namespace vr_shell | 826 } // namespace vr_shell |
| OLD | NEW |