Commit 8b962877 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Remove env parameter from WindowOcclusionTracker::ScopedPause

Bug: 958467
Test: trybot
Change-Id: I163739c1acb5377a6ed19643287a6cd01b3d0ff3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1614704Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660862}
parent 161901cd
...@@ -513,8 +513,7 @@ void OverviewController::PauseOcclusionTracker() { ...@@ -513,8 +513,7 @@ void OverviewController::PauseOcclusionTracker() {
reset_pauser_task_.Cancel(); reset_pauser_task_.Cancel();
occlusion_tracker_pauser_ = occlusion_tracker_pauser_ =
std::make_unique<aura::WindowOcclusionTracker::ScopedPause>( std::make_unique<aura::WindowOcclusionTracker::ScopedPause>();
Shell::Get()->aura_env());
} }
void OverviewController::UnpauseOcclusionTracker(int delay) { void OverviewController::UnpauseOcclusionTracker(int delay) {
......
...@@ -870,8 +870,7 @@ bool TabletModeController::LidAngleIsInTabletModeRange() { ...@@ -870,8 +870,7 @@ bool TabletModeController::LidAngleIsInTabletModeRange() {
void TabletModeController::SuspendOcclusionTracker() { void TabletModeController::SuspendOcclusionTracker() {
occlusion_tracker_reset_timer_.Stop(); occlusion_tracker_reset_timer_.Stop();
occlusion_tracker_pauser_ = occlusion_tracker_pauser_ =
std::make_unique<aura::WindowOcclusionTracker::ScopedPause>( std::make_unique<aura::WindowOcclusionTracker::ScopedPause>();
Shell::Get()->aura_env());
occlusion_tracker_reset_timer_.Start(FROM_HERE, kOcclusionTrackerTimeout, occlusion_tracker_reset_timer_.Start(FROM_HERE, kOcclusionTrackerTimeout,
this, this,
&TabletModeController::ResetPauser); &TabletModeController::ResetPauser);
......
...@@ -110,8 +110,7 @@ void SurfaceTreeHost::SetRootSurface(Surface* root_surface) { ...@@ -110,8 +110,7 @@ void SurfaceTreeHost::SetRootSurface(Surface* root_surface) {
// This method applies multiple changes to the window tree. Use ScopedPause to // This method applies multiple changes to the window tree. Use ScopedPause to
// ensure that occlusion isn't recomputed before all changes have been // ensure that occlusion isn't recomputed before all changes have been
// applied. // applied.
aura::WindowOcclusionTracker::ScopedPause pause_occlusion( aura::WindowOcclusionTracker::ScopedPause pause_occlusion;
aura::Env::GetInstance());
if (root_surface_) { if (root_surface_) {
root_surface_->window()->Hide(); root_surface_->window()->Hide();
...@@ -276,8 +275,7 @@ void SurfaceTreeHost::UpdateHostWindowBounds() { ...@@ -276,8 +275,7 @@ void SurfaceTreeHost::UpdateHostWindowBounds() {
// This method applies multiple changes to the window tree. Use ScopedPause // This method applies multiple changes to the window tree. Use ScopedPause
// to ensure that occlusion isn't recomputed before all changes have been // to ensure that occlusion isn't recomputed before all changes have been
// applied. // applied.
aura::WindowOcclusionTracker::ScopedPause pause_occlusion( aura::WindowOcclusionTracker::ScopedPause pause_occlusion;
aura::Env::GetInstance());
gfx::Rect bounds = root_surface_->surface_hierarchy_content_bounds(); gfx::Rect bounds = root_surface_->surface_hierarchy_content_bounds();
host_window_->SetBounds( host_window_->SetBounds(
......
...@@ -2390,8 +2390,7 @@ void WindowTree::TrackOcclusionState(Id transport_window_id) { ...@@ -2390,8 +2390,7 @@ void WindowTree::TrackOcclusionState(Id transport_window_id) {
void WindowTree::PauseWindowOcclusionTracking() { void WindowTree::PauseWindowOcclusionTracking() {
window_occlusion_tracking_pauses_.emplace_back( window_occlusion_tracking_pauses_.emplace_back(
std::make_unique<aura::WindowOcclusionTracker::ScopedPause>( std::make_unique<aura::WindowOcclusionTracker::ScopedPause>());
window_service_->env()));
} }
void WindowTree::UnpauseWindowOcclusionTracking() { void WindowTree::UnpauseWindowOcclusionTracking() {
......
...@@ -83,7 +83,7 @@ Window::Window(WindowDelegate* delegate, ...@@ -83,7 +83,7 @@ Window::Window(WindowDelegate* delegate,
} }
Window::~Window() { Window::~Window() {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
if (layer()->owner() == this) if (layer()->owner() == this)
layer()->CompleteAllAnimations(); layer()->CompleteAllAnimations();
...@@ -151,7 +151,7 @@ Window::~Window() { ...@@ -151,7 +151,7 @@ Window::~Window() {
} }
void Window::Init(ui::LayerType layer_type) { void Window::Init(ui::LayerType layer_type) {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
if (!port_owner_) { if (!port_owner_) {
port_owner_ = env_->CreateWindowPort(this); port_owner_ = env_->CreateWindowPort(this);
...@@ -280,7 +280,7 @@ gfx::Rect Window::GetBoundsInScreen() const { ...@@ -280,7 +280,7 @@ gfx::Rect Window::GetBoundsInScreen() const {
} }
void Window::SetTransform(const gfx::Transform& transform) { void Window::SetTransform(const gfx::Transform& transform) {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
for (WindowObserver& observer : observers_) for (WindowObserver& observer : observers_)
observer.OnWindowTargetTransformChanging(this, transform); observer.OnWindowTargetTransformChanging(this, transform);
layer()->SetTransform(transform); layer()->SetTransform(transform);
...@@ -372,7 +372,7 @@ void Window::StackChildBelow(Window* child, Window* target) { ...@@ -372,7 +372,7 @@ void Window::StackChildBelow(Window* child, Window* target) {
} }
void Window::AddChild(Window* child) { void Window::AddChild(Window* child) {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
DCHECK(layer()) << "Parent has not been Init()ed yet."; DCHECK(layer()) << "Parent has not been Init()ed yet.";
DCHECK(child->layer()) << "Child has not been Init()ed yt."; DCHECK(child->layer()) << "Child has not been Init()ed yt.";
...@@ -414,7 +414,7 @@ void Window::AddChild(Window* child) { ...@@ -414,7 +414,7 @@ void Window::AddChild(Window* child) {
} }
void Window::RemoveChild(Window* child) { void Window::RemoveChild(Window* child) {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
WindowObserver::HierarchyChangeParams params; WindowObserver::HierarchyChangeParams params;
params.target = child; params.target = child;
...@@ -843,7 +843,7 @@ void Window::SetVisible(bool visible) { ...@@ -843,7 +843,7 @@ void Window::SetVisible(bool visible) {
if (visible == layer()->GetTargetVisibility()) if (visible == layer()->GetTargetVisibility())
return; // No change. return; // No change.
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
for (WindowObserver& observer : observers_) for (WindowObserver& observer : observers_)
observer.OnWindowVisibilityChanging(this, visible); observer.OnWindowVisibilityChanging(this, visible);
...@@ -924,7 +924,7 @@ void Window::StackChildRelativeTo(Window* child, ...@@ -924,7 +924,7 @@ void Window::StackChildRelativeTo(Window* child,
DCHECK_EQ(this, child->parent()); DCHECK_EQ(this, child->parent());
DCHECK_EQ(this, target->parent()); DCHECK_EQ(this, target->parent());
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
client::WindowStackingClient* stacking_client = client::WindowStackingClient* stacking_client =
client::GetWindowStackingClient(); client::GetWindowStackingClient();
...@@ -1228,7 +1228,7 @@ void Window::OnPaintLayer(const ui::PaintContext& context) { ...@@ -1228,7 +1228,7 @@ void Window::OnPaintLayer(const ui::PaintContext& context) {
void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds, void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds,
ui::PropertyChangeReason reason) { ui::PropertyChangeReason reason) {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
bounds_ = layer()->bounds(); bounds_ = layer()->bounds();
...@@ -1245,13 +1245,13 @@ void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds, ...@@ -1245,13 +1245,13 @@ void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds,
} }
void Window::OnLayerOpacityChanged(ui::PropertyChangeReason reason) { void Window::OnLayerOpacityChanged(ui::PropertyChangeReason reason) {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
for (WindowObserver& observer : observers_) for (WindowObserver& observer : observers_)
observer.OnWindowOpacitySet(this, reason); observer.OnWindowOpacitySet(this, reason);
} }
void Window::OnLayerAlphaShapeChanged() { void Window::OnLayerAlphaShapeChanged() {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
for (WindowObserver& observer : observers_) for (WindowObserver& observer : observers_)
observer.OnWindowAlphaShapeSet(this); observer.OnWindowAlphaShapeSet(this);
} }
...@@ -1259,7 +1259,7 @@ void Window::OnLayerAlphaShapeChanged() { ...@@ -1259,7 +1259,7 @@ void Window::OnLayerAlphaShapeChanged() {
void Window::OnLayerFillsBoundsOpaquelyChanged() { void Window::OnLayerFillsBoundsOpaquelyChanged() {
// Let observers know that this window's transparent status has changed. // Let observers know that this window's transparent status has changed.
// Transparent status can affect the occlusion computed for windows. // Transparent status can affect the occlusion computed for windows.
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
// Non-transparent windows should not have opaque regions for occlusion set. // Non-transparent windows should not have opaque regions for occlusion set.
if (!transparent()) if (!transparent())
...@@ -1272,7 +1272,7 @@ void Window::OnLayerFillsBoundsOpaquelyChanged() { ...@@ -1272,7 +1272,7 @@ void Window::OnLayerFillsBoundsOpaquelyChanged() {
void Window::OnLayerTransformed(const gfx::Transform& old_transform, void Window::OnLayerTransformed(const gfx::Transform& old_transform,
ui::PropertyChangeReason reason) { ui::PropertyChangeReason reason) {
port_->OnDidChangeTransform(old_transform, layer()->transform()); port_->OnDidChangeTransform(old_transform, layer()->transform());
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
for (WindowObserver& observer : observers_) for (WindowObserver& observer : observers_)
observer.OnWindowTransformed(this, reason); observer.OnWindowTransformed(this, reason);
} }
...@@ -1337,7 +1337,7 @@ gfx::PointF Window::GetScreenLocationF(const ui::LocatedEvent& event) const { ...@@ -1337,7 +1337,7 @@ gfx::PointF Window::GetScreenLocationF(const ui::LocatedEvent& event) const {
} }
std::unique_ptr<ui::Layer> Window::RecreateLayer() { std::unique_ptr<ui::Layer> Window::RecreateLayer() {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking(env_); WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
ui::LayerAnimator* const animator = layer()->GetAnimator(); ui::LayerAnimator* const animator = layer()->GetAnimator();
const bool was_animating_opacity = const bool was_animating_opacity =
......
...@@ -155,12 +155,12 @@ float GetLayerCombinedTargetOpacity(const ui::Layer* layer) { ...@@ -155,12 +155,12 @@ float GetLayerCombinedTargetOpacity(const ui::Layer* layer) {
} // namespace } // namespace
WindowOcclusionTracker::ScopedPause::ScopedPause(Env* env) : env_(env) { WindowOcclusionTracker::ScopedPause::ScopedPause() {
env_->PauseWindowOcclusionTracking(); Env::GetInstance()->PauseWindowOcclusionTracking();
} }
WindowOcclusionTracker::ScopedPause::~ScopedPause() { WindowOcclusionTracker::ScopedPause::~ScopedPause() {
env_->UnpauseWindowOcclusionTracking(); Env::GetInstance()->UnpauseWindowOcclusionTracking();
} }
WindowOcclusionTracker::ScopedExclude::ScopedExclude(Window* window) WindowOcclusionTracker::ScopedExclude::ScopedExclude(Window* window)
......
...@@ -32,7 +32,6 @@ namespace test { ...@@ -32,7 +32,6 @@ namespace test {
class WindowOcclusionTrackerTestApi; class WindowOcclusionTrackerTestApi;
} }
class Env;
class WindowOcclusionChangeBuilder; class WindowOcclusionChangeBuilder;
// Notifies tracked Windows when their occlusion state change. // Notifies tracked Windows when their occlusion state change.
...@@ -55,14 +54,12 @@ class AURA_EXPORT WindowOcclusionTracker : public ui::LayerAnimationObserver, ...@@ -55,14 +54,12 @@ class AURA_EXPORT WindowOcclusionTracker : public ui::LayerAnimationObserver,
// that could cause window occlusion states to change occurs within the scope // that could cause window occlusion states to change occurs within the scope
// of a ScopedPause, window occlusion state computations are delayed until all // of a ScopedPause, window occlusion state computations are delayed until all
// ScopedPause objects have been destroyed. // ScopedPause objects have been destroyed.
// TODO(crbug.com/867150): Pause the tracker in Window Service under mus.
class AURA_EXPORT ScopedPause { class AURA_EXPORT ScopedPause {
public: public:
explicit ScopedPause(Env* env); ScopedPause();
~ScopedPause(); ~ScopedPause();
private: private:
Env* const env_;
DISALLOW_COPY_AND_ASSIGN(ScopedPause); DISALLOW_COPY_AND_ASSIGN(ScopedPause);
}; };
......
...@@ -1109,8 +1109,7 @@ TEST_F(WindowOcclusionTrackerTest, ScopedPause) { ...@@ -1109,8 +1109,7 @@ TEST_F(WindowOcclusionTrackerTest, ScopedPause) {
// Change bounds multiple times. At the end of the scope, expect window a to // Change bounds multiple times. At the end of the scope, expect window a to
// be occluded. // be occluded.
{ {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking( WindowOcclusionTracker::ScopedPause pause_occlusion_tracking;
root_window()->env());
window_b->SetBounds(window_a->bounds()); window_b->SetBounds(window_a->bounds());
window_a->SetBounds(gfx::Rect(0, 10, 5, 5)); window_a->SetBounds(gfx::Rect(0, 10, 5, 5));
window_b->SetBounds(window_a->bounds()); window_b->SetBounds(window_a->bounds());
...@@ -1140,22 +1139,18 @@ TEST_F(WindowOcclusionTrackerTest, NestedScopedPause) { ...@@ -1140,22 +1139,18 @@ TEST_F(WindowOcclusionTrackerTest, NestedScopedPause) {
// Change bounds multiple times. At the end of the scope, expect window a to // Change bounds multiple times. At the end of the scope, expect window a to
// be occluded. // be occluded.
{ {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_a( WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_a;
root_window()->env());
{ {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_b( WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_b;
root_window()->env());
window_b->SetBounds(window_a->bounds()); window_b->SetBounds(window_a->bounds());
} }
{ {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_c( WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_c;
root_window()->env());
window_a->SetBounds(gfx::Rect(0, 10, 5, 5)); window_a->SetBounds(gfx::Rect(0, 10, 5, 5));
} }
{ {
WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_d( WindowOcclusionTracker::ScopedPause pause_occlusion_tracking_d;
root_window()->env());
window_b->SetBounds(window_a->bounds()); window_b->SetBounds(window_a->bounds());
} }
...@@ -2224,8 +2219,7 @@ TEST_F(WindowOcclusionTrackerTest, ScopedForceVisibleWithOccludedSibling) { ...@@ -2224,8 +2219,7 @@ TEST_F(WindowOcclusionTrackerTest, ScopedForceVisibleWithOccludedSibling) {
// the same bounds. // the same bounds.
std::unique_ptr<WindowOcclusionTracker::ScopedPause> std::unique_ptr<WindowOcclusionTracker::ScopedPause>
pause_occlusion_tracking = pause_occlusion_tracking =
std::make_unique<WindowOcclusionTracker::ScopedPause>( std::make_unique<WindowOcclusionTracker::ScopedPause>();
root_window()->env());
MockWindowDelegate* parent_delegate = new MockWindowDelegate(); MockWindowDelegate* parent_delegate = new MockWindowDelegate();
Window* parent_window = Window* parent_window =
CreateTrackedWindow(parent_delegate, gfx::Rect(0, 0, 10, 10)); CreateTrackedWindow(parent_delegate, gfx::Rect(0, 0, 10, 10));
......
...@@ -118,7 +118,7 @@ void NativeViewHostAura::NativeViewDetaching(bool destroyed) { ...@@ -118,7 +118,7 @@ void NativeViewHostAura::NativeViewDetaching(bool destroyed) {
// change. // change.
base::Optional<aura::WindowOcclusionTracker::ScopedPause> pause_occlusion; base::Optional<aura::WindowOcclusionTracker::ScopedPause> pause_occlusion;
if (clipping_window_) if (clipping_window_)
pause_occlusion.emplace(aura::Env::GetInstance()); pause_occlusion.emplace();
clipping_window_delegate_->set_native_view(nullptr); clipping_window_delegate_->set_native_view(nullptr);
RemoveClippingWindow(); RemoveClippingWindow();
......
...@@ -617,8 +617,7 @@ void DesktopNativeWidgetAura::ReorderNativeViews() { ...@@ -617,8 +617,7 @@ void DesktopNativeWidgetAura::ReorderNativeViews() {
// Instantiate a ScopedPause to recompute occlusion once at the end of this // Instantiate a ScopedPause to recompute occlusion once at the end of this
// scope rather than after each individual change. // scope rather than after each individual change.
// https://crbug.com/829918 // https://crbug.com/829918
aura::WindowOcclusionTracker::ScopedPause pause_occlusion( aura::WindowOcclusionTracker::ScopedPause pause_occlusion;
aura::Env::GetInstance());
window_reorderer_->ReorderChildWindows(); window_reorderer_->ReorderChildWindows();
} }
......
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