Commit 5ccc1e03 authored by Eliot Courtney's avatar Eliot Courtney Committed by Commit Bot

Apply rounded corners to the Picture-in-Picture window.

stayed upon resizing the window.

Bug: b/112668689
Bug: 841886
Test: Created a PIP window and it had rounded corners. Rounded corners
Change-Id: Ie57223d8c5a2701a0013eee0bce2cf5333d2c304
Reviewed-on: https://chromium-review.googlesource.com/1219426
Commit-Queue: Eliot Courtney <edcourtney@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594962}
parent 609ff090
...@@ -39,6 +39,7 @@ void BaseState::OnWMEvent(WindowState* window_state, const WMEvent* event) { ...@@ -39,6 +39,7 @@ void BaseState::OnWMEvent(WindowState* window_state, const WMEvent* event) {
if (event->IsBoundsEvent()) { if (event->IsBoundsEvent()) {
HandleBoundsEvents(window_state, event); HandleBoundsEvents(window_state, event);
window_state->UpdatePipRoundedCorners();
return; return;
} }
DCHECK(event->IsTransitionEvent()); DCHECK(event->IsTransitionEvent());
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/views/painter.h"
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/ime_util_chromeos.h" #include "ui/wm/core/ime_util_chromeos.h"
#include "ui/wm/core/window_util.h" #include "ui/wm/core/window_util.h"
...@@ -40,6 +41,9 @@ namespace ash { ...@@ -40,6 +41,9 @@ namespace ash {
namespace wm { namespace wm {
namespace { namespace {
// TODO(edcourtney): Move this to a PIP specific file, once it's created.
const int kPipRoundedCornerRadius = 8;
bool IsTabletModeEnabled() { bool IsTabletModeEnabled() {
return Shell::Get() return Shell::Get()
->tablet_mode_controller() ->tablet_mode_controller()
...@@ -660,6 +664,28 @@ void WindowState::SetBoundsDirectCrossFade(const gfx::Rect& new_bounds, ...@@ -660,6 +664,28 @@ void WindowState::SetBoundsDirectCrossFade(const gfx::Rect& new_bounds,
CrossFadeAnimation(window_, std::move(old_layer_owner), animation_type); CrossFadeAnimation(window_, std::move(old_layer_owner), animation_type);
} }
void WindowState::UpdatePipRoundedCorners() {
auto* layer = window()->layer();
if (!IsPip()) {
if (layer)
layer->SetMaskLayer(nullptr);
pip_mask_.reset();
return;
}
gfx::Rect bounds = window()->bounds();
if (layer && (!pip_mask_ || pip_mask_->layer()->size() != bounds.size())) {
layer->SetMaskLayer(nullptr);
pip_mask_ = views::Painter::CreatePaintedLayer(
views::Painter::CreateSolidRoundRectPainter(SK_ColorBLACK,
kPipRoundedCornerRadius));
pip_mask_->layer()->SetBounds(bounds);
pip_mask_->layer()->SetFillsBoundsOpaquely(false);
layer->SetFillsBoundsOpaquely(false);
layer->SetMaskLayer(pip_mask_->layer());
}
}
WindowState* GetActiveWindowState() { WindowState* GetActiveWindowState() {
aura::Window* active = GetActiveWindow(); aura::Window* active = GetActiveWindow();
return active ? GetWindowState(active) : nullptr; return active ? GetWindowState(active) : nullptr;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/compositor/layer_owner.h"
#include "ui/gfx/animation/tween.h" #include "ui/gfx/animation/tween.h"
namespace gfx { namespace gfx {
...@@ -399,6 +400,10 @@ class ASH_EXPORT WindowState : public aura::WindowObserver { ...@@ -399,6 +400,10 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
const gfx::Rect& bounds, const gfx::Rect& bounds,
gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT); gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT);
// Updates rounded corners for PIP window states. Removes rounded corners
// for non-PIP window states.
void UpdatePipRoundedCorners();
// aura::WindowObserver: // aura::WindowObserver:
void OnWindowPropertyChanged(aura::Window* window, void OnWindowPropertyChanged(aura::Window* window,
const void* key, const void* key,
...@@ -422,6 +427,9 @@ class ASH_EXPORT WindowState : public aura::WindowObserver { ...@@ -422,6 +427,9 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
bool cached_always_on_top_; bool cached_always_on_top_;
bool allow_set_bounds_direct_ = false; bool allow_set_bounds_direct_ = false;
// Mask layer for PIP windows.
std::unique_ptr<ui::LayerOwner> pip_mask_ = nullptr;
// A property to save the ratio between snapped window width and display // A property to save the ratio between snapped window width and display
// workarea width. It is used to update snapped window width on // workarea width. It is used to update snapped window width on
// AdjustSnappedBounds() when handling workspace events. // AdjustSnappedBounds() when handling workspace events.
......
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