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

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 #pragma once
0010 
0011 #include "core/outputbackend.h"
0012 #include "utils/filedescriptor.h"
0013 
0014 #include <QRect>
0015 
0016 struct gbm_device;
0017 
0018 namespace KWin
0019 {
0020 class VirtualBackend;
0021 class VirtualOutput;
0022 
0023 class KWIN_EXPORT VirtualBackend : public OutputBackend
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     VirtualBackend(QObject *parent = nullptr);
0029     ~VirtualBackend() override;
0030 
0031     bool initialize() override;
0032 
0033     std::unique_ptr<QPainterBackend> createQPainterBackend() override;
0034     std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
0035 
0036     struct OutputInfo
0037     {
0038         QRect geometry;
0039         double scale = 1;
0040         bool internal = false;
0041     };
0042     Output *addOutput(const OutputInfo &info);
0043     void setVirtualOutputs(const QList<OutputInfo> &infos);
0044 
0045     Outputs outputs() const override;
0046 
0047     QList<CompositingType> supportedCompositors() const override;
0048 
0049     void setEglDisplay(std::unique_ptr<EglDisplay> &&display);
0050     EglDisplay *sceneEglDisplayObject() const override;
0051 
0052     gbm_device *gbmDevice() const;
0053 
0054 Q_SIGNALS:
0055     void virtualOutputsSet(bool countChanged);
0056 
0057 private:
0058     VirtualOutput *createOutput(const OutputInfo &info);
0059 
0060     QList<VirtualOutput *> m_outputs;
0061     std::unique_ptr<EglDisplay> m_display;
0062     FileDescriptor m_drmFileDescriptor;
0063     gbm_device *m_gbmDevice = nullptr;
0064 };
0065 
0066 } // namespace KWin