12 : QtWayland::ServerBuffer(qimage.size(),format)
13 , m_integration(integration)
20 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
21 egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
23#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
25 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_A8;
26 egl_format = EGL_DRM_BUFFER_FORMAT_A8_MESA;
30 qWarning(
"DrmEglServerBuffer: unsupported format");
31 m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
32 egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
35 EGLint imageAttribs[] = {
36 EGL_WIDTH, m_size.width(),
37 EGL_HEIGHT, m_size.height(),
38 EGL_DRM_BUFFER_FORMAT_MESA, egl_format,
39 EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA,
43 m_image = m_integration->eglCreateDRMImageMESA(imageAttribs);
46 if (!m_integration->eglExportDRMImageMESA(m_image, &m_name, &handle, &m_stride)) {
47 qWarning(
"DrmEglServerBuffer: Failed to export egl image");
50 m_texture =
new QOpenGLTexture(QOpenGLTexture::Target2D);
54 m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
56 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, qimage.width(), qimage.height(), GL_RGBA, GL_UNSIGNED_BYTE, qimage.constBits());
59 m_texture->setSize(m_size.width(), m_size.height());
64 auto *bufferResource = resourceMap().value(client);
65 if (!bufferResource) {
66 auto integrationResource = m_integration->resourceMap().value(client);
67 if (!integrationResource) {
68 qWarning(
"DrmEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the drm_egl interface");
71 struct ::wl_resource *drm_egl_integration_resource = integrationResource->handle;
72 Resource *resource = add(client, 1);
73 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);
74 return resource->handle;
76 return bufferResource->handle;
103 Q_ASSERT(QGuiApplication::platformNativeInterface());
105 m_egl_display =
static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration(
"egldisplay"));
106 if (!m_egl_display) {
107 qWarning(
"Can't initialize drm egl server buffer integration. Missing egl display from platform plugin");
111 const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS);
112 if (!extensionString || !strstr(extensionString,
"EGL_KHR_image")) {
113 qWarning(
"Failed to initialize drm egl server buffer integration. There is no EGL_KHR_image extension.\n");
116 m_egl_create_image =
reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress(
"eglCreateImageKHR"));
117 m_egl_destroy_image =
reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress(
"eglDestroyImageKHR"));
118 if (!m_egl_create_image || !m_egl_destroy_image) {
119 qWarning(
"Failed to initialize drm egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR");
123 if (!extensionString || !strstr(extensionString,
"EGL_MESA_drm_image")) {
124 qWarning(
"Failed to initialize drm egl server buffer integration. There is no EGL_MESA_drm_image extension.\n");
128 m_egl_create_drm_image =
reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC>(eglGetProcAddress(
"eglCreateDRMImageMESA"));
129 m_egl_export_drm_image =
reinterpret_cast<PFNEGLEXPORTDRMIMAGEMESAPROC>(eglGetProcAddress(
"eglExportDRMImageMESA"));
130 if (!m_egl_create_drm_image || !m_egl_export_drm_image) {
131 qWarning(
"Failed to initialize drm egl server buffer integration. Could not find eglCreateDRMImageMESA or eglExportDRMImageMESA.\n");
135 m_gl_egl_image_target_texture_2d =
reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress(
"glEGLImageTargetTexture2DOES"));
136 if (!m_gl_egl_image_target_texture_2d) {
137 qWarning(
"Failed to initialize drm egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n");
141 QtWaylandServer::qt_drm_egl_server_buffer::init(compositor->display(), 1);