| Index: chrome/browser/android/vr_shell/ui_scene_manager.cc
|
| diff --git a/chrome/browser/android/vr_shell/ui_scene_manager.cc b/chrome/browser/android/vr_shell/ui_scene_manager.cc
|
| index e8a62ad89d2e8117d898443d11a75404e96663fe..15cfa5e28dbd724d95ec0f96654f5b651e4979f6 100644
|
| --- a/chrome/browser/android/vr_shell/ui_scene_manager.cc
|
| +++ b/chrome/browser/android/vr_shell/ui_scene_manager.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/callback.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "chrome/browser/android/vr_shell/color_scheme.h"
|
| #include "chrome/browser/android/vr_shell/textures/close_button_texture.h"
|
| #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
|
| #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h"
|
| @@ -60,28 +61,11 @@ static constexpr float kLoadingIndicatorOffset =
|
| static constexpr float kSceneSize = 25.0;
|
| static constexpr float kSceneHeight = 4.0;
|
| static constexpr int kFloorGridlineCount = 40;
|
| -static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0};
|
| -static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0};
|
| -
|
| -static constexpr float kFullscreenWidthDms = 1.138;
|
| -static constexpr float kFullscreenHeightDms = 0.64;
|
| -static constexpr float kFullscreenVerticalOffsetDms = 0.1;
|
| -// Fullscreen distance calculated as value needed to make the content quad
|
| -// extend down to the floor (with small pullback used to prevent actual
|
| -// intersection). Note this assumes the vertical offset will always be offest
|
| -// below the origin (ie negative).
|
| -static constexpr float kFullscreenDistance =
|
| - (kSceneHeight / 2.0) /
|
| - ((kFullscreenVerticalOffsetDms + (kFullscreenHeightDms / 2.0)) + 0.01);
|
| -
|
| -static constexpr float kFullscreenHeight =
|
| - kFullscreenHeightDms * kFullscreenDistance;
|
| -static constexpr float kFullscreenWidth =
|
| - kFullscreenWidthDms * kFullscreenDistance;
|
| -static constexpr float kFullscreenVerticalOffset =
|
| - -kFullscreenVerticalOffsetDms * kFullscreenDistance;
|
| -static constexpr vr::Colorf kFullscreenHorizonColor = {0.1, 0.1, 0.1, 1.0};
|
| -static constexpr vr::Colorf kFullscreenCenterColor = {0.2, 0.2, 0.2, 1.0};
|
| +
|
| +static constexpr float kFullscreenDistance = 3;
|
| +static constexpr float kFullscreenHeight = 0.64 * kFullscreenDistance;
|
| +static constexpr float kFullscreenWidth = 1.138 * kFullscreenDistance;
|
| +static constexpr float kFullscreenVerticalOffset = -0.1 * kFullscreenDistance;
|
|
|
| // Tiny distance to offset textures that should appear in the same plane.
|
| static constexpr float kTextureOffset = 0.01;
|
| @@ -248,8 +232,8 @@ void UiSceneManager::CreateBackground() {
|
| element->set_translation({0.0, -kSceneHeight / 2, 0.0});
|
| element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0});
|
| element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
|
| - element->set_edge_color(kBackgroundHorizonColor);
|
| - element->set_center_color(kBackgroundCenterColor);
|
| + element->set_edge_color(color_scheme().horizon);
|
| + element->set_center_color(color_scheme().floor);
|
| element->set_draw_phase(0);
|
| floor_ = element.get();
|
| content_elements_.push_back(element.get());
|
| @@ -264,8 +248,8 @@ void UiSceneManager::CreateBackground() {
|
| element->set_translation({0.0, kSceneHeight / 2, 0.0});
|
| element->set_rotation({1.0, 0.0, 0.0, M_PI / 2});
|
| element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
|
| - element->set_edge_color(kBackgroundHorizonColor);
|
| - element->set_center_color(kBackgroundCenterColor);
|
| + element->set_edge_color(color_scheme().horizon);
|
| + element->set_center_color(color_scheme().ceiling);
|
| element->set_draw_phase(0);
|
| ceiling_ = element.get();
|
| content_elements_.push_back(element.get());
|
| @@ -275,22 +259,22 @@ void UiSceneManager::CreateBackground() {
|
| element = base::MakeUnique<UiElement>();
|
| element->set_debug_id(kFloorGrid);
|
| element->set_id(AllocateId());
|
| - element->set_fill(vr_shell::Fill::GRID_GRADIENT);
|
| element->set_size({kSceneSize, kSceneSize, 1.0});
|
| element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0});
|
| element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2});
|
| element->set_fill(vr_shell::Fill::GRID_GRADIENT);
|
| - element->set_center_color(kBackgroundHorizonColor);
|
| - vr::Colorf edge_color = kBackgroundHorizonColor;
|
| + element->set_center_color(color_scheme().horizon);
|
| + vr::Colorf edge_color = color_scheme().horizon;
|
| edge_color.a = 0.0;
|
| element->set_edge_color(edge_color);
|
| element->set_gridline_count(kFloorGridlineCount);
|
| + element->set_center_color(color_scheme().horizon);
|
| element->set_draw_phase(0);
|
| floor_grid_ = element.get();
|
| content_elements_.push_back(element.get());
|
| scene_->AddUiElement(std::move(element));
|
|
|
| - scene_->SetBackgroundColor(kBackgroundHorizonColor);
|
| + scene_->SetBackgroundColor(color_scheme().horizon);
|
| }
|
|
|
| void UiSceneManager::CreateUrlBar() {
|
| @@ -366,32 +350,28 @@ void UiSceneManager::ConfigureScene() {
|
| main_content_->set_translation(
|
| {0, kFullscreenVerticalOffset, -kFullscreenDistance});
|
| main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1});
|
| -
|
| - ConfigureBackgroundColor(kFullscreenCenterColor, kFullscreenHorizonColor);
|
| } else {
|
| // Note that main_content_ is already visible in this case.
|
| main_content_->set_translation(
|
| {0, kContentVerticalOffset, -kContentDistance});
|
| main_content_->set_size({kContentWidth, kContentHeight, 1});
|
| -
|
| - ConfigureBackgroundColor(kBackgroundCenterColor, kBackgroundHorizonColor);
|
| }
|
|
|
| + UpdateBackgroundColor();
|
| scene_->SetBackgroundDistance(main_content_->translation().z() *
|
| -kBackgroundDistanceMultiplier);
|
| }
|
|
|
| -void UiSceneManager::ConfigureBackgroundColor(vr::Colorf center_color,
|
| - vr::Colorf horizon_color) {
|
| - scene_->SetBackgroundColor(horizon_color);
|
| - floor_->set_edge_color(horizon_color);
|
| - floor_->set_center_color(center_color);
|
| - ceiling_->set_edge_color(horizon_color);
|
| - ceiling_->set_center_color(center_color);
|
| - floor_grid_->set_center_color(horizon_color);
|
| - vr::Colorf edge_color = horizon_color;
|
| - edge_color.a = 0.0;
|
| - floor_grid_->set_edge_color(edge_color);
|
| +void UiSceneManager::UpdateBackgroundColor() {
|
| + scene_->SetBackgroundColor(color_scheme().horizon);
|
| + ceiling_->set_center_color(color_scheme().ceiling);
|
| + ceiling_->set_edge_color(color_scheme().horizon);
|
| + floor_->set_center_color(color_scheme().floor);
|
| + floor_->set_edge_color(color_scheme().horizon);
|
| + floor_grid_->set_center_color(color_scheme().grid);
|
| + vr::Colorf floor_grid_edge_color = color_scheme().grid;
|
| + floor_grid_edge_color.a = 0.0;
|
| + floor_grid_->set_edge_color(floor_grid_edge_color);
|
| }
|
|
|
| void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
|
| @@ -411,6 +391,14 @@ void UiSceneManager::SetWebVrSecureOrigin(bool secure) {
|
| ConfigureSecurityWarnings();
|
| }
|
|
|
| +void UiSceneManager::SetIncognito(bool incognito) {
|
| + const bool needs_update = incognito != incognito_;
|
| + incognito_ = incognito;
|
| + if (needs_update)
|
| + UpdateBackgroundColor();
|
| + url_bar_->SetIncognito(incognito);
|
| +}
|
| +
|
| void UiSceneManager::OnAppButtonClicked() {
|
| // App button click exits the WebVR presentation and fullscreen.
|
| browser_->ExitPresent();
|
| @@ -482,4 +470,12 @@ int UiSceneManager::AllocateId() {
|
| return next_available_id_++;
|
| }
|
|
|
| +const ColorScheme& UiSceneManager::color_scheme() const {
|
| + if (incognito_)
|
| + return ColorScheme::GetColorScheme(ColorScheme::kModeIncognito);
|
| + if (fullscreen_)
|
| + return ColorScheme::GetColorScheme(ColorScheme::kModeFullscreen);
|
| + return ColorScheme::GetColorScheme(ColorScheme::kModeNormal);
|
| +}
|
| +
|
| } // namespace vr_shell
|
|
|