| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 main_content_->set_translation( | 342 main_content_->set_translation( |
| 345 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); | 343 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); |
| 346 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); | 344 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); |
| 347 } else { | 345 } else { |
| 348 // Note that main_content_ is already visible in this case. | 346 // Note that main_content_ is already visible in this case. |
| 349 main_content_->set_translation( | 347 main_content_->set_translation( |
| 350 {0, kContentVerticalOffset, -kContentDistance}); | 348 {0, kContentVerticalOffset, -kContentDistance}); |
| 351 main_content_->set_size({kContentWidth, kContentHeight, 1}); | 349 main_content_->set_size({kContentWidth, kContentHeight, 1}); |
| 352 } | 350 } |
| 353 | 351 |
| 354 UpdateBackgroundColor(); | 352 scene_->SetMode(mode()); |
| 355 scene_->SetBackgroundDistance(main_content_->translation().z() * | 353 scene_->SetBackgroundDistance(main_content_->translation().z() * |
| 356 -kBackgroundDistanceMultiplier); | 354 -kBackgroundDistanceMultiplier); |
| 355 UpdateBackgroundColor(); |
| 357 } | 356 } |
| 358 | 357 |
| 359 void UiSceneManager::UpdateBackgroundColor() { | 358 void UiSceneManager::UpdateBackgroundColor() { |
| 360 scene_->SetBackgroundColor(color_scheme().horizon); | 359 // TODO(vollick): it would be nice if ceiling, floor and the grid were |
| 360 // UiElement subclasses and could respond to the OnSetMode signal. |
| 361 ceiling_->set_center_color(color_scheme().ceiling); | 361 ceiling_->set_center_color(color_scheme().ceiling); |
| 362 ceiling_->set_edge_color(color_scheme().horizon); | 362 ceiling_->set_edge_color(color_scheme().horizon); |
| 363 floor_->set_center_color(color_scheme().floor); | 363 floor_->set_center_color(color_scheme().floor); |
| 364 floor_->set_edge_color(color_scheme().horizon); | 364 floor_->set_edge_color(color_scheme().horizon); |
| 365 floor_grid_->set_center_color(color_scheme().floor_grid); | 365 floor_grid_->set_center_color(color_scheme().floor_grid); |
| 366 SkColor floor_grid_edge_color = SkColorSetA(color_scheme().floor_grid, 0); | 366 SkColor floor_grid_edge_color = SkColorSetA(color_scheme().floor_grid, 0); |
| 367 floor_grid_->set_edge_color(floor_grid_edge_color); | 367 floor_grid_->set_edge_color(floor_grid_edge_color); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { | 370 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { |
| 371 audio_capture_indicator_->set_visible(enabled); | 371 audio_capture_indicator_->set_visible(enabled); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { | 374 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { |
| 375 video_capture_indicator_->set_visible(enabled); | 375 video_capture_indicator_->set_visible(enabled); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void UiSceneManager::SetScreenCapturingIndicator(bool enabled) { | 378 void UiSceneManager::SetScreenCapturingIndicator(bool enabled) { |
| 379 // TODO(asimjour) add the indicator and change the visibility here. | 379 // TODO(asimjour) add the indicator and change the visibility here. |
| 380 } | 380 } |
| 381 | 381 |
| 382 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { | 382 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { |
| 383 secure_origin_ = secure; | 383 secure_origin_ = secure; |
| 384 ConfigureSecurityWarnings(); | 384 ConfigureSecurityWarnings(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 void UiSceneManager::SetIncognito(bool incognito) { |
| 388 if (incognito == incognito_) |
| 389 return; |
| 390 incognito_ = incognito; |
| 391 ConfigureScene(); |
| 392 } |
| 393 |
| 387 void UiSceneManager::OnAppButtonClicked() { | 394 void UiSceneManager::OnAppButtonClicked() { |
| 388 // App button click exits the WebVR presentation and fullscreen. | 395 // App button click exits the WebVR presentation and fullscreen. |
| 389 browser_->ExitPresent(); | 396 browser_->ExitPresent(); |
| 390 browser_->ExitFullscreen(); | 397 browser_->ExitFullscreen(); |
| 391 } | 398 } |
| 392 | 399 |
| 393 void UiSceneManager::OnAppButtonGesturePerformed( | 400 void UiSceneManager::OnAppButtonGesturePerformed( |
| 394 UiInterface::Direction direction) {} | 401 UiInterface::Direction direction) {} |
| 395 | 402 |
| 396 void UiSceneManager::SetFullscreen(bool fullscreen) { | 403 void UiSceneManager::SetFullscreen(bool fullscreen) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 459 } |
| 453 | 460 |
| 454 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { | 461 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { |
| 455 browser_->OnUnsupportedMode(mode); | 462 browser_->OnUnsupportedMode(mode); |
| 456 } | 463 } |
| 457 | 464 |
| 458 int UiSceneManager::AllocateId() { | 465 int UiSceneManager::AllocateId() { |
| 459 return next_available_id_++; | 466 return next_available_id_++; |
| 460 } | 467 } |
| 461 | 468 |
| 469 ColorScheme::Mode UiSceneManager::mode() const { |
| 470 if (incognito_) |
| 471 return ColorScheme::kModeIncognito; |
| 472 if (fullscreen_) |
| 473 return ColorScheme::kModeFullscreen; |
| 474 return ColorScheme::kModeNormal; |
| 475 } |
| 476 |
| 462 const ColorScheme& UiSceneManager::color_scheme() const { | 477 const ColorScheme& UiSceneManager::color_scheme() const { |
| 463 return ColorScheme::GetColorScheme(fullscreen_ ? ColorScheme::kModeFullscreen | 478 return ColorScheme::GetColorScheme(mode()); |
| 464 : ColorScheme::kModeNormal); | |
| 465 } | 479 } |
| 466 | 480 |
| 467 } // namespace vr_shell | 481 } // namespace vr_shell |
| OLD | NEW |