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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 int id; | 195 int id; |
196 CHECK(dict.GetInteger("id", &id)); | 196 CHECK(dict.GetInteger("id", &id)); |
197 ContentRectangle* element = GetUiElementById(id); | 197 ContentRectangle* element = GetUiElementById(id); |
198 CHECK_NE(element, nullptr); | 198 CHECK_NE(element, nullptr); |
199 ApplyDictToElement(dict, element); | 199 ApplyDictToElement(dict, element); |
200 } | 200 } |
201 | 201 |
202 void UiScene::RemoveUiElement(int element_id) { | 202 void UiScene::RemoveUiElement(int element_id) { |
203 for (auto it = ui_elements_.begin(); it != ui_elements_.end(); ++it) { | 203 for (auto it = ui_elements_.begin(); it != ui_elements_.end(); ++it) { |
204 if ((*it)->id == element_id) { | 204 if ((*it)->id == element_id) { |
| 205 if ((*it)->content_quad) { |
| 206 content_element_ = nullptr; |
| 207 } |
205 ui_elements_.erase(it); | 208 ui_elements_.erase(it); |
206 return; | 209 return; |
207 } | 210 } |
208 } | 211 } |
209 } | 212 } |
210 | 213 |
211 void UiScene::AddAnimation(int element_id, | 214 void UiScene::AddAnimation(int element_id, |
212 std::unique_ptr<Animation>& animation) { | 215 std::unique_ptr<Animation>& animation) { |
213 ContentRectangle* element = GetUiElementById(element_id); | 216 ContentRectangle* element = GetUiElementById(element_id); |
214 CHECK_NE(element, nullptr); | 217 CHECK_NE(element, nullptr); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 331 |
329 ContentRectangle* UiScene::GetUiElementById(int element_id) { | 332 ContentRectangle* UiScene::GetUiElementById(int element_id) { |
330 for (auto& element : ui_elements_) { | 333 for (auto& element : ui_elements_) { |
331 if (element->id == element_id) { | 334 if (element->id == element_id) { |
332 return element.get(); | 335 return element.get(); |
333 } | 336 } |
334 } | 337 } |
335 return nullptr; | 338 return nullptr; |
336 } | 339 } |
337 | 340 |
| 341 ContentRectangle* UiScene::GetContentQuad() { |
| 342 return content_element_; |
| 343 } |
| 344 |
338 const std::vector<std::unique_ptr<ContentRectangle>>& | 345 const std::vector<std::unique_ptr<ContentRectangle>>& |
339 UiScene::GetUiElements() const { | 346 UiScene::GetUiElements() const { |
340 return ui_elements_; | 347 return ui_elements_; |
341 } | 348 } |
342 | 349 |
343 UiScene::UiScene() = default; | 350 UiScene::UiScene() = default; |
344 | 351 |
345 UiScene::~UiScene() = default; | 352 UiScene::~UiScene() = default; |
346 | 353 |
347 int64_t UiScene::TimeInMicroseconds() { | 354 int64_t UiScene::TimeInMicroseconds() { |
(...skipping 29 matching lines...) Expand all Loading... |
377 | 384 |
378 dict.GetBoolean("visible", &element->visible); | 385 dict.GetBoolean("visible", &element->visible); |
379 dict.GetBoolean("hitTestable", &element->hit_testable); | 386 dict.GetBoolean("hitTestable", &element->hit_testable); |
380 dict.GetBoolean("lockToFov", &element->lock_to_fov); | 387 dict.GetBoolean("lockToFov", &element->lock_to_fov); |
381 ParseRecti(dict, "copyRect", &element->copy_rect); | 388 ParseRecti(dict, "copyRect", &element->copy_rect); |
382 Parse2DVec3f(dict, "size", &element->size); | 389 Parse2DVec3f(dict, "size", &element->size); |
383 ParseVec3f(dict, "scale", &element->scale); | 390 ParseVec3f(dict, "scale", &element->scale); |
384 ParseRotationAxisAngle(dict, "rotation", &element->rotation); | 391 ParseRotationAxisAngle(dict, "rotation", &element->rotation); |
385 ParseVec3f(dict, "translation", &element->translation); | 392 ParseVec3f(dict, "translation", &element->translation); |
386 | 393 |
| 394 if (dict.GetBoolean("contentQuad", &element->content_quad)) { |
| 395 if (element->content_quad) { |
| 396 CHECK_EQ(content_element_, nullptr); |
| 397 content_element_ = element; |
| 398 } else { |
| 399 if (content_element_ == element) { |
| 400 content_element_ = nullptr; |
| 401 } |
| 402 } |
| 403 } |
| 404 |
387 if (dict.GetInteger("xAnchoring", | 405 if (dict.GetInteger("xAnchoring", |
388 reinterpret_cast<int*>(&element->x_anchoring))) { | 406 reinterpret_cast<int*>(&element->x_anchoring))) { |
389 CHECK_GE(element->parent_id, 0); | 407 CHECK_GE(element->parent_id, 0); |
390 } | 408 } |
391 if (dict.GetInteger("yAnchoring", | 409 if (dict.GetInteger("yAnchoring", |
392 reinterpret_cast<int*>(&element->y_anchoring))) { | 410 reinterpret_cast<int*>(&element->y_anchoring))) { |
393 CHECK_GE(element->parent_id, 0); | 411 CHECK_GE(element->parent_id, 0); |
394 } | 412 } |
395 } | 413 } |
396 | 414 |
397 } // namespace vr_shell | 415 } // namespace vr_shell |
OLD | NEW |