Commit a5440da5 authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

VR: Remove inappropriate state from the Scene class.

The Scene is meant to hold state supplied by the SceneManager, and
consumed by the rendering subsystem.  Scene shouldn't know about modes,
prompts, etc.  This CL tries to banish any such state.

BUG=

Change-Id: I5cab334aac5150b725ab6408625367d0554bdabf
Reviewed-on: https://chromium-review.googlesource.com/576471
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488267}
parent fc6bc93f
...@@ -594,6 +594,8 @@ void VrShell::ExitVrDueToUnsupportedMode(vr::UiUnsupportedMode mode) { ...@@ -594,6 +594,8 @@ void VrShell::ExitVrDueToUnsupportedMode(vr::UiUnsupportedMode mode) {
return; return;
} }
ui_->SetIsExiting(); ui_->SetIsExiting();
PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::set_is_exiting,
gl_thread_->GetVrShellGl(), true));
main_thread_task_runner_->PostDelayedTask( main_thread_task_runner_->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::Bind(&VrShell::ForceExitVr, weak_ptr_factory_.GetWeakPtr()), base::Bind(&VrShell::ForceExitVr, weak_ptr_factory_.GetWeakPtr()),
......
...@@ -491,7 +491,7 @@ void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) { ...@@ -491,7 +491,7 @@ void VrShellGl::UpdateController(const gfx::Vector3dF& head_direction) {
} }
void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) { void VrShellGl::HandleControllerInput(const gfx::Vector3dF& head_direction) {
if (scene_->is_exiting()) { if (is_exiting_) {
// When we're exiting, we don't show the reticle and the only input // When we're exiting, we don't show the reticle and the only input
// processing we do is to handle immediate exits. // processing we do is to handle immediate exits.
SendImmediateExitRequestIfNecessary(); SendImmediateExitRequestIfNecessary();
...@@ -975,7 +975,7 @@ void VrShellGl::DrawFrameSubmitWhenReady( ...@@ -975,7 +975,7 @@ void VrShellGl::DrawFrameSubmitWhenReady(
} }
bool VrShellGl::ShouldDrawWebVr() { bool VrShellGl::ShouldDrawWebVr() {
return web_vr_mode_ && scene_->GetWebVrRenderingEnabled(); return web_vr_mode_ && scene_->web_vr_rendering_enabled();
} }
void VrShellGl::DrawWebVr() { void VrShellGl::DrawWebVr() {
......
...@@ -114,6 +114,8 @@ class VrShellGl : public device::mojom::VRPresentationProvider, ...@@ -114,6 +114,8 @@ class VrShellGl : public device::mojom::VRPresentationProvider,
device::mojom::VRSubmitFrameClientPtrInfo submit_client_info, device::mojom::VRSubmitFrameClientPtrInfo submit_client_info,
device::mojom::VRPresentationProviderRequest request); device::mojom::VRPresentationProviderRequest request);
void set_is_exiting(bool exiting) { is_exiting_ = exiting; }
private: private:
void GvrInit(gvr_context* gvr_api); void GvrInit(gvr_context* gvr_api);
void InitializeRenderer(); void InitializeRenderer();
...@@ -236,6 +238,7 @@ class VrShellGl : public device::mojom::VRPresentationProvider, ...@@ -236,6 +238,7 @@ class VrShellGl : public device::mojom::VRPresentationProvider,
bool ready_to_draw_ = false; bool ready_to_draw_ = false;
bool surfaceless_rendering_; bool surfaceless_rendering_;
bool daydream_support_; bool daydream_support_;
bool is_exiting_ = false;
std::unique_ptr<VrController> controller_; std::unique_ptr<VrController> controller_;
......
...@@ -53,7 +53,7 @@ void UiInputManager::HandleInput(const gfx::Vector3dF& laser_direction, ...@@ -53,7 +53,7 @@ void UiInputManager::HandleInput(const gfx::Vector3dF& laser_direction,
gfx::Point3F plane_intersection_point; gfx::Point3F plane_intersection_point;
float distance_to_plane; float distance_to_plane;
if (!GetTargetLocalPoint(eye_to_target, *input_locked_element_, if (!GetTargetLocalPoint(eye_to_target, *input_locked_element_,
2 * scene_->GetBackgroundDistance(), 2 * scene_->background_distance(),
&target_local_point, &plane_intersection_point, &target_local_point, &plane_intersection_point,
&distance_to_plane)) { &distance_to_plane)) {
target_local_point = kInvalidTargetPoint; target_local_point = kInvalidTargetPoint;
...@@ -294,7 +294,7 @@ void UiInputManager::GetVisualTargetElement( ...@@ -294,7 +294,7 @@ void UiInputManager::GetVisualTargetElement(
// Compute the distance from the eyes to the distance limiting sphere. Note // Compute the distance from the eyes to the distance limiting sphere. Note
// that the sphere is centered at the controller, rather than the eye, for // that the sphere is centered at the controller, rather than the eye, for
// simplicity. // simplicity.
float distance = scene_->GetBackgroundDistance(); float distance = scene_->background_distance();
*out_target_point = GetRayPoint(laser_origin, laser_direction, distance); *out_target_point = GetRayPoint(laser_origin, laser_direction, distance);
*out_eye_to_target = *out_target_point - kOrigin; *out_eye_to_target = *out_target_point - kOrigin;
out_eye_to_target->GetNormalized(out_eye_to_target); out_eye_to_target->GetNormalized(out_eye_to_target);
......
...@@ -84,7 +84,7 @@ void UiRenderer::DrawWorldElements(const RenderInfo& render_info, ...@@ -84,7 +84,7 @@ void UiRenderer::DrawWorldElements(const RenderInfo& render_info,
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
const SkColor backgroundColor = scene_->GetWorldBackgroundColor(); const SkColor backgroundColor = scene_->background_color();
glClearColor(SkColorGetR(backgroundColor) / 255.0, glClearColor(SkColorGetR(backgroundColor) / 255.0,
SkColorGetG(backgroundColor) / 255.0, SkColorGetG(backgroundColor) / 255.0,
SkColorGetB(backgroundColor) / 255.0, SkColorGetB(backgroundColor) / 255.0,
...@@ -92,9 +92,8 @@ void UiRenderer::DrawWorldElements(const RenderInfo& render_info, ...@@ -92,9 +92,8 @@ void UiRenderer::DrawWorldElements(const RenderInfo& render_info,
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
} }
std::vector<const UiElement*> elements = scene_->GetWorldElements(); std::vector<const UiElement*> elements = scene_->GetWorldElements();
bool draw_reticle = DrawUiView(render_info, controller_info, elements,
!(scene_->is_exiting() || scene_->showing_splash_screen() || web_vr_mode); scene_->reticle_rendering_enabled());
DrawUiView(render_info, controller_info, elements, draw_reticle);
} }
void UiRenderer::DrawOverlayElements(const RenderInfo& render_info, void UiRenderer::DrawOverlayElements(const RenderInfo& render_info,
......
...@@ -162,53 +162,6 @@ bool UiScene::HasVisibleHeadLockedElements() const { ...@@ -162,53 +162,6 @@ bool UiScene::HasVisibleHeadLockedElements() const {
return !GetHeadLockedElements().empty(); return !GetHeadLockedElements().empty();
} }
void UiScene::SetMode(ColorScheme::Mode mode) {
if (mode == mode_)
return;
mode_ = mode;
for (const auto& element : ui_elements_)
element->SetMode(mode);
}
ColorScheme::Mode UiScene::mode() const {
return mode_;
}
SkColor UiScene::GetWorldBackgroundColor() const {
return showing_splash_screen_
? ColorScheme::GetColorScheme(mode_).splash_screen_background
: ColorScheme::GetColorScheme(mode_).world_background;
}
void UiScene::SetBackgroundDistance(float distance) {
background_distance_ = distance;
}
float UiScene::GetBackgroundDistance() const {
return background_distance_;
}
bool UiScene::GetWebVrRenderingEnabled() const {
return webvr_rendering_enabled_;
}
void UiScene::SetWebVrRenderingEnabled(bool enabled) {
webvr_rendering_enabled_ = enabled;
}
void UiScene::set_is_exiting() {
is_exiting_ = true;
}
void UiScene::set_is_prompting_to_exit(bool prompting) {
is_prompting_to_exit_ = prompting;
}
void UiScene::set_showing_splash_screen(bool showing) {
showing_splash_screen_ = showing;
}
const std::vector<std::unique_ptr<UiElement>>& UiScene::GetUiElements() const { const std::vector<std::unique_ptr<UiElement>>& UiScene::GetUiElements() const {
return ui_elements_; return ui_elements_;
} }
......
...@@ -74,23 +74,19 @@ class UiScene { ...@@ -74,23 +74,19 @@ class UiScene {
std::vector<const UiElement*> GetHeadLockedElements() const; std::vector<const UiElement*> GetHeadLockedElements() const;
bool HasVisibleHeadLockedElements() const; bool HasVisibleHeadLockedElements() const;
void SetMode(ColorScheme::Mode mode); float background_distance() const { return background_distance_; }
ColorScheme::Mode mode() const; void set_background_distance(float d) { background_distance_ = d; }
SkColor background_color() const { return background_color_; }
SkColor GetWorldBackgroundColor() const; void set_background_color(SkColor color) { background_color_ = color; }
void SetBackgroundDistance(float distance); bool web_vr_rendering_enabled() const { return webvr_rendering_enabled_; }
float GetBackgroundDistance() const; void set_web_vr_rendering_enabled(bool enabled) {
webvr_rendering_enabled_ = enabled;
bool GetWebVrRenderingEnabled() const; }
void SetWebVrRenderingEnabled(bool enabled); bool reticle_rendering_enabled() const { return reticle_rendering_enabled_; }
void set_reticle_rendering_enabled(bool enabled) {
bool is_exiting() const { return is_exiting_; } reticle_rendering_enabled_ = enabled;
void set_is_exiting(); }
bool is_prompting_to_exit() const { return is_prompting_to_exit_; }
void set_is_prompting_to_exit(bool prompting);
bool showing_splash_screen() const { return showing_splash_screen_; }
void set_showing_splash_screen(bool showing);
void OnGLInitialized(); void OnGLInitialized();
...@@ -103,11 +99,10 @@ class UiScene { ...@@ -103,11 +99,10 @@ class UiScene {
ColorScheme::Mode mode_ = ColorScheme::kModeNormal; ColorScheme::Mode mode_ = ColorScheme::kModeNormal;
float background_distance_ = 10.0f; float background_distance_ = 10.0f;
bool webvr_rendering_enabled_ = true; SkColor background_color_ = 0;
bool webvr_rendering_enabled_ = false;
bool reticle_rendering_enabled_ = true;
bool gl_initialized_ = false; bool gl_initialized_ = false;
bool is_exiting_ = false;
bool is_prompting_to_exit_ = false;
bool showing_splash_screen_ = false;
DISALLOW_COPY_AND_ASSIGN(UiScene); DISALLOW_COPY_AND_ASSIGN(UiScene);
}; };
......
...@@ -140,7 +140,7 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser, ...@@ -140,7 +140,7 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser,
in_cct_(in_cct), in_cct_(in_cct),
web_vr_mode_(in_web_vr), web_vr_mode_(in_web_vr),
started_for_autopresentation_(web_vr_autopresentation_expected), started_for_autopresentation_(web_vr_autopresentation_expected),
waiting_for_first_web_vr_frame_(web_vr_autopresentation_expected), showing_web_vr_splash_screen_(web_vr_autopresentation_expected),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
CreateSplashScreen(); CreateSplashScreen();
CreateBackground(); CreateBackground();
...@@ -287,7 +287,7 @@ void UiSceneManager::CreateContentQuad() { ...@@ -287,7 +287,7 @@ void UiSceneManager::CreateContentQuad() {
scene_->AddUiElement(std::move(element)); scene_->AddUiElement(std::move(element));
// Limit reticle distance to a sphere based on content distance. // Limit reticle distance to a sphere based on content distance.
scene_->SetBackgroundDistance( scene_->set_background_distance(
main_content_->transform_operations().Apply().matrix().get(2, 3) * main_content_->transform_operations().Apply().matrix().get(2, 3) *
-kBackgroundDistanceMultiplier); -kBackgroundDistanceMultiplier);
} }
...@@ -336,7 +336,7 @@ void UiSceneManager::CreateBackground() { ...@@ -336,7 +336,7 @@ void UiSceneManager::CreateBackground() {
background_elements_.push_back(element.get()); background_elements_.push_back(element.get());
scene_->AddUiElement(std::move(element)); scene_->AddUiElement(std::move(element));
UpdateBackgroundColor(); ConfigureBackgroundColor();
} }
void UiSceneManager::CreateUrlBar() { void UiSceneManager::CreateUrlBar() {
...@@ -457,7 +457,7 @@ void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) { ...@@ -457,7 +457,7 @@ void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) {
web_vr_mode_ = web_vr; web_vr_mode_ = web_vr;
web_vr_show_toast_ = show_toast; web_vr_show_toast_ = show_toast;
if (!web_vr_mode_) { if (!web_vr_mode_) {
waiting_for_first_web_vr_frame_ = false; showing_web_vr_splash_screen_ = false;
started_for_autopresentation_ = false; started_for_autopresentation_ = false;
} }
ConfigureScene(); ConfigureScene();
...@@ -472,9 +472,9 @@ void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) { ...@@ -472,9 +472,9 @@ void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) {
} }
void UiSceneManager::OnWebVrFrameAvailable() { void UiSceneManager::OnWebVrFrameAvailable() {
if (!waiting_for_first_web_vr_frame_) if (!showing_web_vr_splash_screen_)
return; return;
waiting_for_first_web_vr_frame_ = false; showing_web_vr_splash_screen_ = false;
ConfigureScene(); ConfigureScene();
} }
...@@ -482,22 +482,21 @@ void UiSceneManager::ConfigureScene() { ...@@ -482,22 +482,21 @@ void UiSceneManager::ConfigureScene() {
// We disable WebVR rendering if we're expecting to auto present so that we // We disable WebVR rendering if we're expecting to auto present so that we
// can continue to show the 2D splash screen while the site submits the first // can continue to show the 2D splash screen while the site submits the first
// WebVR frame. // WebVR frame.
scene_->SetWebVrRenderingEnabled(web_vr_mode_ && scene_->set_web_vr_rendering_enabled(web_vr_mode_ &&
!waiting_for_first_web_vr_frame_); !showing_web_vr_splash_screen_);
// Splash screen. // Splash screen.
scene_->set_showing_splash_screen(waiting_for_first_web_vr_frame_); splash_screen_icon_->SetEnabled(showing_web_vr_splash_screen_);
splash_screen_icon_->SetEnabled(waiting_for_first_web_vr_frame_);
// Exit warning. // Exit warning.
exit_warning_->SetEnabled(scene_->is_exiting()); exit_warning_->SetEnabled(exiting_);
screen_dimmer_->SetEnabled(scene_->is_exiting()); screen_dimmer_->SetEnabled(exiting_);
bool browsing_mode = !web_vr_mode_ && !scene_->showing_splash_screen(); bool browsing_mode = !web_vr_mode_ && !showing_web_vr_splash_screen_;
// Controls (URL bar, loading progress, etc). // Controls (URL bar, loading progress, etc).
bool controls_visible = browsing_mode && !fullscreen_; bool controls_visible = browsing_mode && !fullscreen_ && !prompting_to_exit_;
for (UiElement* element : control_elements_) { for (UiElement* element : control_elements_) {
element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit()); element->SetEnabled(controls_visible);
} }
// Close button is a special control element that needs to be hidden when in // Close button is a special control element that needs to be hidden when in
...@@ -506,7 +505,7 @@ void UiSceneManager::ConfigureScene() { ...@@ -506,7 +505,7 @@ void UiSceneManager::ConfigureScene() {
// Content elements. // Content elements.
for (UiElement* element : content_elements_) { for (UiElement* element : content_elements_) {
element->SetEnabled(browsing_mode && !scene_->is_prompting_to_exit()); element->SetEnabled(browsing_mode && !prompting_to_exit_);
} }
// Background elements. // Background elements.
...@@ -515,7 +514,7 @@ void UiSceneManager::ConfigureScene() { ...@@ -515,7 +514,7 @@ void UiSceneManager::ConfigureScene() {
} }
// Exit prompt. // Exit prompt.
bool showExitPrompt = browsing_mode && scene_->is_prompting_to_exit(); bool showExitPrompt = browsing_mode && prompting_to_exit_;
exit_prompt_->SetEnabled(showExitPrompt); exit_prompt_->SetEnabled(showExitPrompt);
exit_prompt_backplane_->SetEnabled(showExitPrompt); exit_prompt_backplane_->SetEnabled(showExitPrompt);
...@@ -539,22 +538,26 @@ void UiSceneManager::ConfigureScene() { ...@@ -539,22 +538,26 @@ void UiSceneManager::ConfigureScene() {
-kCloseButtonDistance); -kCloseButtonDistance);
close_button_->SetSize(kCloseButtonWidth, kCloseButtonHeight); close_button_->SetSize(kCloseButtonWidth, kCloseButtonHeight);
} }
scene_->set_background_distance(
scene_->SetMode(mode());
scene_->SetBackgroundDistance(
main_content_->transform_operations().Apply().matrix().get(2, 3) * main_content_->transform_operations().Apply().matrix().get(2, 3) *
-kBackgroundDistanceMultiplier); -kBackgroundDistanceMultiplier);
UpdateBackgroundColor();
for (auto& element : scene_->GetUiElements())
element->SetMode(mode());
transient_url_bar_->SetEnabled(started_for_autopresentation_ && transient_url_bar_->SetEnabled(started_for_autopresentation_ &&
!scene_->showing_splash_screen()); !showing_web_vr_splash_screen_);
scene_->set_reticle_rendering_enabled(
!(web_vr_mode_ || exiting_ || showing_web_vr_splash_screen_));
ConfigureExclusiveScreenToast(); ConfigureExclusiveScreenToast();
ConfigureSecurityWarnings(); ConfigureSecurityWarnings();
ConfigureIndicators(); ConfigureIndicators();
ConfigureBackgroundColor();
} }
void UiSceneManager::UpdateBackgroundColor() { void UiSceneManager::ConfigureBackgroundColor() {
// TODO(vollick): it would be nice if ceiling, floor and the grid were // TODO(vollick): it would be nice if ceiling, floor and the grid were
// UiElement subclasses and could respond to the OnSetMode signal. // UiElement subclasses and could respond to the OnSetMode signal.
ceiling_->set_center_color(color_scheme().ceiling); ceiling_->set_center_color(color_scheme().ceiling);
...@@ -562,6 +565,10 @@ void UiSceneManager::UpdateBackgroundColor() { ...@@ -562,6 +565,10 @@ void UiSceneManager::UpdateBackgroundColor() {
floor_->set_center_color(color_scheme().floor); floor_->set_center_color(color_scheme().floor);
floor_->set_edge_color(color_scheme().world_background); floor_->set_edge_color(color_scheme().world_background);
floor_->set_grid_color(color_scheme().floor_grid); floor_->set_grid_color(color_scheme().floor_grid);
scene_->set_background_color(showing_web_vr_splash_screen_
? color_scheme().splash_screen_background
: color_scheme().world_background);
} }
void UiSceneManager::SetSplashScreenIcon(const SkBitmap& bitmap) { void UiSceneManager::SetSplashScreenIcon(const SkBitmap& bitmap) {
...@@ -632,7 +639,7 @@ void UiSceneManager::SetFullscreen(bool fullscreen) { ...@@ -632,7 +639,7 @@ void UiSceneManager::SetFullscreen(bool fullscreen) {
void UiSceneManager::ConfigureSecurityWarnings() { void UiSceneManager::ConfigureSecurityWarnings() {
bool enabled = bool enabled =
web_vr_mode_ && !secure_origin_ && !waiting_for_first_web_vr_frame_; web_vr_mode_ && !secure_origin_ && !showing_web_vr_splash_screen_;
permanent_security_warning_->SetEnabled(enabled); permanent_security_warning_->SetEnabled(enabled);
transient_security_warning_->SetEnabled(enabled); transient_security_warning_->SetEnabled(enabled);
} }
...@@ -711,9 +718,9 @@ void UiSceneManager::OnExitPromptPrimaryButtonClickedForTesting() { ...@@ -711,9 +718,9 @@ void UiSceneManager::OnExitPromptPrimaryButtonClickedForTesting() {
} }
void UiSceneManager::OnSecurityIconClicked() { void UiSceneManager::OnSecurityIconClicked() {
if (scene_->is_prompting_to_exit()) if (prompting_to_exit_)
return; return;
scene_->set_is_prompting_to_exit(true); prompting_to_exit_ = true;
ConfigureScene(); ConfigureScene();
} }
...@@ -722,9 +729,9 @@ void UiSceneManager::OnExitPromptBackplaneClicked() { ...@@ -722,9 +729,9 @@ void UiSceneManager::OnExitPromptBackplaneClicked() {
} }
void UiSceneManager::CloseExitPrompt() { void UiSceneManager::CloseExitPrompt() {
if (!scene_->is_prompting_to_exit()) if (!prompting_to_exit_)
return; return;
scene_->set_is_prompting_to_exit(false); prompting_to_exit_ = false;
ConfigureScene(); ConfigureScene();
} }
...@@ -750,9 +757,9 @@ void UiSceneManager::SetLoadProgress(float progress) { ...@@ -750,9 +757,9 @@ void UiSceneManager::SetLoadProgress(float progress) {
} }
void UiSceneManager::SetIsExiting() { void UiSceneManager::SetIsExiting() {
if (scene_->is_exiting()) if (exiting_)
return; return;
scene_->set_is_exiting(); exiting_ = true;
ConfigureScene(); ConfigureScene();
} }
......
...@@ -80,7 +80,7 @@ class UiSceneManager { ...@@ -80,7 +80,7 @@ class UiSceneManager {
void ConfigureSecurityWarnings(); void ConfigureSecurityWarnings();
void ConfigureExclusiveScreenToast(); void ConfigureExclusiveScreenToast();
void ConfigureIndicators(); void ConfigureIndicators();
void UpdateBackgroundColor(); void ConfigureBackgroundColor();
void CloseExitPrompt(); void CloseExitPrompt();
void OnBackButtonClicked(); void OnBackButtonClicked();
void OnSecurityIconClicked(); void OnSecurityIconClicked();
...@@ -127,7 +127,10 @@ class UiSceneManager { ...@@ -127,7 +127,10 @@ class UiSceneManager {
// Flag to indicate that we're waiting for the first WebVR frame to show up // Flag to indicate that we're waiting for the first WebVR frame to show up
// before we hide the splash screen. This is used in the case of WebVR // before we hide the splash screen. This is used in the case of WebVR
// auto-presentation. // auto-presentation.
bool waiting_for_first_web_vr_frame_ = false; bool showing_web_vr_splash_screen_ = false;
bool prompting_to_exit_ = false;
bool exiting_ = false;
bool secure_origin_ = false; bool secure_origin_ = false;
bool fullscreen_ = false; bool fullscreen_ = false;
bool incognito_ = false; bool incognito_ = false;
......
...@@ -165,54 +165,54 @@ TEST_F(UiSceneManagerTest, UiUpdatesForIncognito) { ...@@ -165,54 +165,54 @@ TEST_F(UiSceneManagerTest, UiUpdatesForIncognito) {
MakeManager(kNotInCct, kNotInWebVr); MakeManager(kNotInCct, kNotInWebVr);
// Hold onto the background color to make sure it changes. // Hold onto the background color to make sure it changes.
SkColor initial_background = scene_->GetWorldBackgroundColor(); SkColor initial_background = scene_->background_color();
manager_->SetFullscreen(true); manager_->SetFullscreen(true);
{ {
SCOPED_TRACE("Entered Fullsceen"); SCOPED_TRACE("Entered Fullsceen");
// Make sure background has changed for fullscreen. // Make sure background has changed for fullscreen.
EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor()); EXPECT_NE(initial_background, scene_->background_color());
} }
SkColor fullscreen_background = scene_->GetWorldBackgroundColor(); SkColor fullscreen_background = scene_->background_color();
manager_->SetIncognito(true); manager_->SetIncognito(true);
{ {
SCOPED_TRACE("Entered Incognito"); SCOPED_TRACE("Entered Incognito");
// Make sure background has changed for incognito. // Make sure background has changed for incognito.
EXPECT_NE(fullscreen_background, scene_->GetWorldBackgroundColor()); EXPECT_NE(fullscreen_background, scene_->background_color());
EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor()); EXPECT_NE(initial_background, scene_->background_color());
} }
SkColor incognito_background = scene_->GetWorldBackgroundColor(); SkColor incognito_background = scene_->background_color();
manager_->SetIncognito(false); manager_->SetIncognito(false);
{ {
SCOPED_TRACE("Exited Incognito"); SCOPED_TRACE("Exited Incognito");
EXPECT_EQ(fullscreen_background, scene_->GetWorldBackgroundColor()); EXPECT_EQ(fullscreen_background, scene_->background_color());
} }
manager_->SetFullscreen(false); manager_->SetFullscreen(false);
{ {
SCOPED_TRACE("Exited Fullsceen"); SCOPED_TRACE("Exited Fullsceen");
EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); EXPECT_EQ(initial_background, scene_->background_color());
} }
manager_->SetIncognito(true); manager_->SetIncognito(true);
{ {
SCOPED_TRACE("Entered Incognito"); SCOPED_TRACE("Entered Incognito");
EXPECT_EQ(incognito_background, scene_->GetWorldBackgroundColor()); EXPECT_EQ(incognito_background, scene_->background_color());
} }
manager_->SetIncognito(false); manager_->SetIncognito(false);
{ {
SCOPED_TRACE("Exited Incognito"); SCOPED_TRACE("Exited Incognito");
EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); EXPECT_EQ(initial_background, scene_->background_color());
} }
} }
...@@ -268,7 +268,7 @@ TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { ...@@ -268,7 +268,7 @@ TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) {
MakeManager(kNotInCct, kNotInWebVr); MakeManager(kNotInCct, kNotInWebVr);
// Hold onto the background color to make sure it changes. // Hold onto the background color to make sure it changes.
SkColor initial_background = scene_->GetWorldBackgroundColor(); SkColor initial_background = scene_->background_color();
VerifyElementsVisible("Initial", kElementsVisibleInBrowsing); VerifyElementsVisible("Initial", kElementsVisibleInBrowsing);
UiElement* content_quad = scene_->GetUiElementByDebugId(kContentQuad); UiElement* content_quad = scene_->GetUiElementByDebugId(kContentQuad);
gfx::SizeF initial_content_size = content_quad->size(); gfx::SizeF initial_content_size = content_quad->size();
...@@ -280,7 +280,7 @@ TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { ...@@ -280,7 +280,7 @@ TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) {
manager_->SetFullscreen(true); manager_->SetFullscreen(true);
VerifyElementsVisible("In fullscreen", visible_in_fullscreen); VerifyElementsVisible("In fullscreen", visible_in_fullscreen);
// Make sure background has changed for fullscreen. // Make sure background has changed for fullscreen.
EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor()); EXPECT_NE(initial_background, scene_->background_color());
// Should have started transition. // Should have started transition.
EXPECT_TRUE(IsAnimating(content_quad, {TRANSFORM, BOUNDS})); EXPECT_TRUE(IsAnimating(content_quad, {TRANSFORM, BOUNDS}));
// Finish the transition. // Finish the transition.
...@@ -292,7 +292,7 @@ TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { ...@@ -292,7 +292,7 @@ TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) {
// Everything should return to original state after leaving fullscreen. // Everything should return to original state after leaving fullscreen.
manager_->SetFullscreen(false); manager_->SetFullscreen(false);
VerifyElementsVisible("Restore initial", kElementsVisibleInBrowsing); VerifyElementsVisible("Restore initial", kElementsVisibleInBrowsing);
EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); EXPECT_EQ(initial_background, scene_->background_color());
// Should have started transition. // Should have started transition.
EXPECT_TRUE(IsAnimating(content_quad, {TRANSFORM, BOUNDS})); EXPECT_TRUE(IsAnimating(content_quad, {TRANSFORM, BOUNDS}));
// Finish the transition. // Finish the transition.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment