1 /* 2 KWin - the KDE window manager 3 This file is part of the KDE project. 4 5 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org> 6 7 SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 #ifndef KWIN_SCENE_QPAINTER_BACKEND_H 10 #define KWIN_SCENE_QPAINTER_BACKEND_H 11 12 #include <QObject> 13 14 class QImage; 15 class QRegion; 16 class QSize; 17 class QString; 18 19 namespace KWin 20 { 21 22 class PlatformSurfaceTexture; 23 class SurfacePixmapInternal; 24 class SurfacePixmapWayland; 25 class AbstractOutput; 26 27 class QPainterBackend : public QObject 28 { 29 Q_OBJECT 30 31 public: 32 virtual ~QPainterBackend(); 33 34 PlatformSurfaceTexture *createPlatformSurfaceTextureInternal(SurfacePixmapInternal *pixmap); 35 PlatformSurfaceTexture *createPlatformSurfaceTextureWayland(SurfacePixmapWayland *pixmap); 36 37 virtual void endFrame(AbstractOutput *output, const QRegion &damage) = 0; 38 virtual QRegion beginFrame(AbstractOutput *output) = 0; 39 /** 40 * @brief Whether the creation of the Backend failed. 41 * 42 * The SceneQPainter should test whether the Backend got constructed correctly. If this method 43 * returns @c true, the SceneQPainter should not try to start the rendering. 44 * 45 * @return bool @c true if the creation of the Backend failed, @c false otherwise. 46 */ isFailed()47 bool isFailed() const { 48 return m_failed; 49 } 50 /** 51 * Overload for the case that there is a different buffer per screen. 52 * Default implementation just calls buffer. 53 * @param screenId The id of the screen as used in Screens 54 * @todo Get a better identifier for screen then a counter variable 55 */ 56 virtual QImage *bufferForScreen(AbstractOutput *output) = 0; 57 58 protected: 59 QPainterBackend(); 60 /** 61 * @brief Sets the backend initialization to failed. 62 * 63 * This method should be called by the concrete subclass in case the initialization failed. 64 * The given @p reason is logged as a warning. 65 * 66 * @param reason The reason why the initialization failed. 67 */ 68 void setFailed(const QString &reason); 69 70 private: 71 bool m_failed; 72 }; 73 74 } // KWin 75 76 #endif 77