| 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 "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/android/vr_shell/animation.h" | 8 #include "chrome/browser/android/vr_shell/animation.h" |
| 9 #include "chrome/browser/android/vr_shell/easing.h" | 9 #include "chrome/browser/android/vr_shell/easing.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_elements.h" | 10 #include "chrome/browser/android/vr_shell/ui_elements.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 auto& animations = element->animations; | 271 auto& animations = element->animations; |
| 272 for (auto it = animations.begin(); it != animations.end(); ++it) { | 272 for (auto it = animations.begin(); it != animations.end(); ++it) { |
| 273 const Animation& existing_animation = **it; | 273 const Animation& existing_animation = **it; |
| 274 if (existing_animation.id == animation_id) { | 274 if (existing_animation.id == animation_id) { |
| 275 animations.erase(it); | 275 animations.erase(it); |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 void UiScene::HandleCommands(const base::ListValue* commands, | 281 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands, |
| 282 int64_t time_in_micro) { | 282 int64_t time_in_micro) { |
| 283 for (auto& item : *commands) { | 283 for (auto& item : *commands) { |
| 284 base::DictionaryValue* dict; | 284 base::DictionaryValue* dict; |
| 285 CHECK(item->GetAsDictionary(&dict)); | 285 CHECK(item->GetAsDictionary(&dict)); |
| 286 | 286 |
| 287 Command type; | 287 Command type; |
| 288 base::DictionaryValue* data; | 288 base::DictionaryValue* data; |
| 289 CHECK(dict->GetInteger("type", reinterpret_cast<int*>(&type))); | 289 CHECK(dict->GetInteger("type", reinterpret_cast<int*>(&type))); |
| 290 CHECK(dict->GetDictionary("data", &data)); | 290 CHECK(dict->GetDictionary("data", &data)); |
| 291 | 291 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 const std::vector<std::unique_ptr<ContentRectangle>>& | 345 const std::vector<std::unique_ptr<ContentRectangle>>& |
| 346 UiScene::GetUiElements() const { | 346 UiScene::GetUiElements() const { |
| 347 return ui_elements_; | 347 return ui_elements_; |
| 348 } | 348 } |
| 349 | 349 |
| 350 UiScene::UiScene() = default; | 350 UiScene::UiScene() = default; |
| 351 | 351 |
| 352 UiScene::~UiScene() = default; | 352 UiScene::~UiScene() = default; |
| 353 | 353 |
| 354 int64_t UiScene::TimeInMicroseconds() { | |
| 355 return std::chrono::duration_cast<std::chrono::microseconds>( | |
| 356 std::chrono::steady_clock::now().time_since_epoch()).count(); | |
| 357 } | |
| 358 | |
| 359 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element, | 354 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element, |
| 360 ReversibleTransform* transform) { | 355 ReversibleTransform* transform) { |
| 361 transform->Scale(element.scale.x, element.scale.y, element.scale.z); | 356 transform->Scale(element.scale.x, element.scale.y, element.scale.z); |
| 362 transform->Rotate(element.rotation.x, element.rotation.y, | 357 transform->Rotate(element.rotation.x, element.rotation.y, |
| 363 element.rotation.z, element.rotation.angle); | 358 element.rotation.z, element.rotation.angle); |
| 364 transform->Translate(element.translation.x, element.translation.y, | 359 transform->Translate(element.translation.x, element.translation.y, |
| 365 element.translation.z); | 360 element.translation.z); |
| 366 | 361 |
| 367 if (element.parent_id >= 0) { | 362 if (element.parent_id >= 0) { |
| 368 const ContentRectangle* parent = GetUiElementById(element.parent_id); | 363 const ContentRectangle* parent = GetUiElementById(element.parent_id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 reinterpret_cast<int*>(&element->x_anchoring))) { | 401 reinterpret_cast<int*>(&element->x_anchoring))) { |
| 407 CHECK_GE(element->parent_id, 0); | 402 CHECK_GE(element->parent_id, 0); |
| 408 } | 403 } |
| 409 if (dict.GetInteger("yAnchoring", | 404 if (dict.GetInteger("yAnchoring", |
| 410 reinterpret_cast<int*>(&element->y_anchoring))) { | 405 reinterpret_cast<int*>(&element->y_anchoring))) { |
| 411 CHECK_GE(element->parent_id, 0); | 406 CHECK_GE(element->parent_id, 0); |
| 412 } | 407 } |
| 413 } | 408 } |
| 414 | 409 |
| 415 } // namespace vr_shell | 410 } // namespace vr_shell |
| OLD | NEW |