6#include <qoffscreensurface.h>
8#include <private/qimagevideobuffer_p.h>
10#include <QtOpenGL/private/qopenglcompositor_p.h>
11#include <QtOpenGL/private/qopenglframebufferobject_p.h>
19 auto context = std::make_unique<QOpenGLContext>();
20 context->setShareContext(shareContext);
22 if (!context->create()) {
23 qWarning() <<
"Couldn't create an OpenGL context for QOpenGLVideoBuffer";
27 QObject::connect(QThread::currentThread(), &QThread::finished,
28 context.get(), &QOpenGLContext::deleteLater);
29 return context.release();
34 auto compositorContext = QOpenGLCompositor::instance()->context();
38 static thread_local QOpenGLContext *context =
nullptr;
39 static thread_local QOffscreenSurface *surface =
nullptr;
42 context = compositorContext->thread()->isCurrentThread() ? compositorContext
43 : createContext(compositorContext);
48 surface =
new QOffscreenSurface(
nullptr, context);
49 surface->setFormat(context->format());
53 return context->makeCurrent(surface);
72 m_imageBuffer->unmap();
78 return m_fbo->texture();
87 qWarning() <<
"Failed to set current OpenGL context";
89 m_imageBuffer = std::make_unique<QImageVideoBuffer>(m_fbo->toImage(
false));
92 return *m_imageBuffer;
QImageVideoBuffer & ensureImageBuffer()
void unmap() override
Releases the memory mapped by the map() function.
QOpenGLVideoBuffer(std::unique_ptr< QOpenGLFramebufferObject > fbo)
quint64 textureHandle(QRhi &, int plane) override
~QOpenGLVideoBuffer() override
MapData map(QVideoFrame::MapMode mode) override
Maps the planes of a video buffer to memory.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE QOpenGLContext * createContext(QOpenGLContext *shareContext)
static bool setCurrentOpenGLContext()