OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 auto& animations = element->animations; | 277 auto& animations = element->animations; |
278 for (auto it = animations.begin(); it != animations.end(); ++it) { | 278 for (auto it = animations.begin(); it != animations.end(); ++it) { |
279 const Animation& existing_animation = **it; | 279 const Animation& existing_animation = **it; |
280 if (existing_animation.id == animation_id) { | 280 if (existing_animation.id == animation_id) { |
281 animations.erase(it); | 281 animations.erase(it); |
282 return; | 282 return; |
283 } | 283 } |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
287 void UiScene::UpdateBackgroundFromDict(const base::DictionaryValue& dict) { | |
288 ParseColorf(dict, "color", &background_color_); | |
289 ParseFloat(dict, "distance", &background_distance_); | |
290 } | |
291 | |
292 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands, | 287 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands, |
293 int64_t time_in_micro) { | 288 int64_t time_in_micro) { |
294 for (auto& item : *commands) { | 289 for (auto& item : *commands) { |
295 base::DictionaryValue* dict; | 290 base::DictionaryValue* dict; |
296 CHECK(item->GetAsDictionary(&dict)); | 291 CHECK(item->GetAsDictionary(&dict)); |
297 | 292 |
298 Command type; | 293 Command type; |
299 base::DictionaryValue* data; | 294 base::DictionaryValue* data; |
300 CHECK(ParseInt(*dict, "type", &type)); | 295 CHECK(ParseInt(*dict, "type", &type)); |
301 CHECK(dict->GetDictionary("data", &data)); | 296 CHECK(dict->GetDictionary("data", &data)); |
(...skipping 14 matching lines...) Expand all Loading... | |
316 case Command::ADD_ANIMATION: | 311 case Command::ADD_ANIMATION: |
317 AddAnimationFromDict(*data, time_in_micro); | 312 AddAnimationFromDict(*data, time_in_micro); |
318 break; | 313 break; |
319 case Command::REMOVE_ANIMATION: { | 314 case Command::REMOVE_ANIMATION: { |
320 int element_id, animation_id; | 315 int element_id, animation_id; |
321 CHECK(ParseInt(*data, "id", &animation_id)); | 316 CHECK(ParseInt(*data, "id", &animation_id)); |
322 CHECK(ParseInt(*data, "meshId", &element_id)); | 317 CHECK(ParseInt(*data, "meshId", &element_id)); |
323 RemoveAnimation(element_id, animation_id); | 318 RemoveAnimation(element_id, animation_id); |
324 break; | 319 break; |
325 } | 320 } |
326 case Command::UPDATE_BACKGROUND: | 321 case Command::CONFIGURE_SCENE: |
327 UpdateBackgroundFromDict(*data); | 322 ParseColorf(*data, "backgroundColor", &background_color_); |
323 ParseFloat(*data, "backgroundDistance", &background_distance_); | |
324 data->GetBoolean("drawCursor", &cursor_enabled_); | |
325 data->GetBoolean("drawWebVr", &webvr_rendering_enabled_); | |
cjgrant
2017/03/16 15:44:36
We could merge this with the action "pause content
tiborg
2017/03/16 19:40:22
+1 for merging.
cjgrant
2017/03/20 15:34:57
In the end, I merged the two rendering properties,
tiborg
2017/03/20 15:56:08
SGTM.
| |
328 break; | 326 break; |
329 } | 327 } |
330 } | 328 } |
331 } | 329 } |
332 | 330 |
333 void UiScene::UpdateTransforms(int64_t time_in_micro) { | 331 void UiScene::UpdateTransforms(int64_t time_in_micro) { |
334 // Process all animations before calculating object transforms. | 332 // Process all animations before calculating object transforms. |
335 for (auto& element : ui_elements_) { | 333 for (auto& element : ui_elements_) { |
336 element->Animate(time_in_micro); | 334 element->Animate(time_in_micro); |
337 } | 335 } |
(...skipping 10 matching lines...) Expand all Loading... | |
348 | 346 |
349 ContentRectangle* UiScene::GetUiElementById(int element_id) { | 347 ContentRectangle* UiScene::GetUiElementById(int element_id) { |
350 for (auto& element : ui_elements_) { | 348 for (auto& element : ui_elements_) { |
351 if (element->id == element_id) { | 349 if (element->id == element_id) { |
352 return element.get(); | 350 return element.get(); |
353 } | 351 } |
354 } | 352 } |
355 return nullptr; | 353 return nullptr; |
356 } | 354 } |
357 | 355 |
358 const Colorf& UiScene::GetBackgroundColor() { | 356 const Colorf& UiScene::GetBackgroundColor() const { |
tiborg
2017/03/16 19:40:22
+1 for const!
| |
359 return background_color_; | 357 return background_color_; |
360 } | 358 } |
361 | 359 |
362 float UiScene::GetBackgroundDistance() { | 360 float UiScene::GetBackgroundDistance() const { |
363 return background_distance_; | 361 return background_distance_; |
364 } | 362 } |
365 | 363 |
364 bool UiScene::GetCursorEnabled() const { | |
365 return cursor_enabled_; | |
366 } | |
367 | |
368 bool UiScene::GetWebVrRenderingEnabled() const { | |
369 return webvr_rendering_enabled_; | |
370 } | |
371 | |
366 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() | 372 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() |
367 const { | 373 const { |
368 return ui_elements_; | 374 return ui_elements_; |
369 } | 375 } |
370 | 376 |
371 UiScene::UiScene() = default; | 377 UiScene::UiScene() = default; |
372 | 378 |
373 UiScene::~UiScene() = default; | 379 UiScene::~UiScene() = default; |
374 | 380 |
375 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element, | 381 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 content_element_ = element; | 463 content_element_ = element; |
458 break; | 464 break; |
459 default: | 465 default: |
460 element->fill = Fill::NONE; | 466 element->fill = Fill::NONE; |
461 break; | 467 break; |
462 } | 468 } |
463 } | 469 } |
464 } | 470 } |
465 | 471 |
466 } // namespace vr_shell | 472 } // namespace vr_shell |
OLD | NEW |