Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qvideowindow_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QVIDEOWINDOW_P_H
5#define QVIDEOWINDOW_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
18#include <QWindow>
19#include <QOffscreenSurface>
20#include <qtextlayout.h>
21#include <rhi/qrhi.h>
22#include <qvideoframe.h>
23#include <private/qplatformvideosink_p.h>
24#include <private/qvideotexturehelper_p.h>
25#include <qbackingstore.h>
26
28
29class QVideoWindow;
30
32public:
35 bool canRender() const { return m_useRhi; }
36
37 QRhi *rhi() const { return m_rhi.get(); }
38
39 void init();
40 void render();
41
42 void initRhi();
43
44 void resizeSwapChain();
45 void releaseSwapChain();
46
49
51
52 QVideoWindow *q = nullptr;
54
56
57#if QT_CONFIG(opengl)
58 std::unique_ptr<QOffscreenSurface> m_fallbackSurface;
59#endif
60 std::unique_ptr<QRhi> m_rhi;
61 std::unique_ptr<QRhiSwapChain> m_swapChain;
62 std::unique_ptr<QRhiRenderPassDescriptor> m_renderPass;
63
64 std::unique_ptr<QRhiBuffer> m_vertexBuf;
65 bool m_vertexBufReady = false;
66 std::unique_ptr<QRhiBuffer> m_uniformBuf;
67 std::unique_ptr<QVideoFrameTextures> m_frameTextures;
68 std::unique_ptr<QRhiSampler> m_textureSampler;
69 std::unique_ptr<QRhiShaderResourceBindings> m_shaderResourceBindings;
70 std::unique_ptr<QRhiGraphicsPipeline> m_graphicsPipeline;
71
72 std::unique_ptr<QRhiTexture> m_subtitleTexture;
73 std::unique_ptr<QRhiShaderResourceBindings> m_subtitleResourceBindings;
74 std::unique_ptr<QRhiGraphicsPipeline> m_subtitlePipeline;
75 std::unique_ptr<QRhiBuffer> m_subtitleUniformBuf;
76
77 std::unique_ptr<QVideoSink> m_sink;
81
82 enum { NVideoFrameSlots = 4 };
84
85 bool initialized = false;
86 bool isExposed = false;
87 bool m_useRhi = true;
88 bool m_hasSwapChain = false;
89 bool m_texturesDirty = true;
90 bool m_subtitleDirty = false;
91 bool m_hasSubtitle = false;
93};
94
95class Q_MULTIMEDIA_EXPORT QVideoWindow : public QWindow
96{
98public:
99 explicit QVideoWindow(QScreen *screen = nullptr);
100 explicit QVideoWindow(QWindow *parent);
102
103 Q_INVOKABLE QVideoSink *videoSink() const;
104
105 Qt::AspectRatioMode aspectRatioMode() const;
106
107public Q_SLOTS:
108 void setAspectRatioMode(Qt::AspectRatioMode mode);
109
112
113protected:
114 bool event(QEvent *e) override;
115 void resizeEvent(QResizeEvent *) override;
116
117private Q_SLOTS:
118 void setVideoFrame(const QVideoFrame &frame);
119
120private:
122 std::unique_ptr<QVideoWindowPrivate> d;
123};
124
126
127#endif
The QBackingStore class provides a drawing area for QWindow.
\inmodule QtCore
Definition qcoreevent.h:45
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
\inmodule QtGui
Definition qrhi.h:1270
\inmodule QtGui
Definition qrhi.h:1731
\inmodule QtGui
Definition qrhi.h:1214
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
Definition qrhi.h:1806
@ Null
Definition qrhi.h:1807
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
\inmodule QtCore
Definition qsize.h:25
The QVideoFrameFormat class specifies the stream format of a video presentation surface.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
The QVideoSink class represents a generic sink for video data.
Definition qvideosink.h:22
bool canRender() const
void updateSubtitle(QRhiResourceUpdateBatch *rub, const QSize &frameSize)
std::unique_ptr< QRhiShaderResourceBindings > m_shaderResourceBindings
std::unique_ptr< QVideoFrameTextures > m_frameTextures
QVideoFrameFormat format
std::unique_ptr< QRhiShaderResourceBindings > m_subtitleResourceBindings
Qt::AspectRatioMode aspectRatioMode
QVideoTextureHelper::SubtitleLayout m_subtitleLayout
std::unique_ptr< QRhiGraphicsPipeline > m_subtitlePipeline
std::unique_ptr< QRhiSwapChain > m_swapChain
std::unique_ptr< QRhiBuffer > m_uniformBuf
std::unique_ptr< QVideoSink > m_sink
QVideoFrame m_currentFrame
QVideoFrame m_videoFrameSlots[NVideoFrameSlots]
std::unique_ptr< QRhiRenderPassDescriptor > m_renderPass
std::unique_ptr< QRhiGraphicsPipeline > m_graphicsPipeline
QRhi * rhi() const
std::unique_ptr< QRhi > m_rhi
QRhi::Implementation m_graphicsApi
std::unique_ptr< QRhiTexture > m_subtitleTexture
QBackingStore * backingStore
void setupGraphicsPipeline(QRhiGraphicsPipeline *pipeline, QRhiShaderResourceBindings *bindings, const QVideoFrameFormat &fmt)
QVideoWindowPrivate(QVideoWindow *q)
std::unique_ptr< QRhiBuffer > m_subtitleUniformBuf
std::unique_ptr< QRhiBuffer > m_vertexBuf
std::unique_ptr< QRhiSampler > m_textureSampler
void updateTextures(QRhiResourceUpdateBatch *rub)
void aspectRatioModeChanged(Qt::AspectRatioMode mode)
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
AspectRatioMode
@ KeepAspectRatio
GLenum mode
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
static constexpr QSize frameSize(const T &frame)
QScreen * screen
[1]
Definition main.cpp:29
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
QVideoFrameFormat::PixelFormat fmt
QFrame frame
[0]