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

Unified Diff: chrome/browser/android/vr_shell/ui_scene.cc

Issue 2668093002: VrShell background implemented in JS. (Closed)
Patch Set: Removed superfluous tests from previous patch set Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/ui_scene.cc
diff --git a/chrome/browser/android/vr_shell/ui_scene.cc b/chrome/browser/android/vr_shell/ui_scene.cc
index 0035c1c66973e504b1150178c143e827a1f2da8d..30fee7fcb975a4e052adc0899d63e440a2c4d724 100644
--- a/chrome/browser/android/vr_shell/ui_scene.cc
+++ b/chrome/browser/android/vr_shell/ui_scene.cc
@@ -51,6 +51,23 @@ void ParseVec3f(const base::DictionaryValue& dict, const std::string& key,
}
}
+void ParseColorf(const base::DictionaryValue& dict,
+ const std::string& key,
+ Colorf* output) {
+ const base::DictionaryValue* item_dict;
+ if (dict.GetDictionary(key, &item_dict)) {
+ double value;
+ CHECK(item_dict->GetDouble("r", &value));
+ output->r = value;
+ CHECK(item_dict->GetDouble("g", &value));
+ output->g = value;
+ CHECK(item_dict->GetDouble("b", &value));
+ output->b = value;
+ CHECK(item_dict->GetDouble("a", &value));
+ output->a = value;
+ }
+}
+
void ParseRotationAxisAngle(const base::DictionaryValue& dict,
const std::string& key, RotationAxisAngle* output) {
const base::DictionaryValue* item_dict;
@@ -205,7 +222,7 @@ void UiScene::UpdateUiElementFromDict(const base::DictionaryValue& dict) {
void UiScene::RemoveUiElement(int element_id) {
for (auto it = ui_elements_.begin(); it != ui_elements_.end(); ++it) {
if ((*it)->id == element_id) {
- if ((*it)->content_quad) {
+ if ((*it)->fill == Fill::CONTENT) {
content_element_ = nullptr;
}
ui_elements_.erase(it);
@@ -387,7 +404,6 @@ void UiScene::ApplyDictToElement(const base::DictionaryValue& dict,
dict.GetBoolean("visible", &element->visible);
dict.GetBoolean("hitTestable", &element->hit_testable);
dict.GetBoolean("lockToFov", &element->lock_to_fov);
- ParseRecti(dict, "copyRect", &element->copy_rect);
Parse2DVec3f(dict, "size", &element->size);
ParseVec3f(dict, "scale", &element->scale);
ParseRotationAxisAngle(dict, "rotation", &element->rotation);
@@ -397,17 +413,6 @@ void UiScene::ApplyDictToElement(const base::DictionaryValue& dict,
element->opacity = opacity;
}
- if (dict.GetBoolean("contentQuad", &element->content_quad)) {
- if (element->content_quad) {
- CHECK_EQ(content_element_, nullptr);
- content_element_ = element;
- } else {
- if (content_element_ == element) {
- content_element_ = nullptr;
- }
- }
- }
-
if (dict.GetInteger("xAnchoring",
reinterpret_cast<int*>(&element->x_anchoring))) {
CHECK_GE(element->parent_id, 0);
@@ -416,6 +421,39 @@ void UiScene::ApplyDictToElement(const base::DictionaryValue& dict,
reinterpret_cast<int*>(&element->y_anchoring))) {
CHECK_GE(element->parent_id, 0);
}
+
+ // Parse the element fill.
+ if (dict.GetInteger("fillType", reinterpret_cast<int*>(&element->fill))) {
+ // If the previous content element has a new filling now make sure this is
+ // tracked correctly.
+ if (content_element_ == element && element->fill != Fill::CONTENT) {
+ content_element_ = nullptr;
+ }
+
+ switch (element->fill) {
+ case Fill::SPRITE:
+ ParseRecti(dict, "copyRect", &element->copy_rect);
+ break;
+ case Fill::OPAQUE_GRADIENT:
+ ParseColorf(dict, "edgeColor", &element->edge_color);
+ ParseColorf(dict, "centerColor", &element->center_color);
+ break;
+ case Fill::GRID_GRADIENT:
+ ParseColorf(dict, "edgeColor", &element->edge_color);
+ ParseColorf(dict, "centerColor", &element->center_color);
+ int value;
+ dict.GetInteger("tileNumber", &value);
cjgrant 2017/02/02 14:48:25 - This code is setting tile_number to a random val
tiborg1 2017/02/02 16:52:27 Good call! I changed tile number to unsigned since
cjgrant 2017/02/03 15:58:29 We should also check that the read from the dictio
+ element->tile_number = value;
+ break;
+ case Fill::CONTENT:
+ CHECK_EQ(content_element_, nullptr);
+ content_element_ = element;
+ break;
+ default:
+ element->fill = Fill::NONE;
+ break;
+ }
+ }
}
} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698