30void QEglFSOpenWFDIntegration::platformInit()
32 QEglFSDeviceIntegration::platformInit();
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");
102EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow *window,
104 const QSurfaceFormat &format)
110 WFDint numPipelines = wfdEnumeratePipelines(mDevice,
nullptr, 0,
nullptr);
113 wfdEnumeratePipelines(mDevice, pipelineIds, numPipelines,
nullptr);
116 WFDint pipelineId = qgetenv(
"QT_OPENWFD_PIPELINE_ID").toInt(&ok);
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");
169 wfd_window_t* nativeWindow = (wfd_window_t*)malloc(
sizeof(wfd_window_t));
170 if (
nullptr == nativeWindow)
171 qFatal(
"Failed to allocate memory for native window");
173 nativeWindow->dev = mDevice;
174 nativeWindow->port = mPort;
175 nativeWindow->pipeline = mPipeline;
179 nativeWindow->buffers[i].image = wfdEglImages[i];
180 nativeWindow->buffers[i].source = source[i];
182 return (EGLNativeWindowType)nativeWindow;
185QSurfaceFormat QEglFSOpenWFDIntegration::surfaceFormatFor(
const QSurfaceFormat &inputFormat)
const
187 QSurfaceFormat format = inputFormat;
188 format.setRedBufferSize(8);
189 format.setGreenBufferSize(8);
190 format.setBlueBufferSize(8);
191 format.setAlphaBufferSize(8);