Commit 460cfa5b authored by adrien faveraux's avatar adrien faveraux Committed by Vlad Zahorodnii
Browse files

move eglstream controler to the new approach

parent 1c4a22b3
......@@ -213,9 +213,9 @@ ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
BASENAME xdg-decoration-unstable-v1
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
ecm_add_qtwayland_server_protocol(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/wayland-eglstream-controller.xml
BASENAME eglstream-controller
BASENAME wl-eglstream-controller
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
......
......@@ -3,88 +3,62 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "eglstream_controller_interface_p.h"
#include "eglstream_controller_interface.h"
#include "clientconnection.h"
#include "display.h"
#include "logging.h"
#include <wayland-util.h>
#include <QLibrary>
#include <qwayland-server-eglstream-controller.h>
namespace KWaylandServer
{
const quint32 EglStreamControllerInterface::Private::s_version = 1;
class EglStreamControllerInterfacePrivate : public QtWaylandServer::wl_eglstream_controller
{
public:
EglStreamControllerInterfacePrivate(EglStreamControllerInterface *controller, Display *display);
private:
static const quint32 s_version;
EglStreamControllerInterface *q;
#ifndef K_DOXYGEN
const struct wl_eglstream_controller_interface EglStreamControllerInterface::Private::s_interface = {
attachStreamConsumer,
attachStreamConsumerAttribs
};
#endif
protected:
void eglstream_controller_attach_eglstream_consumer(Resource *resource, wl_resource *wl_surface, wl_resource *eglStream) override;
void eglstream_controller_attach_eglstream_consumer_attribs(Resource *resource, wl_resource *wl_surface, wl_resource *eglStream, wl_array *attribs) override;
void EglStreamControllerInterface::Private::attachStreamConsumer(wl_client *client,
wl_resource *resource,
wl_resource *surface,
wl_resource *eglStream)
{
wl_array noAttribs = { 0, 0, nullptr };
attachStreamConsumerAttribs(client, resource, surface, eglStream, &noAttribs);
}
};
void EglStreamControllerInterface::Private::attachStreamConsumerAttribs(wl_client *client,
wl_resource *resource,
wl_resource *surface,
wl_resource *eglStream,
wl_array *attribs)
{
Q_UNUSED(client);
Private *p = reinterpret_cast<Private *>(wl_resource_get_user_data(resource));
emit p->q->streamConsumerAttached(SurfaceInterface::get(surface), eglStream, attribs);
}
const quint32 EglStreamControllerInterfacePrivate::s_version = 1;
EglStreamControllerInterface::Private::Private(EglStreamControllerInterface *q, Display *display)
// libnvidia-egl-wayland.so.1 may not be present on all systems, so we load it dynamically
: Global::Private(display,
reinterpret_cast<wl_interface *>(QLibrary::resolve(QLatin1String("libnvidia-egl-wayland.so.1"),
"wl_eglstream_controller_interface")),
s_version)
, q(q)
void EglStreamControllerInterfacePrivate::eglstream_controller_attach_eglstream_consumer(Resource *resource, wl_resource *wl_surface, wl_resource *eglStream)
{
wl_array noAttribs = { 0, 0, nullptr };
eglstream_controller_attach_eglstream_consumer_attribs(resource, wl_surface, eglStream, &noAttribs);
}
void EglStreamControllerInterface::Private::create()
void EglStreamControllerInterfacePrivate::eglstream_controller_attach_eglstream_consumer_attribs(Resource *resource, wl_resource *wl_surface, wl_resource *eglStream, wl_array *attribs)
{
// bail out early if we were unable to load the interface
if (m_interface == nullptr) {
qCWarning(KWAYLAND_SERVER) << "failed to resolve wl_eglstream_controller_interface";
SurfaceInterface *surface = SurfaceInterface::get(wl_surface);
if (!surface) {
wl_resource_post_error(resource->handle, 0, "Invalid surface");
return;
}
Global::Private::create();
emit q->streamConsumerAttached(surface, eglStream, attribs);
}
void EglStreamControllerInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
EglStreamControllerInterfacePrivate::EglStreamControllerInterfacePrivate(EglStreamControllerInterface *_q, Display *display)
: QtWaylandServer::wl_eglstream_controller(*display, s_version)
, q(_q)
{
wl_resource *r = display->getConnection(client)->createResource(m_interface, version, id);
if (r == nullptr) {
wl_client_post_no_memory(client);
return;
}
wl_resource_set_implementation(r, &s_interface, this, nullptr);
}
EglStreamControllerInterface::~EglStreamControllerInterface() = default;
EglStreamControllerInterface::EglStreamControllerInterface(Display *display, QObject *parent)
: Global(new Private(this, display), parent)
{
}
void EglStreamControllerInterface::create()
: QObject(parent)
, d(new EglStreamControllerInterfacePrivate(this, display))
{
static_cast<Private &>(*d).create();
}
}
......@@ -17,7 +17,7 @@ namespace KWaylandServer
{
class Display;
class EglStreamControllerInterfacePrivate;
/**
* @brief Represents the Global for the wl_eglstream_controller interface.
*
......@@ -26,22 +26,22 @@ class Display;
* of buffer contents between client and compositor.
*
*/
class KWAYLANDSERVER_EXPORT EglStreamControllerInterface : public Global
class KWAYLANDSERVER_EXPORT EglStreamControllerInterface : public QObject
{
Q_OBJECT
public:
~EglStreamControllerInterface() override;
void create();
Q_SIGNALS:
/**
* Emitted when a new stream attach request is received.
*/
void streamConsumerAttached(SurfaceInterface *surface, void *eglStream, wl_array *attribs);
private:
explicit EglStreamControllerInterface(Display *display, QObject *parent = nullptr);
class Private;
QScopedPointer<EglStreamControllerInterfacePrivate> d;
friend class Display;
};
......
/*
SPDX-FileCopyrightText: 2019 NVIDIA Inc.
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef WAYLAND_SERVER_EGLSTREAM_CONTROLLER_INTERFACE_P_H
#define WAYLAND_SERVER_EGLSTREAM_CONTROLLER_INTERFACE_P_H
#include "eglstream_controller_interface.h"
#include "global_p.h"
#include <wayland-eglstream-controller-server-protocol.h>
namespace KWaylandServer
{
class Q_DECL_HIDDEN EglStreamControllerInterface::Private : public Global::Private
{
public:
Private(EglStreamControllerInterface *controller, Display *display);
void create();
private:
static void attachStreamConsumer(wl_client *client,
wl_resource *resource,
wl_resource *surface,
wl_resource *eglStream);
static void attachStreamConsumerAttribs(wl_client *client,
wl_resource *resource,
wl_resource *surface,
wl_resource *eglStream,
wl_array *attribs);
static const struct wl_eglstream_controller_interface s_interface;
static const quint32 s_version;
void bind(wl_client *client, uint32_t version, uint32_t id) override;
EglStreamControllerInterface *q;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment