| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 double value; | 44 double value; |
| 45 CHECK(item_dict->GetDouble("x", &value)); | 45 CHECK(item_dict->GetDouble("x", &value)); |
| 46 output->x = value; | 46 output->x = value; |
| 47 CHECK(item_dict->GetDouble("y", &value)); | 47 CHECK(item_dict->GetDouble("y", &value)); |
| 48 output->y = value; | 48 output->y = value; |
| 49 CHECK(item_dict->GetDouble("z", &value)); | 49 CHECK(item_dict->GetDouble("z", &value)); |
| 50 output->z = value; | 50 output->z = value; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ParseColorf(const base::DictionaryValue& dict, |
| 55 const std::string& key, |
| 56 Colorf* output) { |
| 57 const base::DictionaryValue* item_dict; |
| 58 if (dict.GetDictionary(key, &item_dict)) { |
| 59 double value; |
| 60 CHECK(item_dict->GetDouble("r", &value)); |
| 61 output->r = value; |
| 62 CHECK(item_dict->GetDouble("g", &value)); |
| 63 output->g = value; |
| 64 CHECK(item_dict->GetDouble("b", &value)); |
| 65 output->b = value; |
| 66 CHECK(item_dict->GetDouble("a", &value)); |
| 67 output->a = value; |
| 68 } |
| 69 } |
| 70 |
| 54 void ParseRotationAxisAngle(const base::DictionaryValue& dict, | 71 void ParseRotationAxisAngle(const base::DictionaryValue& dict, |
| 55 const std::string& key, RotationAxisAngle* output) { | 72 const std::string& key, RotationAxisAngle* output) { |
| 56 const base::DictionaryValue* item_dict; | 73 const base::DictionaryValue* item_dict; |
| 57 if (dict.GetDictionary(key, &item_dict)) { | 74 if (dict.GetDictionary(key, &item_dict)) { |
| 58 double value; | 75 double value; |
| 59 CHECK(item_dict->GetDouble("x", &value)); | 76 CHECK(item_dict->GetDouble("x", &value)); |
| 60 output->x = value; | 77 output->x = value; |
| 61 CHECK(item_dict->GetDouble("y", &value)); | 78 CHECK(item_dict->GetDouble("y", &value)); |
| 62 output->y = value; | 79 output->y = value; |
| 63 CHECK(item_dict->GetDouble("z", &value)); | 80 CHECK(item_dict->GetDouble("z", &value)); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 int parent_id; | 397 int parent_id; |
| 381 if (dict.GetInteger("parentId", &parent_id)) { | 398 if (dict.GetInteger("parentId", &parent_id)) { |
| 382 CHECK_GE(parent_id, 0); | 399 CHECK_GE(parent_id, 0); |
| 383 CHECK_NE(GetUiElementById(parent_id), nullptr); | 400 CHECK_NE(GetUiElementById(parent_id), nullptr); |
| 384 element->parent_id = parent_id; | 401 element->parent_id = parent_id; |
| 385 } | 402 } |
| 386 | 403 |
| 387 dict.GetBoolean("visible", &element->visible); | 404 dict.GetBoolean("visible", &element->visible); |
| 388 dict.GetBoolean("hitTestable", &element->hit_testable); | 405 dict.GetBoolean("hitTestable", &element->hit_testable); |
| 389 dict.GetBoolean("lockToFov", &element->lock_to_fov); | 406 dict.GetBoolean("lockToFov", &element->lock_to_fov); |
| 390 ParseRecti(dict, "copyRect", &element->copy_rect); | |
| 391 Parse2DVec3f(dict, "size", &element->size); | 407 Parse2DVec3f(dict, "size", &element->size); |
| 392 ParseVec3f(dict, "scale", &element->scale); | 408 ParseVec3f(dict, "scale", &element->scale); |
| 393 ParseRotationAxisAngle(dict, "rotation", &element->rotation); | 409 ParseRotationAxisAngle(dict, "rotation", &element->rotation); |
| 394 ParseVec3f(dict, "translation", &element->translation); | 410 ParseVec3f(dict, "translation", &element->translation); |
| 395 double opacity; | 411 double opacity; |
| 396 if (dict.GetDouble("opacity", &opacity)) { | 412 if (dict.GetDouble("opacity", &opacity)) { |
| 397 element->opacity = opacity; | 413 element->opacity = opacity; |
| 398 } | 414 } |
| 399 | 415 |
| 400 if (dict.GetBoolean("contentQuad", &element->content_quad)) { | 416 if (dict.GetBoolean("contentQuad", &element->content_quad)) { |
| 401 if (element->content_quad) { | 417 if (element->content_quad) { |
| 402 CHECK_EQ(content_element_, nullptr); | 418 CHECK_EQ(content_element_, nullptr); |
| 403 content_element_ = element; | 419 content_element_ = element; |
| 404 } else { | 420 } else { |
| 405 if (content_element_ == element) { | 421 if (content_element_ == element) { |
| 406 content_element_ = nullptr; | 422 content_element_ = nullptr; |
| 407 } | 423 } |
| 408 } | 424 } |
| 409 } | 425 } |
| 410 | 426 |
| 411 if (dict.GetInteger("xAnchoring", | 427 if (dict.GetInteger("xAnchoring", |
| 412 reinterpret_cast<int*>(&element->x_anchoring))) { | 428 reinterpret_cast<int*>(&element->x_anchoring))) { |
| 413 CHECK_GE(element->parent_id, 0); | 429 CHECK_GE(element->parent_id, 0); |
| 414 } | 430 } |
| 415 if (dict.GetInteger("yAnchoring", | 431 if (dict.GetInteger("yAnchoring", |
| 416 reinterpret_cast<int*>(&element->y_anchoring))) { | 432 reinterpret_cast<int*>(&element->y_anchoring))) { |
| 417 CHECK_GE(element->parent_id, 0); | 433 CHECK_GE(element->parent_id, 0); |
| 418 } | 434 } |
| 435 |
| 436 // Parse the element fill. |
| 437 if (dict.GetInteger("fillType", reinterpret_cast<int*>(&element->fill))) { |
| 438 switch (element->fill) { |
| 439 case Fill::SPRITE: |
| 440 ParseRecti(dict, "copyRect", &element->copy_rect); |
| 441 break; |
| 442 case Fill::OPAQUE_GRADIENT: |
| 443 ParseColorf(dict, "edgeColor", &element->edge_color); |
| 444 ParseColorf(dict, "centerColor", &element->center_color); |
| 445 case Fill::GRID_GRADIENT: |
| 446 ParseColorf(dict, "edgeColor", &element->edge_color); |
| 447 ParseColorf(dict, "centerColor", &element->center_color); |
| 448 int value; |
| 449 dict.GetInteger("tileNumber", &value); |
| 450 element->tile_number = value; |
| 451 break; |
| 452 default: |
| 453 element->fill = Fill::NONE; |
| 454 break; |
| 455 } |
| 456 } |
| 419 } | 457 } |
| 420 | 458 |
| 421 } // namespace vr_shell | 459 } // namespace vr_shell |
| OLD | NEW |