b8a70e62d5
At the moment, our frame scheduling infrastructure is still heavily based on Xinerama-style rendering. Specifically, we assume that painting is driven by a single timer, etc. This change introduces a new type - RenderLoop. Its main purpose is to drive compositing on a specific output, or in case of X11, on the overlay window. With RenderLoop, compositing is synchronized to vblank events. It exposes the last and the next estimated presentation timestamp. The expected presentation timestamp can be used by effects to ensure that animations are synchronized with the upcoming vblank event. On Wayland, every outputs has its own render loop. On X11, per screen rendering is not possible, therefore the platform exposes the render loop for the overlay window. Ideally, the Scene has to expose the RenderLoop, but as the first step towards better compositing scheduling it's good as is for the time being. The RenderLoop tries to minimize the latency by delaying compositing as close as possible to the next vblank event. One tricky thing about it is that if compositing is too close to the next vblank event, animations may become a little bit choppy. However, increasing the latency reduces the choppiness. Given that, there is no any "silver bullet" solution for the choppiness issue, a new option has been added in the Compositing KCM to specify the amount of latency. By default, it's "Medium," but if a user is not satisfied with the upstream default, they can tweak it.
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "xrenderbackend.h"
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
class SoftwareVsyncMonitor;
|
|
class X11StandalonePlatform;
|
|
|
|
/**
|
|
* @brief XRenderBackend using an X11 Overlay Window as compositing target.
|
|
*/
|
|
class X11XRenderBackend : public QObject, public XRenderBackend
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit X11XRenderBackend(X11StandalonePlatform *backend);
|
|
~X11XRenderBackend() override;
|
|
|
|
void present(int mask, const QRegion &damage) override;
|
|
OverlayWindow *overlayWindow() override;
|
|
void showOverlay() override;
|
|
void screenGeometryChanged(const QSize &size) override;
|
|
bool usesOverlayWindow() const override;
|
|
|
|
private:
|
|
void init(bool createOverlay);
|
|
void createBuffer();
|
|
void vblank(std::chrono::nanoseconds timestamp);
|
|
|
|
X11StandalonePlatform *m_backend;
|
|
SoftwareVsyncMonitor *m_vsyncMonitor;
|
|
QScopedPointer<OverlayWindow> m_overlayWindow;
|
|
xcb_render_picture_t m_front;
|
|
xcb_render_pictformat_t m_format;
|
|
};
|
|
|
|
} // namespace KWin
|