11#define MAX_NUM_OF_WFD_BUFFERS 3
12#define MAX_NUM_OF_WFD_DEVICES 4
13#define MAX_NUM_OF_WFD_PIPELINES 16
14#define MAX_NUM_OF_WFD_PORT_MODES 64
15#define MAX_NUM_OF_WFD_PORTS 4
34 mNativeDisplay = EGL_DEFAULT_DISPLAY;
37 WFDint numDevs = wfdEnumerateDevices(
nullptr, 0,
nullptr);
41 wfdEnumerateDevices(devIds, numDevs,
nullptr);
44 WFDint dev_attribs[3] = {WFD_DEVICE_CLIENT_TYPE,
45 WFD_CLIENT_ID_CLUSTER,
49 WFDint clientType =
qgetenv(
"QT_OPENWFD_CLIENT_ID").
toInt(&
ok, 16);
52 dev_attribs[1] = clientType;
54 mDevice = wfdCreateDevice(WFD_DEFAULT_DEVICE_ID, dev_attribs);
56 if (WFD_INVALID_HANDLE == mDevice)
57 qFatal(
"Failed to create wfd device");
61 WFDint numPorts = wfdEnumeratePorts(mDevice,
nullptr, 0,
nullptr);
62 wfdEnumeratePorts(mDevice, portIds, numPorts,
nullptr);
65 mPort = wfdCreatePort(mDevice, portIds[0],
nullptr);
67 if (WFD_INVALID_HANDLE == mPort)
68 qFatal(
"Failed to create wfd port");
71 WFDint numPortModes = wfdGetPortModes(mDevice, mPort,
nullptr, 0);
73 wfdGetPortModes(mDevice, mPort, portModes, numPortModes);
76 mScreenSize.
setWidth(wfdGetPortModeAttribi(mDevice, mPort, portModes[0], WFD_PORT_MODE_WIDTH));
77 mScreenSize.
setHeight(wfdGetPortModeAttribi(mDevice, mPort, portModes[0], WFD_PORT_MODE_HEIGHT));
80 wfdSetPortMode(mDevice, mPort, portModes[0]);
81 WFDErrorCode eError = wfdGetError(mDevice);
82 if (WFD_ERROR_NONE != eError)
83 qFatal(
"Failed to set wfd port mode");
86 wfdSetPortAttribi(mDevice, mPort, WFD_PORT_POWER_MODE, WFD_POWER_MODE_ON);
87 eError = wfdGetError(mDevice);
88 if (WFD_ERROR_NONE != eError)
89 qFatal(
"Failed to power on wfd port");
99 return mNativeDisplay;
110 WFDint numPipelines = wfdEnumeratePipelines(mDevice,
nullptr, 0,
nullptr);
113 wfdEnumeratePipelines(mDevice, pipelineIds, numPipelines,
nullptr);
119 pipelineId = pipelineIds[0];
121 mPipeline = wfdCreatePipeline(mDevice, pipelineId,
nullptr);
122 if (WFD_INVALID_HANDLE == mPipeline)
123 qFatal(
"Failed to create wfd pipeline");
125 wfdSetPipelineAttribi(mDevice, mPipeline, WFD_PIPELINE_TRANSPARENCY_ENABLE,
126 (WFD_TRANSPARENCY_SOURCE_ALPHA|WFD_TRANSPARENCY_GLOBAL_ALPHA));
128 WFDErrorCode eError = wfdGetError(mDevice);
129 if (WFD_ERROR_NONE != eError)
130 qFatal(
"Failed to set WFD_PIPELINE_TRANSPARENCY_ENABLE");
132 wfdSetPipelineAttribi(mDevice, mPipeline, WFD_PIPELINE_GLOBAL_ALPHA, 255);
133 eError = wfdGetError(mDevice);
134 if (WFD_ERROR_NONE != eError)
135 qFatal(
"Failed to set WFD_PIPELINE_GLOBAL_ALPHA");
137 wfdBindPipelineToPort(mDevice, mPort, mPipeline);
138 eError = wfdGetError(mDevice);
139 if (WFD_ERROR_NONE != eError)
140 qFatal(
"Failed to bind port to pipeline");
149 wfdCreateWFDEGLImages(mDevice, mScreenSize.
width(), mScreenSize.
height(),
150 WFD_FORMAT_RGBA8888, WFD_USAGE_OPENGL_ES2 | WFD_USAGE_DISPLAY,
151 1, &(eglImageHandles[
i]), 0);
153 wfdEglImages[
i] = (WFD_EGLImageType *)(eglImageHandles[
i]);
154 if (WFD_INVALID_HANDLE == wfdEglImages[
i])
155 qFatal(
"Failed to create WDFEGLImages");
157 source[
i] = wfdCreateSourceFromImage(mDevice, mPipeline, eglImageHandles[
i],
nullptr);
158 if (WFD_INVALID_HANDLE ==
source[
i])
159 qFatal(
"Failed to create source from EGLImage");
163 wfdDeviceCommit(mDevice, WFD_COMMIT_ENTIRE_PORT, mPort);
164 eError = wfdGetError(mDevice);
165 if (WFD_ERROR_NONE != eError)
166 qFatal(
"Failed to commit port");
171 qFatal(
"Failed to allocate memory for native window");
189 format.setGreenBufferSize(8);
190 format.setBlueBufferSize(8);
191 format.setAlphaBufferSize(8);
197 wfdDestroyPipeline(mDevice, mPipeline);
203 wfdDestroyPort(mDevice, mPort);
204 WFDErrorCode
error = wfdDestroyDevice(mDevice);
205 if (
error != WFD_ERROR_NONE)
206 qWarning() <<
"Failed to release wfd device! Error = " <<
error;
int toInt(bool *ok=nullptr, int base=10) const
Returns the byte array converted to an int using base base, which is ten by default.
virtual void platformInit()
QSize screenSize() const override
virtual QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const
void platformDestroy() override
void platformInit() override
EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) override
EGLNativeDisplayType platformDisplay() const override
void destroyNativeWindow(EGLNativeWindowType window) override
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define MAX_NUM_OF_WFD_DEVICES
#define MAX_NUM_OF_WFD_PORT_MODES
#define MAX_NUM_OF_WFD_PORTS
#define MAX_NUM_OF_WFD_PIPELINES
#define MAX_NUM_OF_WFD_BUFFERS
struct wfd_buffer wfd_buffer_t
struct wfd_window wfd_window_t
GLuint const GLuint * buffers
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QWindowsDirect2DWindow * nativeWindow(QWindow *window)