diff --git a/ash/shelf/window_preview.cc b/ash/shelf/window_preview.cc index 42bd8f95ce90b..523101639d78e 100644 --- a/ash/shelf/window_preview.cc +++ b/ash/shelf/window_preview.cc @@ -38,8 +38,7 @@ constexpr int kPreviewBorderRadius = 4; WindowPreview::WindowPreview(aura::Window* window, Delegate* delegate) : delegate_(delegate) { - preview_view_ = - new WindowPreviewView(window, /*trilinear_filtering_on_init=*/false); + preview_view_ = new WindowPreviewView(window); preview_container_view_ = new views::View(); preview_container_view_->SetBackground(views::CreateRoundedRectBackground( kPreviewContainerBgColor, kPreviewBorderRadius)); diff --git a/ash/wm/drag_window_controller.cc b/ash/wm/drag_window_controller.cc index b19c6b7b75900..f841611e6629a 100644 --- a/ash/wm/drag_window_controller.cc +++ b/ash/wm/drag_window_controller.cc @@ -121,14 +121,13 @@ class DragWindowController::DragWindowDetails { widget_->set_focus_on_creation(false); widget_->Init(std::move(params)); - // TODO(crbug.com/1026746): Change this to WindowPreviewView. + // TODO(b/252525521): Change this to WindowPreviewView. // WindowPreviewView can show transient children, but currently does not // show popups due to performance reasons. WindowPreviewView also needs to // be modified so that it can optionally be clipped to the main window's // bounds. widget_->SetContentsView(std::make_unique<WindowMirrorView>( - original_window, /*trilinear_filtering_on_init=*/false, - /*show_non_client_view=*/true)); + original_window, /*show_non_client_view=*/true)); aura::Window* window = widget_->GetNativeWindow(); window->SetId(kShellWindowId_PhantomWindow); diff --git a/ash/wm/window_mini_view.cc b/ash/wm/window_mini_view.cc index f054c7c2387a8..a55925c930c14 100644 --- a/ash/wm/window_mini_view.cc +++ b/ash/wm/window_mini_view.cc @@ -108,9 +108,8 @@ void WindowMiniView::SetShowPreview(bool show) { return; } - preview_view_ = AddChildView(std::make_unique<WindowPreviewView>( - source_window_, - /*trilinear_filtering_on_init=*/false)); + preview_view_ = + AddChildView(std::make_unique<WindowPreviewView>(source_window_)); preview_view_->SetPaintToLayer(); preview_view_->layer()->SetFillsBoundsOpaquely(false); Layout(); diff --git a/ash/wm/window_mirror_view.cc b/ash/wm/window_mirror_view.cc index 328e6a9b3fc19..e482c85ff5915 100644 --- a/ash/wm/window_mirror_view.cc +++ b/ash/wm/window_mirror_view.cc @@ -32,11 +32,8 @@ void EnsureAllChildrenAreVisible(ui::Layer* layer) { } // namespace WindowMirrorView::WindowMirrorView(aura::Window* source, - bool trilinear_filtering_on_init, bool show_non_client_view) - : source_(source), - trilinear_filtering_on_init_(trilinear_filtering_on_init), - show_non_client_view_(show_non_client_view) { + : source_(source), show_non_client_view_(show_non_client_view) { source_->AddObserver(this); DCHECK(source); } @@ -147,11 +144,6 @@ void WindowMirrorView::InitLayerOwner() { EnsureAllChildrenAreVisible(mirror_layer); } - if (trilinear_filtering_on_init_) { - mirror_layer->AddCacheRenderSurfaceRequest(); - mirror_layer->AddTrilinearFilteringRequest(); - } - Layout(); } diff --git a/ash/wm/window_mirror_view.h b/ash/wm/window_mirror_view.h index d52fee72a85fc..36f51dd43dd83 100644 --- a/ash/wm/window_mirror_view.h +++ b/ash/wm/window_mirror_view.h @@ -27,9 +27,8 @@ namespace ash { class ASH_EXPORT WindowMirrorView : public views::View, public aura::WindowObserver { public: - WindowMirrorView(aura::Window* source, - bool trilinear_filtering_on_init, - bool show_non_client_view = false); + explicit WindowMirrorView(aura::Window* source, + bool show_non_client_view = false); WindowMirrorView(const WindowMirrorView&) = delete; WindowMirrorView& operator=(const WindowMirrorView&) = delete; @@ -77,10 +76,6 @@ class ASH_EXPORT WindowMirrorView : public views::View, // the first time the view becomes visible. std::unique_ptr<ui::LayerTreeOwner> layer_owner_; - // True if trilinear filtering should be performed on the layer in - // InitLayerOwner(). - const bool trilinear_filtering_on_init_; - // If true, shows the non client view in the mirror. const bool show_non_client_view_; diff --git a/ash/wm/window_mirror_view_pip.cc b/ash/wm/window_mirror_view_pip.cc index c2c7fbf50ba6b..9d90a00c7dff9 100644 --- a/ash/wm/window_mirror_view_pip.cc +++ b/ash/wm/window_mirror_view_pip.cc @@ -6,9 +6,8 @@ namespace ash { -WindowMirrorViewPip::WindowMirrorViewPip(aura::Window* source, - bool trilinear_filtering_on_init) - : WindowMirrorView(source, trilinear_filtering_on_init) {} +WindowMirrorViewPip::WindowMirrorViewPip(aura::Window* source) + : WindowMirrorView(source) {} WindowMirrorViewPip::~WindowMirrorViewPip() = default; diff --git a/ash/wm/window_mirror_view_pip.h b/ash/wm/window_mirror_view_pip.h index 88b18b08ad525..1cea8827bc182 100644 --- a/ash/wm/window_mirror_view_pip.h +++ b/ash/wm/window_mirror_view_pip.h @@ -14,7 +14,7 @@ namespace ash { // PIP windows with the controls not shown. class WindowMirrorViewPip : public WindowMirrorView { public: - WindowMirrorViewPip(aura::Window* source, bool trilinear_filtering_on_init); + explicit WindowMirrorViewPip(aura::Window* source); WindowMirrorViewPip(const WindowMirrorViewPip&) = delete; WindowMirrorViewPip& operator=(const WindowMirrorViewPip&) = delete; diff --git a/ash/wm/window_mirror_view_unittest.cc b/ash/wm/window_mirror_view_unittest.cc index 6de4e73f5c41c..66b561ba753f1 100644 --- a/ash/wm/window_mirror_view_unittest.cc +++ b/ash/wm/window_mirror_view_unittest.cc @@ -27,8 +27,7 @@ TEST_F(WindowMirrorViewTest, LocalWindowOcclusionMadeVisible) { widget_window->GetOcclusionState()); auto mirror_widget = CreateTestWidget(); - auto mirror_view = std::make_unique<WindowMirrorView>( - widget_window, /*trilinear_filtering_on_init=*/false); + auto mirror_view = std::make_unique<WindowMirrorView>(widget_window); mirror_widget->widget_delegate()->GetContentsView()->AddChildView( mirror_view.get()); @@ -51,8 +50,7 @@ TEST_F(WindowMirrorViewTest, MirrorLayerHasNoTransformWhenNonClientViewShown) { auto mirror_widget = CreateTestWidget(); auto mirror_view = std::make_unique<WindowMirrorView>( - widget_window, /*trilinear_filtering_on_init=*/false, - /*show_non_client_view=*/true); + widget_window, /*show_non_client_view=*/true); mirror_view->RecreateMirrorLayers(); EXPECT_TRUE( diff --git a/ash/wm/window_preview_view.cc b/ash/wm/window_preview_view.cc index af076bc5ca5ee..2a6e7c74c02c3 100644 --- a/ash/wm/window_preview_view.cc +++ b/ash/wm/window_preview_view.cc @@ -41,10 +41,7 @@ gfx::Rect GetClientAreaBoundsInScreen(aura::Window* window) { } // namespace -WindowPreviewView::WindowPreviewView(aura::Window* window, - bool trilinear_filtering_on_init) - : window_(window), - trilinear_filtering_on_init_(trilinear_filtering_on_init) { +WindowPreviewView::WindowPreviewView(aura::Window* window) : window_(window) { DCHECK(window); aura::client::GetTransientWindowClient()->AddObserver(this); @@ -158,12 +155,11 @@ void WindowPreviewView::AddWindow(aura::Window* window) { if (!window->HasObserver(this)) window->AddObserver(this); - auto* mirror_view = - window_util::IsArcPipWindow(window) - ? new WindowMirrorViewPip(window, trilinear_filtering_on_init_) - : new WindowMirrorView(window, trilinear_filtering_on_init_); - mirror_views_[window] = mirror_view; - AddChildView(mirror_view); + auto mirror_view = window_util::IsArcPipWindow(window) + ? std::make_unique<WindowMirrorViewPip>(window) + : std::make_unique<WindowMirrorView>(window); + mirror_views_[window] = mirror_view.get(); + AddChildView(std::move(mirror_view)); } void WindowPreviewView::RemoveWindow(aura::Window* window) { @@ -180,11 +176,10 @@ void WindowPreviewView::RemoveWindow(aura::Window* window) { return; auto* view = it->second; - RemoveChildView(view); + RemoveChildViewT(view); it->first->RemoveObserver(this); mirror_views_.erase(it); - delete view; } gfx::RectF WindowPreviewView::GetUnionRect() const { diff --git a/ash/wm/window_preview_view.h b/ash/wm/window_preview_view.h index 1357bd965f8b3..62ab3a39eab11 100644 --- a/ash/wm/window_preview_view.h +++ b/ash/wm/window_preview_view.h @@ -24,7 +24,7 @@ class ASH_EXPORT WindowPreviewView public aura::client::TransientWindowClientObserver, public aura::WindowObserver { public: - WindowPreviewView(aura::Window* window, bool trilinear_filtering_on_init); + explicit WindowPreviewView(aura::Window* window); WindowPreviewView(const WindowPreviewView&) = delete; WindowPreviewView& operator=(const WindowPreviewView&) = delete; @@ -63,7 +63,6 @@ class ASH_EXPORT WindowPreviewView gfx::RectF GetUnionRect() const; raw_ptr<aura::Window, ExperimentalAsh> window_; - bool trilinear_filtering_on_init_; base::flat_map<aura::Window*, WindowMirrorView*> mirror_views_; diff --git a/ash/wm/window_preview_view_unittest.cc b/ash/wm/window_preview_view_unittest.cc index 40bb46c1be872..d7083b2987569 100644 --- a/ash/wm/window_preview_view_unittest.cc +++ b/ash/wm/window_preview_view_unittest.cc @@ -27,7 +27,7 @@ std::unique_ptr<views::Widget> CreateTransientChild( params.bounds = gfx::Rect{40, 50}; params.context = params.parent = parent_widget->GetNativeWindow(); params.init_properties_container.SetProperty( - aura::client::kAppType, static_cast<int>(ash::AppType::ARC_APP)); + aura::client::kAppType, static_cast<int>(AppType::ARC_APP)); widget->Init(std::move(params)); widget->Show(); return widget; @@ -40,10 +40,9 @@ TEST_F(WindowPreviewViewTest, Basic) { auto widget1 = CreateTestWidget(); auto widget2 = CreateTestWidget(); - ::wm::AddTransientChild(widget1->GetNativeWindow(), - widget2->GetNativeWindow()); - auto preview_view = std::make_unique<WindowPreviewView>( - widget1->GetNativeWindow(), /*trilinear_filtering_on_init=*/false); + wm::AddTransientChild(widget1->GetNativeWindow(), widget2->GetNativeWindow()); + auto preview_view = + std::make_unique<WindowPreviewView>(widget1->GetNativeWindow()); WindowPreviewViewTestApi test_api(preview_view.get()); EXPECT_EQ(2u, test_api.GetMirrorViews().size()); EXPECT_TRUE(test_api.GetMirrorViews().contains(widget1->GetNativeWindow())); @@ -56,8 +55,7 @@ TEST_F(WindowPreviewViewTest, AspectRatio) { // Default frame header is 32dp, so we expect a window of size 300, 300 to // have a preview of 1:1 ratio. auto window = CreateAppWindow(gfx::Rect(300, 332)); - auto preview_view = std::make_unique<WindowPreviewView>( - window.get(), /*trilinear_filtering_on_init=*/false); + auto preview_view = std::make_unique<WindowPreviewView>(window.get()); const gfx::SizeF preferred_size(preview_view->GetPreferredSize()); EXPECT_EQ(1.f, preferred_size.width() / preferred_size.height()); @@ -72,8 +70,8 @@ TEST_F(WindowPreviewViewTest, TransientChildAddedAndRemoved) { ::wm::AddTransientChild(widget1->GetNativeWindow(), widget2->GetNativeWindow()); - auto preview_view = std::make_unique<WindowPreviewView>( - widget1->GetNativeWindow(), /*trilinear_filtering_on_init=*/false); + auto preview_view = + std::make_unique<WindowPreviewView>(widget1->GetNativeWindow()); WindowPreviewViewTestApi test_api(preview_view.get()); ASSERT_EQ(2u, test_api.GetMirrorViews().size()); @@ -99,8 +97,8 @@ TEST_F(WindowPreviewViewTest, NoCrashWithTransientChildWithNoWindowState) { EXPECT_EQ(widget1->GetNativeWindow(), wm::GetTransientParent(transient_child1->GetNativeWindow())); - auto preview_view = std::make_unique<WindowPreviewView>( - widget1->GetNativeWindow(), /*trilinear_filtering_on_init=*/false); + auto preview_view = + std::make_unique<WindowPreviewView>(widget1->GetNativeWindow()); WindowPreviewViewTestApi test_api(preview_view.get()); ASSERT_EQ(2u, test_api.GetMirrorViews().size()); @@ -135,8 +133,8 @@ TEST_F(WindowPreviewViewTest, NoCrashWhenWindowCyclingIsCanceledWithATransientPopup) { auto widget1 = CreateTestWidget(); - auto preview_view = std::make_unique<WindowPreviewView>( - widget1->GetNativeWindow(), /*trilinear_filtering_on_init=*/false); + auto preview_view = + std::make_unique<WindowPreviewView>(widget1->GetNativeWindow()); WindowPreviewViewTestApi test_api(preview_view.get()); ASSERT_EQ(1u, test_api.GetMirrorViews().size()); @@ -163,8 +161,8 @@ TEST_F(WindowPreviewViewTest, LayoutChildWithinParentBounds) { widget2->GetNativeWindow()); // The top inset is excluded from GetUnionRect() calculations. - auto preview_view = std::make_unique<WindowPreviewView>( - widget1->GetNativeWindow(), /*trilinear_filtering_on_init=*/false); + auto preview_view = + std::make_unique<WindowPreviewView>(widget1->GetNativeWindow()); WindowPreviewViewTestApi test_api(preview_view.get()); EXPECT_EQ(gfx::RectF(100.f, 100.f), test_api.GetUnionRect()); @@ -196,8 +194,8 @@ TEST_F(WindowPreviewViewTest, LayoutChildOutsideParentBounds) { // Get the union rect of the two windows. The top inset is excluded from // calculations. - auto preview_view = std::make_unique<WindowPreviewView>( - widget1->GetNativeWindow(), /*trilinear_filtering_on_init=*/false); + auto preview_view = + std::make_unique<WindowPreviewView>(widget1->GetNativeWindow()); WindowPreviewViewTestApi test_api(preview_view.get()); EXPECT_EQ(gfx::RectF(400.f, 400.f), test_api.GetUnionRect());