10#include <QQuickWindow>
12#include <QtWaylandClient/private/qwaylandintegration_p.h>
13#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
14#include <QtGui/QGuiApplication>
15#include <QtGui/private/qguiapplication_p.h>
16#include <QtQuick/private/qsgrhisupport_p.h>
17#include <QtGui/qpa/qplatformnativeinterface.h>
18#include <QtGui/QWindow>
19#include <QOpenGLTexture>
20#include <QImageReader>
32 : m_buffer(
buffer), m_id(
id), m_registry(registry)
47 return m_buffer ? m_buffer->
size() :
QSize();
57 if (m_buffer !=
nullptr) {
59 return QNativeInterface::QSGOpenGLTexture::fromNative(
texture->textureId(),
62 QQuickWindow::TextureHasAlphaChannel);
88 return m_buffers.
value(
id);
95 m_pendingBuffers <<
id;
108void SharedTextureRegistry::handleExtensionActive()
112 while (!m_pendingBuffers.isEmpty())
119 qWarning() <<
"The shared-texture extension is only supported on OpenGL. Use QQuickWindow::setSceneGraphBackend() to override the default.";
125 if (!serverBufferIntegration) {
126 qWarning() <<
"Wayland Server Buffer Integration not available.";
146 : m_id(
id), m_registry(registry)
173 m_errorString =
QStringLiteral(
"Shared buffer not found, and no fallback path set.");
180 qWarning() <<
"Could not load local image from id/path" << reader.
fileName();
181 m_errorString =
QStringLiteral(
"Shared buffer not found, and fallback local file loading failed: ") + reader.
errorString();
189 return m_errorString;
195 static bool isInit =
false;
231 if (!m_sharingAvailable) {
233 qWarning() <<
"Shared buffer images not available, and no fallback directory set.";
250 if (m_sharingAvailable && !m_registry)
258#include "moc_sharedtextureprovider_p.cpp"
260#include "sharedtextureprovider.moc"
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QPlatformIntegration * platformIntegration()
bool remove(const Key &key)
Removes the item that has the key from the hash.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
The QImageReader class provides a format independent interface for reading images from files or other...
QString errorString() const
Returns a human readable description of the last error that occurred.
QString fileName() const
If the currently assigned device is a QFile, or if setFileName() has been called, this function retur...
QImage read()
Reads an image from the device.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QQuickImageResponse class provides an interface for asynchronous image loading in QQuickAsyncImag...
void finished()
Signals that the job execution has finished (be it successfully, because an error happened or because...
The QQuickTextureFactory class provides an interface for loading custom textures from QML....
static QQuickTextureFactory * textureFactoryForImage(const QImage &image)
Returns a QQuickTextureFactory holding the given image.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
static QSGRhiSupport * instance()
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & append(QChar c)
QSGTexture * createTexture(QQuickWindow *window) const override
This function is called on the scene graph rendering thread to create a QSGTexture instance from the ...
SharedTextureFactory(const QtWaylandClient::QWaylandServerBuffer *buffer, const QString &id, SharedTextureRegistry *registry)
QSize textureSize() const override
Returns the size of the texture.
~SharedTextureFactory() override
int textureByteCount() const override
Returns the number of bytes of memory the texture consumes.
void doResponse(const QString &key, QtWayland::ServerBuffer *buffer)
void doResponse(const QString &key)
QString errorString() const override
Returns the error string for the job execution.
SharedTextureImageResponse(SharedTextureRegistry *registry, const QString &id)
QQuickTextureFactory * textureFactory() const override
Returns the texture factory for the job.
static QString fallbackPath()
~SharedTextureProvider() override
QQuickImageResponse * requestImageResponse(const QString &id, const QSize &requestedSize) override
Implement this method to return the job that will provide the texture with id.
const QtWaylandClient::QWaylandServerBuffer * bufferForId(const QString &id) const
static bool preinitialize()
void receiveBuffer(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &id)
void abandonBuffer(const QString &id)
void requestBuffer(const QString &id)
void replyReceived(const QString &id)
~SharedTextureRegistry() override
void abandonImage(const QString &key)
void requestImage(const QString &key)
void bufferReceived(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &key)
Combined button and popup list for selecting options.
#define Q_ARG(Type, data)
#define QStringLiteral(str)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
myObject disconnect()
[26]
\inmodule QtCore \reentrant