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

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: 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 19 matching lines...) Expand all
30 static constexpr float kContentVerticalOffset = -0.26; 30 static constexpr float kContentVerticalOffset = -0.26;
31 static constexpr float kBackplaneSize = 1000.0; 31 static constexpr float kBackplaneSize = 1000.0;
32 static constexpr float kBackgroundDistanceMultiplier = 1.414; 32 static constexpr float kBackgroundDistanceMultiplier = 1.414;
33 33
34 static constexpr float kSceneSize = 25.0; 34 static constexpr float kSceneSize = 25.0;
35 static constexpr float kSceneHeight = 4.0; 35 static constexpr float kSceneHeight = 4.0;
36 static constexpr int kFloorGridlineCount = 40; 36 static constexpr int kFloorGridlineCount = 40;
37 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; 37 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0};
38 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; 38 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0};
39 39
40 // Placeholders to demonstrate UI changes when in CCT.
41 static constexpr vr::Colorf kCctBackgroundHorizonColor = {0.2, 0.6, 0.2, 1.0};
42 static constexpr vr::Colorf kCctBackgroundCenterColor = {0.13, 0.52, 0.13, 1.0};
43
40 // Tiny distance to offset textures that should appear in the same plane. 44 // Tiny distance to offset textures that should appear in the same plane.
41 static constexpr float kTextureOffset = 0.01; 45 static constexpr float kTextureOffset = 0.01;
42 46
43 } // namespace 47 } // namespace
44 48
45 UiSceneManager::UiSceneManager(UiScene* scene) 49 UiSceneManager::UiSceneManager(UiScene* scene, bool in_cct)
46 : scene_(scene), weak_ptr_factory_(this) { 50 : scene_(scene), in_cct_(in_cct), weak_ptr_factory_(this) {
ymalik 2017/05/05 14:32:53 This may have merge conflicts with https://coderev
47 std::unique_ptr<UiElement> element; 51 std::unique_ptr<UiElement> element;
48 52
49 CreateBackground(); 53 CreateBackground();
50 CreateContentQuad(); 54 CreateContentQuad();
51 CreateSecurityWarnings(); 55 CreateSecurityWarnings();
52 } 56 }
53 57
54 UiSceneManager::~UiSceneManager() {} 58 UiSceneManager::~UiSceneManager() {}
55 59
56 void UiSceneManager::CreateSecurityWarnings() { 60 void UiSceneManager::CreateSecurityWarnings() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 browser_ui_elements_.push_back(element.get()); 113 browser_ui_elements_.push_back(element.get());
110 scene_->AddUiElement(std::move(element)); 114 scene_->AddUiElement(std::move(element));
111 115
112 // Limit reticle distance to a sphere based on content distance. 116 // Limit reticle distance to a sphere based on content distance.
113 scene_->SetBackgroundDistance(main_content_->translation.z() * 117 scene_->SetBackgroundDistance(main_content_->translation.z() *
114 -kBackgroundDistanceMultiplier); 118 -kBackgroundDistanceMultiplier);
115 } 119 }
116 120
117 void UiSceneManager::CreateBackground() { 121 void UiSceneManager::CreateBackground() {
118 std::unique_ptr<UiElement> element; 122 std::unique_ptr<UiElement> element;
123 vr::Colorf horizon =
124 in_cct_ ? kCctBackgroundHorizonColor : kBackgroundHorizonColor;
125 vr::Colorf center =
126 in_cct_ ? kCctBackgroundCenterColor : kBackgroundCenterColor;
119 127
120 // Floor. 128 // Floor.
121 element = base::MakeUnique<UiElement>(); 129 element = base::MakeUnique<UiElement>();
122 element->id = AllocateId(); 130 element->id = AllocateId();
123 element->size = {kSceneSize, kSceneSize, 1.0}; 131 element->size = {kSceneSize, kSceneSize, 1.0};
124 element->translation = {0.0, -kSceneHeight / 2, 0.0}; 132 element->translation = {0.0, -kSceneHeight / 2, 0.0};
125 element->rotation = {1.0, 0.0, 0.0, -M_PI / 2.0}; 133 element->rotation = {1.0, 0.0, 0.0, -M_PI / 2.0};
126 element->fill = vr_shell::Fill::OPAQUE_GRADIENT; 134 element->fill = vr_shell::Fill::OPAQUE_GRADIENT;
127 element->edge_color = kBackgroundHorizonColor; 135 element->edge_color = horizon;
128 element->center_color = kBackgroundCenterColor; 136 element->center_color = center;
129 element->draw_phase = 0; 137 element->draw_phase = 0;
130 browser_ui_elements_.push_back(element.get()); 138 browser_ui_elements_.push_back(element.get());
131 scene_->AddUiElement(std::move(element)); 139 scene_->AddUiElement(std::move(element));
132 140
133 // Ceiling. 141 // Ceiling.
134 element = base::MakeUnique<UiElement>(); 142 element = base::MakeUnique<UiElement>();
135 element->id = AllocateId(); 143 element->id = AllocateId();
136 element->fill = vr_shell::Fill::OPAQUE_GRADIENT; 144 element->fill = vr_shell::Fill::OPAQUE_GRADIENT;
137 element->size = {kSceneSize, kSceneSize, 1.0}; 145 element->size = {kSceneSize, kSceneSize, 1.0};
138 element->translation = {0.0, kSceneHeight / 2, 0.0}; 146 element->translation = {0.0, kSceneHeight / 2, 0.0};
139 element->rotation = {1.0, 0.0, 0.0, M_PI / 2}; 147 element->rotation = {1.0, 0.0, 0.0, M_PI / 2};
140 element->fill = vr_shell::Fill::OPAQUE_GRADIENT; 148 element->fill = vr_shell::Fill::OPAQUE_GRADIENT;
141 element->edge_color = kBackgroundHorizonColor; 149 element->edge_color = horizon;
142 element->center_color = kBackgroundCenterColor; 150 element->center_color = center;
143 element->draw_phase = 0; 151 element->draw_phase = 0;
144 browser_ui_elements_.push_back(element.get()); 152 browser_ui_elements_.push_back(element.get());
145 scene_->AddUiElement(std::move(element)); 153 scene_->AddUiElement(std::move(element));
146 154
147 // Floor grid. 155 // Floor grid.
148 element = base::MakeUnique<UiElement>(); 156 element = base::MakeUnique<UiElement>();
149 element->id = AllocateId(); 157 element->id = AllocateId();
150 element->fill = vr_shell::Fill::GRID_GRADIENT; 158 element->fill = vr_shell::Fill::GRID_GRADIENT;
151 element->size = {kSceneSize, kSceneSize, 1.0}; 159 element->size = {kSceneSize, kSceneSize, 1.0};
152 element->translation = {0.0, -kSceneHeight / 2 + kTextureOffset, 0.0}; 160 element->translation = {0.0, -kSceneHeight / 2 + kTextureOffset, 0.0};
153 element->rotation = {1.0, 0.0, 0.0, -M_PI / 2}; 161 element->rotation = {1.0, 0.0, 0.0, -M_PI / 2};
154 element->fill = vr_shell::Fill::GRID_GRADIENT; 162 element->fill = vr_shell::Fill::GRID_GRADIENT;
155 element->center_color = kBackgroundHorizonColor; 163 element->center_color = horizon;
156 vr::Colorf edge_color = kBackgroundHorizonColor; 164 vr::Colorf edge_color = center;
157 edge_color.a = 0.0; 165 edge_color.a = 0.0;
158 element->edge_color = edge_color; 166 element->edge_color = edge_color;
159 element->gridline_count = kFloorGridlineCount; 167 element->gridline_count = kFloorGridlineCount;
160 element->draw_phase = 0; 168 element->draw_phase = 0;
161 browser_ui_elements_.push_back(element.get()); 169 browser_ui_elements_.push_back(element.get());
162 scene_->AddUiElement(std::move(element)); 170 scene_->AddUiElement(std::move(element));
163 171
164 scene_->SetBackgroundColor(kBackgroundHorizonColor); 172 scene_->SetBackgroundColor(horizon);
165 } 173 }
166 174
167 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 175 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
168 return weak_ptr_factory_.GetWeakPtr(); 176 return weak_ptr_factory_.GetWeakPtr();
169 } 177 }
170 178
171 void UiSceneManager::SetWebVRMode(bool web_vr) { 179 void UiSceneManager::SetWebVRMode(bool web_vr) {
172 web_vr_mode_ = web_vr; 180 web_vr_mode_ = web_vr;
173 181
174 // Make all VR scene UI elements visible if not in WebVR. 182 // Make all VR scene UI elements visible if not in WebVR.
(...skipping 24 matching lines...) Expand all
199 207
200 void UiSceneManager::OnSecurityWarningTimer() { 208 void UiSceneManager::OnSecurityWarningTimer() {
201 transient_security_warning_->visible = false; 209 transient_security_warning_->visible = false;
202 } 210 }
203 211
204 int UiSceneManager::AllocateId() { 212 int UiSceneManager::AllocateId() {
205 return next_available_id_++; 213 return next_available_id_++;
206 } 214 }
207 215
208 } // namespace vr_shell 216 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698