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
evrd3dpresentengine_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 EVRD3DPRESENTENGINE_H
5#define EVRD3DPRESENTENGINE_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 <QMutex>
19#include <QSize>
20#include <QVideoFrameFormat>
21#include <private/qcomptr_p.h>
22#include <qpointer.h>
23
24#include <d3d9.h>
25
26struct IDirect3D9Ex;
27struct IDirect3DDevice9Ex;
28struct IDirect3DDeviceManager9;
29struct IDirect3DSurface9;
30struct IDirect3DTexture9;
31struct IMFSample;
32struct IMFMediaType;
33
35class QVideoFrame;
36class QVideoSink;
38
39// Randomly generated GUIDs
41{ 0xb0bb83cc, 0xf10f, 0x4e2e, { 0xaa, 0x2b, 0x29, 0xea, 0x5e, 0x92, 0xef, 0x85 } };
42
43#if QT_CONFIG(opengl)
44# include <qopengl.h>
45#endif
46
48
49#ifdef MAYBE_ANGLE
50
51class OpenGLResources;
52
53class EGLWrapper
54{
55 Q_DISABLE_COPY(EGLWrapper)
56public:
57 EGLWrapper();
58
59 __eglMustCastToProperFunctionPointerType getProcAddress(const char *procname);
60 EGLSurface createPbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
61 EGLBoolean destroySurface(EGLDisplay dpy, EGLSurface surface);
62 EGLBoolean bindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
63 EGLBoolean releaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
64
65private:
66 typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP EglGetProcAddress)(const char *procname);
67 typedef EGLSurface (EGLAPIENTRYP EglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
68 typedef EGLBoolean (EGLAPIENTRYP EglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
69 typedef EGLBoolean (EGLAPIENTRYP EglBindTexImage)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
70 typedef EGLBoolean (EGLAPIENTRYP EglReleaseTexImage)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
71
72 EglGetProcAddress m_eglGetProcAddress;
73 EglCreatePbufferSurface m_eglCreatePbufferSurface;
74 EglDestroySurface m_eglDestroySurface;
75 EglBindTexImage m_eglBindTexImage;
76 EglReleaseTexImage m_eglReleaseTexImage;
77};
78
79#endif // MAYBE_ANGLE
80
81#if QT_CONFIG(opengl)
82
83struct WglNvDxInterop {
84 HANDLE (WINAPI* wglDXOpenDeviceNV) (void* dxDevice);
85 BOOL (WINAPI* wglDXCloseDeviceNV) (HANDLE hDevice);
86 HANDLE (WINAPI* wglDXRegisterObjectNV) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
87 BOOL (WINAPI* wglDXSetResourceShareHandleNV) (void *dxResource, HANDLE shareHandle);
88 BOOL (WINAPI* wglDXLockObjectsNV) (HANDLE hDevice, GLint count, HANDLE *hObjects);
89 BOOL (WINAPI* wglDXUnlockObjectsNV) (HANDLE hDevice, GLint count, HANDLE *hObjects);
90 BOOL (WINAPI* wglDXUnregisterObjectNV) (HANDLE hDevice, HANDLE hObject);
91
92 static const int WGL_ACCESS_READ_ONLY_NV = 0;
93};
94
95#endif
96
98{
99 Q_DISABLE_COPY(D3DPresentEngine)
100public:
102 virtual ~D3DPresentEngine();
103
104 bool isValid() const;
105
106 HRESULT getService(REFGUID guidService, REFIID riid, void** ppv);
107 HRESULT checkFormat(D3DFORMAT format);
108 UINT refreshRate() const { return m_displayMode.RefreshRate; }
109
110 HRESULT createVideoSamples(IMFMediaType *format, QList<ComPtr<IMFSample>> &videoSampleQueue,
112 QVideoFrameFormat videoSurfaceFormat() const { return m_surfaceFormat; }
113 QVideoFrame makeVideoFrame(const ComPtr<IMFSample> &sample);
114
115 void releaseResources();
116 void setSink(QVideoSink *sink);
117
118private:
119 static const int PRESENTER_BUFFER_COUNT = 3;
120
121 HRESULT initializeD3D();
122 HRESULT createD3DDevice();
123
124 std::pair<IMFSample *, HANDLE> m_sampleTextureHandle[PRESENTER_BUFFER_COUNT] = {};
125
126 UINT m_deviceResetToken;
127 D3DDISPLAYMODE m_displayMode;
128
129 ComPtr<IDirect3D9Ex> m_D3D9;
130 ComPtr<IDirect3DDevice9Ex> m_device;
131 ComPtr<IDirect3DDeviceManager9> m_devices;
132
133 QVideoFrameFormat m_surfaceFormat;
134
135 QPointer<QVideoSink> m_sink;
136 bool m_useTextureRendering = false;
137#if QT_CONFIG(opengl)
138 WglNvDxInterop m_wglNvDxInterop;
139#endif
140
141#ifdef MAYBE_ANGLE
142 unsigned int updateTexture(IDirect3DSurface9 *src);
143
144 OpenGLResources *m_glResources;
145 IDirect3DTexture9 *m_texture;
146#endif
147
148 friend class IMFSampleVideoBuffer;
149};
150
152
153#endif // EVRD3DPRESENTENGINE_H
void setSink(QVideoSink *sink)
HRESULT createVideoSamples(IMFMediaType *format, QList< ComPtr< IMFSample > > &videoSampleQueue, QSize frameSize)
QVideoFrameFormat videoSurfaceFormat() const
HRESULT getService(REFGUID guidService, REFIID riid, void **ppv)
D3DPresentEngine(QVideoSink *sink)
HRESULT checkFormat(D3DFORMAT format)
QVideoFrame makeVideoFrame(const ComPtr< IMFSample > &sample)
Definition qlist.h:75
\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
static QT_END_NAMESPACE const GUID MFSamplePresenter_SampleCounter
Combined button and popup list for selecting options.
void * HANDLE
EGLConfig config
typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC)(EGLint max_devices
typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
void const EGLint * attrib_list
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLenum GLenum GLsizei count
GLenum src
GLenum GLuint buffer
GLenum type
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLenum access
GLuint name
GLint GLsizei GLsizei GLenum format
const void * getProcAddress
GLsizei GLenum GLboolean sink
static constexpr QSize frameSize(const T &frame)
#define GLuint
IUIViewSettingsInterop __RPC__in REFIID riid
IUIViewSettingsInterop __RPC__in REFIID __RPC__deref_out_opt void ** ppv
long HRESULT