Commit 648aa9e1 authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Apply PIP mask correctly to second (and later) PIP window

Previously the mask was applied only to the first PIP window. This CL
fixes this bug.

Bug: 902637
Test: Tested manually with the steps on the issue
Test: Added test passes

Change-Id: I4f86fa1713a861243ab3c87d051ff491f7b6bd32
Reviewed-on: https://chromium-review.googlesource.com/c/1322188Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609924}
parent e0ee32e4
...@@ -868,5 +868,14 @@ void WindowState::OnWindowDestroying(aura::Window* window) { ...@@ -868,5 +868,14 @@ void WindowState::OnWindowDestroying(aura::Window* window) {
delegate_.reset(); delegate_.reset();
} }
void WindowState::OnWindowLayerRecreated(aura::Window* window) {
DCHECK_EQ(window_, window);
// THe mask layer will be moved with old layer.
DCHECK(!window_->layer()->layer_mask_layer());
pip_mask_.reset();
if (IsPip())
UpdatePipRoundedCorners();
}
} // namespace wm } // namespace wm
} // namespace ash } // namespace ash
...@@ -361,6 +361,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver { ...@@ -361,6 +361,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds); FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds);
FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest,
CrossFadeToBoundsFromTransform); CrossFadeToBoundsFromTransform);
FRIEND_TEST_ALL_PREFIXES(WindowStateTest, PipWindowMaskRecreated);
FRIEND_TEST_ALL_PREFIXES(WindowStateTest, PipWindowHasMaskLayer); FRIEND_TEST_ALL_PREFIXES(WindowStateTest, PipWindowHasMaskLayer);
// Class to host the rounded mask for PIP windows. // Class to host the rounded mask for PIP windows.
...@@ -435,6 +436,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver { ...@@ -435,6 +436,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
intptr_t old) override; intptr_t old) override;
void OnWindowAddedToRootWindow(aura::Window* window) override; void OnWindowAddedToRootWindow(aura::Window* window) override;
void OnWindowDestroying(aura::Window* window) override; void OnWindowDestroying(aura::Window* window) override;
void OnWindowLayerRecreated(aura::Window* window) override;
// The owner of this window settings. // The owner of this window settings.
aura::Window* window_; aura::Window* window_;
......
...@@ -173,6 +173,31 @@ TEST_F(WindowStateTest, PipWindowCannotSnap) { ...@@ -173,6 +173,31 @@ TEST_F(WindowStateTest, PipWindowCannotSnap) {
EXPECT_FALSE(window_state->CanSnap()); EXPECT_FALSE(window_state->CanSnap());
} }
// Test that a mask layer is created correctly.
TEST_F(WindowStateTest, PipWindowMaskRecreated) {
// Prepare a PIP window.
std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
WindowState* window_state = GetWindowState(window.get());
window_state->SetStateObject(std::unique_ptr<WindowState::State>(
new InitialStateTestState(mojom::WindowStateType::PIP)));
window_state->UpdatePipRoundedCorners();
// Mask layer exists.
EXPECT_TRUE(window->layer());
EXPECT_TRUE(window->layer()->layer_mask_layer());
// Close the PIP window.
window->Hide();
// Reshow the PIP window.
window->Show();
// Confirms a mask layer exists.
EXPECT_TRUE(window->layer());
EXPECT_TRUE(window->layer()->layer_mask_layer());
}
// Test that a PIP window cannot be snapped. // Test that a PIP window cannot be snapped.
TEST_F(WindowStateTest, PipWindowHasMaskLayer) { TEST_F(WindowStateTest, PipWindowHasMaskLayer) {
// Prepare a PIP window. // Prepare a PIP window.
......
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