1 | // Copyright (C) 2019 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "texturesharingextension_p.h" |
5 | #include <QtWaylandClient/private/qwaylanddisplay_p.h> |
6 | #include <QtWaylandClient/private/qwaylandintegration_p.h> |
7 | #include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> |
8 | #include <QtGui/QGuiApplication> |
9 | #include <QtGui/private/qguiapplication_p.h> |
10 | #include <QtGui/QWindow> |
11 | #include <QtGui/QPlatformSurfaceEvent> |
12 | #include <QtGui/qpa/qplatformnativeinterface.h> |
13 | #include <QDebug> |
14 | |
15 | QT_BEGIN_NAMESPACE |
16 | |
17 | TextureSharingExtension::TextureSharingExtension() |
18 | : QWaylandClientExtensionTemplate(/* Supported protocol version */ 1 ) |
19 | { |
20 | auto *wayland_integration = static_cast<QtWaylandClient::QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration()); |
21 | m_server_buffer_integration = wayland_integration->serverBufferIntegration(); |
22 | if (!m_server_buffer_integration) { |
23 | qCritical() << "This application requires a working serverBufferIntegration"; |
24 | QGuiApplication::quit(); |
25 | } |
26 | } |
27 | |
28 | void TextureSharingExtension::zqt_texture_sharing_v1_provide_buffer(struct ::qt_server_buffer *buffer, const QString &key) |
29 | { |
30 | QtWaylandClient::QWaylandServerBuffer *serverBuffer = m_server_buffer_integration->serverBuffer(buffer: buffer); |
31 | emit bufferReceived(buffer: serverBuffer, key); |
32 | } |
33 | |
34 | void TextureSharingExtension::zqt_texture_sharing_v1_image_failed(const QString &key, const QString &message) |
35 | { |
36 | qWarning() << "TextureSharingExtension"<< key << "not found"<< message; |
37 | emit bufferReceived(buffer: nullptr, key); |
38 | } |
39 | void TextureSharingExtension::requestImage(const QString &key) |
40 | { |
41 | request_image(key); |
42 | } |
43 | |
44 | void TextureSharingExtension::abandonImage(const QString &key) |
45 | { |
46 | abandon_image(key); |
47 | } |
48 | |
49 | QT_END_NAMESPACE |
50 | |
51 | #include "moc_texturesharingextension_p.cpp" |
52 |