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

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

Issue 2861003003: VR: Enable browsing for CCT and make ui_scene_manager aware of whether we're in CCT. (Closed)
Patch Set: Fix test compile Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_manager.h" 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" 8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" 9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h"
10 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" 10 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h"
(...skipping 21 matching lines...) Expand all
32 static constexpr float kContentVerticalOffset = -0.26; 32 static constexpr float kContentVerticalOffset = -0.26;
33 static constexpr float kBackplaneSize = 1000.0; 33 static constexpr float kBackplaneSize = 1000.0;
34 static constexpr float kBackgroundDistanceMultiplier = 1.414; 34 static constexpr float kBackgroundDistanceMultiplier = 1.414;
35 35
36 static constexpr float kSceneSize = 25.0; 36 static constexpr float kSceneSize = 25.0;
37 static constexpr float kSceneHeight = 4.0; 37 static constexpr float kSceneHeight = 4.0;
38 static constexpr int kFloorGridlineCount = 40; 38 static constexpr int kFloorGridlineCount = 40;
39 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; 39 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0};
40 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; 40 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0};
41 41
42 // Placeholders to demonstrate UI changes when in CCT.
43 static constexpr vr::Colorf kCctBackgroundHorizonColor = {0.2, 0.6, 0.2, 1.0};
44 static constexpr vr::Colorf kCctBackgroundCenterColor = {0.13, 0.52, 0.13, 1.0};
45
42 // Tiny distance to offset textures that should appear in the same plane. 46 // Tiny distance to offset textures that should appear in the same plane.
43 static constexpr float kTextureOffset = 0.01; 47 static constexpr float kTextureOffset = 0.01;
44 48
45 } // namespace 49 } // namespace
46 50
47 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, UiScene* scene) 51 UiSceneManager::UiSceneManager(VrBrowserInterface* browser,
48 : browser_(browser), scene_(scene), weak_ptr_factory_(this) { 52 UiScene* scene,
53 bool in_cct)
54 : browser_(browser),
55 scene_(scene),
56 in_cct_(in_cct),
57 weak_ptr_factory_(this) {
49 CreateBackground(); 58 CreateBackground();
50 CreateContentQuad(); 59 CreateContentQuad();
51 CreateSecurityWarnings(); 60 CreateSecurityWarnings();
52 } 61 }
53 62
54 UiSceneManager::~UiSceneManager() {} 63 UiSceneManager::~UiSceneManager() {}
55 64
56 void UiSceneManager::CreateSecurityWarnings() { 65 void UiSceneManager::CreateSecurityWarnings() {
57 std::unique_ptr<UiElement> element; 66 std::unique_ptr<UiElement> element;
58 67
59 // TODO(mthiesse): Programatically compute the proper texture size for these 68 // TODO(mthiesse): Programatically compute the proper texture size for these
60 // textured UI elements. 69 // textured UI elements.
61 element = base::MakeUnique<PermanentSecurityWarning>(512); 70 element = base::MakeUnique<PermanentSecurityWarning>(512);
62 element->set_id(AllocateId()); 71 element->set_id(AllocateId());
63 element->set_fill(vr_shell::Fill::NONE); 72 element->set_fill(vr_shell::Fill::NONE);
64 element->set_size({kPermanentWarningWidth, kPermanentWarningHeight, 1}); 73 element->set_size({kPermanentWarningWidth, kPermanentWarningHeight, 1});
65 element->set_scale({kWarningDistance, kWarningDistance, 1}); 74 element->set_scale({kWarningDistance, kWarningDistance, 1});
66 element->set_translation({0, kWarningDistance * sin(kWarningAngleRadians), 75 element->set_translation(
67 -kWarningDistance * cos(kWarningAngleRadians)}); 76 gfx::Vector3dF(0, kWarningDistance * sin(kWarningAngleRadians),
77 -kWarningDistance * cos(kWarningAngleRadians)));
68 element->set_rotation({1.0f, 0, 0, kWarningAngleRadians}); 78 element->set_rotation({1.0f, 0, 0, kWarningAngleRadians});
69 element->set_visible(false); 79 element->set_visible(false);
70 element->set_hit_testable(false); 80 element->set_hit_testable(false);
71 element->set_lock_to_fov(true); 81 element->set_lock_to_fov(true);
72 permanent_security_warning_ = element.get(); 82 permanent_security_warning_ = element.get();
73 scene_->AddUiElement(std::move(element)); 83 scene_->AddUiElement(std::move(element));
74 84
75 element = base::MakeUnique<TransientSecurityWarning>(1024); 85 element = base::MakeUnique<TransientSecurityWarning>(1024);
76 element->set_id(AllocateId()); 86 element->set_id(AllocateId());
77 element->set_fill(vr_shell::Fill::NONE); 87 element->set_fill(vr_shell::Fill::NONE);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 browser_ui_elements_.push_back(element.get()); 119 browser_ui_elements_.push_back(element.get());
110 scene_->AddUiElement(std::move(element)); 120 scene_->AddUiElement(std::move(element));
111 121
112 // Limit reticle distance to a sphere based on content distance. 122 // Limit reticle distance to a sphere based on content distance.
113 scene_->SetBackgroundDistance(main_content_->translation().z() * 123 scene_->SetBackgroundDistance(main_content_->translation().z() *
114 -kBackgroundDistanceMultiplier); 124 -kBackgroundDistanceMultiplier);
115 } 125 }
116 126
117 void UiSceneManager::CreateBackground() { 127 void UiSceneManager::CreateBackground() {
118 std::unique_ptr<UiElement> element; 128 std::unique_ptr<UiElement> element;
129 vr::Colorf horizon =
130 in_cct_ ? kCctBackgroundHorizonColor : kBackgroundHorizonColor;
131 vr::Colorf center =
132 in_cct_ ? kCctBackgroundCenterColor : kBackgroundCenterColor;
119 133
120 // Floor. 134 // Floor.
121 element = base::MakeUnique<UiElement>(); 135 element = base::MakeUnique<UiElement>();
122 element->set_id(AllocateId()); 136 element->set_id(AllocateId());
123 element->set_size({kSceneSize, kSceneSize, 1.0}); 137 element->set_size({kSceneSize, kSceneSize, 1.0});
124 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); 138 element->set_translation({0.0, -kSceneHeight / 2, 0.0});
125 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); 139 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0});
126 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 140 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
127 element->set_edge_color(kBackgroundHorizonColor); 141 element->set_edge_color(horizon);
128 element->set_center_color(kBackgroundCenterColor); 142 element->set_center_color(center);
129 element->set_draw_phase(0); 143 element->set_draw_phase(0);
130 browser_ui_elements_.push_back(element.get()); 144 browser_ui_elements_.push_back(element.get());
131 scene_->AddUiElement(std::move(element)); 145 scene_->AddUiElement(std::move(element));
132 146
133 // Ceiling. 147 // Ceiling.
134 element = base::MakeUnique<UiElement>(); 148 element = base::MakeUnique<UiElement>();
135 element->set_id(AllocateId()); 149 element->set_id(AllocateId());
136 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 150 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
137 element->set_size({kSceneSize, kSceneSize, 1.0}); 151 element->set_size({kSceneSize, kSceneSize, 1.0});
138 element->set_translation({0.0, kSceneHeight / 2, 0.0}); 152 element->set_translation({0.0, kSceneHeight / 2, 0.0});
139 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); 153 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2});
140 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 154 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
141 element->set_edge_color(kBackgroundHorizonColor); 155 element->set_edge_color(horizon);
142 element->set_center_color(kBackgroundCenterColor); 156 element->set_center_color(center);
143 element->set_draw_phase(0); 157 element->set_draw_phase(0);
144 browser_ui_elements_.push_back(element.get()); 158 browser_ui_elements_.push_back(element.get());
145 scene_->AddUiElement(std::move(element)); 159 scene_->AddUiElement(std::move(element));
146 160
147 // Floor grid. 161 // Floor grid.
148 element = base::MakeUnique<UiElement>(); 162 element = base::MakeUnique<UiElement>();
149 element->set_id(AllocateId()); 163 element->set_id(AllocateId());
150 element->set_fill(vr_shell::Fill::GRID_GRADIENT); 164 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
151 element->set_size({kSceneSize, kSceneSize, 1.0}); 165 element->set_size({kSceneSize, kSceneSize, 1.0});
152 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); 166 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0});
153 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); 167 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2});
154 element->set_fill(vr_shell::Fill::GRID_GRADIENT); 168 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
155 element->set_center_color(kBackgroundHorizonColor); 169 element->set_center_color(horizon);
156 vr::Colorf edge_color = kBackgroundHorizonColor; 170 vr::Colorf edge_color = horizon;
157 edge_color.a = 0.0; 171 edge_color.a = 0.0;
158 element->set_edge_color(edge_color); 172 element->set_edge_color(edge_color);
159 element->set_gridline_count(kFloorGridlineCount); 173 element->set_gridline_count(kFloorGridlineCount);
160 element->set_draw_phase(0); 174 element->set_draw_phase(0);
161 browser_ui_elements_.push_back(element.get()); 175 browser_ui_elements_.push_back(element.get());
162 scene_->AddUiElement(std::move(element)); 176 scene_->AddUiElement(std::move(element));
163 177
164 scene_->SetBackgroundColor(kBackgroundHorizonColor); 178 scene_->SetBackgroundColor(horizon);
165 } 179 }
166 180
167 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 181 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
168 return weak_ptr_factory_.GetWeakPtr(); 182 return weak_ptr_factory_.GetWeakPtr();
169 } 183 }
170 184
171 void UiSceneManager::SetWebVRMode(bool web_vr) { 185 void UiSceneManager::SetWebVRMode(bool web_vr) {
172 web_vr_mode_ = web_vr; 186 web_vr_mode_ = web_vr;
173 187
174 // Make all VR scene UI elements visible if not in WebVR. 188 // Make all VR scene UI elements visible if not in WebVR.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 221
208 void UiSceneManager::OnSecurityWarningTimer() { 222 void UiSceneManager::OnSecurityWarningTimer() {
209 transient_security_warning_->set_visible(false); 223 transient_security_warning_->set_visible(false);
210 } 224 }
211 225
212 int UiSceneManager::AllocateId() { 226 int UiSceneManager::AllocateId() {
213 return next_available_id_++; 227 return next_available_id_++;
214 } 228 }
215 229
216 } // namespace vr_shell 230 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.h ('k') | chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698