File indexing completed on 2024-05-19 05:31:36

0001 /*
0002     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "effect/globals.h"
0010 #include "kwin_export.h"
0011 
0012 #include <QRegion>
0013 #include <chrono>
0014 
0015 namespace KWin
0016 {
0017 
0018 class RenderLayer;
0019 class RenderTarget;
0020 class RenderViewport;
0021 class SurfaceItem;
0022 class OutputFrame;
0023 
0024 /**
0025  * The RenderLayerDelegate class represents a render layer's contents.
0026  */
0027 class KWIN_EXPORT RenderLayerDelegate
0028 {
0029 public:
0030     virtual ~RenderLayerDelegate() = default;
0031 
0032     RenderLayer *layer() const;
0033     void setLayer(RenderLayer *layer);
0034 
0035     /**
0036      * This function is called by the compositor after compositing the frame.
0037      */
0038     virtual void frame(OutputFrame *frame);
0039 
0040     /**
0041      * This function is called by the compositor before starting painting. Reimplement
0042      * this function to do frame initialization.
0043      */
0044     virtual QRegion prePaint();
0045 
0046     /**
0047      * This function is called by the compositor after finishing painting. Reimplement
0048      * this function to do post frame cleanup.
0049      */
0050     virtual void postPaint();
0051 
0052     /**
0053      * Returns the direct scanout candidate hint. It can be used to avoid compositing the
0054      * render layer.
0055      */
0056     virtual SurfaceItem *scanoutCandidate() const;
0057 
0058     /**
0059      * This function is called when the compositor wants the render layer delegate
0060      * to repaint its contents.
0061      */
0062     virtual void paint(const RenderTarget &renderTarget, const QRegion &region) = 0;
0063 
0064 private:
0065     RenderLayer *m_layer = nullptr;
0066 };
0067 
0068 } // namespace KWin