diff --git a/src/backends/drm/drm_egl_layer_surface.cpp b/src/backends/drm/drm_egl_layer_surface.cpp index ab0b51f468..4b591101f4 100644 --- a/src/backends/drm/drm_egl_layer_surface.cpp +++ b/src/backends/drm/drm_egl_layer_surface.cpp @@ -198,7 +198,7 @@ bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion) glDisable(GL_BLEND); m_surface->currentShadowSlot->texture()->render(m_surface->gbmSwapchain->size()); EGLNativeFence fence(m_surface->context->displayObject()); - m_surface->shadowSwapchain->release(m_surface->currentShadowSlot, fence.fileDescriptor().duplicate()); + m_surface->shadowSwapchain->release(m_surface->currentShadowSlot, fence.takeFileDescriptor()); GLFramebuffer::popFramebuffer(); } m_surface->damageJournal.add(damagedRegion); @@ -211,7 +211,7 @@ bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion) glFinish(); } m_surface->gbmSwapchain->release(m_surface->currentSlot, sourceFence.fileDescriptor().duplicate()); - const auto buffer = importBuffer(m_surface.get(), m_surface->currentSlot.get(), sourceFence.fileDescriptor()); + const auto buffer = importBuffer(m_surface.get(), m_surface->currentSlot.get(), sourceFence.takeFileDescriptor()); m_surface->renderEnd = std::chrono::steady_clock::now(); if (buffer) { m_surface->currentFramebuffer = buffer; @@ -533,14 +533,14 @@ std::shared_ptr EglGbmLayerSurface::doRenderTestBuffer(Surface * } } -std::shared_ptr EglGbmLayerSurface::importBuffer(Surface *surface, EglSwapchainSlot *slot, const FileDescriptor &readFence) const +std::shared_ptr EglGbmLayerSurface::importBuffer(Surface *surface, EglSwapchainSlot *slot, FileDescriptor &&readFence) const { if (surface->bufferTarget == BufferTarget::Dumb || surface->importMode == MultiGpuImportMode::DumbBuffer) { return importWithCpu(surface, slot); } else if (surface->importMode == MultiGpuImportMode::Egl) { - return importWithEgl(surface, slot->buffer(), readFence); + return importWithEgl(surface, slot->buffer(), std::move(readFence)); } else { - const auto ret = m_gpu->importBuffer(slot->buffer(), readFence.duplicate()); + const auto ret = m_gpu->importBuffer(slot->buffer(), std::move(readFence)); if (!ret) { qCWarning(KWIN_DRM, "Failed to create framebuffer: %s", strerror(errno)); } @@ -548,7 +548,7 @@ std::shared_ptr EglGbmLayerSurface::importBuffer(Surface *surfac } } -std::shared_ptr EglGbmLayerSurface::importWithEgl(Surface *surface, GraphicsBuffer *sourceBuffer, const FileDescriptor &readFence) const +std::shared_ptr EglGbmLayerSurface::importWithEgl(Surface *surface, GraphicsBuffer *sourceBuffer, FileDescriptor &&readFence) const { Q_ASSERT(surface->importGbmSwapchain); @@ -564,7 +564,7 @@ std::shared_ptr EglGbmLayerSurface::importWithEgl(Surface *surfa surface->importTimeQuery->begin(); if (readFence.isValid()) { - const auto destinationFence = EGLNativeFence::importFence(surface->importContext->displayObject(), readFence.duplicate()); + const auto destinationFence = EGLNativeFence::importFence(surface->importContext->displayObject(), std::move(readFence)); destinationFence.waitSync(); } @@ -609,7 +609,7 @@ std::shared_ptr EglGbmLayerSurface::importWithEgl(Surface *surfa // restore the old context m_eglBackend->makeCurrent(); - return m_gpu->importBuffer(slot->buffer(), endFence.fileDescriptor().duplicate()); + return m_gpu->importBuffer(slot->buffer(), endFence.takeFileDescriptor()); } std::shared_ptr EglGbmLayerSurface::importWithCpu(Surface *surface, EglSwapchainSlot *source) const diff --git a/src/backends/drm/drm_egl_layer_surface.h b/src/backends/drm/drm_egl_layer_surface.h index e4c1356d3f..d533ecefe4 100644 --- a/src/backends/drm/drm_egl_layer_surface.h +++ b/src/backends/drm/drm_egl_layer_surface.h @@ -118,8 +118,8 @@ private: std::shared_ptr createGbmSwapchain(DrmGpu *gpu, EglContext *context, const QSize &size, uint32_t format, const QList &modifiers, MultiGpuImportMode importMode, BufferTarget bufferTarget) const; std::shared_ptr doRenderTestBuffer(Surface *surface) const; - std::shared_ptr importBuffer(Surface *surface, EglSwapchainSlot *source, const FileDescriptor &readFence) const; - std::shared_ptr importWithEgl(Surface *surface, GraphicsBuffer *sourceBuffer, const FileDescriptor &readFence) const; + std::shared_ptr importBuffer(Surface *surface, EglSwapchainSlot *source, FileDescriptor &&readFence) const; + std::shared_ptr importWithEgl(Surface *surface, GraphicsBuffer *sourceBuffer, FileDescriptor &&readFence) const; std::shared_ptr importWithCpu(Surface *surface, EglSwapchainSlot *source) const; std::unique_ptr m_surface; diff --git a/src/backends/drm/drm_virtual_egl_layer.cpp b/src/backends/drm/drm_virtual_egl_layer.cpp index 505c533600..0b4e5b5a28 100644 --- a/src/backends/drm/drm_virtual_egl_layer.cpp +++ b/src/backends/drm/drm_virtual_egl_layer.cpp @@ -92,7 +92,7 @@ bool VirtualEglGbmLayer::endFrame(const QRegion &renderedRegion, const QRegion & m_damageJournal.add(damagedRegion); EGLNativeFence releaseFence{m_eglBackend->eglDisplayObject()}; - m_gbmSwapchain->release(m_currentSlot, releaseFence.fileDescriptor().duplicate()); + m_gbmSwapchain->release(m_currentSlot, releaseFence.takeFileDescriptor()); return true; } diff --git a/src/backends/wayland/wayland_egl_backend.cpp b/src/backends/wayland/wayland_egl_backend.cpp index f1495a21cc..c3a631408c 100644 --- a/src/backends/wayland/wayland_egl_backend.cpp +++ b/src/backends/wayland/wayland_egl_backend.cpp @@ -110,7 +110,7 @@ bool WaylandEglPrimaryLayer::endFrame(const QRegion &renderedRegion, const QRegi EGLNativeFence releaseFence{m_backend->eglDisplayObject()}; m_presentationBuffer = m_backend->backend()->importBuffer(m_buffer->buffer()); - m_swapchain->release(m_buffer, releaseFence.fileDescriptor().duplicate()); + m_swapchain->release(m_buffer, releaseFence.takeFileDescriptor()); m_damageJournal.add(damagedRegion); return true; @@ -217,7 +217,7 @@ bool WaylandEglCursorLayer::endFrame(const QRegion &renderedRegion, const QRegio m_output->cursor()->update(buffer, scale(), hotspot().toPoint()); EGLNativeFence releaseFence{m_backend->eglDisplayObject()}; - m_swapchain->release(m_buffer, releaseFence.fileDescriptor().duplicate()); + m_swapchain->release(m_buffer, releaseFence.takeFileDescriptor()); return true; } diff --git a/src/opengl/eglnativefence.cpp b/src/opengl/eglnativefence.cpp index 13c42ade54..41f950590c 100644 --- a/src/opengl/eglnativefence.cpp +++ b/src/opengl/eglnativefence.cpp @@ -51,7 +51,7 @@ const FileDescriptor &EGLNativeFence::fileDescriptor() const return m_fileDescriptor; } -FileDescriptor &&EGLNativeFence::fileDescriptor() +FileDescriptor &&EGLNativeFence::takeFileDescriptor() { return std::move(m_fileDescriptor); } diff --git a/src/opengl/eglnativefence.h b/src/opengl/eglnativefence.h index 05c248ff8e..4a14c5f988 100644 --- a/src/opengl/eglnativefence.h +++ b/src/opengl/eglnativefence.h @@ -27,7 +27,7 @@ public: bool isValid() const; const FileDescriptor &fileDescriptor() const; - FileDescriptor &&fileDescriptor(); + FileDescriptor &&takeFileDescriptor(); bool waitSync() const; static EGLNativeFence importFence(EglDisplay *display, FileDescriptor &&fd);