Commit 00e1b903 authored by kylechar's avatar kylechar Committed by Commit Bot

Reland "Don't disable draw during resize"

This is a reland of 985a1f41. Also fix
an issue where SoftwareOutputDeviceWinProxy was crashing if we draw the
root RenderPass but never call SwapBuffers() as the |swap_ack_callback_|
wasn't set.

Original change's description:
> Don't disable draw during resize
>
> https://crrev.com/c/2011130 changed Display::DisableSwapUntilResize() to
> also block draw instead of just swap. This had the side of effect of
> blocking draw when the browser window is minimized, which means we stop
> casting tab/window contents. Switch DisableSwapUntilResize() back to
> just block swap instead of draw+swap.
>
> Bug: 1054239, b/149923568
> Change-Id: I66a10dc1e801c56783107ce4412ab557f70da9f8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2068642
> Commit-Queue: kylechar <kylechar@chromium.org>
> Reviewed-by: Saman Sami <samans@chromium.org>
> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#744018}

Bug: 1054239, b/149923568
Change-Id: I4f96bcb9547f4c4b24c020ffff728e4fa08d0ce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078840Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745161}
parent 86f9dd91
......@@ -354,7 +354,7 @@ void Display::SetVisible(bool visible) {
}
void Display::Resize(const gfx::Size& size) {
disable_draw_until_resize_ = false;
disable_swap_until_resize_ = false;
if (size == current_surface_size_)
return;
......@@ -376,7 +376,7 @@ void Display::DisableSwapUntilResize(
TRACE_EVENT0("viz", "Display::DisableSwapUntilResize");
DCHECK(no_pending_swaps_callback_.is_null());
if (!disable_draw_until_resize_) {
if (!disable_swap_until_resize_) {
DCHECK(scheduler_);
if (!swapped_since_resize_)
......@@ -388,7 +388,7 @@ void Display::DisableSwapUntilResize(
no_pending_swaps_callback_ = std::move(no_pending_swaps_callback);
}
disable_draw_until_resize_ = true;
disable_swap_until_resize_ = true;
}
// There are no pending swaps for current size so immediately run callback.
......@@ -618,8 +618,7 @@ bool Display::DrawAndSwap(base::TimeTicks expected_display_time) {
if (!size_matches)
TRACE_EVENT_INSTANT0("viz", "Size mismatch.", TRACE_EVENT_SCOPE_THREAD);
bool should_draw = !disable_draw_until_resize_ &&
(have_copy_requests || (have_damage && size_matches));
bool should_draw = have_copy_requests || (have_damage && size_matches);
client_->DisplayWillDrawAndSwap(should_draw, &frame.render_pass_list);
base::Optional<base::ElapsedTimer> draw_timer;
......@@ -666,7 +665,7 @@ bool Display::DrawAndSwap(base::TimeTicks expected_display_time) {
TRACE_EVENT_INSTANT0("viz", "Draw skipped.", TRACE_EVENT_SCOPE_THREAD);
}
bool should_swap = should_draw && size_matches;
bool should_swap = !disable_swap_until_resize_ && should_draw && size_matches;
if (should_swap) {
PresentationGroupTiming presentation_group_timing;
presentation_group_timing.OnDraw(draw_timer->Begin());
......
......@@ -253,7 +253,7 @@ class VIZ_SERVICE_EXPORT Display : public DisplaySchedulerClient,
base::circular_deque<Display::PresentationGroupTiming>
pending_presentation_group_timings_;
bool disable_draw_until_resize_ = true;
bool disable_swap_until_resize_ = true;
// Callback that will be run after all pending swaps have acked.
base::OnceClosure no_pending_swaps_callback_;
......
......@@ -277,12 +277,15 @@ void SoftwareOutputDeviceWinProxy::EndPaintDelegated(
void SoftwareOutputDeviceWinProxy::DrawAck() {
DCHECK(waiting_on_draw_ack_);
DCHECK(!swap_ack_callback_.is_null());
TRACE_EVENT_ASYNC_END0("viz", "SoftwareOutputDeviceWinProxy::Draw", this);
waiting_on_draw_ack_ = false;
std::move(swap_ack_callback_).Run();
// It's possible the display compositor won't call SwapBuffers() so there will
// be no callback to run.
if (swap_ack_callback_)
std::move(swap_ack_callback_).Run();
}
} // namespace
......
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