File indexing completed on 2025-04-27 05:03:45
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "effect/globals.h" 0013 #include <epoxy/egl.h> 0014 #include <kwin_export.h> 0015 0016 #include <QObject> 0017 0018 #include <memory> 0019 #include <optional> 0020 0021 namespace KWin 0022 { 0023 0024 class Output; 0025 class InputBackend; 0026 class OpenGLBackend; 0027 class QPainterBackend; 0028 class OutputConfiguration; 0029 class EglDisplay; 0030 class Session; 0031 0032 class KWIN_EXPORT Outputs : public QList<Output *> 0033 { 0034 public: 0035 Outputs(){}; 0036 template<typename T> 0037 Outputs(const QList<T> &other) 0038 { 0039 resize(other.size()); 0040 std::copy(other.constBegin(), other.constEnd(), begin()); 0041 } 0042 }; 0043 0044 class KWIN_EXPORT OutputBackend : public QObject 0045 { 0046 Q_OBJECT 0047 public: 0048 ~OutputBackend() override; 0049 0050 virtual bool initialize() = 0; 0051 virtual std::unique_ptr<InputBackend> createInputBackend(); 0052 virtual std::unique_ptr<OpenGLBackend> createOpenGLBackend(); 0053 virtual std::unique_ptr<QPainterBackend> createQPainterBackend(); 0054 0055 virtual EglDisplay *sceneEglDisplayObject() const = 0; 0056 /** 0057 * Returns the compositor-wide shared EGL context. This function may return EGL_NO_CONTEXT 0058 * if the underlying rendering backend does not use EGL. 0059 * 0060 * Note that the returned context should never be made current. Instead, create a context 0061 * that shares with this one and make the new context current. 0062 */ 0063 ::EGLContext sceneEglGlobalShareContext() const; 0064 /** 0065 * Sets the global share context to @a context. This function is intended to be called only 0066 * by rendering backends. 0067 */ 0068 void setSceneEglGlobalShareContext(::EGLContext context); 0069 0070 /** 0071 * The CompositingTypes supported by the Platform. 0072 * The first item should be the most preferred one. 0073 * @since 5.11 0074 */ 0075 virtual QList<CompositingType> supportedCompositors() const = 0; 0076 0077 virtual Outputs outputs() const = 0; 0078 Output *findOutput(const QString &name) const; 0079 0080 /** 0081 * A string of information to include in kwin debug output 0082 * It should not be translated. 0083 * 0084 * The base implementation prints the name. 0085 * @since 5.12 0086 */ 0087 virtual QString supportInformation() const; 0088 0089 virtual Output *createVirtualOutput(const QString &name, const QSize &size, qreal scale); 0090 virtual void removeVirtualOutput(Output *output); 0091 0092 /** 0093 * Applies the output changes. Default implementation only sets values common between platforms 0094 */ 0095 virtual bool applyOutputChanges(const OutputConfiguration &config); 0096 0097 virtual Session *session() const; 0098 0099 public Q_SLOTS: 0100 virtual void sceneInitialized(){}; 0101 0102 Q_SIGNALS: 0103 void outputsQueried(); 0104 /** 0105 * This signal is emitted when an output has been connected. The @a output is not ready 0106 * for compositing yet. 0107 */ 0108 void outputAdded(Output *output); 0109 /** 0110 * This signal is emitted when an output has been disconnected. 0111 */ 0112 void outputRemoved(Output *output); 0113 0114 protected: 0115 explicit OutputBackend(QObject *parent = nullptr); 0116 0117 ::EGLContext m_globalShareContext = EGL_NO_CONTEXT; 0118 }; 0119 0120 } // namespace KWin