Chromium Code Reviews| 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..b3d6a7c7d885ad1c3e39dc3443f114602587e2f3 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,8 +61,6 @@ 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; |
| @@ -80,8 +79,6 @@ 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}; |
| // Tiny distance to offset textures that should appear in the same plane. |
| static constexpr float kTextureOffset = 0.01; |
| @@ -248,8 +245,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); |
|
acondor_
2017/05/25 15:34:41
We could remove these calls and call UpdateBackgro
Ian Vollick
2017/05/25 15:54:05
Good call. That's much nicer. Done.
amp
2017/05/25 15:55:30
I had thought about doing that as well. It does h
|
| + element->set_center_color(color_scheme().floor); |
| element->set_draw_phase(0); |
| floor_ = element.get(); |
| content_elements_.push_back(element.get()); |
| @@ -264,8 +261,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 +272,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 +363,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) { |
| @@ -482,4 +475,9 @@ int UiSceneManager::AllocateId() { |
| return next_available_id_++; |
| } |
| +const ColorScheme& UiSceneManager::color_scheme() const { |
| + return ColorScheme::GetColorScheme(fullscreen_ ? ColorScheme::kModeFullscreen |
| + : ColorScheme::kModeNormal); |
| +} |
| + |
| } // namespace vr_shell |