31void QEglFSOpenWFDIntegration::platformInit()
33 QEglFSDeviceIntegration::platformInit();
35 mNativeDisplay = EGL_DEFAULT_DISPLAY;
38 WFDint numDevs = wfdEnumerateDevices(
nullptr, 0,
nullptr);
42 wfdEnumerateDevices(devIds, numDevs,
nullptr);
45 WFDint dev_attribs[3] = {WFD_DEVICE_CLIENT_TYPE,
46 WFD_CLIENT_ID_CLUSTER,
50 WFDint clientType = qgetenv(
"QT_OPENWFD_CLIENT_ID").toInt(&ok, 16);
53 dev_attribs[1] = clientType;
55 mDevice = wfdCreateDevice(WFD_DEFAULT_DEVICE_ID, dev_attribs);
57 if (WFD_INVALID_HANDLE == mDevice)
58 qFatal(
"Failed to create wfd device");
62 WFDint numPorts = wfdEnumeratePorts(mDevice,
nullptr, 0,
nullptr);
63 wfdEnumeratePorts(mDevice, portIds, numPorts,
nullptr);
66 mPort = wfdCreatePort(mDevice, portIds[0],
nullptr);
68 if (WFD_INVALID_HANDLE == mPort)
69 qFatal(
"Failed to create wfd port");
72 WFDint numPortModes = wfdGetPortModes(mDevice, mPort,
nullptr, 0);
74 wfdGetPortModes(mDevice, mPort, portModes, numPortModes);
77 mScreenSize.setWidth(wfdGetPortModeAttribi(mDevice, mPort, portModes[0], WFD_PORT_MODE_WIDTH));
78 mScreenSize.setHeight(wfdGetPortModeAttribi(mDevice, mPort, portModes[0], WFD_PORT_MODE_HEIGHT));
81 wfdSetPortMode(mDevice, mPort, portModes[0]);
82 WFDErrorCode eError = wfdGetError(mDevice);
83 if (WFD_ERROR_NONE != eError)
84 qFatal(
"Failed to set wfd port mode");
87 wfdSetPortAttribi(mDevice, mPort, WFD_PORT_POWER_MODE, WFD_POWER_MODE_ON);
88 eError = wfdGetError(mDevice);
89 if (WFD_ERROR_NONE != eError)
90 qFatal(
"Failed to power on wfd port");
103EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow *window,
105 const QSurfaceFormat &format)
111 WFDint numPipelines = wfdEnumeratePipelines(mDevice,
nullptr, 0,
nullptr);
114 wfdEnumeratePipelines(mDevice, pipelineIds, numPipelines,
nullptr);
117 WFDint pipelineId = qgetenv(
"QT_OPENWFD_PIPELINE_ID").toInt(&ok);
120 pipelineId = pipelineIds[0];
122 mPipeline = wfdCreatePipeline(mDevice, pipelineId,
nullptr);
123 if (WFD_INVALID_HANDLE == mPipeline)
124 qFatal(
"Failed to create wfd pipeline");
126 wfdSetPipelineAttribi(mDevice, mPipeline, WFD_PIPELINE_TRANSPARENCY_ENABLE,
127 (WFD_TRANSPARENCY_SOURCE_ALPHA|WFD_TRANSPARENCY_GLOBAL_ALPHA));
129 WFDErrorCode eError = wfdGetError(mDevice);
130 if (WFD_ERROR_NONE != eError)
131 qFatal(
"Failed to set WFD_PIPELINE_TRANSPARENCY_ENABLE");
133 wfdSetPipelineAttribi(mDevice, mPipeline, WFD_PIPELINE_GLOBAL_ALPHA, 255);
134 eError = wfdGetError(mDevice);
135 if (WFD_ERROR_NONE != eError)
136 qFatal(
"Failed to set WFD_PIPELINE_GLOBAL_ALPHA");
138 wfdBindPipelineToPort(mDevice, mPort, mPipeline);
139 eError = wfdGetError(mDevice);
140 if (WFD_ERROR_NONE != eError)
141 qFatal(
"Failed to bind port to pipeline");
150 wfdCreateWFDEGLImages(mDevice, mScreenSize.width(), mScreenSize.height(),
151 WFD_FORMAT_RGBA8888, WFD_USAGE_OPENGL_ES2 | WFD_USAGE_DISPLAY,
152 1, &(eglImageHandles[i]), 0);
154 wfdEglImages[i] = (WFD_EGLImageType *)(eglImageHandles[i]);
155 if (WFD_INVALID_HANDLE == wfdEglImages[i])
156 qFatal(
"Failed to create WDFEGLImages");
158 source[i] = wfdCreateSourceFromImage(mDevice, mPipeline, eglImageHandles[i],
nullptr);
159 if (WFD_INVALID_HANDLE == source[i])
160 qFatal(
"Failed to create source from EGLImage");
164 wfdDeviceCommit(mDevice, WFD_COMMIT_ENTIRE_PORT, mPort);
165 eError = wfdGetError(mDevice);
166 if (WFD_ERROR_NONE != eError)
167 qFatal(
"Failed to commit port");
170 wfd_window_t* nativeWindow = (wfd_window_t*)malloc(
sizeof(wfd_window_t));
171 if (
nullptr == nativeWindow)
172 qFatal(
"Failed to allocate memory for native window");
174 nativeWindow->dev = mDevice;
175 nativeWindow->port = mPort;
176 nativeWindow->pipeline = mPipeline;
180 nativeWindow->buffers[i].image = wfdEglImages[i];
181 nativeWindow->buffers[i].source = source[i];
183 return (EGLNativeWindowType)nativeWindow;
186QSurfaceFormat QEglFSOpenWFDIntegration::surfaceFormatFor(
const QSurfaceFormat &inputFormat)
const
188 QSurfaceFormat format = inputFormat;
189 format.setRedBufferSize(8);
190 format.setGreenBufferSize(8);
191 format.setBlueBufferSize(8);
192 format.setAlphaBufferSize(8);