Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene.cc

Issue 2773903003: Add way to get native VR UI information from Java (Closed)
Patch Set: Update JavaDoc Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(const 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
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 const std::string& element_name) {
397 auto result = base::MakeUnique<base::DictionaryValue>();
398 const ContentRectangle* element = GetUiElementByName(element_name);
399 // Return an empty dict if not found and let Java handle the failure
cjgrant 2017/03/30 21:20:16 The comment is unnecessary, but if you feel it's n
bsheedy 2017/03/30 21:23:04 Removed. Not quite sure why I'm having so much tro
400 if (!element)
401 return result;
402
403 result->SetBoolean("isVisible", element->IsVisible());
404 result->SetBoolean("isHitTestable", element->IsHitTestable());
405 result->SetInteger("id", element->id);
406 result->SetInteger("parentId", element->parent_id);
407 result->SetBoolean("lockToFov", element->lock_to_fov);
408 result->SetDouble("opacity", element->opacity);
409 result->SetDouble("computedOpacity", element->computed_opacity);
410 result->SetBoolean("computedLockToFov", element->computed_lock_to_fov);
411 result->SetInteger("xAnchoring", element->x_anchoring);
412 result->SetInteger("yAnchoring", element->y_anchoring);
413 result->SetInteger("fill", element->fill);
414 result->SetInteger("gridlineCount", element->gridline_count);
415 result->SetInteger("drawPhase", element->draw_phase);
416
417 auto temp_dictionary = base::MakeUnique<base::DictionaryValue>();
418 temp_dictionary->SetInteger("x", element->copy_rect.x);
419 temp_dictionary->SetInteger("y", element->copy_rect.y);
420 temp_dictionary->SetInteger("width", element->copy_rect.width);
421 temp_dictionary->SetInteger("height", element->copy_rect.height);
422 result->Set("copyRect", std::move(temp_dictionary));
423
424 temp_dictionary = base::MakeUnique<base::DictionaryValue>();
425 temp_dictionary->SetDouble("x", element->size.x);
426 temp_dictionary->SetDouble("y", element->size.y);
427 temp_dictionary->SetDouble("z", element->size.z);
428 result->Set("size", std::move(temp_dictionary));
429
430 temp_dictionary = base::MakeUnique<base::DictionaryValue>();
431 temp_dictionary->SetDouble("x", element->scale.x);
432 temp_dictionary->SetDouble("y", element->scale.y);
433 temp_dictionary->SetDouble("z", element->scale.z);
434 result->Set("scale", std::move(temp_dictionary));
435
436 temp_dictionary = base::MakeUnique<base::DictionaryValue>();
437 temp_dictionary->SetDouble("x", element->rotation.x);
438 temp_dictionary->SetDouble("y", element->rotation.y);
439 temp_dictionary->SetDouble("z", element->rotation.z);
440 temp_dictionary->SetDouble("angle", element->rotation.angle);
441 result->Set("rotation", std::move(temp_dictionary));
442
443 temp_dictionary = base::MakeUnique<base::DictionaryValue>();
444 temp_dictionary->SetDouble("x", element->translation.x);
445 temp_dictionary->SetDouble("y", element->translation.y);
446 temp_dictionary->SetDouble("z", element->translation.z);
447 result->Set("translation", std::move(temp_dictionary));
448
449 temp_dictionary = base::MakeUnique<base::DictionaryValue>();
450 temp_dictionary->SetDouble("r", element->edge_color.r);
451 temp_dictionary->SetDouble("g", element->edge_color.g);
452 temp_dictionary->SetDouble("b", element->edge_color.b);
453 temp_dictionary->SetDouble("a", element->edge_color.a);
454 result->Set("edgeColor", std::move(temp_dictionary));
455
456 temp_dictionary = base::MakeUnique<base::DictionaryValue>();
457 temp_dictionary->SetDouble("r", element->center_color.r);
458 temp_dictionary->SetDouble("g", element->center_color.g);
459 temp_dictionary->SetDouble("b", element->center_color.b);
460 temp_dictionary->SetDouble("a", element->center_color.a);
461 result->Set("centerColor", std::move(temp_dictionary));
462
463 return result;
464 }
465
386 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() 466 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements()
387 const { 467 const {
388 return ui_elements_; 468 return ui_elements_;
389 } 469 }
390 470
391 UiScene::UiScene() = default; 471 UiScene::UiScene() = default;
392 472
393 UiScene::~UiScene() = default; 473 UiScene::~UiScene() = default;
394 474
395 void UiScene::ApplyRecursiveTransforms(ContentRectangle* element) { 475 void UiScene::ApplyRecursiveTransforms(ContentRectangle* element) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 content_element_ = element; 581 content_element_ = element;
502 break; 582 break;
503 default: 583 default:
504 element->fill = Fill::NONE; 584 element->fill = Fill::NONE;
505 break; 585 break;
506 } 586 }
507 } 587 }
508 } 588 }
509 589
510 } // namespace vr_shell 590 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698