diff options
| author | Artem Dyomin <[email protected]> | 2023-12-26 13:25:47 +0100 |
|---|---|---|
| committer | Artem Dyomin <[email protected]> | 2024-01-07 12:53:34 +0000 |
| commit | b96160191fc79514173b202bf6325553a798926d (patch) | |
| tree | 25d7824f5ffcff3554faa75111c6af4e05ebaf9f /src/opengl/qopenglcompositor.cpp | |
| parent | c4bd6ac4e5a0782d8771af1485a3b78733180785 (diff) | |
Add an opportunity to grab via QOpenGLCompositor to FBO
The feature is needed for screen capturing Qt multimedia in order
to have better performance of getting frames
(avoid recreating fbo). In QtMM, we're going to create FBO
and use it as a hw frame (or just render it to image on the first stage)
Pick-to: 6.7 6.6 6.5
Change-Id: Id08a86b76447faa0f341c6967c2dad8f34c84959
Reviewed-by: Laszlo Agocs <[email protected]>
Diffstat (limited to 'src/opengl/qopenglcompositor.cpp')
| -rw-r--r-- | src/opengl/qopenglcompositor.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/opengl/qopenglcompositor.cpp b/src/opengl/qopenglcompositor.cpp index b260445fece..6fda40c27c2 100644 --- a/src/opengl/qopenglcompositor.cpp +++ b/src/opengl/qopenglcompositor.cpp @@ -85,10 +85,21 @@ void QOpenGLCompositor::update() QImage QOpenGLCompositor::grab() { Q_ASSERT(m_context && m_targetWindow); + QOpenGLFramebufferObject fbo(m_nativeTargetGeometry.size()); + grabToFrameBufferObject(&fbo); + return fbo.toImage(); +} + +bool QOpenGLCompositor::grabToFrameBufferObject(QOpenGLFramebufferObject *fbo) +{ + Q_ASSERT(fbo); + if (fbo->size() != m_nativeTargetGeometry.size() + || fbo->format().textureTarget() != GL_TEXTURE_2D) + return false; + m_context->makeCurrent(m_targetWindow); - QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(m_nativeTargetGeometry.size())); - renderAll(fbo.data()); - return fbo->toImage(); + renderAll(fbo); + return true; } void QOpenGLCompositor::handleRenderAllRequest() |
