Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_manager.cc

Issue 2902043005: [vr] Add incognito coloring (Closed)
Patch Set: merged changes from aldo and amp Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 64
66 static constexpr float kFullscreenWidthDms = 1.138; 65 static constexpr float kFullscreenDistance = 3;
67 static constexpr float kFullscreenHeightDms = 0.64; 66 static constexpr float kFullscreenHeight = 0.64 * kFullscreenDistance;
68 static constexpr float kFullscreenVerticalOffsetDms = 0.1; 67 static constexpr float kFullscreenWidth = 1.138 * kFullscreenDistance;
69 // Fullscreen distance calculated as value needed to make the content quad 68 static constexpr float kFullscreenVerticalOffset = -0.1 * kFullscreenDistance;
70 // extend down to the floor (with small pullback used to prevent actual
71 // intersection). Note this assumes the vertical offset will always be offest
72 // below the origin (ie negative).
73 static constexpr float kFullscreenDistance =
74 (kSceneHeight / 2.0) /
75 ((kFullscreenVerticalOffsetDms + (kFullscreenHeightDms / 2.0)) + 0.01);
76
77 static constexpr float kFullscreenHeight =
78 kFullscreenHeightDms * kFullscreenDistance;
79 static constexpr float kFullscreenWidth =
80 kFullscreenWidthDms * kFullscreenDistance;
81 static constexpr float kFullscreenVerticalOffset =
82 -kFullscreenVerticalOffsetDms * kFullscreenDistance;
83 static constexpr vr::Colorf kFullscreenHorizonColor = {0.1, 0.1, 0.1, 1.0};
84 static constexpr vr::Colorf kFullscreenCenterColor = {0.2, 0.2, 0.2, 1.0};
85 69
86 // 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.
87 static constexpr float kTextureOffset = 0.01; 71 static constexpr float kTextureOffset = 0.01;
88 72
89 } // namespace 73 } // namespace
90 74
91 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, 75 UiSceneManager::UiSceneManager(VrBrowserInterface* browser,
92 UiScene* scene, 76 UiScene* scene,
93 bool in_cct, 77 bool in_cct,
94 bool in_web_vr) 78 bool in_web_vr)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 std::unique_ptr<UiElement> element; 225 std::unique_ptr<UiElement> element;
242 226
243 // Floor. 227 // Floor.
244 element = base::MakeUnique<UiElement>(); 228 element = base::MakeUnique<UiElement>();
245 element->set_debug_id(kFloor); 229 element->set_debug_id(kFloor);
246 element->set_id(AllocateId()); 230 element->set_id(AllocateId());
247 element->set_size({kSceneSize, kSceneSize, 1.0}); 231 element->set_size({kSceneSize, kSceneSize, 1.0});
248 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); 232 element->set_translation({0.0, -kSceneHeight / 2, 0.0});
249 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});
250 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 234 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
251 element->set_edge_color(kBackgroundHorizonColor); 235 element->set_edge_color(color_scheme().horizon);
252 element->set_center_color(kBackgroundCenterColor); 236 element->set_center_color(color_scheme().floor);
253 element->set_draw_phase(0); 237 element->set_draw_phase(0);
254 floor_ = element.get(); 238 floor_ = element.get();
255 content_elements_.push_back(element.get()); 239 content_elements_.push_back(element.get());
256 scene_->AddUiElement(std::move(element)); 240 scene_->AddUiElement(std::move(element));
257 241
258 // Ceiling. 242 // Ceiling.
259 element = base::MakeUnique<UiElement>(); 243 element = base::MakeUnique<UiElement>();
260 element->set_debug_id(kCeiling); 244 element->set_debug_id(kCeiling);
261 element->set_id(AllocateId()); 245 element->set_id(AllocateId());
262 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 246 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
263 element->set_size({kSceneSize, kSceneSize, 1.0}); 247 element->set_size({kSceneSize, kSceneSize, 1.0});
264 element->set_translation({0.0, kSceneHeight / 2, 0.0}); 248 element->set_translation({0.0, kSceneHeight / 2, 0.0});
265 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); 249 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2});
266 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 250 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
267 element->set_edge_color(kBackgroundHorizonColor); 251 element->set_edge_color(color_scheme().horizon);
268 element->set_center_color(kBackgroundCenterColor); 252 element->set_center_color(color_scheme().ceiling);
269 element->set_draw_phase(0); 253 element->set_draw_phase(0);
270 ceiling_ = element.get(); 254 ceiling_ = element.get();
271 content_elements_.push_back(element.get()); 255 content_elements_.push_back(element.get());
272 scene_->AddUiElement(std::move(element)); 256 scene_->AddUiElement(std::move(element));
273 257
274 // Floor grid. 258 // Floor grid.
275 element = base::MakeUnique<UiElement>(); 259 element = base::MakeUnique<UiElement>();
276 element->set_debug_id(kFloorGrid); 260 element->set_debug_id(kFloorGrid);
277 element->set_id(AllocateId()); 261 element->set_id(AllocateId());
278 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
279 element->set_size({kSceneSize, kSceneSize, 1.0}); 262 element->set_size({kSceneSize, kSceneSize, 1.0});
280 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); 263 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0});
281 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); 264 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2});
282 element->set_fill(vr_shell::Fill::GRID_GRADIENT); 265 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
283 element->set_center_color(kBackgroundHorizonColor); 266 element->set_center_color(color_scheme().horizon);
284 vr::Colorf edge_color = kBackgroundHorizonColor; 267 vr::Colorf edge_color = color_scheme().horizon;
285 edge_color.a = 0.0; 268 edge_color.a = 0.0;
286 element->set_edge_color(edge_color); 269 element->set_edge_color(edge_color);
287 element->set_gridline_count(kFloorGridlineCount); 270 element->set_gridline_count(kFloorGridlineCount);
271 element->set_center_color(color_scheme().horizon);
288 element->set_draw_phase(0); 272 element->set_draw_phase(0);
289 floor_grid_ = element.get(); 273 floor_grid_ = element.get();
290 content_elements_.push_back(element.get()); 274 content_elements_.push_back(element.get());
291 scene_->AddUiElement(std::move(element)); 275 scene_->AddUiElement(std::move(element));
292 276
293 scene_->SetBackgroundColor(kBackgroundHorizonColor); 277 scene_->SetBackgroundColor(color_scheme().horizon);
294 } 278 }
295 279
296 void UiSceneManager::CreateUrlBar() { 280 void UiSceneManager::CreateUrlBar() {
297 // TODO(cjgrant): Incorporate final size and position. 281 // TODO(cjgrant): Incorporate final size and position.
298 auto url_bar = base::MakeUnique<UrlBar>(512); 282 auto url_bar = base::MakeUnique<UrlBar>(512);
299 url_bar->set_debug_id(kUrlBar); 283 url_bar->set_debug_id(kUrlBar);
300 url_bar->set_id(AllocateId()); 284 url_bar->set_id(AllocateId());
301 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); 285 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance});
302 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); 286 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1});
303 url_bar->SetBackButtonCallback( 287 url_bar->SetBackButtonCallback(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 for (UiElement* element : content_elements_) { 343 for (UiElement* element : content_elements_) {
360 element->SetEnabled(!web_vr_mode_); 344 element->SetEnabled(!web_vr_mode_);
361 } 345 }
362 346
363 // Update content quad parameters depending on fullscreen. 347 // Update content quad parameters depending on fullscreen.
364 // TODO(http://crbug.com/642937): Animate fullscreen transitions. 348 // TODO(http://crbug.com/642937): Animate fullscreen transitions.
365 if (fullscreen_) { 349 if (fullscreen_) {
366 main_content_->set_translation( 350 main_content_->set_translation(
367 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); 351 {0, kFullscreenVerticalOffset, -kFullscreenDistance});
368 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); 352 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1});
369
370 ConfigureBackgroundColor(kFullscreenCenterColor, kFullscreenHorizonColor);
371 } else { 353 } else {
372 // Note that main_content_ is already visible in this case. 354 // Note that main_content_ is already visible in this case.
373 main_content_->set_translation( 355 main_content_->set_translation(
374 {0, kContentVerticalOffset, -kContentDistance}); 356 {0, kContentVerticalOffset, -kContentDistance});
375 main_content_->set_size({kContentWidth, kContentHeight, 1}); 357 main_content_->set_size({kContentWidth, kContentHeight, 1});
376
377 ConfigureBackgroundColor(kBackgroundCenterColor, kBackgroundHorizonColor);
378 } 358 }
379 359
360 UpdateBackgroundColor();
380 scene_->SetBackgroundDistance(main_content_->translation().z() * 361 scene_->SetBackgroundDistance(main_content_->translation().z() *
381 -kBackgroundDistanceMultiplier); 362 -kBackgroundDistanceMultiplier);
382 } 363 }
383 364
384 void UiSceneManager::ConfigureBackgroundColor(vr::Colorf center_color, 365 void UiSceneManager::UpdateBackgroundColor() {
385 vr::Colorf horizon_color) { 366 scene_->SetBackgroundColor(color_scheme().horizon);
386 scene_->SetBackgroundColor(horizon_color); 367 ceiling_->set_center_color(color_scheme().ceiling);
387 floor_->set_edge_color(horizon_color); 368 ceiling_->set_edge_color(color_scheme().horizon);
388 floor_->set_center_color(center_color); 369 floor_->set_center_color(color_scheme().floor);
389 ceiling_->set_edge_color(horizon_color); 370 floor_->set_edge_color(color_scheme().horizon);
390 ceiling_->set_center_color(center_color); 371 floor_grid_->set_center_color(color_scheme().grid);
391 floor_grid_->set_center_color(horizon_color); 372 vr::Colorf floor_grid_edge_color = color_scheme().grid;
392 vr::Colorf edge_color = horizon_color; 373 floor_grid_edge_color.a = 0.0;
393 edge_color.a = 0.0; 374 floor_grid_->set_edge_color(floor_grid_edge_color);
394 floor_grid_->set_edge_color(edge_color);
395 } 375 }
396 376
397 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { 377 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
398 audio_capture_indicator_->set_visible(enabled); 378 audio_capture_indicator_->set_visible(enabled);
399 } 379 }
400 380
401 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { 381 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) {
402 video_capture_indicator_->set_visible(enabled); 382 video_capture_indicator_->set_visible(enabled);
403 } 383 }
404 384
405 void UiSceneManager::SetScreenCapturingIndicator(bool enabled) { 385 void UiSceneManager::SetScreenCapturingIndicator(bool enabled) {
406 // TODO(asimjour) add the indicator and change the visibility here. 386 // TODO(asimjour) add the indicator and change the visibility here.
407 } 387 }
408 388
409 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { 389 void UiSceneManager::SetWebVrSecureOrigin(bool secure) {
410 secure_origin_ = secure; 390 secure_origin_ = secure;
411 ConfigureSecurityWarnings(); 391 ConfigureSecurityWarnings();
412 } 392 }
413 393
394 void UiSceneManager::SetIncognito(bool incognito) {
395 const bool needs_update = incognito != incognito_;
396 incognito_ = incognito;
397 if (needs_update)
398 UpdateBackgroundColor();
399 url_bar_->SetIncognito(incognito);
400 }
401
414 void UiSceneManager::OnAppButtonClicked() { 402 void UiSceneManager::OnAppButtonClicked() {
415 // App button click exits the WebVR presentation and fullscreen. 403 // App button click exits the WebVR presentation and fullscreen.
416 browser_->ExitPresent(); 404 browser_->ExitPresent();
417 browser_->ExitFullscreen(); 405 browser_->ExitFullscreen();
418 } 406 }
419 407
420 void UiSceneManager::OnAppButtonGesturePerformed( 408 void UiSceneManager::OnAppButtonGesturePerformed(
421 UiInterface::Direction direction) {} 409 UiInterface::Direction direction) {}
422 410
423 void UiSceneManager::SetFullscreen(bool fullscreen) { 411 void UiSceneManager::SetFullscreen(bool fullscreen) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 bool can_go_forward) {} 463 bool can_go_forward) {}
476 464
477 void UiSceneManager::OnCloseButtonClicked() { 465 void UiSceneManager::OnCloseButtonClicked() {
478 browser_->ExitCct(); 466 browser_->ExitCct();
479 } 467 }
480 468
481 int UiSceneManager::AllocateId() { 469 int UiSceneManager::AllocateId() {
482 return next_available_id_++; 470 return next_available_id_++;
483 } 471 }
484 472
473 const ColorScheme& UiSceneManager::color_scheme() const {
474 if (incognito_)
475 return ColorScheme::GetColorScheme(ColorScheme::kModeIncognito);
476 if (fullscreen_)
477 return ColorScheme::GetColorScheme(ColorScheme::kModeFullscreen);
478 return ColorScheme::GetColorScheme(ColorScheme::kModeNormal);
479 }
480
485 } // namespace vr_shell 481 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698