| 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/color_scheme.h" |
| 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" | 10 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" |
| 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 11 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 11 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" | 12 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" |
| 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" | 13 #include "chrome/browser/android/vr_shell/ui_elements/button.h" |
| 13 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" | 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" |
| 14 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" | 15 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
| 15 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning
.h" | 16 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning
.h" |
| 16 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h
" | 17 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h
" |
| 17 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" | 18 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" |
| 18 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning
.h" | 19 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning
.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; | 54 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; |
| 54 | 55 |
| 55 static constexpr float kLoadingIndicatorWidth = 0.24 * kUrlBarDistance; | 56 static constexpr float kLoadingIndicatorWidth = 0.24 * kUrlBarDistance; |
| 56 static constexpr float kLoadingIndicatorHeight = 0.008 * kUrlBarDistance; | 57 static constexpr float kLoadingIndicatorHeight = 0.008 * kUrlBarDistance; |
| 57 static constexpr float kLoadingIndicatorOffset = | 58 static constexpr float kLoadingIndicatorOffset = |
| 58 -0.016 * kUrlBarDistance - kLoadingIndicatorHeight / 2; | 59 -0.016 * kUrlBarDistance - kLoadingIndicatorHeight / 2; |
| 59 | 60 |
| 60 static constexpr float kSceneSize = 25.0; | 61 static constexpr float kSceneSize = 25.0; |
| 61 static constexpr float kSceneHeight = 4.0; | 62 static constexpr float kSceneHeight = 4.0; |
| 62 static constexpr int kFloorGridlineCount = 40; | 63 static constexpr int kFloorGridlineCount = 40; |
| 63 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; | |
| 64 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; | |
| 65 static constexpr vr::Colorf kFullscreenHorizonColor = {0.1, 0.1, 0.1, 1.0}; | |
| 66 static constexpr vr::Colorf kFullscreenCenterColor = {0.2, 0.2, 0.2, 1.0}; | |
| 67 | 64 |
| 68 static constexpr float kFullscreenDistance = 3; | 65 static constexpr float kFullscreenDistance = 3; |
| 69 static constexpr float kFullscreenHeight = 0.64 * kFullscreenDistance; | 66 static constexpr float kFullscreenHeight = 0.64 * kFullscreenDistance; |
| 70 static constexpr float kFullscreenWidth = 1.138 * kFullscreenDistance; | 67 static constexpr float kFullscreenWidth = 1.138 * kFullscreenDistance; |
| 71 static constexpr float kFullscreenVerticalOffset = -0.1 * kFullscreenDistance; | 68 static constexpr float kFullscreenVerticalOffset = -0.1 * kFullscreenDistance; |
| 72 | 69 |
| 73 // Tiny distance to offset textures that should appear in the same plane. | 70 // Tiny distance to offset textures that should appear in the same plane. |
| 74 static constexpr float kTextureOffset = 0.01; | 71 static constexpr float kTextureOffset = 0.01; |
| 75 | 72 |
| 76 } // namespace | 73 } // namespace |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 std::unique_ptr<UiElement> element; | 225 std::unique_ptr<UiElement> element; |
| 229 | 226 |
| 230 // Floor. | 227 // Floor. |
| 231 element = base::MakeUnique<UiElement>(); | 228 element = base::MakeUnique<UiElement>(); |
| 232 element->set_debug_id(kFloor); | 229 element->set_debug_id(kFloor); |
| 233 element->set_id(AllocateId()); | 230 element->set_id(AllocateId()); |
| 234 element->set_size({kSceneSize, kSceneSize, 1.0}); | 231 element->set_size({kSceneSize, kSceneSize, 1.0}); |
| 235 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); | 232 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); |
| 236 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); | 233 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); |
| 237 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 234 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
| 238 element->set_edge_color(kBackgroundHorizonColor); | |
| 239 element->set_center_color(kBackgroundCenterColor); | |
| 240 element->set_draw_phase(0); | 235 element->set_draw_phase(0); |
| 241 floor_ = element.get(); | 236 floor_ = element.get(); |
| 242 content_elements_.push_back(element.get()); | 237 content_elements_.push_back(element.get()); |
| 243 scene_->AddUiElement(std::move(element)); | 238 scene_->AddUiElement(std::move(element)); |
| 244 | 239 |
| 245 // Ceiling. | 240 // Ceiling. |
| 246 element = base::MakeUnique<UiElement>(); | 241 element = base::MakeUnique<UiElement>(); |
| 247 element->set_debug_id(kCeiling); | 242 element->set_debug_id(kCeiling); |
| 248 element->set_id(AllocateId()); | 243 element->set_id(AllocateId()); |
| 249 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 244 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
| 250 element->set_size({kSceneSize, kSceneSize, 1.0}); | 245 element->set_size({kSceneSize, kSceneSize, 1.0}); |
| 251 element->set_translation({0.0, kSceneHeight / 2, 0.0}); | 246 element->set_translation({0.0, kSceneHeight / 2, 0.0}); |
| 252 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); | 247 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); |
| 253 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 248 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
| 254 element->set_edge_color(kBackgroundHorizonColor); | |
| 255 element->set_center_color(kBackgroundCenterColor); | |
| 256 element->set_draw_phase(0); | 249 element->set_draw_phase(0); |
| 257 ceiling_ = element.get(); | 250 ceiling_ = element.get(); |
| 258 content_elements_.push_back(element.get()); | 251 content_elements_.push_back(element.get()); |
| 259 scene_->AddUiElement(std::move(element)); | 252 scene_->AddUiElement(std::move(element)); |
| 260 | 253 |
| 261 // Floor grid. | 254 // Floor grid. |
| 262 element = base::MakeUnique<UiElement>(); | 255 element = base::MakeUnique<UiElement>(); |
| 263 element->set_debug_id(kFloorGrid); | 256 element->set_debug_id(kFloorGrid); |
| 264 element->set_id(AllocateId()); | 257 element->set_id(AllocateId()); |
| 265 element->set_fill(vr_shell::Fill::GRID_GRADIENT); | 258 element->set_fill(vr_shell::Fill::GRID_GRADIENT); |
| 266 element->set_size({kSceneSize, kSceneSize, 1.0}); | 259 element->set_size({kSceneSize, kSceneSize, 1.0}); |
| 267 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); | 260 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); |
| 268 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); | 261 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); |
| 269 element->set_fill(vr_shell::Fill::GRID_GRADIENT); | 262 element->set_fill(vr_shell::Fill::GRID_GRADIENT); |
| 270 element->set_center_color(kBackgroundHorizonColor); | |
| 271 vr::Colorf edge_color = kBackgroundHorizonColor; | |
| 272 edge_color.a = 0.0; | |
| 273 element->set_edge_color(edge_color); | |
| 274 element->set_gridline_count(kFloorGridlineCount); | 263 element->set_gridline_count(kFloorGridlineCount); |
| 275 element->set_draw_phase(0); | 264 element->set_draw_phase(0); |
| 276 floor_grid_ = element.get(); | 265 floor_grid_ = element.get(); |
| 277 content_elements_.push_back(element.get()); | 266 content_elements_.push_back(element.get()); |
| 278 scene_->AddUiElement(std::move(element)); | 267 scene_->AddUiElement(std::move(element)); |
| 279 | 268 |
| 280 scene_->SetBackgroundColor(kBackgroundHorizonColor); | 269 UpdateBackgroundColor(); |
| 281 } | 270 } |
| 282 | 271 |
| 283 void UiSceneManager::CreateUrlBar() { | 272 void UiSceneManager::CreateUrlBar() { |
| 284 // TODO(cjgrant): Incorporate final size and position. | 273 // TODO(cjgrant): Incorporate final size and position. |
| 285 auto url_bar = base::MakeUnique<UrlBar>(512); | 274 auto url_bar = base::MakeUnique<UrlBar>(512); |
| 286 url_bar->set_debug_id(kUrlBar); | 275 url_bar->set_debug_id(kUrlBar); |
| 287 url_bar->set_id(AllocateId()); | 276 url_bar->set_id(AllocateId()); |
| 288 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); | 277 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); |
| 289 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); | 278 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); |
| 290 url_bar->SetBackButtonCallback( | 279 url_bar->SetBackButtonCallback( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 for (UiElement* element : content_elements_) { | 335 for (UiElement* element : content_elements_) { |
| 347 element->SetEnabled(!web_vr_mode_); | 336 element->SetEnabled(!web_vr_mode_); |
| 348 } | 337 } |
| 349 | 338 |
| 350 // Update content quad parameters depending on fullscreen. | 339 // Update content quad parameters depending on fullscreen. |
| 351 // TODO(http://crbug.com/642937): Animate fullscreen transitions. | 340 // TODO(http://crbug.com/642937): Animate fullscreen transitions. |
| 352 if (fullscreen_) { | 341 if (fullscreen_) { |
| 353 main_content_->set_translation( | 342 main_content_->set_translation( |
| 354 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); | 343 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); |
| 355 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); | 344 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); |
| 356 | |
| 357 ConfigureBackgroundColor(kFullscreenCenterColor, kFullscreenHorizonColor); | |
| 358 } else { | 345 } else { |
| 359 // Note that main_content_ is already visible in this case. | 346 // Note that main_content_ is already visible in this case. |
| 360 main_content_->set_translation( | 347 main_content_->set_translation( |
| 361 {0, kContentVerticalOffset, -kContentDistance}); | 348 {0, kContentVerticalOffset, -kContentDistance}); |
| 362 main_content_->set_size({kContentWidth, kContentHeight, 1}); | 349 main_content_->set_size({kContentWidth, kContentHeight, 1}); |
| 363 | |
| 364 ConfigureBackgroundColor(kBackgroundCenterColor, kBackgroundHorizonColor); | |
| 365 } | 350 } |
| 366 | 351 |
| 352 UpdateBackgroundColor(); |
| 367 scene_->SetBackgroundDistance(main_content_->translation().z() * | 353 scene_->SetBackgroundDistance(main_content_->translation().z() * |
| 368 -kBackgroundDistanceMultiplier); | 354 -kBackgroundDistanceMultiplier); |
| 369 } | 355 } |
| 370 | 356 |
| 371 void UiSceneManager::ConfigureBackgroundColor(vr::Colorf center_color, | 357 void UiSceneManager::UpdateBackgroundColor() { |
| 372 vr::Colorf horizon_color) { | 358 scene_->SetBackgroundColor(color_scheme().horizon); |
| 373 scene_->SetBackgroundColor(horizon_color); | 359 ceiling_->set_center_color(color_scheme().ceiling); |
| 374 floor_->set_edge_color(horizon_color); | 360 ceiling_->set_edge_color(color_scheme().horizon); |
| 375 floor_->set_center_color(center_color); | 361 floor_->set_center_color(color_scheme().floor); |
| 376 ceiling_->set_edge_color(horizon_color); | 362 floor_->set_edge_color(color_scheme().horizon); |
| 377 ceiling_->set_center_color(center_color); | 363 floor_grid_->set_center_color(color_scheme().floor_grid); |
| 378 floor_grid_->set_center_color(horizon_color); | 364 vr::Colorf floor_grid_edge_color = color_scheme().floor_grid; |
| 379 vr::Colorf edge_color = horizon_color; | 365 floor_grid_edge_color.a = 0.0; |
| 380 edge_color.a = 0.0; | 366 floor_grid_->set_edge_color(floor_grid_edge_color); |
| 381 floor_grid_->set_edge_color(edge_color); | |
| 382 } | 367 } |
| 383 | 368 |
| 384 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { | 369 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { |
| 385 audio_capture_indicator_->set_visible(enabled); | 370 audio_capture_indicator_->set_visible(enabled); |
| 386 } | 371 } |
| 387 | 372 |
| 388 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { | 373 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { |
| 389 video_capture_indicator_->set_visible(enabled); | 374 video_capture_indicator_->set_visible(enabled); |
| 390 } | 375 } |
| 391 | 376 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 bool can_go_forward) {} | 447 bool can_go_forward) {} |
| 463 | 448 |
| 464 void UiSceneManager::OnCloseButtonClicked() { | 449 void UiSceneManager::OnCloseButtonClicked() { |
| 465 browser_->ExitCct(); | 450 browser_->ExitCct(); |
| 466 } | 451 } |
| 467 | 452 |
| 468 int UiSceneManager::AllocateId() { | 453 int UiSceneManager::AllocateId() { |
| 469 return next_available_id_++; | 454 return next_available_id_++; |
| 470 } | 455 } |
| 471 | 456 |
| 457 const ColorScheme& UiSceneManager::color_scheme() const { |
| 458 return ColorScheme::GetColorScheme(fullscreen_ ? ColorScheme::kModeFullscreen |
| 459 : ColorScheme::kModeNormal); |
| 460 } |
| 461 |
| 472 } // namespace vr_shell | 462 } // namespace vr_shell |
| OLD | NEW |