| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 ContentRectangle* UiScene::GetUiElementById(int element_id) { | 341 ContentRectangle* UiScene::GetUiElementById(int element_id) { |
| 342 for (auto& element : ui_elements_) { | 342 for (auto& element : ui_elements_) { |
| 343 if (element->id == element_id) { | 343 if (element->id == element_id) { |
| 344 return element.get(); | 344 return element.get(); |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 return nullptr; | 347 return nullptr; |
| 348 } | 348 } |
| 349 | 349 |
| 350 ContentRectangle* UiScene::GetUiElementByName(std::string element_name) { |
| 351 for (auto& element : ui_elements_) { |
| 352 if (element->name == element_name) { |
| 353 return element.get(); |
| 354 } |
| 355 } |
| 356 return nullptr; |
| 357 } |
| 358 |
| 350 std::vector<const ContentRectangle*> UiScene::GetWorldElements() const { | 359 std::vector<const ContentRectangle*> UiScene::GetWorldElements() const { |
| 351 std::vector<const ContentRectangle*> elements; | 360 std::vector<const ContentRectangle*> elements; |
| 352 for (const auto& element : ui_elements_) { | 361 for (const auto& element : ui_elements_) { |
| 353 if (element->IsVisible() && !element->lock_to_fov) { | 362 if (element->IsVisible() && !element->lock_to_fov) { |
| 354 elements.push_back(element.get()); | 363 elements.push_back(element.get()); |
| 355 } | 364 } |
| 356 } | 365 } |
| 357 return elements; | 366 return elements; |
| 358 } | 367 } |
| 359 | 368 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 376 } | 385 } |
| 377 | 386 |
| 378 float UiScene::GetBackgroundDistance() const { | 387 float UiScene::GetBackgroundDistance() const { |
| 379 return background_distance_; | 388 return background_distance_; |
| 380 } | 389 } |
| 381 | 390 |
| 382 bool UiScene::GetWebVrRenderingEnabled() const { | 391 bool UiScene::GetWebVrRenderingEnabled() const { |
| 383 return webvr_rendering_enabled_; | 392 return webvr_rendering_enabled_; |
| 384 } | 393 } |
| 385 | 394 |
| 395 std::unique_ptr<base::DictionaryValue> UiScene::CreateUiElementInfo( |
| 396 std::string element_name) { |
| 397 auto result = base::MakeUnique<base::DictionaryValue>(); |
| 398 const ContentRectangle* element = GetUiElementByName(element_name); |
| 399 CHECK_NE(element, nullptr); |
| 400 |
| 401 result->SetBoolean("isVisible", element->IsVisible()); |
| 402 result->SetBoolean("isHitTestable", element->IsHitTestable()); |
| 403 result->SetInteger("id", element->id); |
| 404 result->SetInteger("parentId", element->parent_id); |
| 405 result->SetBoolean("lockToFov", element->lock_to_fov); |
| 406 result->SetDouble("opacity", element->opacity); |
| 407 result->SetDouble("computedOpacity", element->computed_opacity); |
| 408 result->SetBoolean("computedLockToFov", element->computed_lock_to_fov); |
| 409 result->SetInteger("xAnchoring", element->x_anchoring); |
| 410 result->SetInteger("yAnchoring", element->y_anchoring); |
| 411 result->SetInteger("fill", element->fill); |
| 412 result->SetInteger("gridlineCount", element->gridline_count); |
| 413 result->SetInteger("drawPhase", element->draw_phase); |
| 414 |
| 415 auto temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 416 temp_dictionary->SetInteger("x", element->copy_rect.x); |
| 417 temp_dictionary->SetInteger("y", element->copy_rect.y); |
| 418 temp_dictionary->SetInteger("width", element->copy_rect.width); |
| 419 temp_dictionary->SetInteger("height", element->copy_rect.height); |
| 420 result->Set("copyRect", std::move(temp_dictionary)); |
| 421 |
| 422 temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 423 temp_dictionary->SetDouble("x", element->size.x); |
| 424 temp_dictionary->SetDouble("y", element->size.y); |
| 425 temp_dictionary->SetDouble("z", element->size.z); |
| 426 result->Set("size", std::move(temp_dictionary)); |
| 427 |
| 428 temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 429 temp_dictionary->SetDouble("x", element->scale.x); |
| 430 temp_dictionary->SetDouble("y", element->scale.y); |
| 431 temp_dictionary->SetDouble("z", element->scale.z); |
| 432 result->Set("scale", std::move(temp_dictionary)); |
| 433 |
| 434 temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 435 temp_dictionary->SetDouble("x", element->rotation.x); |
| 436 temp_dictionary->SetDouble("y", element->rotation.y); |
| 437 temp_dictionary->SetDouble("z", element->rotation.z); |
| 438 temp_dictionary->SetDouble("angle", element->rotation.angle); |
| 439 result->Set("rotation", std::move(temp_dictionary)); |
| 440 |
| 441 temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 442 temp_dictionary->SetDouble("x", element->translation.x); |
| 443 temp_dictionary->SetDouble("y", element->translation.y); |
| 444 temp_dictionary->SetDouble("z", element->translation.z); |
| 445 result->Set("translation", std::move(temp_dictionary)); |
| 446 |
| 447 temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 448 temp_dictionary->SetDouble("r", element->edge_color.r); |
| 449 temp_dictionary->SetDouble("g", element->edge_color.g); |
| 450 temp_dictionary->SetDouble("b", element->edge_color.b); |
| 451 temp_dictionary->SetDouble("a", element->edge_color.a); |
| 452 result->Set("edgeColor", std::move(temp_dictionary)); |
| 453 |
| 454 temp_dictionary = base::MakeUnique<base::DictionaryValue>(); |
| 455 temp_dictionary->SetDouble("r", element->center_color.r); |
| 456 temp_dictionary->SetDouble("g", element->center_color.g); |
| 457 temp_dictionary->SetDouble("b", element->center_color.b); |
| 458 temp_dictionary->SetDouble("a", element->center_color.a); |
| 459 result->Set("centerColor", std::move(temp_dictionary)); |
| 460 |
| 461 return result; |
| 462 } |
| 463 |
| 386 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() | 464 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() |
| 387 const { | 465 const { |
| 388 return ui_elements_; | 466 return ui_elements_; |
| 389 } | 467 } |
| 390 | 468 |
| 391 UiScene::UiScene() = default; | 469 UiScene::UiScene() = default; |
| 392 | 470 |
| 393 UiScene::~UiScene() = default; | 471 UiScene::~UiScene() = default; |
| 394 | 472 |
| 395 void UiScene::ApplyRecursiveTransforms(ContentRectangle* element) { | 473 void UiScene::ApplyRecursiveTransforms(ContentRectangle* element) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 content_element_ = element; | 579 content_element_ = element; |
| 502 break; | 580 break; |
| 503 default: | 581 default: |
| 504 element->fill = Fill::NONE; | 582 element->fill = Fill::NONE; |
| 505 break; | 583 break; |
| 506 } | 584 } |
| 507 } | 585 } |
| 508 } | 586 } |
| 509 | 587 |
| 510 } // namespace vr_shell | 588 } // namespace vr_shell |
| OLD | NEW |