Commit 0c5d294c authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Partial revert of dimming the wallpaper.

Partial revert of https://chromium-review.googlesource.com/c/chromium/src/+/1481899.
It turns out that that change did not remove a full screen blit, so it
was a lateral change at best. But that cl does fix another wallpaper bug
and left some framework for the next change, which confirm to remove a
fullscreen blit, but will not make it in time for m74.

TBR=xiyuan@chromium.org

Test: none
Bug: 774690
Change-Id: I3a42d9a2dfdc81b848998858ea4fad0218c7f7a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506372
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638285}
parent 9fbbb56b
......@@ -27,7 +27,6 @@
#include "ash/wallpaper/wallpaper_window_state_manager.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_enumerator.h"
......@@ -1503,9 +1502,9 @@ void WallpaperController::InstallDesktopController(aura::Window* root_window) {
const int container_id = GetWallpaperContainerId(locked_);
float blur = login_constants::kClearBlurSigma;
if (is_wallpaper_blurred) {
if (is_wallpaper_blurred)
blur = session_blocked ? login_constants::kBlurSigma : kWallpaperBlurSigma;
}
WallpaperView* wallpaper_view = nullptr;
auto* wallpaper_widget_controller =
RootWindowController::ForWindow(root_window)
......
......@@ -22,11 +22,11 @@ class WallpaperView : public views::View, public views::ContextMenuController {
private:
friend class WallpaperControllerTest;
// Overridden from views::View:
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
bool OnMousePressed(const ui::MouseEvent& event) override;
// Overridden from views::ContextMenuController:
// views::ContextMenuController:
void ShowContextMenuForView(views::View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) override;
......
......@@ -13,7 +13,6 @@
#include "base/scoped_observer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/views/widget/widget.h"
......@@ -233,12 +232,6 @@ float WallpaperWidgetController::GetWallpaperBlur() const {
return active_widget_ ? active_widget_->blur_sigma() : 0.f;
}
ui::Layer* WallpaperWidgetController::GetLayer() {
if (GetAnimatingWidget())
return GetAnimatingWidget()->GetNativeWindow()->layer();
return GetWidget() ? GetWidget()->GetNativeWindow()->layer() : nullptr;
}
void WallpaperWidgetController::ResetWidgetsForTesting() {
animating_widget_.reset();
active_widget_.reset();
......
......@@ -16,10 +16,6 @@ namespace aura {
class Window;
}
namespace ui {
class Layer;
}
namespace views {
class Widget;
}
......@@ -72,10 +68,6 @@ class ASH_EXPORT WallpaperWidgetController {
// Returns the blur sigma applied on the wallpaper layer.
float GetWallpaperBlur() const;
// Gets the layer associated with |animating_widget_| if that exists. If not
// then gets the layer associated with |active_widget_|.
ui::Layer* GetLayer();
// TODO: Get the wallpaper view from |animating_widget_| or |active_widget_|
// instead of caching the pointer value.
WallpaperView* wallpaper_view() const { return wallpaper_view_; }
......
......@@ -20,7 +20,6 @@
#include "ash/wm/overview/overview_item.h"
#include "ash/wm/overview/overview_session.h"
#include "ash/wm/overview/overview_utils.h"
#include "ash/wm/overview/scoped_overview_animation_settings.h"
#include "ash/wm/root_window_finder.h"
#include "ash/wm/screen_pinning_controller.h"
#include "ash/wm/splitview/split_view_controller.h"
......@@ -34,7 +33,6 @@
#include "base/metrics/user_metrics.h"
#include "base/stl_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/compositor/layer_animator.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/wm/core/window_util.h"
......@@ -86,30 +84,6 @@ bool ShouldSlideInOutOverview(const std::vector<aura::Window*>& windows) {
return true;
}
// Helper to dim the wallpaper. Optionally animates the dimming.
void SetWallpaperDimmed(bool dimmed) {
// Wallpaper is already dimmed in tablet mode for the home launcher, so no
// need to dim anymore.
if (!Shell::Get()->tablet_mode_controller() ||
Shell::Get()
->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled()) {
return;
}
const float target_opacity = dimmed ? kShieldOpacity : 1.0f;
for (aura::Window* root : Shell::Get()->GetAllRootWindows()) {
WallpaperWidgetController* wallpaper_widget_controller =
RootWindowController::ForWindow(root)->wallpaper_widget_controller();
ui::Layer* layer = wallpaper_widget_controller->GetLayer();
if (layer) {
ScopedOverviewAnimationSettings settings(OVERVIEW_ANIMATION_SHIELD_FADE,
layer->GetAnimator());
layer->SetOpacity(target_opacity);
}
}
}
} // namespace
// Class that handles of blurring wallpaper upon entering and exiting overview
......@@ -400,7 +374,6 @@ bool OverviewController::ToggleOverview(
void OverviewController::OnStartingAnimationComplete(bool canceled) {
if (IsBlurAllowed())
overview_blur_controller_->Blur(/*animate_only=*/true);
SetWallpaperDimmed(true);
for (auto& observer : observers_)
observer.OnOverviewModeStartingAnimationComplete(canceled);
......@@ -415,7 +388,6 @@ void OverviewController::OnEndingAnimationComplete(bool canceled) {
// the blur.
if (IsBlurAllowed() && !canceled)
overview_blur_controller_->Unblur();
SetWallpaperDimmed(false);
for (auto& observer : observers_)
observer.OnOverviewModeEndingAnimationComplete(canceled);
......
......@@ -11,6 +11,7 @@
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/wallpaper_types.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/public/cpp/window_state_type.h"
#include "ash/root_window_controller.h"
......@@ -20,6 +21,8 @@
#include "ash/shelf/shelf_constants.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wm/desks/desks_bar_view.h"
#include "ash/wm/overview/cleanup_animation_observer.h"
#include "ash/wm/overview/drop_target_view.h"
......@@ -47,6 +50,8 @@
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/compositor_extra/shadow.h"
#include "ui/gfx/color_analysis.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/views/background.h"
......@@ -60,6 +65,9 @@
namespace ash {
namespace {
// The color and opacity of the screen shield in overview.
constexpr SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0);
// The color and opacity of the overview selector.
constexpr SkColor kWindowSelectionColor = SkColorSetARGB(36, 255, 255, 255);
......@@ -67,6 +75,10 @@ constexpr SkColor kWindowSelectionColor = SkColorSetARGB(36, 255, 255, 255);
constexpr int kWindowSelectionRadius = 9;
constexpr int kWindowSelectionShadowElevation = 24;
// The base color which is mixed with the dark muted color from wallpaper to
// form the shield widgets color.
constexpr SkColor kShieldBaseColor = SkColorSetARGB(179, 0, 0, 0);
// Windows are not allowed to get taller than this.
constexpr int kMaxHeight = 512;
......@@ -183,6 +195,16 @@ gfx::Rect GetGridBoundsInScreenAfterDragging(aura::Window* dragged_window) {
class OverviewGrid::ShieldView : public views::View {
public:
ShieldView() {
background_view_ = new views::View();
background_view_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
background_view_->layer()->SetColor(kShieldBaseColor);
background_view_->layer()->SetOpacity(
!Shell::Get()
->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled()
? kShieldOpacity
: 0.f);
label_ = new views::Label(
l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_NO_RECENT_ITEMS),
views::style::CONTEXT_LABEL);
......@@ -204,6 +226,7 @@ class OverviewGrid::ShieldView : public views::View {
label_container_->layer()->SetOpacity(kNoItemsIndicatorBackgroundOpacity);
label_container_->SetVisible(false);
AddChildView(background_view_);
AddChildView(label_container_);
}
......@@ -223,6 +246,10 @@ class OverviewGrid::ShieldView : public views::View {
desks_bar_view_->Init();
}
void SetBackgroundColor(SkColor color) {
background_view_->layer()->SetColor(color);
}
void SetLabelVisibility(bool visible) {
label_container_->SetVisible(visible);
}
......@@ -250,6 +277,7 @@ class OverviewGrid::ShieldView : public views::View {
protected:
// views::View:
void Layout() override {
background_view_->SetBoundsRect(GetLocalBounds());
UpdateDesksBarBounds();
}
......@@ -300,6 +328,7 @@ class OverviewGrid::ShieldView : public views::View {
}
// Owned by views heirarchy.
views::View* background_view_ = nullptr;
RoundedRectView* label_container_ = nullptr;
views::Label* label_ = nullptr;
DesksBarView* desks_bar_view_ = nullptr;
......@@ -405,6 +434,22 @@ OverviewGrid::OverviewGrid(aura::Window* root_window,
OverviewGrid::~OverviewGrid() = default;
// static
SkColor OverviewGrid::GetShieldColor() {
SkColor shield_color = kShieldColor;
// Extract the dark muted color from the wallpaper and mix it with
// |kShieldBaseColor|. Just use |kShieldBaseColor| if the dark muted color
// could not be extracted.
SkColor dark_muted_color =
Shell::Get()->wallpaper_controller()->GetProminentColor(
color_utils::ColorProfile());
if (dark_muted_color != ash::kInvalidWallpaperColor) {
shield_color =
color_utils::GetResultingPaintColor(kShieldBaseColor, dark_muted_color);
}
return shield_color;
}
void OverviewGrid::Shutdown() {
ScreenRotationAnimator::GetForRootWindow(root_window_)->RemoveObserver(this);
......@@ -1277,6 +1322,7 @@ void OverviewGrid::InitShieldWidget(bool animate) {
shield_view_ = new ShieldView();
shield_widget_->SetContentsView(shield_view_);
shield_view_->MaybeInitVirtualDesksBar();
shield_view_->SetBackgroundColor(GetShieldColor());
shield_view_->SetGridBounds(bounds_);
if (animate) {
......
......@@ -61,6 +61,9 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver,
const gfx::Rect& bounds_in_screen);
~OverviewGrid() override;
// Returns the shield color that is used to darken the background of the grid.
static SkColor GetShieldColor();
// Exits overview mode, fading out the |shield_widget_| if necessary.
void Shutdown();
......
......@@ -7,15 +7,14 @@
#include <vector>
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/public/cpp/wallpaper_types.h"
#include "ash/root_window_controller.h"
#include "ash/scoped_animation_disabler.h"
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_widget_controller.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_utils.h"
#include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/tablet_mode/tablet_mode_window_state.h"
......@@ -24,8 +23,6 @@
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/screen.h"
#include "ui/gfx/color_analysis.h"
#include "ui/gfx/color_utils.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"
......@@ -43,29 +40,6 @@ constexpr float kSourceWindowScale = 0.85;
// window after drag ends and do not try to merge it back into source window.
constexpr float kFlingToStayAsNewWindowThreshold = 2000.f;
// The color and opacity of the screen shield.
constexpr SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0);
// The base color which is mixed with the dark muted color from wallpaper to
// form the shield widgets color.
constexpr SkColor kShieldBaseColor = SkColorSetARGB(179, 0, 0, 0);
// Returns the shield color that is used to darken the background.
SkColor GetShieldColor() {
SkColor shield_color = kShieldColor;
// Extract the dark muted color from the wallpaper and mix it with
// |kShieldBaseColor|. Just use |kShieldBaseColor| if the dark muted color
// could not be extracted.
SkColor dark_muted_color =
Shell::Get()->wallpaper_controller()->GetProminentColor(
color_utils::ColorProfile());
if (dark_muted_color != ash::kInvalidWallpaperColor) {
shield_color =
color_utils::GetResultingPaintColor(kShieldBaseColor, dark_muted_color);
}
return shield_color;
}
// The class to observe the source window's bounds change animation. It's used
// to prevent the dragged window to merge back into the source window during
// dragging. Only when the source window restores to its maximized window size,
......@@ -181,8 +155,6 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
->SetWallpaperBlur(kWallpaperBlurSigma);
// Darken the background.
// TODO: Do dimming in wallpaper to avoid creating another fullscreen
// widget.
shield_widget_ = CreateBackgroundWidget(
root_window, ui::LAYER_SOLID_COLOR, SK_ColorTRANSPARENT, 0, 0,
SK_ColorTRANSPARENT, /*initial_opacity*/ 1.f, /*parent=*/nullptr,
......@@ -192,7 +164,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider
widget_window->SetBounds(bounds);
views::View* shield_view = new views::View();
shield_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
shield_view->layer()->SetColor(GetShieldColor());
shield_view->layer()->SetColor(OverviewGrid::GetShieldColor());
shield_view->layer()->SetOpacity(kShieldOpacity);
shield_widget_->SetContentsView(shield_view);
}
......
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