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
qhwvideobuffer_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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
4#ifndef QHWVIDEOBUFFER_P_H
5#define QHWVIDEOBUFFER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
19#include "qvideoframe.h"
20
21#include <QtGui/qmatrix4x4.h>
22
23QT_BEGIN_NAMESPACE
24
25class QRhi;
26class QRhiTexture;
27class QVideoFrame;
28
29/**
30 * @brief QVideoFrameTexturesHandles is the base class, providing texture handles for frame planes.
31 * Instances of the class may own textures, share ownership, or refer to inner hw textures
32 * of QVideoFrame. Referencing to inner frame's textures without shared ownership is
33 * not recommended, we strive to get around it; if texture are referencing,
34 * the source frame is kept in the QVideoFrameTextures instance via its
35 * constructor-provided source frame.
36 */
37class Q_MULTIMEDIA_EXPORT QVideoFrameTexturesHandles
38{
39public:
40 virtual ~QVideoFrameTexturesHandles();
41
42 virtual quint64 textureHandle(QRhi &, int /*plane*/) { return 0; }
43};
44using QVideoFrameTexturesHandlesUPtr = std::unique_ptr<QVideoFrameTexturesHandles>;
45
46/**
47 * @brief QVideoFrameTextures is the base class representing an abstraction layer
48 * between QVideoFrame's texture(s) and rhi's plane textures.
49 * QVideoFrameTextures must own the inner rhi textures or
50 * share ownership. QVideoFrameTextures instances are propagated to
51 * QVideoFrameTexturesPool, where their lifetime is managed
52 * according to results of QRhi::currentFrameSlot upon rendering.
53 *
54 */
55class Q_MULTIMEDIA_EXPORT QVideoFrameTextures
56{
57public:
58 explicit QVideoFrameTextures(QVideoFrame sourceFrame = {});
59 virtual ~QVideoFrameTextures();
60 virtual QRhiTexture *texture(uint plane) const = 0;
61
62 /**
63 * @brief The virtual method should be invoked after QRhi::endFrame to unmap and free
64 * internal resources that are not needed anymore.
65 */
66 virtual void onFrameEndInvoked() { }
67
68 virtual QVideoFrameTexturesHandlesUPtr takeHandles() { return nullptr; }
69
70private:
71 QVideoFrame m_sourceFrame;
72};
73using QVideoFrameTexturesUPtr = std::unique_ptr<QVideoFrameTextures>;
74
75class Q_MULTIMEDIA_EXPORT QHwVideoBuffer : public QAbstractVideoBuffer,
76 public QVideoFrameTexturesHandles
77{
78public:
79 QHwVideoBuffer();
80
81 ~QHwVideoBuffer() override;
82
83 // returns rhi in the current thread that has been associated with the frame
84 // during texture mapping or texture converter initialization.
85 virtual QRhi *associatedCurrentThreadRhi() const { return nullptr; }
86
87 QVideoFrameFormat format() const final
88 {
89 // invalid by design: we have to go through QVideoFramePrivate::createFrame
90 return {};
91 }
92
93 virtual QMatrix4x4 externalTextureMatrix() const { return {}; }
94
95 virtual QVideoFrameTexturesUPtr mapTextures(QRhi &rhi,
96 QVideoFrameTexturesUPtr & /*oldTextures*/)
97 {
98 return mapTextures(rhi);
99 }
100 virtual QVideoFrameTexturesUPtr mapTextures(QRhi &) { return nullptr; }
101
102 virtual void initTextureConverter(QRhi &) { }
103
104 virtual bool isDmaBuf() const { return false; }
105};
106
107QT_END_NAMESPACE
108
109#endif // QHWVIDEOBUFFER_P_H
QVideoFrameTexturesHandles is the base class, providing texture handles for frame planes....
QVideoFrameTextures is the base class representing an abstraction layer between QVideoFrame's texture...
static bool dmaModifierIsNotSupportedByDisplay(const DmaBufPlane &plane, EGLDisplay eglDisplay)
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)