Changeset View
Changeset View
Standalone View
Standalone View
platformsupport/scenes/opengl/egl_dmabuf.cpp
Show First 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | |||||
213 | void EglDmabufBuffer::removeImages() | 213 | void EglDmabufBuffer::removeImages() | ||
214 | { | 214 | { | ||
215 | for (auto image : m_images) { | 215 | for (auto image : m_images) { | ||
216 | eglDestroyImageKHR(m_interfaceImpl->m_backend->eglDisplay(), image); | 216 | eglDestroyImageKHR(m_interfaceImpl->m_backend->eglDisplay(), image); | ||
217 | } | 217 | } | ||
218 | m_images.clear(); | 218 | m_images.clear(); | ||
219 | } | 219 | } | ||
220 | 220 | | |||
221 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | 221 | using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane; | ||
222 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | 222 | using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags; | ||
223 | 223 | | |||
224 | EGLImage EglDmabuf::createImage(const QVector<Plane> &planes, | 224 | EGLImage EglDmabuf::createImage(const QVector<Plane> &planes, | ||
225 | uint32_t format, | 225 | uint32_t format, | ||
226 | const QSize &size) | 226 | const QSize &size) | ||
227 | { | 227 | { | ||
228 | const bool hasModifiers = eglQueryDmaBufModifiersEXT != nullptr && | 228 | const bool hasModifiers = eglQueryDmaBufModifiersEXT != nullptr && | ||
229 | planes[0].modifier != DRM_FORMAT_MOD_INVALID; | 229 | planes[0].modifier != DRM_FORMAT_MOD_INVALID; | ||
230 | 230 | | |||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 287 | EGLImage image = eglCreateImageKHR(m_backend->eglDisplay(), | |||
291 | attribs.data()); | 291 | attribs.data()); | ||
292 | if (image == EGL_NO_IMAGE_KHR) { | 292 | if (image == EGL_NO_IMAGE_KHR) { | ||
293 | return nullptr; | 293 | return nullptr; | ||
294 | } | 294 | } | ||
295 | 295 | | |||
296 | return image; | 296 | return image; | ||
297 | } | 297 | } | ||
298 | 298 | | |||
299 | KWayland::Server::LinuxDmabufUnstableV1Buffer* EglDmabuf::importBuffer(const QVector<Plane> &planes, | 299 | KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::importBuffer(const QVector<Plane> &planes, | ||
300 | uint32_t format, | 300 | uint32_t format, | ||
301 | const QSize &size, | 301 | const QSize &size, | ||
302 | Flags flags) | 302 | Flags flags) | ||
303 | { | 303 | { | ||
304 | Q_ASSERT(planes.count() > 0); | 304 | Q_ASSERT(planes.count() > 0); | ||
305 | 305 | | |||
306 | // Try first to import as a single image | 306 | // Try first to import as a single image | ||
307 | if (auto *img = createImage(planes, format, size)) { | 307 | if (auto *img = createImage(planes, format, size)) { | ||
308 | return new EglDmabufBuffer(img, planes, format, size, flags, this); | 308 | return new EglDmabufBuffer(img, planes, format, size, flags, this); | ||
309 | } | 309 | } | ||
310 | 310 | | |||
311 | // TODO: to enable this we must be able to store multiple textures per window pixmap | 311 | // TODO: to enable this we must be able to store multiple textures per window pixmap | ||
312 | // and when on window draw do yuv to rgb transformation per shader (see Weston) | 312 | // and when on window draw do yuv to rgb transformation per shader (see Weston) | ||
313 | // // not a single image, try yuv import | 313 | // // not a single image, try yuv import | ||
314 | // return yuvImport(planes, format, size, flags); | 314 | // return yuvImport(planes, format, size, flags); | ||
315 | 315 | | |||
316 | return nullptr; | 316 | return nullptr; | ||
317 | } | 317 | } | ||
318 | 318 | | |||
319 | KWayland::Server::LinuxDmabufUnstableV1Buffer* EglDmabuf::yuvImport(const QVector<Plane> &planes, | 319 | KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::yuvImport(const QVector<Plane> &planes, | ||
320 | uint32_t format, | 320 | uint32_t format, | ||
321 | const QSize &size, | 321 | const QSize &size, | ||
322 | Flags flags) | 322 | Flags flags) | ||
323 | { | 323 | { | ||
324 | YuvFormat yuvFormat; | 324 | YuvFormat yuvFormat; | ||
325 | for (YuvFormat f : yuvFormats) { | 325 | for (YuvFormat f : yuvFormats) { | ||
326 | if (f.format == format) { | 326 | if (f.format == format) { | ||
327 | yuvFormat = f; | 327 | yuvFormat = f; | ||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |