kwin/src/renderlayerdelegate.h

68 lines
1.5 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 "kwin_export.h"
#include <QObject>
#include <QRegion>
namespace KWin
{
class RenderLayer;
class RenderTarget;
class SurfaceItem;
/**
* The RenderLayerDelegate class represents a render layer's contents.
*/
class KWIN_EXPORT RenderLayerDelegate : public QObject
{
Q_OBJECT
public:
explicit RenderLayerDelegate(QObject *parent = nullptr);
RenderLayer *layer() const;
void setLayer(RenderLayer *layer);
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
/**
* Returns the repaints schduled for the next frame.
*/
virtual QRegion repaints() const;
/**
* This function is called by the compositor before starting compositing. Reimplement
* this function to do frame initialization.
*/
virtual void prePaint();
/**
* This function is called by the compositor after finishing compositing. Reimplement
* this function to do post frame cleanup.
*/
virtual void postPaint();
/**
* Returns the direct scanout candidate hint. It can be used to avoid compositing the
* render layer.
*/
virtual SurfaceItem *scanoutCandidate() const;
/**
* This function is called when the compositor wants the render layer delegate
* to repaint its contents.
*/
virtual void paint(RenderTarget *renderTarget, const QRegion &region) = 0;
private:
RenderLayer *m_layer = nullptr;
};
} // namespace KWin