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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "chrome/browser/android/vr_shell/vr_math.h" | 12 #include "chrome/browser/android/vr_shell/vr_math.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class DictionaryValue; | 15 class DictionaryValue; |
16 class ListValue; | 16 class ListValue; |
17 } | 17 } |
18 | 18 |
19 namespace vr_shell { | 19 namespace vr_shell { |
20 | 20 |
21 class Animation; | 21 class Animation; |
22 struct ContentRectangle; | 22 struct ContentRectangle; |
23 struct ReversibleTransform; | 23 struct Transform; |
24 | 24 |
25 class UiScene { | 25 class UiScene { |
26 public: | 26 public: |
27 enum Command { | 27 enum Command { |
28 ADD_ELEMENT, | 28 ADD_ELEMENT, |
29 UPDATE_ELEMENT, | 29 UPDATE_ELEMENT, |
30 REMOVE_ELEMENT, | 30 REMOVE_ELEMENT, |
31 ADD_ANIMATION, | 31 ADD_ANIMATION, |
32 REMOVE_ANIMATION, | 32 REMOVE_ANIMATION, |
33 UPDATE_BACKGROUND, | 33 UPDATE_BACKGROUND, |
(...skipping 18 matching lines...) Expand all Loading... |
52 // Add an animation according to a dictionary passed from the UI HTML. | 52 // Add an animation according to a dictionary passed from the UI HTML. |
53 void AddAnimationFromDict(const base::DictionaryValue& dict, | 53 void AddAnimationFromDict(const base::DictionaryValue& dict, |
54 int64_t time_in_micro); | 54 int64_t time_in_micro); |
55 | 55 |
56 // Remove |animation_id| from element |element_id|. | 56 // Remove |animation_id| from element |element_id|. |
57 void RemoveAnimation(int element_id, int animation_id); | 57 void RemoveAnimation(int element_id, int animation_id); |
58 | 58 |
59 void UpdateBackgroundFromDict(const base::DictionaryValue& dict); | 59 void UpdateBackgroundFromDict(const base::DictionaryValue& dict); |
60 | 60 |
61 // Update the positions of all elements in the scene, according to active | 61 // Update the positions of all elements in the scene, according to active |
62 // animations, desired screen tilt and time. The units of time are | 62 // animations and time. The units of time are arbitrary, but must match the |
63 // arbitrary, but must match the unit used in animations. | 63 // unit used in animations. |
64 void UpdateTransforms(float screen_tilt, int64_t time_in_micro); | 64 void UpdateTransforms(int64_t time_in_micro); |
65 | 65 |
66 // Handle a batch of commands passed from the UI HTML. | 66 // Handle a batch of commands passed from the UI HTML. |
67 void HandleCommands(std::unique_ptr<base::ListValue> commands, | 67 void HandleCommands(std::unique_ptr<base::ListValue> commands, |
68 int64_t time_in_micro); | 68 int64_t time_in_micro); |
69 | 69 |
70 const std::vector<std::unique_ptr<ContentRectangle>>& GetUiElements() const; | 70 const std::vector<std::unique_ptr<ContentRectangle>>& GetUiElements() const; |
71 | 71 |
72 ContentRectangle* GetUiElementById(int element_id); | 72 ContentRectangle* GetUiElementById(int element_id); |
73 | 73 |
74 const Colorf& GetBackgroundColor(); | 74 const Colorf& GetBackgroundColor(); |
75 float GetBackgroundDistance(); | 75 float GetBackgroundDistance(); |
76 | 76 |
77 private: | 77 private: |
78 void ApplyRecursiveTransforms(const ContentRectangle& element, | 78 void ApplyRecursiveTransforms(const ContentRectangle& element, |
79 ReversibleTransform* transform, | 79 Transform* transform, |
80 float* opacity); | 80 float* opacity); |
81 void ApplyDictToElement(const base::DictionaryValue& dict, | 81 void ApplyDictToElement(const base::DictionaryValue& dict, |
82 ContentRectangle* element); | 82 ContentRectangle* element); |
83 | 83 |
84 std::vector<std::unique_ptr<ContentRectangle>> ui_elements_; | 84 std::vector<std::unique_ptr<ContentRectangle>> ui_elements_; |
85 ContentRectangle* content_element_ = nullptr; | 85 ContentRectangle* content_element_ = nullptr; |
86 Colorf background_color_ = {0.1f, 0.1f, 0.1f, 1.0f}; | 86 Colorf background_color_ = {0.1f, 0.1f, 0.1f, 1.0f}; |
87 float background_distance_ = 10.0f; | 87 float background_distance_ = 10.0f; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(UiScene); | 89 DISALLOW_COPY_AND_ASSIGN(UiScene); |
90 }; | 90 }; |
91 | 91 |
92 } // namespace vr_shell | 92 } // namespace vr_shell |
93 | 93 |
94 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ | 94 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ |
OLD | NEW |