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

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

Issue 2905013002: [vr] Introduce ColorScheme (Closed)
Patch Set: added comment about naming of colors in the scheme Created 3 years, 7 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 kFullscreenWidthDms = 1.138;
67 static constexpr float kFullscreenHeightDms = 0.64; 66 static constexpr float kFullscreenHeightDms = 0.64;
68 static constexpr float kFullscreenVerticalOffsetDms = 0.1; 67 static constexpr float kFullscreenVerticalOffsetDms = 0.1;
69 // Fullscreen distance calculated as value needed to make the content quad 68 // Fullscreen distance calculated as value needed to make the content quad
70 // extend down to the floor (with small pullback used to prevent actual 69 // extend down to the floor (with small pullback used to prevent actual
71 // intersection). Note this assumes the vertical offset will always be offest 70 // intersection). Note this assumes the vertical offset will always be offest
72 // below the origin (ie negative). 71 // below the origin (ie negative).
73 static constexpr float kFullscreenDistance = 72 static constexpr float kFullscreenDistance =
74 (kSceneHeight / 2.0) / 73 (kSceneHeight / 2.0) /
75 ((kFullscreenVerticalOffsetDms + (kFullscreenHeightDms / 2.0)) + 0.01); 74 ((kFullscreenVerticalOffsetDms + (kFullscreenHeightDms / 2.0)) + 0.01);
76 75
77 static constexpr float kFullscreenHeight = 76 static constexpr float kFullscreenHeight =
78 kFullscreenHeightDms * kFullscreenDistance; 77 kFullscreenHeightDms * kFullscreenDistance;
79 static constexpr float kFullscreenWidth = 78 static constexpr float kFullscreenWidth =
80 kFullscreenWidthDms * kFullscreenDistance; 79 kFullscreenWidthDms * kFullscreenDistance;
81 static constexpr float kFullscreenVerticalOffset = 80 static constexpr float kFullscreenVerticalOffset =
82 -kFullscreenVerticalOffsetDms * kFullscreenDistance; 81 -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 82
86 // Tiny distance to offset textures that should appear in the same plane. 83 // Tiny distance to offset textures that should appear in the same plane.
87 static constexpr float kTextureOffset = 0.01; 84 static constexpr float kTextureOffset = 0.01;
88 85
89 } // namespace 86 } // namespace
90 87
91 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, 88 UiSceneManager::UiSceneManager(VrBrowserInterface* browser,
92 UiScene* scene, 89 UiScene* scene,
93 bool in_cct, 90 bool in_cct,
94 bool in_web_vr) 91 bool in_web_vr)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 std::unique_ptr<UiElement> element; 238 std::unique_ptr<UiElement> element;
242 239
243 // Floor. 240 // Floor.
244 element = base::MakeUnique<UiElement>(); 241 element = base::MakeUnique<UiElement>();
245 element->set_debug_id(kFloor); 242 element->set_debug_id(kFloor);
246 element->set_id(AllocateId()); 243 element->set_id(AllocateId());
247 element->set_size({kSceneSize, kSceneSize, 1.0}); 244 element->set_size({kSceneSize, kSceneSize, 1.0});
248 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); 245 element->set_translation({0.0, -kSceneHeight / 2, 0.0});
249 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); 246 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0});
250 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 247 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
251 element->set_edge_color(kBackgroundHorizonColor); 248 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
252 element->set_center_color(kBackgroundCenterColor); 249 element->set_center_color(color_scheme().floor);
253 element->set_draw_phase(0); 250 element->set_draw_phase(0);
254 floor_ = element.get(); 251 floor_ = element.get();
255 content_elements_.push_back(element.get()); 252 content_elements_.push_back(element.get());
256 scene_->AddUiElement(std::move(element)); 253 scene_->AddUiElement(std::move(element));
257 254
258 // Ceiling. 255 // Ceiling.
259 element = base::MakeUnique<UiElement>(); 256 element = base::MakeUnique<UiElement>();
260 element->set_debug_id(kCeiling); 257 element->set_debug_id(kCeiling);
261 element->set_id(AllocateId()); 258 element->set_id(AllocateId());
262 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 259 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
263 element->set_size({kSceneSize, kSceneSize, 1.0}); 260 element->set_size({kSceneSize, kSceneSize, 1.0});
264 element->set_translation({0.0, kSceneHeight / 2, 0.0}); 261 element->set_translation({0.0, kSceneHeight / 2, 0.0});
265 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); 262 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2});
266 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 263 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
267 element->set_edge_color(kBackgroundHorizonColor); 264 element->set_edge_color(color_scheme().horizon);
268 element->set_center_color(kBackgroundCenterColor); 265 element->set_center_color(color_scheme().ceiling);
269 element->set_draw_phase(0); 266 element->set_draw_phase(0);
270 ceiling_ = element.get(); 267 ceiling_ = element.get();
271 content_elements_.push_back(element.get()); 268 content_elements_.push_back(element.get());
272 scene_->AddUiElement(std::move(element)); 269 scene_->AddUiElement(std::move(element));
273 270
274 // Floor grid. 271 // Floor grid.
275 element = base::MakeUnique<UiElement>(); 272 element = base::MakeUnique<UiElement>();
276 element->set_debug_id(kFloorGrid); 273 element->set_debug_id(kFloorGrid);
277 element->set_id(AllocateId()); 274 element->set_id(AllocateId());
278 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
279 element->set_size({kSceneSize, kSceneSize, 1.0}); 275 element->set_size({kSceneSize, kSceneSize, 1.0});
280 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); 276 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0});
281 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); 277 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2});
282 element->set_fill(vr_shell::Fill::GRID_GRADIENT); 278 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
283 element->set_center_color(kBackgroundHorizonColor); 279 element->set_center_color(color_scheme().horizon);
284 vr::Colorf edge_color = kBackgroundHorizonColor; 280 vr::Colorf edge_color = color_scheme().horizon;
285 edge_color.a = 0.0; 281 edge_color.a = 0.0;
286 element->set_edge_color(edge_color); 282 element->set_edge_color(edge_color);
287 element->set_gridline_count(kFloorGridlineCount); 283 element->set_gridline_count(kFloorGridlineCount);
284 element->set_center_color(color_scheme().horizon);
288 element->set_draw_phase(0); 285 element->set_draw_phase(0);
289 floor_grid_ = element.get(); 286 floor_grid_ = element.get();
290 content_elements_.push_back(element.get()); 287 content_elements_.push_back(element.get());
291 scene_->AddUiElement(std::move(element)); 288 scene_->AddUiElement(std::move(element));
292 289
293 scene_->SetBackgroundColor(kBackgroundHorizonColor); 290 scene_->SetBackgroundColor(color_scheme().horizon);
294 } 291 }
295 292
296 void UiSceneManager::CreateUrlBar() { 293 void UiSceneManager::CreateUrlBar() {
297 // TODO(cjgrant): Incorporate final size and position. 294 // TODO(cjgrant): Incorporate final size and position.
298 auto url_bar = base::MakeUnique<UrlBar>(512); 295 auto url_bar = base::MakeUnique<UrlBar>(512);
299 url_bar->set_debug_id(kUrlBar); 296 url_bar->set_debug_id(kUrlBar);
300 url_bar->set_id(AllocateId()); 297 url_bar->set_id(AllocateId());
301 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); 298 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance});
302 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); 299 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1});
303 url_bar->SetBackButtonCallback( 300 url_bar->SetBackButtonCallback(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 for (UiElement* element : content_elements_) { 356 for (UiElement* element : content_elements_) {
360 element->SetEnabled(!web_vr_mode_); 357 element->SetEnabled(!web_vr_mode_);
361 } 358 }
362 359
363 // Update content quad parameters depending on fullscreen. 360 // Update content quad parameters depending on fullscreen.
364 // TODO(http://crbug.com/642937): Animate fullscreen transitions. 361 // TODO(http://crbug.com/642937): Animate fullscreen transitions.
365 if (fullscreen_) { 362 if (fullscreen_) {
366 main_content_->set_translation( 363 main_content_->set_translation(
367 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); 364 {0, kFullscreenVerticalOffset, -kFullscreenDistance});
368 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); 365 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1});
369
370 ConfigureBackgroundColor(kFullscreenCenterColor, kFullscreenHorizonColor);
371 } else { 366 } else {
372 // Note that main_content_ is already visible in this case. 367 // Note that main_content_ is already visible in this case.
373 main_content_->set_translation( 368 main_content_->set_translation(
374 {0, kContentVerticalOffset, -kContentDistance}); 369 {0, kContentVerticalOffset, -kContentDistance});
375 main_content_->set_size({kContentWidth, kContentHeight, 1}); 370 main_content_->set_size({kContentWidth, kContentHeight, 1});
376
377 ConfigureBackgroundColor(kBackgroundCenterColor, kBackgroundHorizonColor);
378 } 371 }
379 372
373 UpdateBackgroundColor();
380 scene_->SetBackgroundDistance(main_content_->translation().z() * 374 scene_->SetBackgroundDistance(main_content_->translation().z() *
381 -kBackgroundDistanceMultiplier); 375 -kBackgroundDistanceMultiplier);
382 } 376 }
383 377
384 void UiSceneManager::ConfigureBackgroundColor(vr::Colorf center_color, 378 void UiSceneManager::UpdateBackgroundColor() {
385 vr::Colorf horizon_color) { 379 scene_->SetBackgroundColor(color_scheme().horizon);
386 scene_->SetBackgroundColor(horizon_color); 380 ceiling_->set_center_color(color_scheme().ceiling);
387 floor_->set_edge_color(horizon_color); 381 ceiling_->set_edge_color(color_scheme().horizon);
388 floor_->set_center_color(center_color); 382 floor_->set_center_color(color_scheme().floor);
389 ceiling_->set_edge_color(horizon_color); 383 floor_->set_edge_color(color_scheme().horizon);
390 ceiling_->set_center_color(center_color); 384 floor_grid_->set_center_color(color_scheme().grid);
391 floor_grid_->set_center_color(horizon_color); 385 vr::Colorf floor_grid_edge_color = color_scheme().grid;
392 vr::Colorf edge_color = horizon_color; 386 floor_grid_edge_color.a = 0.0;
393 edge_color.a = 0.0; 387 floor_grid_->set_edge_color(floor_grid_edge_color);
394 floor_grid_->set_edge_color(edge_color);
395 } 388 }
396 389
397 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { 390 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
398 audio_capture_indicator_->set_visible(enabled); 391 audio_capture_indicator_->set_visible(enabled);
399 } 392 }
400 393
401 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { 394 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) {
402 video_capture_indicator_->set_visible(enabled); 395 video_capture_indicator_->set_visible(enabled);
403 } 396 }
404 397
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 bool can_go_forward) {} 468 bool can_go_forward) {}
476 469
477 void UiSceneManager::OnCloseButtonClicked() { 470 void UiSceneManager::OnCloseButtonClicked() {
478 browser_->ExitCct(); 471 browser_->ExitCct();
479 } 472 }
480 473
481 int UiSceneManager::AllocateId() { 474 int UiSceneManager::AllocateId() {
482 return next_available_id_++; 475 return next_available_id_++;
483 } 476 }
484 477
478 const ColorScheme& UiSceneManager::color_scheme() const {
479 return ColorScheme::GetColorScheme(fullscreen_ ? ColorScheme::kModeFullscreen
480 : ColorScheme::kModeNormal);
481 }
482
485 } // namespace vr_shell 483 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698