| 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" | |
| 10 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" |
| 11 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 12 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" | 11 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" |
| 13 #include "chrome/browser/android/vr_shell/ui_elements/button.h" | 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" |
| 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" | 13 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" |
| 15 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" | 14 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
| 16 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning
.h" | 15 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning
.h" |
| 17 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h
" | 16 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h
" |
| 18 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" | 17 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" |
| 19 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning
.h" | 18 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning
.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 247 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
| 249 element->set_draw_phase(0); | 248 element->set_draw_phase(0); |
| 250 ceiling_ = element.get(); | 249 ceiling_ = element.get(); |
| 251 content_elements_.push_back(element.get()); | 250 content_elements_.push_back(element.get()); |
| 252 scene_->AddUiElement(std::move(element)); | 251 scene_->AddUiElement(std::move(element)); |
| 253 | 252 |
| 254 // Floor grid. | 253 // Floor grid. |
| 255 element = base::MakeUnique<UiElement>(); | 254 element = base::MakeUnique<UiElement>(); |
| 256 element->set_debug_id(kFloorGrid); | 255 element->set_debug_id(kFloorGrid); |
| 257 element->set_id(AllocateId()); | 256 element->set_id(AllocateId()); |
| 258 element->set_fill(vr_shell::Fill::GRID_GRADIENT); | |
| 259 element->set_size({kSceneSize, kSceneSize, 1.0}); | 257 element->set_size({kSceneSize, kSceneSize, 1.0}); |
| 260 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); | 258 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); |
| 261 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); | 259 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); |
| 262 element->set_fill(vr_shell::Fill::GRID_GRADIENT); | 260 element->set_fill(vr_shell::Fill::GRID_GRADIENT); |
| 263 element->set_gridline_count(kFloorGridlineCount); | 261 element->set_gridline_count(kFloorGridlineCount); |
| 264 element->set_draw_phase(0); | 262 element->set_draw_phase(0); |
| 265 floor_grid_ = element.get(); | 263 floor_grid_ = element.get(); |
| 266 content_elements_.push_back(element.get()); | 264 content_elements_.push_back(element.get()); |
| 267 scene_->AddUiElement(std::move(element)); | 265 scene_->AddUiElement(std::move(element)); |
| 268 | 266 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 main_content_->set_translation( | 345 main_content_->set_translation( |
| 348 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); | 346 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); |
| 349 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); | 347 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); |
| 350 } else { | 348 } else { |
| 351 // Note that main_content_ is already visible in this case. | 349 // Note that main_content_ is already visible in this case. |
| 352 main_content_->set_translation( | 350 main_content_->set_translation( |
| 353 {0, kContentVerticalOffset, -kContentDistance}); | 351 {0, kContentVerticalOffset, -kContentDistance}); |
| 354 main_content_->set_size({kContentWidth, kContentHeight, 1}); | 352 main_content_->set_size({kContentWidth, kContentHeight, 1}); |
| 355 } | 353 } |
| 356 | 354 |
| 357 UpdateBackgroundColor(); | 355 scene_->SetMode(mode()); |
| 358 scene_->SetBackgroundDistance(main_content_->translation().z() * | 356 scene_->SetBackgroundDistance(main_content_->translation().z() * |
| 359 -kBackgroundDistanceMultiplier); | 357 -kBackgroundDistanceMultiplier); |
| 358 UpdateBackgroundColor(); |
| 360 } | 359 } |
| 361 | 360 |
| 362 void UiSceneManager::UpdateBackgroundColor() { | 361 void UiSceneManager::UpdateBackgroundColor() { |
| 363 scene_->SetBackgroundColor(color_scheme().horizon); | 362 // TODO(vollick): it would be nice if ceiling, floor and the grid were |
| 363 // UiElement subclasses and could respond to the OnSetMode signal. |
| 364 ceiling_->set_center_color(color_scheme().ceiling); | 364 ceiling_->set_center_color(color_scheme().ceiling); |
| 365 ceiling_->set_edge_color(color_scheme().horizon); | 365 ceiling_->set_edge_color(color_scheme().horizon); |
| 366 floor_->set_center_color(color_scheme().floor); | 366 floor_->set_center_color(color_scheme().floor); |
| 367 floor_->set_edge_color(color_scheme().horizon); | 367 floor_->set_edge_color(color_scheme().horizon); |
| 368 floor_grid_->set_center_color(color_scheme().floor_grid); | 368 floor_grid_->set_center_color(color_scheme().floor_grid); |
| 369 SkColor floor_grid_edge_color = SkColorSetA(color_scheme().floor_grid, 0); | 369 SkColor floor_grid_edge_color = SkColorSetA(color_scheme().floor_grid, 0); |
| 370 floor_grid_->set_edge_color(floor_grid_edge_color); | 370 floor_grid_->set_edge_color(floor_grid_edge_color); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { | 373 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { |
| 374 audio_capturing_ = enabled; | 374 audio_capturing_ = enabled; |
| 375 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); | 375 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { | 378 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { |
| 379 video_capturing_ = enabled; | 379 video_capturing_ = enabled; |
| 380 video_capture_indicator_->set_visible(enabled && !web_vr_mode_); | 380 video_capture_indicator_->set_visible(enabled && !web_vr_mode_); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void UiSceneManager::SetScreenCapturingIndicator(bool enabled) { | 383 void UiSceneManager::SetScreenCapturingIndicator(bool enabled) { |
| 384 screen_capturing_ = enabled; | 384 screen_capturing_ = enabled; |
| 385 screen_capture_indicator_->set_visible(enabled && !web_vr_mode_); | 385 screen_capture_indicator_->set_visible(enabled && !web_vr_mode_); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { | 388 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { |
| 389 secure_origin_ = secure; | 389 secure_origin_ = secure; |
| 390 ConfigureSecurityWarnings(); | 390 ConfigureSecurityWarnings(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void UiSceneManager::SetIncognito(bool incognito) { |
| 394 if (incognito == incognito_) |
| 395 return; |
| 396 incognito_ = incognito; |
| 397 ConfigureScene(); |
| 398 } |
| 399 |
| 393 void UiSceneManager::OnAppButtonClicked() { | 400 void UiSceneManager::OnAppButtonClicked() { |
| 394 // App button click exits the WebVR presentation and fullscreen. | 401 // App button click exits the WebVR presentation and fullscreen. |
| 395 browser_->ExitPresent(); | 402 browser_->ExitPresent(); |
| 396 browser_->ExitFullscreen(); | 403 browser_->ExitFullscreen(); |
| 397 } | 404 } |
| 398 | 405 |
| 399 void UiSceneManager::OnAppButtonGesturePerformed( | 406 void UiSceneManager::OnAppButtonGesturePerformed( |
| 400 UiInterface::Direction direction) {} | 407 UiInterface::Direction direction) {} |
| 401 | 408 |
| 402 void UiSceneManager::SetFullscreen(bool fullscreen) { | 409 void UiSceneManager::SetFullscreen(bool fullscreen) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 465 } |
| 459 | 466 |
| 460 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { | 467 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { |
| 461 browser_->OnUnsupportedMode(mode); | 468 browser_->OnUnsupportedMode(mode); |
| 462 } | 469 } |
| 463 | 470 |
| 464 int UiSceneManager::AllocateId() { | 471 int UiSceneManager::AllocateId() { |
| 465 return next_available_id_++; | 472 return next_available_id_++; |
| 466 } | 473 } |
| 467 | 474 |
| 475 ColorScheme::Mode UiSceneManager::mode() const { |
| 476 if (incognito_) |
| 477 return ColorScheme::kModeIncognito; |
| 478 if (fullscreen_) |
| 479 return ColorScheme::kModeFullscreen; |
| 480 return ColorScheme::kModeNormal; |
| 481 } |
| 482 |
| 468 const ColorScheme& UiSceneManager::color_scheme() const { | 483 const ColorScheme& UiSceneManager::color_scheme() const { |
| 469 return ColorScheme::GetColorScheme(fullscreen_ ? ColorScheme::kModeFullscreen | 484 return ColorScheme::GetColorScheme(mode()); |
| 470 : ColorScheme::kModeNormal); | |
| 471 } | 485 } |
| 472 | 486 |
| 473 } // namespace vr_shell | 487 } // namespace vr_shell |
| OLD | NEW |