2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2017-05-09 19:00:33 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2017-05-09 19:00:33 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2017-05-09 19:00:33 +00:00
|
|
|
#ifndef KWIN_DRM_BUFFER_GBM_H
|
|
|
|
#define KWIN_DRM_BUFFER_GBM_H
|
|
|
|
|
|
|
|
#include "drm_buffer.h"
|
|
|
|
|
2021-03-22 14:46:09 +00:00
|
|
|
#include <QSharedPointer>
|
2017-10-05 16:58:57 +00:00
|
|
|
|
2017-05-09 19:00:33 +00:00
|
|
|
struct gbm_bo;
|
|
|
|
|
2021-02-02 13:26:43 +00:00
|
|
|
namespace KWaylandServer
|
|
|
|
{
|
2021-07-20 19:37:03 +00:00
|
|
|
class ClientBuffer;
|
2021-02-02 13:26:43 +00:00
|
|
|
}
|
|
|
|
|
2017-05-09 19:00:33 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2017-10-05 16:58:57 +00:00
|
|
|
class GbmSurface;
|
2017-05-09 19:00:33 +00:00
|
|
|
|
2021-03-29 11:17:44 +00:00
|
|
|
class GbmBuffer : public QObject
|
2017-05-09 19:00:33 +00:00
|
|
|
{
|
2021-03-29 11:17:44 +00:00
|
|
|
Q_OBJECT
|
2017-05-09 19:00:33 +00:00
|
|
|
public:
|
2021-05-25 17:25:55 +00:00
|
|
|
GbmBuffer(GbmSurface *surface, gbm_bo *bo);
|
2021-07-20 19:37:03 +00:00
|
|
|
GbmBuffer(gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
|
2021-03-29 11:17:44 +00:00
|
|
|
virtual ~GbmBuffer();
|
|
|
|
|
|
|
|
gbm_bo* getBo() const {
|
|
|
|
return m_bo;
|
|
|
|
}
|
|
|
|
|
2021-05-02 20:38:36 +00:00
|
|
|
void releaseBuffer();
|
|
|
|
|
2021-05-04 10:19:31 +00:00
|
|
|
bool map(uint32_t flags);
|
|
|
|
void *mappedData() const {
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
uint32_t stride() const {
|
|
|
|
return m_stride;
|
|
|
|
}
|
|
|
|
|
2021-03-29 11:17:44 +00:00
|
|
|
protected:
|
2021-05-25 17:25:55 +00:00
|
|
|
GbmSurface *m_surface = nullptr;
|
2021-03-29 11:17:44 +00:00
|
|
|
gbm_bo *m_bo = nullptr;
|
2021-07-20 19:37:03 +00:00
|
|
|
KWaylandServer::ClientBuffer *m_clientBuffer = nullptr;
|
2021-03-29 11:17:44 +00:00
|
|
|
|
2021-05-04 10:19:31 +00:00
|
|
|
void *m_data = nullptr;
|
|
|
|
void *m_mapping = nullptr;
|
|
|
|
uint32_t m_stride = 0;
|
2021-03-29 11:17:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DrmGbmBuffer : public DrmBuffer, public GbmBuffer
|
|
|
|
{
|
|
|
|
public:
|
2021-05-25 17:25:55 +00:00
|
|
|
DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo);
|
2021-07-20 19:37:03 +00:00
|
|
|
DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
|
2021-03-29 11:17:44 +00:00
|
|
|
~DrmGbmBuffer() override;
|
2017-05-09 19:00:33 +00:00
|
|
|
|
|
|
|
bool needsModeChange(DrmBuffer *b) const override {
|
2021-03-29 11:17:44 +00:00
|
|
|
if (DrmGbmBuffer *sb = dynamic_cast<DrmGbmBuffer*>(b)) {
|
2017-05-09 19:00:33 +00:00
|
|
|
return hasBo() != sb->hasBo();
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasBo() const {
|
|
|
|
return m_bo != nullptr;
|
|
|
|
}
|
GBM remote access support for KWin
Summary:
Implements a KWayland protocol to pass GBM fd from KWin to KRfb and
addictions to relevant projects from both sides.
Note that this patch does not affect default behaviour of mentioned projects. It can be used
only with KWIN_REMOTE=1 in env from KWin side and with preferredFrameBufferPlugin=gbm in krfbrc from
KRfb side. In all other aspects app behaviour remains unchanged.
Test Plan: Launched KWin in Wayland mode, launched KRfb in it, launched KRDC on a laptop, connected in read-only mode, observed a correctly retrieved desktop with Krfb window
Reviewers: graesslin, davidedmundson, romangg, #kwin
Reviewed By: davidedmundson, romangg, #kwin
Subscribers: kossebau, jgrulich, romangg, ngraham, alexeymin, aacid, kwin, #kwin, davidedmundson, plasma-devel
Tags: #plasma_on_wayland, #kwin
Maniphest Tasks: T5653, T7785
Differential Revision: https://phabricator.kde.org/D1230
2016-04-30 23:01:44 +00:00
|
|
|
|
2017-05-09 19:00:33 +00:00
|
|
|
private:
|
2021-03-06 15:24:52 +00:00
|
|
|
void initialize();
|
2017-05-09 19:00:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|