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

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

Issue 2698623007: Change how the VR reticle distance is determined. (Closed)
Patch Set: Change background distance multplier to 1.414; move Reload UI button out of the floor. Created 3 years, 10 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
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/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/android/vr_shell/animation.h" 11 #include "chrome/browser/android/vr_shell/animation.h"
12 #include "chrome/browser/android/vr_shell/easing.h" 12 #include "chrome/browser/android/vr_shell/easing.h"
13 #include "chrome/browser/android/vr_shell/ui_elements.h" 13 #include "chrome/browser/android/vr_shell/ui_elements.h"
14 14
15 namespace vr_shell { 15 namespace vr_shell {
16 16
17 namespace { 17 namespace {
18 18
19 bool ParseFloat(const base::DictionaryValue& dict,
20 const std::string& key,
21 float* output) {
22 double value;
23 if (!dict.GetDouble(key, &value)) {
24 return false;
25 }
26 *output = value;
27 return true;
28 }
29
19 bool ParseRecti(const base::DictionaryValue& dict, 30 bool ParseRecti(const base::DictionaryValue& dict,
20 const std::string& key, 31 const std::string& key,
21 Recti* output) { 32 Recti* output) {
22 const base::DictionaryValue* item_dict; 33 const base::DictionaryValue* item_dict;
23 if (dict.GetDictionary(key, &item_dict)) { 34 if (dict.GetDictionary(key, &item_dict)) {
24 CHECK(item_dict->GetInteger("x", &output->x)); 35 CHECK(item_dict->GetInteger("x", &output->x));
25 CHECK(item_dict->GetInteger("y", &output->y)); 36 CHECK(item_dict->GetInteger("y", &output->y));
26 CHECK(item_dict->GetInteger("width", &output->width)); 37 CHECK(item_dict->GetInteger("width", &output->width));
27 CHECK(item_dict->GetInteger("height", &output->height)); 38 CHECK(item_dict->GetInteger("height", &output->height));
28 return true; 39 return true;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 const Animation& existing_animation = **it; 327 const Animation& existing_animation = **it;
317 if (existing_animation.id == animation_id) { 328 if (existing_animation.id == animation_id) {
318 animations.erase(it); 329 animations.erase(it);
319 return; 330 return;
320 } 331 }
321 } 332 }
322 } 333 }
323 334
324 void UiScene::UpdateBackgroundFromDict(const base::DictionaryValue& dict) { 335 void UiScene::UpdateBackgroundFromDict(const base::DictionaryValue& dict) {
325 ParseColorf(dict, "color", &background_color_); 336 ParseColorf(dict, "color", &background_color_);
337 ParseFloat(dict, "distance", &background_distance_);
326 } 338 }
327 339
328 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands, 340 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands,
329 int64_t time_in_micro) { 341 int64_t time_in_micro) {
330 for (auto& item : *commands) { 342 for (auto& item : *commands) {
331 base::DictionaryValue* dict; 343 base::DictionaryValue* dict;
332 CHECK(item->GetAsDictionary(&dict)); 344 CHECK(item->GetAsDictionary(&dict));
333 345
334 Command type; 346 Command type;
335 base::DictionaryValue* data; 347 base::DictionaryValue* data;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 395
384 ContentRectangle* UiScene::GetUiElementById(int element_id) { 396 ContentRectangle* UiScene::GetUiElementById(int element_id) {
385 for (auto& element : ui_elements_) { 397 for (auto& element : ui_elements_) {
386 if (element->id == element_id) { 398 if (element->id == element_id) {
387 return element.get(); 399 return element.get();
388 } 400 }
389 } 401 }
390 return nullptr; 402 return nullptr;
391 } 403 }
392 404
393 ContentRectangle* UiScene::GetContentQuad() {
394 return content_element_;
395 }
396
397 const Colorf& UiScene::GetBackgroundColor() { 405 const Colorf& UiScene::GetBackgroundColor() {
398 return background_color_; 406 return background_color_;
399 } 407 }
400 408
409 float UiScene::GetBackgroundDistance() {
410 return background_distance_;
411 }
412
401 const std::vector<std::unique_ptr<ContentRectangle>>& 413 const std::vector<std::unique_ptr<ContentRectangle>>&
402 UiScene::GetUiElements() const { 414 UiScene::GetUiElements() const {
403 return ui_elements_; 415 return ui_elements_;
404 } 416 }
405 417
406 UiScene::UiScene() = default; 418 UiScene::UiScene() = default;
407 419
408 UiScene::~UiScene() = default; 420 UiScene::~UiScene() = default;
409 421
410 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element, 422 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 content_element_ = element; 496 content_element_ = element;
485 break; 497 break;
486 default: 498 default:
487 element->fill = Fill::NONE; 499 element->fill = Fill::NONE;
488 break; 500 break;
489 } 501 }
490 } 502 }
491 } 503 }
492 504
493 } // namespace vr_shell 505 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/ui_scene_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698