| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 void UiScene::AddUiElement(std::unique_ptr<UiElement> element) { | 56 void UiScene::AddUiElement(std::unique_ptr<UiElement> element) { |
| 57 CHECK_GE(element->id(), 0); | 57 CHECK_GE(element->id(), 0); |
| 58 CHECK_EQ(GetUiElementById(element->id()), nullptr); | 58 CHECK_EQ(GetUiElementById(element->id()), nullptr); |
| 59 if (element->parent_id() >= 0) { | 59 if (element->parent_id() >= 0) { |
| 60 CHECK_NE(GetUiElementById(element->parent_id()), nullptr); | 60 CHECK_NE(GetUiElementById(element->parent_id()), nullptr); |
| 61 } else { | 61 } else { |
| 62 CHECK_EQ(element->x_anchoring(), XAnchoring::XNONE); | 62 CHECK_EQ(element->x_anchoring(), XAnchoring::XNONE); |
| 63 CHECK_EQ(element->y_anchoring(), YAnchoring::YNONE); | 63 CHECK_EQ(element->y_anchoring(), YAnchoring::YNONE); |
| 64 } | 64 } |
| 65 if (gl_initialized_) | 65 if (gl_initialized_) |
| 66 element->Initialize(); | 66 element->Initialize(surface_provider_); |
| 67 ui_elements_.push_back(std::move(element)); | 67 ui_elements_.push_back(std::move(element)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void UiScene::RemoveUiElement(int element_id) { | 70 void UiScene::RemoveUiElement(int element_id) { |
| 71 for (auto it = ui_elements_.begin(); it != ui_elements_.end(); ++it) { | 71 for (auto it = ui_elements_.begin(); it != ui_elements_.end(); ++it) { |
| 72 if ((*it)->id() == element_id) { | 72 if ((*it)->id() == element_id) { |
| 73 if ((*it)->fill() == Fill::CONTENT) { | 73 if ((*it)->fill() == Fill::CONTENT) { |
| 74 content_element_ = nullptr; | 74 content_element_ = nullptr; |
| 75 } | 75 } |
| 76 ui_elements_.erase(it); | 76 ui_elements_.erase(it); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 parent->opacity()); | 212 parent->opacity()); |
| 213 element->set_computed_lock_to_fov(parent->lock_to_fov()); | 213 element->set_computed_lock_to_fov(parent->lock_to_fov()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 vr::MatrixMul(inheritable->to_world, transform->to_world, | 216 vr::MatrixMul(inheritable->to_world, transform->to_world, |
| 217 &transform->to_world); | 217 &transform->to_world); |
| 218 element->set_dirty(false); | 218 element->set_dirty(false); |
| 219 } | 219 } |
| 220 | 220 |
| 221 // TODO(mthiesse): Move this to UiSceneManager. | 221 // TODO(mthiesse): Move this to UiSceneManager. |
| 222 void UiScene::OnGLInitialized() { | 222 void UiScene::OnGLInitialized(VrSurfaceProvider* provider) { |
| 223 gl_initialized_ = true; | 223 gl_initialized_ = true; |
| 224 surface_provider_ = provider; |
| 224 for (auto& element : ui_elements_) { | 225 for (auto& element : ui_elements_) { |
| 225 element->Initialize(); | 226 element->Initialize(provider); |
| 226 } | 227 } |
| 227 } | 228 } |
| 228 | 229 |
| 229 } // namespace vr_shell | 230 } // namespace vr_shell |
| OLD | NEW |