Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdmabuftextureimporter_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QDMABUFTEXTUREIMPORTER_P_H
4#define QDMABUFTEXTUREIMPORTER_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
18
19#include <QtMultimedia/qvideoframeformat.h>
20#include <QtMultimedia/private/qmultimedia_drm_support_p.h>
21#include <QtMultimedia/private/qtmultimediaglobal_p.h>
22
23#include <QtGui/qopenglfunctions.h>
24
25#include <QtCore/qsize.h>
26#include <QtCore/private/qexpected_p.h>
27
28#include <array>
29#include <memory>
30
31static_assert(QT_CONFIG(linux_dmabuf));
32
33QT_BEGIN_NAMESPACE
34
35class QRhi;
36class QOpenGLContext;
37
38namespace QtMultimediaPrivate {
39
48
49class Q_MULTIMEDIA_EXPORT QEglImageFunctions
50{
52
53public:
54 static const QEglImageFunctions &instance();
55
56 bool isValid() const;
57
59
60private:
62};
63
64class Q_MULTIMEDIA_EXPORT DmaBufEglContext
65{
66public:
67 explicit DmaBufEglContext(QRhi *rhi);
68
69 bool isValid() const { return m_valid; }
70 void invalidate() { m_valid = false; }
71
72 QOpenGLContext *glContext() const { return m_glContext; }
73 EGLDisplay eglDisplay() const { return m_eglDisplay; }
74
75private:
76 QOpenGLContext *m_glContext = nullptr;
77 EGLDisplay m_eglDisplay = nullptr;
78 bool m_valid = false;
79};
80
81class Q_MULTIMEDIA_EXPORT DmaBufTextureHandles final : public QVideoFrameTexturesHandles
82{
83public:
84 DmaBufTextureHandles(QRhi &rhi, QOpenGLContext *glContext, int nPlanes,
85 std::array<GLuint, 4> textures,
86 std::shared_ptr<void> parentKeepAlive = {});
87
88 ~DmaBufTextureHandles() override;
89
90 quint64 textureHandle(QRhi &, int plane) override { return m_textures[plane]; }
91
92private:
93 const std::shared_ptr<void> m_parentKeepAlive; // keep the backend alive
94 QRhi &m_rhi;
95 QOpenGLContext *const m_glContext;
96 const int m_nPlanes;
97 const std::array<GLuint, 4> m_textures;
98};
99
100// Severity of a failure to import DMABUF planes as GL textures.
101enum class FailureSeverity {
102 recoverable, // the caller may retry, e.g. with a different frame
103 unrecoverable, // the caller should permanently disable DMABUF import
104};
105
106Q_MULTIMEDIA_EXPORT q23::expected<QVideoFrameTexturesHandlesUPtr, FailureSeverity>
107importDmaBufTextures(QRhi &rhi, const DmaBufEglContext &eglContext, QSpan<const DmaBufPlane> planes,
108 QVideoFrameFormat::PixelFormat qtFormat, QSize frameSize,
109 std::shared_ptr<void> parentKeepAlive = {});
110
111} // namespace QtMultimediaPrivate
112
113QT_END_NAMESPACE
114
115#endif // QDMABUFTEXTUREIMPORTER_P_H
void glEGLImageTargetTexture2DOES(GLenum, GLeglImageOES) const
q23::expected< QVideoFrameTexturesHandlesUPtr, FailureSeverity > importDmaBufTextures(QRhi &rhi, const DmaBufEglContext &eglContext, QSpan< const DmaBufPlane > planes, QVideoFrameFormat::PixelFormat qtFormat, QSize frameSize, std::shared_ptr< void > parentKeepAlive)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)