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/textures/ui_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
10 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" | 10 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 static constexpr float kUrlBarDistance = 2.4; | 41 static constexpr float kUrlBarDistance = 2.4; |
42 static constexpr float kUrlBarWidth = 0.672 * kUrlBarDistance; | 42 static constexpr float kUrlBarWidth = 0.672 * kUrlBarDistance; |
43 static constexpr float kUrlBarHeight = 0.088 * kUrlBarDistance; | 43 static constexpr float kUrlBarHeight = 0.088 * kUrlBarDistance; |
44 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; | 44 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; |
45 | 45 |
46 static constexpr float kLoadingIndicatorWidth = 0.24 * kUrlBarDistance; | 46 static constexpr float kLoadingIndicatorWidth = 0.24 * kUrlBarDistance; |
47 static constexpr float kLoadingIndicatorHeight = 0.008 * kUrlBarDistance; | 47 static constexpr float kLoadingIndicatorHeight = 0.008 * kUrlBarDistance; |
48 static constexpr float kLoadingIndicatorOffset = | 48 static constexpr float kLoadingIndicatorOffset = |
49 -0.016 * kUrlBarDistance - kLoadingIndicatorHeight / 2; | 49 -0.016 * kUrlBarDistance - kLoadingIndicatorHeight / 2; |
50 | 50 |
51 static constexpr float kFullscreenWidth = 2.88; | |
52 static constexpr float kFullscreenHeight = 1.62; | |
53 static constexpr float kFullscreenDistance = 3; | |
54 static constexpr float kFullscreenVerticalOffset = -0.26; | |
55 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0}; | |
56 | |
57 static constexpr float kSceneSize = 25.0; | 51 static constexpr float kSceneSize = 25.0; |
58 static constexpr float kSceneHeight = 4.0; | 52 static constexpr float kSceneHeight = 4.0; |
59 static constexpr int kFloorGridlineCount = 40; | 53 static constexpr int kFloorGridlineCount = 40; |
60 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; | 54 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; |
61 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; | 55 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; |
62 | 56 |
57 static constexpr float kFullscreenWidthDms = 1.138; | |
cjgrant
2017/05/18 16:07:16
We're implying Dms elsewhere (ie. lateral meters a
amp
2017/05/18 16:15:33
The only reason I added them here was to calculate
| |
58 static constexpr float kFullscreenHeightDms = 0.64; | |
59 static constexpr float kFullscreenVerticalOffsetDms = 0.1; | |
60 // Fullscreen distance calculated as value needed to make the content quad | |
61 // extend down to the floor (with small pullback used to prevent actual | |
62 // intersection). Note this assumes the vertical offset will always be offest | |
63 // below the origin (ie negative). | |
64 static constexpr float kFullscreenDistance = | |
65 (kSceneHeight / 2.0) / | |
66 ((kFullscreenVerticalOffsetDms + (kFullscreenHeightDms / 2.0)) + 0.01); | |
67 | |
68 static constexpr float kFullscreenHeight = | |
69 kFullscreenHeightDms * kFullscreenDistance; | |
70 static constexpr float kFullscreenWidth = | |
71 kFullscreenWidthDms * kFullscreenDistance; | |
72 static constexpr float kFullscreenVerticalOffset = | |
73 -kFullscreenVerticalOffsetDms * kFullscreenDistance; | |
74 static constexpr vr::Colorf kFullscreenHorizonColor = {0.1, 0.1, 0.1, 1.0}; | |
75 static constexpr vr::Colorf kFullscreenCenterColor = {0.2, 0.2, 0.2, 1.0}; | |
76 | |
63 // Tiny distance to offset textures that should appear in the same plane. | 77 // Tiny distance to offset textures that should appear in the same plane. |
64 static constexpr float kTextureOffset = 0.01; | 78 static constexpr float kTextureOffset = 0.01; |
65 | 79 |
66 } // namespace | 80 } // namespace |
67 | 81 |
68 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, | 82 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, |
69 UiScene* scene, | 83 UiScene* scene, |
70 bool in_cct, | 84 bool in_cct, |
71 bool in_web_vr) | 85 bool in_web_vr) |
72 : browser_(browser), | 86 : browser_(browser), |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 // Floor. | 191 // Floor. |
178 element = base::MakeUnique<UiElement>(); | 192 element = base::MakeUnique<UiElement>(); |
179 element->set_id(AllocateId()); | 193 element->set_id(AllocateId()); |
180 element->set_size({kSceneSize, kSceneSize, 1.0}); | 194 element->set_size({kSceneSize, kSceneSize, 1.0}); |
181 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); | 195 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); |
182 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); | 196 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); |
183 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 197 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
184 element->set_edge_color(kBackgroundHorizonColor); | 198 element->set_edge_color(kBackgroundHorizonColor); |
185 element->set_center_color(kBackgroundCenterColor); | 199 element->set_center_color(kBackgroundCenterColor); |
186 element->set_draw_phase(0); | 200 element->set_draw_phase(0); |
187 control_elements_.push_back(element.get()); | 201 floor_ = element.get(); |
202 content_elements_.push_back(element.get()); | |
188 scene_->AddUiElement(std::move(element)); | 203 scene_->AddUiElement(std::move(element)); |
189 | 204 |
190 // Ceiling. | 205 // Ceiling. |
191 element = base::MakeUnique<UiElement>(); | 206 element = base::MakeUnique<UiElement>(); |
192 element->set_id(AllocateId()); | 207 element->set_id(AllocateId()); |
193 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 208 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
194 element->set_size({kSceneSize, kSceneSize, 1.0}); | 209 element->set_size({kSceneSize, kSceneSize, 1.0}); |
195 element->set_translation({0.0, kSceneHeight / 2, 0.0}); | 210 element->set_translation({0.0, kSceneHeight / 2, 0.0}); |
196 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); | 211 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); |
197 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); | 212 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
198 element->set_edge_color(kBackgroundHorizonColor); | 213 element->set_edge_color(kBackgroundHorizonColor); |
199 element->set_center_color(kBackgroundCenterColor); | 214 element->set_center_color(kBackgroundCenterColor); |
200 element->set_draw_phase(0); | 215 element->set_draw_phase(0); |
201 control_elements_.push_back(element.get()); | 216 ceiling_ = element.get(); |
217 content_elements_.push_back(element.get()); | |
202 scene_->AddUiElement(std::move(element)); | 218 scene_->AddUiElement(std::move(element)); |
203 | 219 |
204 // Floor grid. | 220 // Floor grid. |
205 element = base::MakeUnique<UiElement>(); | 221 element = base::MakeUnique<UiElement>(); |
206 element->set_id(AllocateId()); | 222 element->set_id(AllocateId()); |
207 element->set_fill(vr_shell::Fill::GRID_GRADIENT); | 223 element->set_fill(vr_shell::Fill::GRID_GRADIENT); |
208 element->set_size({kSceneSize, kSceneSize, 1.0}); | 224 element->set_size({kSceneSize, kSceneSize, 1.0}); |
209 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); | 225 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); |
210 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); | 226 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); |
211 element->set_fill(vr_shell::Fill::GRID_GRADIENT); | 227 element->set_fill(vr_shell::Fill::GRID_GRADIENT); |
212 element->set_center_color(kBackgroundHorizonColor); | 228 element->set_center_color(kBackgroundHorizonColor); |
213 vr::Colorf edge_color = kBackgroundHorizonColor; | 229 vr::Colorf edge_color = kBackgroundHorizonColor; |
214 edge_color.a = 0.0; | 230 edge_color.a = 0.0; |
215 element->set_edge_color(edge_color); | 231 element->set_edge_color(edge_color); |
216 element->set_gridline_count(kFloorGridlineCount); | 232 element->set_gridline_count(kFloorGridlineCount); |
217 element->set_draw_phase(0); | 233 element->set_draw_phase(0); |
218 control_elements_.push_back(element.get()); | 234 floor_grid_ = element.get(); |
235 content_elements_.push_back(element.get()); | |
219 scene_->AddUiElement(std::move(element)); | 236 scene_->AddUiElement(std::move(element)); |
220 | 237 |
221 scene_->SetBackgroundColor(kBackgroundHorizonColor); | 238 scene_->SetBackgroundColor(kBackgroundHorizonColor); |
222 } | 239 } |
223 | 240 |
224 void UiSceneManager::CreateUrlBar() { | 241 void UiSceneManager::CreateUrlBar() { |
225 // TODO(cjgrant): Incorporate final size and position. | 242 // TODO(cjgrant): Incorporate final size and position. |
226 auto url_bar = base::MakeUnique<UrlBar>(512); | 243 auto url_bar = base::MakeUnique<UrlBar>(512); |
227 url_bar->set_id(AllocateId()); | 244 url_bar->set_id(AllocateId()); |
228 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); | 245 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 } | 294 } |
278 | 295 |
279 // Content elements. | 296 // Content elements. |
280 for (UiElement* element : content_elements_) { | 297 for (UiElement* element : content_elements_) { |
281 element->SetEnabled(!web_vr_mode_); | 298 element->SetEnabled(!web_vr_mode_); |
282 } | 299 } |
283 | 300 |
284 // Update content quad parameters depending on fullscreen. | 301 // Update content quad parameters depending on fullscreen. |
285 // TODO(http://crbug.com/642937): Animate fullscreen transitions. | 302 // TODO(http://crbug.com/642937): Animate fullscreen transitions. |
286 if (fullscreen_) { | 303 if (fullscreen_) { |
287 scene_->SetBackgroundColor(kFullscreenBackgroundColor); | 304 scene_->SetBackgroundColor(kFullscreenHorizonColor); |
288 main_content_->set_translation( | 305 main_content_->set_translation( |
289 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); | 306 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); |
290 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); | 307 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); |
308 | |
309 floor_->set_edge_color(kFullscreenHorizonColor); | |
310 floor_->set_center_color(kFullscreenCenterColor); | |
311 ceiling_->set_edge_color(kFullscreenHorizonColor); | |
312 ceiling_->set_center_color(kFullscreenCenterColor); | |
313 floor_grid_->set_center_color(kFullscreenHorizonColor); | |
314 vr::Colorf edge_color = kFullscreenHorizonColor; | |
315 edge_color.a = 0.0; | |
316 floor_grid_->set_edge_color(edge_color); | |
291 } else { | 317 } else { |
292 scene_->SetBackgroundColor(kBackgroundHorizonColor); | 318 scene_->SetBackgroundColor(kBackgroundHorizonColor); |
293 // Note that main_content_ is already visible in this case. | 319 // Note that main_content_ is already visible in this case. |
294 main_content_->set_translation( | 320 main_content_->set_translation( |
295 {0, kContentVerticalOffset, -kContentDistance}); | 321 {0, kContentVerticalOffset, -kContentDistance}); |
296 main_content_->set_size({kContentWidth, kContentHeight, 1}); | 322 main_content_->set_size({kContentWidth, kContentHeight, 1}); |
323 | |
324 floor_->set_edge_color(kBackgroundHorizonColor); | |
325 floor_->set_center_color(kBackgroundCenterColor); | |
326 ceiling_->set_edge_color(kBackgroundHorizonColor); | |
327 ceiling_->set_center_color(kBackgroundCenterColor); | |
328 floor_grid_->set_center_color(kBackgroundHorizonColor); | |
329 vr::Colorf edge_color = kBackgroundHorizonColor; | |
330 edge_color.a = 0.0; | |
331 floor_grid_->set_edge_color(edge_color); | |
297 } | 332 } |
298 | 333 |
299 scene_->SetBackgroundDistance(main_content_->translation().z() * | 334 scene_->SetBackgroundDistance(main_content_->translation().z() * |
300 -kBackgroundDistanceMultiplier); | 335 -kBackgroundDistanceMultiplier); |
301 } | 336 } |
302 | 337 |
303 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { | 338 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { |
304 secure_origin_ = secure; | 339 secure_origin_ = secure; |
305 ConfigureSecurityWarnings(); | 340 ConfigureSecurityWarnings(); |
306 } | 341 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 396 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
362 bool can_go_forward) {} | 397 bool can_go_forward) {} |
363 | 398 |
364 void UiSceneManager::OnCloseButtonClicked() {} | 399 void UiSceneManager::OnCloseButtonClicked() {} |
365 | 400 |
366 int UiSceneManager::AllocateId() { | 401 int UiSceneManager::AllocateId() { |
367 return next_available_id_++; | 402 return next_available_id_++; |
368 } | 403 } |
369 | 404 |
370 } // namespace vr_shell | 405 } // namespace vr_shell |
OLD | NEW |