backends: move output refresh duration to compositor
This commit is contained in:
parent
3ebbe28b64
commit
df9b0bd8f0
11 changed files with 19 additions and 16 deletions
|
@ -384,7 +384,7 @@ void DrmTest::testModeset()
|
|||
layer->beginFrame();
|
||||
output->renderLoop()->prepareNewFrame();
|
||||
output->renderLoop()->beginPaint();
|
||||
const auto frame = std::make_shared<OutputFrame>(output->renderLoop());
|
||||
const auto frame = std::make_shared<OutputFrame>(output->renderLoop(), std::chrono::nanoseconds(1'000'000'000'000 / output->refreshRate()));
|
||||
layer->endFrame(infiniteRegion(), infiniteRegion(), frame.get());
|
||||
QVERIFY(output->present(frame));
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void DrmAbstractOutput::frameFailed() const
|
|||
|
||||
void DrmAbstractOutput::pageFlipped(std::chrono::nanoseconds timestamp, PresentationMode mode)
|
||||
{
|
||||
m_frame->presented(std::chrono::nanoseconds(1'000'000'000'000 / refreshRate()), timestamp, mode);
|
||||
m_frame->presented(timestamp, mode);
|
||||
m_frame.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,10 @@ void VirtualOutput::updateEnabled(bool enabled)
|
|||
|
||||
void VirtualOutput::vblank(std::chrono::nanoseconds timestamp)
|
||||
{
|
||||
m_frame->presented(std::chrono::nanoseconds(1'000'000'000'000 / refreshRate()), timestamp, PresentationMode::VSync);
|
||||
m_frame.reset();
|
||||
if (m_frame) {
|
||||
m_frame->presented(timestamp, PresentationMode::VSync);
|
||||
m_frame.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,8 +125,7 @@ WaylandOutput::WaylandOutput(const QString &name, WaylandBackend *backend)
|
|||
|
||||
connect(m_surface.get(), &KWayland::Client::Surface::frameRendered, this, [this]() {
|
||||
Q_ASSERT(m_frame);
|
||||
const auto primary = Compositor::self()->backend()->primaryLayer(this);
|
||||
m_frame->presented(std::chrono::nanoseconds(1'000'000'000'000 / refreshRate()), std::chrono::steady_clock::now().time_since_epoch(), PresentationMode::VSync);
|
||||
m_frame->presented(std::chrono::steady_clock::now().time_since_epoch(), PresentationMode::VSync);
|
||||
m_frame.reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -441,7 +441,7 @@ OutputLayer *EglBackend::primaryLayer(Output *output)
|
|||
|
||||
void EglBackend::vblank(std::chrono::nanoseconds timestamp)
|
||||
{
|
||||
m_frame->presented(std::chrono::nanoseconds::zero(), timestamp, PresentationMode::VSync);
|
||||
m_frame->presented(timestamp, PresentationMode::VSync);
|
||||
m_frame.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -714,7 +714,7 @@ void GlxBackend::present(Output *output, const std::shared_ptr<OutputFrame> &fra
|
|||
|
||||
void GlxBackend::vblank(std::chrono::nanoseconds timestamp)
|
||||
{
|
||||
m_frame->presented(std::chrono::nanoseconds::zero(), timestamp, PresentationMode::VSync);
|
||||
m_frame->presented(timestamp, PresentationMode::VSync);
|
||||
m_frame.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ void X11WindowedOutput::resize(const QSize &pixelSize)
|
|||
void X11WindowedOutput::handlePresentCompleteNotify(xcb_present_complete_notify_event_t *event)
|
||||
{
|
||||
std::chrono::microseconds timestamp(event->ust);
|
||||
m_frame->presented(std::chrono::nanoseconds(1'000'000'000'000 / refreshRate()), timestamp, PresentationMode::VSync);
|
||||
m_frame->presented(timestamp, PresentationMode::VSync);
|
||||
m_frame.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ void WaylandCompositor::composite(RenderLoop *renderLoop)
|
|||
superLayer->setOutputLayer(primaryLayer);
|
||||
|
||||
renderLoop->prepareNewFrame();
|
||||
auto frame = std::make_shared<OutputFrame>(renderLoop);
|
||||
auto frame = std::make_shared<OutputFrame>(renderLoop, std::chrono::nanoseconds(1'000'000'000'000 / output->refreshRate()));
|
||||
|
||||
if (primaryLayer->needsRepaint() || superLayer->needsRepaint()) {
|
||||
renderLoop->beginPaint();
|
||||
|
|
|
@ -457,7 +457,7 @@ void X11Compositor::composite(RenderLoop *renderLoop)
|
|||
superLayer->setOutputLayer(primaryLayer);
|
||||
|
||||
renderLoop->prepareNewFrame();
|
||||
auto frame = std::make_shared<OutputFrame>(renderLoop);
|
||||
auto frame = std::make_shared<OutputFrame>(renderLoop, std::chrono::nanoseconds(1'000'000'000'000) / renderLoop->refreshRate());
|
||||
|
||||
if (primaryLayer->needsRepaint() || superLayer->needsRepaint()) {
|
||||
renderLoop->beginPaint();
|
||||
|
|
|
@ -42,8 +42,9 @@ std::optional<RenderTimeSpan> CpuRenderTimeQuery::query()
|
|||
};
|
||||
}
|
||||
|
||||
OutputFrame::OutputFrame(RenderLoop *loop)
|
||||
OutputFrame::OutputFrame(RenderLoop *loop, std::chrono::nanoseconds refreshDuration)
|
||||
: m_loop(loop)
|
||||
, m_refreshDuration(refreshDuration)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -74,12 +75,12 @@ std::optional<std::chrono::nanoseconds> OutputFrame::queryRenderTime() const
|
|||
return ret.end - ret.start;
|
||||
}
|
||||
|
||||
void OutputFrame::presented(std::chrono::nanoseconds refreshDuration, std::chrono::nanoseconds timestamp, PresentationMode mode)
|
||||
void OutputFrame::presented(std::chrono::nanoseconds timestamp, PresentationMode mode)
|
||||
{
|
||||
std::optional<std::chrono::nanoseconds> renderTime = queryRenderTime();
|
||||
RenderLoopPrivate::get(m_loop)->notifyFrameCompleted(timestamp, renderTime, mode);
|
||||
for (const auto &feedback : m_feedbacks) {
|
||||
feedback->presented(refreshDuration, timestamp, mode);
|
||||
feedback->presented(m_refreshDuration, timestamp, mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,10 +75,10 @@ private:
|
|||
class KWIN_EXPORT OutputFrame
|
||||
{
|
||||
public:
|
||||
explicit OutputFrame(RenderLoop *loop);
|
||||
explicit OutputFrame(RenderLoop *loop, std::chrono::nanoseconds refreshDuration);
|
||||
~OutputFrame();
|
||||
|
||||
void presented(std::chrono::nanoseconds refreshDuration, std::chrono::nanoseconds timestamp, PresentationMode mode);
|
||||
void presented(std::chrono::nanoseconds timestamp, PresentationMode mode);
|
||||
void failed();
|
||||
|
||||
void addFeedback(std::unique_ptr<PresentationFeedback> &&feedback);
|
||||
|
@ -97,6 +97,7 @@ private:
|
|||
std::optional<std::chrono::nanoseconds> queryRenderTime() const;
|
||||
|
||||
RenderLoop *const m_loop;
|
||||
const std::chrono::nanoseconds m_refreshDuration;
|
||||
std::vector<std::unique_ptr<PresentationFeedback>> m_feedbacks;
|
||||
std::optional<ContentType> m_contentType;
|
||||
PresentationMode m_presentationMode = PresentationMode::VSync;
|
||||
|
|
Loading…
Reference in a new issue