Commit 86168611 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Make DefaultEstimatedParentDrawTime take into account vsync interval

Rather than hard-coding the estimated draw time, calculate it from the
BeginFrame interval.

Change-Id: I5fc7494d5c08cf8ef84a55f1c672c173caf75bd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529621
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642308}
parent 453a193d
......@@ -86,14 +86,18 @@ struct VIZ_COMMON_EXPORT BeginFrameArgs {
return base::TimeDelta::FromMicroseconds(16666);
}
// This is a hard-coded deadline adjustment that assumes 60Hz, to be used in
// cases where a good estimated draw time is not known. Using 1/3 of the vsync
// as the default adjustment gives the Browser the last 1/3 of a frame to
// produce output, the Renderer Impl thread the middle 1/3 of a frame to
// produce ouput, and the Renderer Main thread the first 1/3 of a frame to
// produce output.
static constexpr base::TimeDelta DefaultEstimatedParentDrawTime() {
return base::TimeDelta::FromMicroseconds(16666 / 3);
// This is a hard-coded deadline adjustment used by the display compositor.
// Using 1/3 of the vsync as the default adjustment gives the display
// compositor the last 1/3 of a frame to produce output, the client impl
// thread the middle 1/3 of a frame to produce output, and the client's main
// thread the first 1/3 of a frame to produce output.
static constexpr float kDefaultEstimatedDisplayDrawTimeRatio = 1.f / 3;
// Returns how much time the display should reserve for draw and swap if the
// BeginFrame interval is |interval|.
static base::TimeDelta DefaultEstimatedDisplayDrawTime(
base::TimeDelta interval) {
return interval * kDefaultEstimatedDisplayDrawTimeRatio;
}
bool IsValid() const { return interval >= base::TimeDelta(); }
......
......@@ -259,7 +259,7 @@ bool DisplayScheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) {
// Schedule the deadline.
current_begin_frame_args_ = save_args;
current_begin_frame_args_.deadline -=
BeginFrameArgs::DefaultEstimatedParentDrawTime();
BeginFrameArgs::DefaultEstimatedDisplayDrawTime(save_args.interval);
inside_begin_frame_deadline_interval_ = true;
UpdateHasPendingSurfaces();
ScheduleBeginFrameDeadline();
......
......@@ -687,7 +687,8 @@ TEST_F(DisplaySchedulerTest, DidSwapBuffers) {
AdvanceTimeAndBeginFrameForTest({sid2});
base::TimeTicks expected_deadline =
scheduler_.LastUsedBeginFrameArgs().deadline -
BeginFrameArgs::DefaultEstimatedParentDrawTime();
BeginFrameArgs::DefaultEstimatedDisplayDrawTime(
scheduler_.LastUsedBeginFrameArgs().interval);
EXPECT_EQ(expected_deadline,
scheduler_.DesiredBeginFrameDeadlineTimeForTest());
// Still waiting for surface 2. Once it updates, deadline should trigger
......
......@@ -28,7 +28,8 @@ BeginFrameArgs CreateBeginFrameArgsForTesting(
return BeginFrameArgs::Create(
location, source_id, sequence_number, frame_time,
frame_time + BeginFrameArgs::DefaultInterval() -
BeginFrameArgs::DefaultEstimatedParentDrawTime(),
BeginFrameArgs::DefaultEstimatedDisplayDrawTime(
BeginFrameArgs::DefaultInterval()),
BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
}
......@@ -70,7 +71,8 @@ BeginFrameArgs CreateBeginFrameArgsForTesting(
return BeginFrameArgs::Create(
location, source_id, sequence_number, now,
now + BeginFrameArgs::DefaultInterval() -
BeginFrameArgs::DefaultEstimatedParentDrawTime(),
BeginFrameArgs::DefaultEstimatedDisplayDrawTime(
BeginFrameArgs::DefaultInterval()),
BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
}
......
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