6#include <QWaylandSurface>
10#include <QQuickWindow>
16#include <QtGui/private/qtexturefilereader_p.h>
18#include <QtOpenGL/QOpenGLTexture>
19#include <QtGui/QImageReader>
21#include <QtQuick/QSGTexture>
43 return m_buffer ? m_buffer->
size() :
QSize();
53 if (m_buffer !=
nullptr) {
55 return QNativeInterface::QSGOpenGLTexture::fromNative(
texture->textureId(),
58 QQuickWindow::TextureHasAlphaChannel);
140 m_pendingResponses << response;
147 for (
auto *response : std::as_const(m_pendingResponses))
149 m_pendingResponses.
clear();
171 for (
auto b : m_server_buffers)
182 for (
auto it = m_image_dirs.begin();
it != m_image_dirs.end(); ++
it)
194 if (!image_search_path.
isEmpty())
197 if (m_image_dirs.isEmpty())
202 for (
auto ext : std::as_const(suffixes))
218QString QWaylandTextureSharingExtension::getExistingFilePath(
const QString &
key)
const
227 for (
auto dir :
std::as_const(m_image_dirs)) {
233 for (
auto dir :
std::as_const(m_image_dirs)) {
234 for (
auto ext : m_image_suffixes) {
246 if (!initServerBufferIntegration())
258 uint glInternalFormat = GL_NONE;
264 qWarning() <<
"QWaylandTextureSharingExtension: could not create buffer from custom data for key:" <<
key;
272 buffer = getCompressedBuffer(pathName);
298 qWarning(
"QWaylandTextureSharingExtension::requestBuffer() called from outside main thread: possible race condition");
303 m_server_buffers[
key].usedLocally =
true;
315 struct ::wl_client *client = resource->client();
316 struct ::wl_resource *buffer_resource =
buffer->resourceForClient(client);
319 send_provide_buffer(resource->handle, buffer_resource,
key);
321 qWarning() <<
"QWaylandTextureSharingExtension: no buffer resource for client";
323 send_image_failed(resource->handle,
key,
QString());
345bool QWaylandTextureSharingExtension::initServerBufferIntegration()
347 if (!m_server_buffer_integration) {
351 if (!m_server_buffer_integration) {
352 qWarning(
"QWaylandTextureSharingExtension initialization failed: No Server Buffer Integration");
354 qWarning(
"Set the environment variable 'QT_WAYLAND_SERVER_BUFFER_INTEGRATION' to specify.");
377 qWarning() <<
"VulkanServerBufferIntegration:" << pathName <<
"not valid compressed texture";
382 td.glInternalFormat());
387 for (
auto it = m_server_buffers.
begin();
it != m_server_buffers.
end(); ) {
389 if (!
it.value().usedLocally && !
buffer->bufferInUse()) {
400void QWaylandTextureSharingExtension::dumpBufferInfo()
402 qDebug() <<
"shared buffers:" << m_server_buffers.
size();
403 for (
auto it = m_server_buffers.
cbegin();
it != m_server_buffers.
cend(); ++
it)
404 qDebug() <<
" " <<
it.key() <<
":" <<
it.value().buffer <<
"in use" <<
it.value().buffer->bufferInUse() <<
"usedLocally" <<
it.value().usedLocally ;
409#include "moc_qwltexturesharingextension_p.cpp"
411#include "qwltexturesharingextension.moc"
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
bool exists() const
Returns true if the file exists; otherwise returns false.
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
const_iterator cbegin() const noexcept
qsizetype size() const noexcept
Returns the number of items in the hash.
iterator erase(const_iterator it)
T value(const Key &key) const noexcept
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
const_iterator cend() const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
static QList< QByteArray > supportedImageFormats()
Returns the list of image formats supported by QImageReader.
@ Format_RGBA8888_Premultiplied
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QThread * thread() const
Returns the thread in which the object lives.
The QQmlEngine class provides an environment for instantiating QML components.
static QQmlContext * contextForObject(const QObject *)
Returns the QQmlContext for the object, or nullptr if no context has been set.
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....
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QList< QByteArray > supportedFileFormats()
static QThread * currentThread()
bool singleShot
whether the timer is a single-shot timer
\inmodule QtWaylandCompositor
virtual void initialize()
Initializes the QWaylandCompositorExtension.
QWaylandObject * extensionContainer() const
static QWaylandCompositorPrivate * get(QWaylandCompositor *compositor)
QtWayland::ServerBufferIntegration * serverBufferIntegration() const
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
QQuickImageResponse * requestImageResponse(const QString &id, const QSize &requestedSize) override
Implement this method to return the job that will provide the texture with id.
QWaylandSharedTextureProvider()
void setExtensionReady(QWaylandTextureSharingExtension *extension)
~QWaylandSharedTextureProvider() override
void zqt_texture_sharing_v1_destroy_resource(Resource *resource) override
void zqt_texture_sharing_v1_request_image(Resource *resource, const QString &key) override
~QWaylandTextureSharingExtension() override
QWaylandTextureSharingExtension()
void initialize() override
Initializes the QWaylandCompositorExtension.
virtual bool customPixelData(const QString &key, QByteArray *data, QSize *size, uint *glInternalFormat)
void zqt_texture_sharing_v1_abandon_image(Resource *resource, const QString &key) override
void bufferResult(const QString &key, QtWayland::ServerBuffer *buffer)
void setImageSearchPath(const QString &path)
static QWaylandTextureSharingExtension * self()
void requestBuffer(const QString &key)
virtual ServerBuffer * createServerBufferFromData(QByteArrayView view, const QSize &size, uint glInternalFormat)
virtual ServerBuffer * createServerBufferFromImage(const QImage &qimage, ServerBuffer::Format format)=0
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 QtWayland::ServerBuffer *buffer)
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 doRequest(QWaylandTextureSharingExtension *extension)
SharedTextureImageResponse(QWaylandTextureSharingExtension *extension, const QString &id)
void doResponse(const QString &key, QtWayland::ServerBuffer *buffer)
QString errorString() const override
Returns the error string for the job execution.
QQuickTextureFactory * textureFactory() const override
Returns the texture factory for the job.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QOpenGLCompositor * compositor
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLchar *const * path
QLatin1StringView QLatin1String
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
myObject disconnect()
[26]
\inmodule QtCore \reentrant