Compositor presentation happened immediately whenever a frame or async scroll requested it, so compositor-local updates could run faster than thedisplay cadence and compete with bitmap ack back-pressure. Introduce VSyncScheduler as the compositor scheduling interface and add a TimerVSyncScheduler implementation that uses a single-shot timer at the context refresh rate on every platform. CompositorState now keeps a scheduler per display metadata bucket, marks contexts with pending frames, and drains matching pending contexts from that scheduler while preserving existing screenshot behavior and async-present ack flow.
30 lines
563 B
C++
30 lines
563 B
C++
/*
|
|
* Copyright (c) 2026, the Ladybird developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Function.h>
|
|
#include <AK/Optional.h>
|
|
#include <AK/OwnPtr.h>
|
|
|
|
namespace Compositor {
|
|
|
|
class VSyncScheduler {
|
|
AK_MAKE_NONCOPYABLE(VSyncScheduler);
|
|
AK_MAKE_NONMOVABLE(VSyncScheduler);
|
|
|
|
public:
|
|
virtual ~VSyncScheduler() = default;
|
|
|
|
virtual void schedule(double refresh_rate) = 0;
|
|
|
|
protected:
|
|
VSyncScheduler() = default;
|
|
};
|
|
|
|
OwnPtr<VSyncScheduler> create_vsync_scheduler(Optional<u64> display_id, Function<void()>&&);
|
|
|
|
}
|