kwin/src/renderbackend.h

54 lines
1.3 KiB
C
Raw Normal View History

/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "kwinglobals.h"
#include <QObject>
namespace KWin
{
class AbstractOutput;
class OverlayWindow;
class SurfaceItem;
/**
* The RenderBackend class is the base class for all rendering backends.
*/
class KWIN_EXPORT RenderBackend : public QObject
{
Q_OBJECT
public:
explicit RenderBackend(QObject *parent = nullptr);
virtual CompositingType compositingType() const = 0;
virtual OverlayWindow *overlayWindow() const;
virtual bool checkGraphicsReset();
scene: Rework surface damage tracking It's not possible to get the surface damage before calling Scene::paint(), which is a big problem because it blocks proper surface damage and buffer damage calculation when walking render layer tree. This change reworks the scene compositing stages to allow getting the next surface damage before calling Scene::paint(). The main challenge is that the effects can expand the surface damage. We have to call prePaintWindow() and prePaintScreen() before actually starting painting. However, prePaintWindow() is called after starting rendering. This change makes Scene call prePaintWindow() and prePaintScreen() so it's possible to know the surface damage beforehand. Unfortunately, it's also a breaking change. Some fullscreen effects will have to adapt to the new Scene paint order. Paint hooks will be invoked in the following order: * prePaintScreen() once per frame * prePaintWindow() once per frame * paintScreen() can be called multiple times * paintWindow() can be called as many times as paintScreen() * postPaintWindow() once per frame * postPaintScreen() once per frame After walking the render layer tree, the Compositor will poke the render backend for the back buffer repair region and combine it with the surface damage to get the buffer damage, which can be passed to the render backend (in order to optimize performance with tiled gpus) and Scene::paint(), which will determine what parts of the scene have to repainted based on the buffer damage.
2022-02-16 17:13:57 +00:00
/**
* Notifies about starting to paint.
*
* @p damage contains the reported damage as suggested by windows and effects on prepaint calls.
*/
virtual void aboutToStartPainting(AbstractOutput *output, const QRegion &damage);
virtual QRegion beginFrame(AbstractOutput *output) = 0;
virtual void endFrame(AbstractOutput *output, const QRegion &renderedRegion, const QRegion &damagedRegion) = 0;
virtual void present(AbstractOutput *output) = 0;
/**
* Tries to directly scan out a surface to the screen
* Returns @c true if scanout succeeds, @c false if rendering is necessary
*/
virtual bool scanout(AbstractOutput *output, SurfaceItem *surfaceItem);
};
} // namespace KWin