* speeds up incremental builds as changes to a header will not always need the full mocs_compilation.cpp for all the target's headers rebuild, while having a moc file sourced into a source file only adds minor extra costs, due to small own code and the used headers usually already covered by the source file, being for the same class/struct * seems to not slow down clean builds, due to empty mocs_compilation.cpp resulting in those quickly processed, while the minor extra cost of the sourced moc files does not outweigh that in summary. Measured times actually improved by some percent points. (ideally CMake would just skip empty mocs_compilation.cpp & its object file one day) * enables compiler to see all methods of a class in same compilation unit to do some sanity checks * potentially more inlining in general, due to more in the compilation unit * allows to keep using more forward declarations in the header, as with the moc code being sourced into the cpp file there definitions can be ensured and often are already for the needs of the normal class methods
138 lines
5.7 KiB
C++
138 lines
5.7 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
*/
|
|
|
|
#include "drmclientbuffer.h"
|
|
#include "display.h"
|
|
#include "utils/common.h"
|
|
|
|
#include "qwayland-server-drm.h"
|
|
|
|
namespace KWaylandServer
|
|
{
|
|
|
|
static constexpr int s_version = 2;
|
|
|
|
class DrmClientBufferIntegrationPrivate : public QtWaylandServer::wl_drm
|
|
{
|
|
public:
|
|
explicit DrmClientBufferIntegrationPrivate(Display *display);
|
|
|
|
QString nodeName;
|
|
|
|
protected:
|
|
void drm_bind_resource(Resource *resource) override;
|
|
void drm_authenticate(Resource *resource, uint32_t id) override;
|
|
void drm_create_buffer(Resource *resource,
|
|
uint32_t id,
|
|
uint32_t name,
|
|
int32_t width,
|
|
int32_t height,
|
|
uint32_t stride,
|
|
uint32_t format) override;
|
|
void drm_create_planar_buffer(Resource *resource,
|
|
uint32_t id,
|
|
uint32_t name,
|
|
int32_t width,
|
|
int32_t height,
|
|
uint32_t format,
|
|
int32_t offset0,
|
|
int32_t stride0,
|
|
int32_t offset1,
|
|
int32_t stride1,
|
|
int32_t offset2,
|
|
int32_t stride2) override;
|
|
void drm_create_prime_buffer(Resource *resource,
|
|
uint32_t id,
|
|
int32_t name,
|
|
int32_t width,
|
|
int32_t height,
|
|
uint32_t format,
|
|
int32_t offset0,
|
|
int32_t stride0,
|
|
int32_t offset1,
|
|
int32_t stride1,
|
|
int32_t offset2,
|
|
int32_t stride2) override;
|
|
};
|
|
|
|
DrmClientBufferIntegrationPrivate::DrmClientBufferIntegrationPrivate(Display *display)
|
|
: QtWaylandServer::wl_drm(*display, s_version)
|
|
{
|
|
}
|
|
|
|
void DrmClientBufferIntegrationPrivate::drm_bind_resource(Resource *resource)
|
|
{
|
|
send_device(resource->handle, nodeName);
|
|
send_capabilities(resource->handle, capability_prime);
|
|
}
|
|
|
|
void DrmClientBufferIntegrationPrivate::drm_authenticate(Resource *resource, uint32_t id)
|
|
{
|
|
send_authenticated(resource->handle);
|
|
}
|
|
|
|
void DrmClientBufferIntegrationPrivate::drm_create_buffer(Resource *resource,
|
|
uint32_t id,
|
|
uint32_t name,
|
|
int32_t width,
|
|
int32_t height,
|
|
uint32_t stride,
|
|
uint32_t format)
|
|
{
|
|
wl_resource_post_error(resource->handle, 0, "wl_drm.create_buffer is not implemented");
|
|
}
|
|
|
|
void DrmClientBufferIntegrationPrivate::drm_create_planar_buffer(Resource *resource,
|
|
uint32_t id,
|
|
uint32_t name,
|
|
int32_t width,
|
|
int32_t height,
|
|
uint32_t format,
|
|
int32_t offset0,
|
|
int32_t stride0,
|
|
int32_t offset1,
|
|
int32_t stride1,
|
|
int32_t offset2,
|
|
int32_t stride2)
|
|
{
|
|
wl_resource_post_error(resource->handle, 0, "wl_drm.create_planar_buffer is not implemented");
|
|
}
|
|
|
|
void DrmClientBufferIntegrationPrivate::drm_create_prime_buffer(Resource *resource,
|
|
uint32_t id,
|
|
int32_t name,
|
|
int32_t width,
|
|
int32_t height,
|
|
uint32_t format,
|
|
int32_t offset0,
|
|
int32_t stride0,
|
|
int32_t offset1,
|
|
int32_t stride1,
|
|
int32_t offset2,
|
|
int32_t stride2)
|
|
{
|
|
close(name);
|
|
wl_resource_post_error(resource->handle, 0, "wl_drm.create_prime_buffer is not implemented");
|
|
}
|
|
|
|
DrmClientBufferIntegration::DrmClientBufferIntegration(Display *display)
|
|
: QObject(display)
|
|
, d(std::make_unique<DrmClientBufferIntegrationPrivate>(display))
|
|
{
|
|
}
|
|
|
|
DrmClientBufferIntegration::~DrmClientBufferIntegration()
|
|
{
|
|
}
|
|
|
|
void DrmClientBufferIntegration::setDevice(const QString &node)
|
|
{
|
|
d->nodeName = node;
|
|
}
|
|
|
|
} // namespace KWaylandServer
|
|
|
|
#include "moc_drmclientbuffer.cpp"
|