13 : QtWayland::ServerBuffer(qimage.size(),format)
14 , m_integration(integration)
21 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
22 egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
24#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
26 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_A8;
27 egl_format = EGL_DRM_BUFFER_FORMAT_A8_MESA;
31 qWarning(
"DrmEglServerBuffer: unsupported format");
32 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
33 egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
36 EGLint imageAttribs[] = {
37 EGL_WIDTH, m_size.width(),
38 EGL_HEIGHT, m_size.height(),
39 EGL_DRM_BUFFER_FORMAT_MESA, egl_format,
40 EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA,
44 m_image = m_integration->eglCreateDRMImageMESA(imageAttribs);
47 if (!m_integration->eglExportDRMImageMESA(m_image, &m_name, &handle, &m_stride)) {
48 qWarning(
"DrmEglServerBuffer: Failed to export egl image");
51 m_texture =
new QOpenGLTexture(QOpenGLTexture::Target2D);
55 m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
57 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, qimage.width(), qimage.height(), GL_RGBA, GL_UNSIGNED_BYTE, qimage.constBits());
60 m_texture->setSize(m_size.width(), m_size.height());
65 auto *bufferResource = resourceMap().value(client);
66 if (!bufferResource) {
67 auto integrationResource = m_integration->resourceMap().value(client);
68 if (!integrationResource) {
69 qWarning(
"DrmEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the drm_egl interface");
72 struct ::wl_resource *drm_egl_integration_resource = integrationResource->handle;
73 Resource *resource = add(client, 1);
74 m_integration->send_server_buffer_created(drm_egl_integration_resource, resource->handle, m_name, m_size.width(), m_size.height(), m_stride, m_drm_format);
75 return resource->handle;
77 return bufferResource->handle;
104 Q_ASSERT(QGuiApplication::platformNativeInterface());
106 m_egl_display =
static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration(
"egldisplay"));
107 if (!m_egl_display) {
108 qWarning(
"Can't initialize drm egl server buffer integration. Missing egl display from platform plugin");
112 const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS);
113 if (!extensionString || !strstr(extensionString,
"EGL_KHR_image")) {
114 qWarning(
"Failed to initialize drm egl server buffer integration. There is no EGL_KHR_image extension.\n");
117 m_egl_create_image =
reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress(
"eglCreateImageKHR"));
118 m_egl_destroy_image =
reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress(
"eglDestroyImageKHR"));
119 if (!m_egl_create_image || !m_egl_destroy_image) {
120 qWarning(
"Failed to initialize drm egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR");
124 if (!extensionString || !strstr(extensionString,
"EGL_MESA_drm_image")) {
125 qWarning(
"Failed to initialize drm egl server buffer integration. There is no EGL_MESA_drm_image extension.\n");
129 m_egl_create_drm_image =
reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC>(eglGetProcAddress(
"eglCreateDRMImageMESA"));
130 m_egl_export_drm_image =
reinterpret_cast<PFNEGLEXPORTDRMIMAGEMESAPROC>(eglGetProcAddress(
"eglExportDRMImageMESA"));
131 if (!m_egl_create_drm_image || !m_egl_export_drm_image) {
132 qWarning(
"Failed to initialize drm egl server buffer integration. Could not find eglCreateDRMImageMESA or eglExportDRMImageMESA.\n");
136 m_gl_egl_image_target_texture_2d =
reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress(
"glEGLImageTargetTexture2DOES"));
137 if (!m_gl_egl_image_target_texture_2d) {
138 qWarning(
"Failed to initialize drm egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n");
142 QtWaylandServer::qt_drm_egl_server_buffer::init(compositor->display(), 1);