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>
22#include <QtCore/qpointer.h>
33 : m_buffer(
buffer), m_id(
id), m_registry(registry)
48 return m_buffer ? m_buffer->
size() :
QSize();
58 if (m_buffer !=
nullptr) {
60 return QNativeInterface::QSGOpenGLTexture::fromNative(
texture->textureId(),
63 QQuickWindow::TextureHasAlphaChannel);
71 QPointer<SharedTextureRegistry> m_registry;
89 return m_buffers.
value(
id);
96 m_pendingBuffers <<
id;
109void SharedTextureRegistry::handleExtensionActive()
113 while (!m_pendingBuffers.isEmpty())
120 qWarning() <<
"The shared-texture extension is only supported on OpenGL. Use QQuickWindow::setSceneGraphBackend() to override the default.";
126 if (!serverBufferIntegration) {
127 qWarning() <<
"Wayland Server Buffer Integration not available.";
147 : m_id(
id), m_registry(registry)
173 if (fbPath.isEmpty()) {
174 m_errorString =
QStringLiteral(
"Shared buffer not found, and no fallback path set.");
181 qWarning() <<
"Could not load local image from id/path" << reader.
fileName();
182 m_errorString =
QStringLiteral(
"Shared buffer not found, and fallback local file loading failed: ") + reader.
errorString();
190 return m_errorString;
196 static bool isInit =
false;
200 if (!envVal.isEmpty()) {
232 if (!m_sharingAvailable) {
234 qWarning() <<
"Shared buffer images not available, and no fallback directory set.";
251 if (m_sharingAvailable && !m_registry)
259#include "moc_sharedtextureprovider_p.cpp"
261#include "sharedtextureprovider.moc"
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...
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