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

Unified Diff: chrome/browser/android/vr_shell/ui_scene_manager.cc

Issue 2844313002: Add VR gradient and grid background to non-WebVR scene. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/ui_scene_manager.cc
diff --git a/chrome/browser/android/vr_shell/ui_scene_manager.cc b/chrome/browser/android/vr_shell/ui_scene_manager.cc
index b2aadfb32b2b6fc35e9afbeed8cef08b2fa70b53..ee71a3ab14022fb8314f0d51f07c02c7331e7277 100644
--- a/chrome/browser/android/vr_shell/ui_scene_manager.cc
+++ b/chrome/browser/android/vr_shell/ui_scene_manager.cc
@@ -20,21 +20,31 @@ static constexpr int kWarningTimeoutSeconds = 30;
static constexpr float kWarningDistance = 0.7;
static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0;
+static constexpr float kBackplaneSize = 1000.0;
amp 2017/04/27 17:28:53 As long as you are changing things here want to me
cjgrant 2017/04/27 18:50:20 I would have said yes, but your CL is now in the C
amp 2017/04/27 18:54:27 Indeed, thanks Michael! It was small enough I did
+static constexpr float kBackgroundDistanceMultiplier = 1.414;
+
+static constexpr float kSceneSize = 25.0;
+static constexpr float kSceneHeight = 4.0;
+static constexpr int kFloorGridlineCount = 40;
+static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0};
+static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0};
+
+// Tiny distance to offset textures that should appear in the same plane.
+static constexpr float kTextureOffset = 0.01;
+
} // namespace
UiSceneManager::UiSceneManager(UiScene* scene)
: scene_(scene), weak_ptr_factory_(this) {
std::unique_ptr<UiElement> element;
- // For now, use an ID range that does not conflict with the HTML UI.
- int id = 1000;
+ int id = 0;
- // Permanent WebVR security warning.
// TODO(mthiesse): Programatically compute the proper texture size for these
// textured UI elements.
element = base::MakeUnique<PermanentSecurityWarning>(512);
- element->id = id++;
element->name = "Permanent security warning";
mthiesse 2017/04/27 15:47:11 Hmm. Is there an easy way to make these element na
cjgrant 2017/04/27 18:50:19 Agreed on no strings. I don't know of any fancine
cjgrant 2017/04/27 21:28:33 Done.
+ element->id = id++;
element->fill = vr_shell::Fill::NONE;
element->size = {0.226f, 0.078f, 1};
element->scale = {kWarningDistance, kWarningDistance, 1};
@@ -47,10 +57,9 @@ UiSceneManager::UiSceneManager(UiScene* scene)
permanent_security_warning_ = element.get();
scene_->AddUiElement(std::move(element));
- // Transient WebVR security warning.
element = base::MakeUnique<TransientSecurityWarning>(1024);
- element->id = id++;
element->name = "Transient security warning";
+ element->id = id++;
element->fill = vr_shell::Fill::NONE;
element->size = {0.512f, 0.160f, 1};
element->scale = {kWarningDistance, kWarningDistance, 1};
@@ -61,16 +70,78 @@ UiSceneManager::UiSceneManager(UiScene* scene)
transient_security_warning_ = element.get();
scene_->AddUiElement(std::move(element));
- // Main web content quad.
element = base::MakeUnique<UiElement>();
- element->id = id++;
element->name = "Content";
+ element->id = id++;
element->fill = vr_shell::Fill::CONTENT;
element->size = {2.4f, 1.6f, 1};
element->translation = {0, -0.1f, -2.5f};
element->visible = false;
main_content_ = element.get();
+ browser_ui_elements_.push_back(element.get());
+ scene_->AddUiElement(std::move(element));
+
+ // Place an invisible but hittable plane behind the content quad, to keep the
cjgrant 2017/04/27 15:11:14 Thoughts on this wall of initialization. I though
mthiesse 2017/04/27 15:47:11 I think member functions for each element creation
cjgrant 2017/04/27 18:50:19 Done. Let me know what you think...
+ // reticle roughly planar with the content if near content.
+ element = base::MakeUnique<UiElement>();
+ element->name = "Backplane";
+ element->id = id++;
+ element->fill = vr_shell::Fill::NONE;
+ element->size = {kBackplaneSize, kBackplaneSize, 1.0};
+ element->translation = {0.0, 0.0, -kTextureOffset};
+ element->parent_id = main_content_->id;
+ browser_ui_elements_.push_back(element.get());
scene_->AddUiElement(std::move(element));
+
+ element = base::MakeUnique<UiElement>();
+ element->name = "Floor";
+ element->id = id++;
+ element->size = {kSceneSize, kSceneSize, 1.0};
+ element->translation = {0.0, -kSceneHeight / 2, 0.0};
+ element->rotation = {1.0, 0.0, 0.0, -M_PI / 2.0};
+ element->fill = vr_shell::Fill::OPAQUE_GRADIENT;
+ element->edge_color = kBackgroundHorizonColor;
+ element->center_color = kBackgroundCenterColor;
+ element->draw_phase = 0;
+ browser_ui_elements_.push_back(element.get());
+ scene_->AddUiElement(std::move(element));
+
+ element = base::MakeUnique<UiElement>();
+ element->name = "Ceiling";
+ element->id = id++;
+ element->fill = vr_shell::Fill::OPAQUE_GRADIENT;
+ element->size = {kSceneSize, kSceneSize, 1.0};
+ element->translation = {0.0, kSceneHeight / 2, 0.0};
+ element->rotation = {1.0, 0.0, 0.0, M_PI / 2};
+ element->fill = vr_shell::Fill::OPAQUE_GRADIENT;
+ element->edge_color = kBackgroundHorizonColor;
+ element->center_color = kBackgroundCenterColor;
+ element->draw_phase = 0;
+ browser_ui_elements_.push_back(element.get());
+ scene_->AddUiElement(std::move(element));
+
+ element = base::MakeUnique<UiElement>();
+ element->name = "Floor grid";
+ element->id = id++;
+ element->fill = vr_shell::Fill::GRID_GRADIENT;
+ element->size = {kSceneSize, kSceneSize, 1.0};
+ element->translation = {0.0, -kSceneHeight / 2 + kTextureOffset, 0.0};
+ element->rotation = {1.0, 0.0, 0.0, -M_PI / 2};
+ element->fill = vr_shell::Fill::GRID_GRADIENT;
+ element->center_color = kBackgroundHorizonColor;
+ vr::Colorf edge_color = kBackgroundHorizonColor;
+ edge_color.a = 0.0;
+ element->edge_color = edge_color;
+ element->gridline_count = kFloorGridlineCount;
+ element->draw_phase = 0;
+ browser_ui_elements_.push_back(element.get());
+ scene_->AddUiElement(std::move(element));
+
+ scene_->SetBackgroundColor(kBackgroundHorizonColor);
+
+ // Limit reticle distance to a sphere based on content distance.
+ scene_->SetBackgroundDistance(main_content_->translation.z() *
+ -kBackgroundDistanceMultiplier);
}
UiSceneManager::~UiSceneManager() {}
@@ -81,7 +152,12 @@ base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
void UiSceneManager::SetWebVRMode(bool web_vr) {
web_vr_mode_ = web_vr;
- main_content_->visible = !web_vr_mode_;
+
+ // Make all VR scene UI elements visible if not in WebVR.
+ for (UiElement* element : browser_ui_elements_) {
+ element->visible = !web_vr_mode_;
+ }
+
ConfigureSecurityWarnings();
}
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698