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

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

Issue 2749703007: Add menu mode plumbing for WebVR mode. (Closed)
Patch Set: Rename JS WebVR rendering functions for clarity. Created 3 years, 9 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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 auto& animations = element->animations; 277 auto& animations = element->animations;
278 for (auto it = animations.begin(); it != animations.end(); ++it) { 278 for (auto it = animations.begin(); it != animations.end(); ++it) {
279 const Animation& existing_animation = **it; 279 const Animation& existing_animation = **it;
280 if (existing_animation.id == animation_id) { 280 if (existing_animation.id == animation_id) {
281 animations.erase(it); 281 animations.erase(it);
282 return; 282 return;
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 void UiScene::UpdateBackgroundFromDict(const base::DictionaryValue& dict) {
288 ParseColorf(dict, "color", &background_color_);
289 ParseFloat(dict, "distance", &background_distance_);
290 }
291
292 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands, 287 void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands,
293 int64_t time_in_micro) { 288 int64_t time_in_micro) {
294 for (auto& item : *commands) { 289 for (auto& item : *commands) {
295 base::DictionaryValue* dict; 290 base::DictionaryValue* dict;
296 CHECK(item->GetAsDictionary(&dict)); 291 CHECK(item->GetAsDictionary(&dict));
297 292
298 Command type; 293 Command type;
299 base::DictionaryValue* data; 294 base::DictionaryValue* data;
300 CHECK(ParseInt(*dict, "type", &type)); 295 CHECK(ParseInt(*dict, "type", &type));
301 CHECK(dict->GetDictionary("data", &data)); 296 CHECK(dict->GetDictionary("data", &data));
(...skipping 14 matching lines...) Expand all
316 case Command::ADD_ANIMATION: 311 case Command::ADD_ANIMATION:
317 AddAnimationFromDict(*data, time_in_micro); 312 AddAnimationFromDict(*data, time_in_micro);
318 break; 313 break;
319 case Command::REMOVE_ANIMATION: { 314 case Command::REMOVE_ANIMATION: {
320 int element_id, animation_id; 315 int element_id, animation_id;
321 CHECK(ParseInt(*data, "id", &animation_id)); 316 CHECK(ParseInt(*data, "id", &animation_id));
322 CHECK(ParseInt(*data, "meshId", &element_id)); 317 CHECK(ParseInt(*data, "meshId", &element_id));
323 RemoveAnimation(element_id, animation_id); 318 RemoveAnimation(element_id, animation_id);
324 break; 319 break;
325 } 320 }
326 case Command::UPDATE_BACKGROUND: 321 case Command::CONFIGURE_SCENE:
327 UpdateBackgroundFromDict(*data); 322 ParseColorf(*data, "backgroundColor", &background_color_);
323 ParseFloat(*data, "backgroundDistance", &background_distance_);
324 data->GetBoolean("drawWebVr", &webvr_rendering_enabled_);
328 break; 325 break;
329 } 326 }
330 } 327 }
331 } 328 }
332 329
333 void UiScene::UpdateTransforms(int64_t time_in_micro) { 330 void UiScene::UpdateTransforms(int64_t time_in_micro) {
334 // Process all animations before calculating object transforms. 331 // Process all animations before calculating object transforms.
335 for (auto& element : ui_elements_) { 332 for (auto& element : ui_elements_) {
336 element->Animate(time_in_micro); 333 element->Animate(time_in_micro);
337 } 334 }
(...skipping 12 matching lines...) Expand all
350 347
351 ContentRectangle* UiScene::GetUiElementById(int element_id) { 348 ContentRectangle* UiScene::GetUiElementById(int element_id) {
352 for (auto& element : ui_elements_) { 349 for (auto& element : ui_elements_) {
353 if (element->id == element_id) { 350 if (element->id == element_id) {
354 return element.get(); 351 return element.get();
355 } 352 }
356 } 353 }
357 return nullptr; 354 return nullptr;
358 } 355 }
359 356
360 const Colorf& UiScene::GetBackgroundColor() { 357 const Colorf& UiScene::GetBackgroundColor() const {
361 return background_color_; 358 return background_color_;
362 } 359 }
363 360
364 float UiScene::GetBackgroundDistance() { 361 float UiScene::GetBackgroundDistance() const {
365 return background_distance_; 362 return background_distance_;
366 } 363 }
367 364
365 bool UiScene::GetWebVrRenderingEnabled() const {
366 return webvr_rendering_enabled_;
367 }
368
368 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements() 369 const std::vector<std::unique_ptr<ContentRectangle>>& UiScene::GetUiElements()
369 const { 370 const {
370 return ui_elements_; 371 return ui_elements_;
371 } 372 }
372 373
373 UiScene::UiScene() = default; 374 UiScene::UiScene() = default;
374 375
375 UiScene::~UiScene() = default; 376 UiScene::~UiScene() = default;
376 377
377 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element, 378 void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 content_element_ = element; 465 content_element_ = element;
465 break; 466 break;
466 default: 467 default:
467 element->fill = Fill::NONE; 468 element->fill = Fill::NONE;
468 break; 469 break;
469 } 470 }
470 } 471 }
471 } 472 }
472 473
473 } // namespace vr_shell 474 } // 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_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698