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

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

Issue 2869273008: VR: Fix cursor draw order. (Closed)
Patch Set: Address comments 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/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" 9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
10 #include "chrome/browser/android/vr_shell/ui_elements/close_button.h" 10 #include "chrome/browser/android/vr_shell/ui_elements/close_button.h"
(...skipping 29 matching lines...) Expand all
40 static constexpr float kFullscreenDistance = 3; 40 static constexpr float kFullscreenDistance = 3;
41 static constexpr float kFullscreenVerticalOffset = -0.26; 41 static constexpr float kFullscreenVerticalOffset = -0.26;
42 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0}; 42 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0};
43 43
44 static constexpr float kSceneSize = 25.0; 44 static constexpr float kSceneSize = 25.0;
45 static constexpr float kSceneHeight = 4.0; 45 static constexpr float kSceneHeight = 4.0;
46 static constexpr int kFloorGridlineCount = 40; 46 static constexpr int kFloorGridlineCount = 40;
47 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; 47 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0};
48 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; 48 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0};
49 49
50 // Placeholders to demonstrate UI changes when in CCT.
51 static constexpr vr::Colorf kCctBackgroundHorizonColor = {0.2, 0.6, 0.2, 1.0};
52 static constexpr vr::Colorf kCctBackgroundCenterColor = {0.13, 0.52, 0.13, 1.0};
53
54 // Tiny distance to offset textures that should appear in the same plane. 50 // Tiny distance to offset textures that should appear in the same plane.
55 static constexpr float kTextureOffset = 0.01; 51 static constexpr float kTextureOffset = 0.01;
56 52
57 } // namespace 53 } // namespace
58 54
59 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, 55 UiSceneManager::UiSceneManager(VrBrowserInterface* browser,
60 UiScene* scene, 56 UiScene* scene,
61 bool in_cct, 57 bool in_cct,
62 bool in_web_vr) 58 bool in_web_vr)
63 : browser_(browser), 59 : browser_(browser),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 browser_ui_elements_.push_back(element.get()); 129 browser_ui_elements_.push_back(element.get());
134 scene_->AddUiElement(std::move(element)); 130 scene_->AddUiElement(std::move(element));
135 131
136 // Limit reticle distance to a sphere based on content distance. 132 // Limit reticle distance to a sphere based on content distance.
137 scene_->SetBackgroundDistance(main_content_->translation().z() * 133 scene_->SetBackgroundDistance(main_content_->translation().z() *
138 -kBackgroundDistanceMultiplier); 134 -kBackgroundDistanceMultiplier);
139 } 135 }
140 136
141 void UiSceneManager::CreateBackground() { 137 void UiSceneManager::CreateBackground() {
142 std::unique_ptr<UiElement> element; 138 std::unique_ptr<UiElement> element;
143 vr::Colorf horizon =
144 in_cct_ ? kCctBackgroundHorizonColor : kBackgroundHorizonColor;
145 vr::Colorf center =
146 in_cct_ ? kCctBackgroundCenterColor : kBackgroundCenterColor;
147 139
148 // Floor. 140 // Floor.
149 element = base::MakeUnique<UiElement>(); 141 element = base::MakeUnique<UiElement>();
150 element->set_id(AllocateId()); 142 element->set_id(AllocateId());
151 element->set_size({kSceneSize, kSceneSize, 1.0}); 143 element->set_size({kSceneSize, kSceneSize, 1.0});
152 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); 144 element->set_translation({0.0, -kSceneHeight / 2, 0.0});
153 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0}); 145 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2.0});
154 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 146 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
155 element->set_edge_color(horizon); 147 element->set_edge_color(kBackgroundHorizonColor);
156 element->set_center_color(center); 148 element->set_center_color(kBackgroundCenterColor);
157 element->set_draw_phase(0); 149 element->set_draw_phase(0);
158 browser_ui_elements_.push_back(element.get()); 150 browser_ui_elements_.push_back(element.get());
159 scene_->AddUiElement(std::move(element)); 151 scene_->AddUiElement(std::move(element));
160 152
161 // Ceiling. 153 // Ceiling.
162 element = base::MakeUnique<UiElement>(); 154 element = base::MakeUnique<UiElement>();
163 element->set_id(AllocateId()); 155 element->set_id(AllocateId());
164 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 156 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
165 element->set_size({kSceneSize, kSceneSize, 1.0}); 157 element->set_size({kSceneSize, kSceneSize, 1.0});
166 element->set_translation({0.0, kSceneHeight / 2, 0.0}); 158 element->set_translation({0.0, kSceneHeight / 2, 0.0});
167 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2}); 159 element->set_rotation({1.0, 0.0, 0.0, M_PI / 2});
168 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); 160 element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT);
169 element->set_edge_color(horizon); 161 element->set_edge_color(kBackgroundHorizonColor);
170 element->set_center_color(center); 162 element->set_center_color(kBackgroundCenterColor);
171 element->set_draw_phase(0); 163 element->set_draw_phase(0);
172 browser_ui_elements_.push_back(element.get()); 164 browser_ui_elements_.push_back(element.get());
173 scene_->AddUiElement(std::move(element)); 165 scene_->AddUiElement(std::move(element));
174 166
175 // Floor grid. 167 // Floor grid.
176 element = base::MakeUnique<UiElement>(); 168 element = base::MakeUnique<UiElement>();
177 element->set_id(AllocateId()); 169 element->set_id(AllocateId());
178 element->set_fill(vr_shell::Fill::GRID_GRADIENT); 170 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
179 element->set_size({kSceneSize, kSceneSize, 1.0}); 171 element->set_size({kSceneSize, kSceneSize, 1.0});
180 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}); 172 element->set_translation({0.0, -kSceneHeight / 2 + kTextureOffset, 0.0});
181 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2}); 173 element->set_rotation({1.0, 0.0, 0.0, -M_PI / 2});
182 element->set_fill(vr_shell::Fill::GRID_GRADIENT); 174 element->set_fill(vr_shell::Fill::GRID_GRADIENT);
183 element->set_center_color(horizon); 175 element->set_center_color(kBackgroundHorizonColor);
184 vr::Colorf edge_color = horizon; 176 vr::Colorf edge_color = kBackgroundHorizonColor;
185 edge_color.a = 0.0; 177 edge_color.a = 0.0;
186 element->set_edge_color(edge_color); 178 element->set_edge_color(edge_color);
187 element->set_gridline_count(kFloorGridlineCount); 179 element->set_gridline_count(kFloorGridlineCount);
188 element->set_draw_phase(0); 180 element->set_draw_phase(0);
189 browser_ui_elements_.push_back(element.get()); 181 browser_ui_elements_.push_back(element.get());
190 scene_->AddUiElement(std::move(element)); 182 scene_->AddUiElement(std::move(element));
191 183
192 scene_->SetBackgroundColor(horizon); 184 scene_->SetBackgroundColor(kBackgroundHorizonColor);
193 } 185 }
194 186
195 void UiSceneManager::CreateUrlBar() { 187 void UiSceneManager::CreateUrlBar() {
196 // TODO(cjgrant): Incorporate final size and position. 188 // TODO(cjgrant): Incorporate final size and position.
197 // TODO(cjgrant): Add the loading progress indicator element. 189 // TODO(cjgrant): Add the loading progress indicator element.
198 std::unique_ptr<UrlBar> element = base::MakeUnique<UrlBar>(512); 190 std::unique_ptr<UrlBar> element = base::MakeUnique<UrlBar>(512);
199 element->set_id(AllocateId()); 191 element->set_id(AllocateId());
200 element->set_translation({0, -0.9, -1.8}); 192 element->set_translation({0, -0.9, -1.8});
201 element->set_size({0.9, 0, 1}); 193 element->set_size({0.9, 0, 1});
202 element->SetBackButtonCallback( 194 element->SetBackButtonCallback(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, 307 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back,
316 bool can_go_forward) {} 308 bool can_go_forward) {}
317 309
318 void UiSceneManager::OnCloseButtonClicked() {} 310 void UiSceneManager::OnCloseButtonClicked() {}
319 311
320 int UiSceneManager::AllocateId() { 312 int UiSceneManager::AllocateId() {
321 return next_available_id_++; 313 return next_available_id_++;
322 } 314 }
323 315
324 } // namespace vr_shell 316 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | chrome/browser/android/vr_shell/vr_shell_gl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698