Commit 9a6c4e4b authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

mac: Don't use CATransactionObserver for RWHVMac in views mode

The surface sync APIs are used in views mode (becaused we use a single
ui::Compositor).

Delete some of the now-dead code from RWHVMac (it has deep roots which
still need to go).

Change-Id: I6f065288c27d3ebecf113494751bfc8dfd199fd7
Reviewed-on: https://chromium-review.googlesource.com/1105024Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568218}
parent 0e717111
...@@ -140,8 +140,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient, ...@@ -140,8 +140,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
void DidNavigate(); void DidNavigate();
void BeginPauseForFrame(bool auto_resize_enabled);
void EndPauseForFrame();
bool ShouldContinueToPauseForFrame() const; bool ShouldContinueToPauseForFrame() const;
bool ForceNewSurfaceForTesting(); bool ForceNewSurfaceForTesting();
...@@ -222,18 +220,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient, ...@@ -222,18 +220,6 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
gfx::Size dfh_size_dip_; gfx::Size dfh_size_dip_;
display::Display dfh_display_; display::Display dfh_display_;
// Used to disable screen updates while resizing (because frames are drawn in
// the GPU process, they can end up appearing on-screen before our window
// resizes).
enum class RepaintState {
// No repaint in progress.
None,
// Synchronously waiting for a new frame.
Paused,
// Screen updates are disabled while a new frame is swapped in.
ScreenUpdatesDisabled,
} repaint_state_ = RepaintState::None;
bool repaint_auto_resize_enabled_ = false;
bool is_first_navigation_ = true; bool is_first_navigation_ = true;
base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; base::WeakPtrFactory<BrowserCompositorMac> weak_factory_;
......
...@@ -536,19 +536,6 @@ void BrowserCompositorMac::OnFirstSurfaceActivation( ...@@ -536,19 +536,6 @@ void BrowserCompositorMac::OnFirstSurfaceActivation(
return; return;
recyclable_compositor_->Unsuspend(); recyclable_compositor_->Unsuspend();
// Disable screen updates until the frame of the new size appears (because the
// content is drawn in the GPU process, it may change before we want it to).
if (repaint_state_ == RepaintState::Paused) {
bool compositor_is_nsview_size =
recyclable_compositor_->pixel_size() == dfh_size_pixels_ &&
recyclable_compositor_->scale_factor() ==
dfh_display_.device_scale_factor();
if (compositor_is_nsview_size || repaint_auto_resize_enabled_) {
NSDisableScreenUpdates();
repaint_state_ = RepaintState::ScreenUpdatesDisabled;
}
}
} }
void BrowserCompositorMac::OnBeginFrame(base::TimeTicks frame_time) { void BrowserCompositorMac::OnBeginFrame(base::TimeTicks frame_time) {
...@@ -578,17 +565,6 @@ void BrowserCompositorMac::DidReceiveFirstFrameAfterNavigation() { ...@@ -578,17 +565,6 @@ void BrowserCompositorMac::DidReceiveFirstFrameAfterNavigation() {
client_->DidReceiveFirstFrameAfterNavigation(); client_->DidReceiveFirstFrameAfterNavigation();
} }
void BrowserCompositorMac::BeginPauseForFrame(bool auto_resize_enabled) {
repaint_auto_resize_enabled_ = auto_resize_enabled;
repaint_state_ = RepaintState::Paused;
}
void BrowserCompositorMac::EndPauseForFrame() {
if (repaint_state_ == RepaintState::ScreenUpdatesDisabled)
NSEnableScreenUpdates();
repaint_state_ = RepaintState::None;
}
bool BrowserCompositorMac::ShouldContinueToPauseForFrame() const { bool BrowserCompositorMac::ShouldContinueToPauseForFrame() const {
if (state_ == UseParentLayerCompositor) if (state_ == UseParentLayerCompositor)
return false; return false;
......
...@@ -155,7 +155,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac ...@@ -155,7 +155,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() override; gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() override;
base::Optional<SkColor> GetBackgroundColor() const override; base::Optional<SkColor> GetBackgroundColor() const override;
bool ShouldContinueToPauseForFrame() override;
void SetParentUiLayer(ui::Layer* parent_ui_layer) override; void SetParentUiLayer(ui::Layer* parent_ui_layer) override;
gfx::Vector2d GetOffsetFromRootSurface() override; gfx::Vector2d GetOffsetFromRootSurface() override;
gfx::Rect GetBoundsInRootWindow() override; gfx::Rect GetBoundsInRootWindow() override;
...@@ -299,8 +298,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac ...@@ -299,8 +298,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
// RenderWidgetHostImpl as well. // RenderWidgetHostImpl as well.
void UpdateNSViewAndDisplayProperties(); void UpdateNSViewAndDisplayProperties();
void PauseForPendingResizeOrRepaintsAndDraw();
// RenderWidgetHostNSViewClient implementation. // RenderWidgetHostNSViewClient implementation.
BrowserAccessibilityManager* GetRootBrowserAccessibilityManager() override; BrowserAccessibilityManager* GetRootBrowserAccessibilityManager() override;
void OnNSViewSyncIsRenderViewHost(bool* is_render_view) override; void OnNSViewSyncIsRenderViewHost(bool* is_render_view) override;
...@@ -499,9 +496,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac ...@@ -499,9 +496,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
// Indicates if the page is loading. // Indicates if the page is loading.
bool is_loading_; bool is_loading_;
// Whether it's allowed to pause waiting for a new frame.
bool allow_pause_for_resize_or_repaint_;
// True when this view acts as a platform view hack for a // True when this view acts as a platform view hack for a
// RenderWidgetHostViewGuest. // RenderWidgetHostViewGuest.
bool is_guest_view_hack_; bool is_guest_view_hack_;
......
...@@ -140,7 +140,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, ...@@ -140,7 +140,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget,
page_at_minimum_scale_(true), page_at_minimum_scale_(true),
mouse_wheel_phase_handler_(this), mouse_wheel_phase_handler_(this),
is_loading_(false), is_loading_(false),
allow_pause_for_resize_or_repaint_(true),
is_guest_view_hack_(is_guest_view_hack), is_guest_view_hack_(is_guest_view_hack),
gesture_provider_(ui::GetGestureProviderConfig( gesture_provider_(ui::GetGestureProviderConfig(
ui::GestureProviderConfigType::CURRENT_PLATFORM), ui::GestureProviderConfigType::CURRENT_PLATFORM),
...@@ -198,10 +197,12 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, ...@@ -198,10 +197,12 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget,
// startup raciness and decrease latency. // startup raciness and decrease latency.
needs_begin_frames_ = needs_begin_frames; needs_begin_frames_ = needs_begin_frames;
UpdateNeedsBeginFramesInternal(); UpdateNeedsBeginFramesInternal();
if (features::IsViewsBrowserCocoa())
ui::CATransactionCoordinator::Get().AddPreCommitObserver(this); ui::CATransactionCoordinator::Get().AddPreCommitObserver(this);
} }
RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
if (features::IsViewsBrowserCocoa())
ui::CATransactionCoordinator::Get().RemovePreCommitObserver(this); ui::CATransactionCoordinator::Get().RemovePreCommitObserver(this);
} }
...@@ -230,7 +231,8 @@ void RenderWidgetHostViewMac::SetDelegate( ...@@ -230,7 +231,8 @@ void RenderWidgetHostViewMac::SetDelegate(
} }
void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) {
allow_pause_for_resize_or_repaint_ = allow; // TODO: Remove SetAllowPauseForResizeOrRepaint and SetAllowOtherViews, since
// they aren't used anymore.
} }
ui::TextInputType RenderWidgetHostViewMac::GetTextInputType() { ui::TextInputType RenderWidgetHostViewMac::GetTextInputType() {
...@@ -332,6 +334,8 @@ void RenderWidgetHostViewMac::UpdateNSViewAndDisplayProperties() { ...@@ -332,6 +334,8 @@ void RenderWidgetHostViewMac::UpdateNSViewAndDisplayProperties() {
LOG(ERROR) << "Failed to create display link."; LOG(ERROR) << "Failed to create display link.";
} }
} }
if (features::IsViewsBrowserCocoa())
ui::CATransactionCoordinator::Get().Synchronize(); ui::CATransactionCoordinator::Get().Synchronize();
// During auto-resize it is the responsibility of the caller to ensure that // During auto-resize it is the responsibility of the caller to ensure that
...@@ -368,7 +372,6 @@ void RenderWidgetHostViewMac::Show() { ...@@ -368,7 +372,6 @@ void RenderWidgetHostViewMac::Show() {
// If there is not a frame being currently drawn, kick one, so that the below // If there is not a frame being currently drawn, kick one, so that the below
// pause will have a frame to wait on. // pause will have a frame to wait on.
host()->RequestRepaintForTesting(); host()->RequestRepaintForTesting();
PauseForPendingResizeOrRepaintsAndDraw();
} }
void RenderWidgetHostViewMac::Hide() { void RenderWidgetHostViewMac::Hide() {
...@@ -553,7 +556,7 @@ void RenderWidgetHostViewMac::OnTextSelectionChanged( ...@@ -553,7 +556,7 @@ void RenderWidgetHostViewMac::OnTextSelectionChanged(
} }
bool RenderWidgetHostViewMac::ShouldWaitInPreCommit() { bool RenderWidgetHostViewMac::ShouldWaitInPreCommit() {
return ShouldContinueToPauseForFrame(); return browser_compositor_->ShouldContinueToPauseForFrame();
} }
base::TimeDelta RenderWidgetHostViewMac::PreCommitTimeout() { base::TimeDelta RenderWidgetHostViewMac::PreCommitTimeout() {
...@@ -950,14 +953,6 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange( ...@@ -950,14 +953,6 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(
return true; return true;
} }
bool RenderWidgetHostViewMac::ShouldContinueToPauseForFrame() {
// Only pause for frames when drawing through a separate ui::Compositor.
if (display_only_using_parent_ui_layer_)
return false;
return browser_compositor_->ShouldContinueToPauseForFrame();
}
void RenderWidgetHostViewMac::FocusedNodeChanged( void RenderWidgetHostViewMac::FocusedNodeChanged(
bool is_editable_node, bool is_editable_node,
const gfx::Rect& node_bounds_in_screen) { const gfx::Rect& node_bounds_in_screen) {
...@@ -1299,24 +1294,6 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { ...@@ -1299,24 +1294,6 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
password_input_enabler_.reset(); password_input_enabler_.reset();
} }
void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() {
return; // TODO(https://crbug.com/682825): Delete this during cleanup.
if (!host() || !browser_compositor_ || host()->is_hidden()) {
return;
}
// Pausing for one view prevents others from receiving frames.
// This may lead to large delays, causing overlaps. See crbug.com/352020.
if (!allow_pause_for_resize_or_repaint_)
return;
// Wait for a frame of the right size to come in.
browser_compositor_->BeginPauseForFrame(host()->auto_resize_enabled());
host()->PauseForPendingResizeOrRepaints();
browser_compositor_->EndPauseForFrame();
}
// static // static
viz::FrameSinkId viz::FrameSinkId
RenderWidgetHostViewMac::AllocateFrameSinkIdForGuestViewHack() { RenderWidgetHostViewMac::AllocateFrameSinkIdForGuestViewHack() {
...@@ -1385,14 +1362,8 @@ void RenderWidgetHostViewMac::OnNSViewBoundsInWindowChanged( ...@@ -1385,14 +1362,8 @@ void RenderWidgetHostViewMac::OnNSViewBoundsInWindowChanged(
view_bounds_in_window_dip_.set_size(view_bounds_in_window_dip.size()); view_bounds_in_window_dip_.set_size(view_bounds_in_window_dip.size());
} }
if (view_size_changed) { if (view_size_changed)
UpdateNSViewAndDisplayProperties(); UpdateNSViewAndDisplayProperties();
// Wait for the frame that WasResize might have requested. If the view is
// being made visible at a new size, then this call will have no effect
// because the view widget is still hidden, and the pause call in WasShown
// will have this effect for us.
PauseForPendingResizeOrRepaintsAndDraw();
}
} }
void RenderWidgetHostViewMac::OnNSViewWindowFrameInScreenChanged( void RenderWidgetHostViewMac::OnNSViewWindowFrameInScreenChanged(
......
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