From 2ade92d69b2fe00167511cb96a5ff33ce60ddb87 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 4 Feb 2021 10:40:20 +0200 Subject: [PATCH] platform: Make OpenGLBackend::scanout take SurfaceItem This allows removing SurfaceInterface::trackedDamage(). --- src/platformsupport/scenes/opengl/openglbackend.cpp | 4 ++-- src/platformsupport/scenes/opengl/openglbackend.h | 8 ++------ src/plugins/platforms/drm/egl_gbm_backend.cpp | 13 ++++++++++--- src/plugins/platforms/drm/egl_gbm_backend.h | 3 ++- src/plugins/platforms/drm/egl_multi_backend.cpp | 4 ++-- src/plugins/platforms/drm/egl_multi_backend.h | 2 +- src/plugins/scenes/opengl/scene_opengl.cpp | 4 ++-- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/platformsupport/scenes/opengl/openglbackend.cpp b/src/platformsupport/scenes/opengl/openglbackend.cpp index 4abfa66b99..a4ba52ff82 100644 --- a/src/platformsupport/scenes/opengl/openglbackend.cpp +++ b/src/platformsupport/scenes/opengl/openglbackend.cpp @@ -64,10 +64,10 @@ OverlayWindow* OpenGLBackend::overlayWindow() const return nullptr; } -bool OpenGLBackend::scanout(int screenId, KWaylandServer::SurfaceInterface *surface) +bool OpenGLBackend::scanout(int screenId, SurfaceItem *surfaceItem) { Q_UNUSED(screenId) - Q_UNUSED(surface) + Q_UNUSED(surfaceItem) return false; } diff --git a/src/platformsupport/scenes/opengl/openglbackend.h b/src/platformsupport/scenes/opengl/openglbackend.h index 6e232d2923..6cabb81a32 100644 --- a/src/platformsupport/scenes/opengl/openglbackend.h +++ b/src/platformsupport/scenes/opengl/openglbackend.h @@ -14,11 +14,6 @@ #include -namespace KWaylandServer -{ -class SurfaceInterface; -} - namespace KWin { class AbstractOutput; @@ -27,6 +22,7 @@ class OverlayWindow; class SceneOpenGL; class SceneOpenGLTexture; class SceneOpenGLTexturePrivate; +class SurfaceItem; class WindowPixmap; class GLTexture; @@ -69,7 +65,7 @@ public: * Tries to directly scan out a surface to the screen) * @return if the scanout fails (or is not supported on the specified screen) */ - virtual bool scanout(int screenId, KWaylandServer::SurfaceInterface *surface); + virtual bool scanout(int screenId, SurfaceItem *surfaceItem); /** * @brief Returns the OverlayWindow used by the backend. diff --git a/src/plugins/platforms/drm/egl_gbm_backend.cpp b/src/plugins/platforms/drm/egl_gbm_backend.cpp index 63f63b3944..32bcb7dd74 100644 --- a/src/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/src/plugins/platforms/drm/egl_gbm_backend.cpp @@ -16,6 +16,7 @@ #include "options.h" #include "renderloop_p.h" #include "screens.h" +#include "surfaceitem_wayland.h" #include "drm_gpu.h" #include "linux_dmabuf.h" // kwin libs @@ -691,8 +692,14 @@ void EglGbmBackend::endFrame(int screenId, const QRegion &renderedRegion, } } -bool EglGbmBackend::scanout(int screenId, KWaylandServer::SurfaceInterface *surface) +bool EglGbmBackend::scanout(int screenId, SurfaceItem *surfaceItem) { + SurfaceItemWayland *item = qobject_cast(surfaceItem); + if (!item) { + return false; + } + + KWaylandServer::SurfaceInterface *surface = item->surface(); if (!surface || !surface->buffer() || !surface->buffer()->linuxDmabufBuffer()) { return false; } @@ -740,8 +747,8 @@ bool EglGbmBackend::scanout(int screenId, KWaylandServer::SurfaceInterface *surf // damage tracking for screen casting QRegion damage; if (output.surfaceInterface == surface && buffer->size() == output.output->modeSize()) { - QRegion trackedDamage = surface->trackedDamage(); - surface->resetTrackedDamage(); + QRegion trackedDamage = surfaceItem->damage(); + surfaceItem->resetDamage(); for (const auto &rect : trackedDamage) { auto damageRect = QRect(rect); damageRect.translate(output.output->geometry().topLeft()); diff --git a/src/plugins/platforms/drm/egl_gbm_backend.h b/src/plugins/platforms/drm/egl_gbm_backend.h index 0ed3d74c45..bab1d132db 100644 --- a/src/plugins/platforms/drm/egl_gbm_backend.h +++ b/src/plugins/platforms/drm/egl_gbm_backend.h @@ -18,6 +18,7 @@ struct gbm_bo; namespace KWaylandServer { class BufferInterface; +class SurfaceInterface; } namespace KWin @@ -41,7 +42,7 @@ public: QRegion beginFrame(int screenId) override; void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; void init() override; - bool scanout(int screenId, KWaylandServer::SurfaceInterface *surface) override; + bool scanout(int screenId, SurfaceItem *surfaceItem) override; QSharedPointer textureForOutput(AbstractOutput *requestedOutput) const override; diff --git a/src/plugins/platforms/drm/egl_multi_backend.cpp b/src/plugins/platforms/drm/egl_multi_backend.cpp index c609a5373e..fd4cab0006 100644 --- a/src/plugins/platforms/drm/egl_multi_backend.cpp +++ b/src/plugins/platforms/drm/egl_multi_backend.cpp @@ -72,12 +72,12 @@ void EglMultiBackend::endFrame(int screenId, const QRegion &damage, const QRegio backend->endFrame(internalScreenId, damage, damagedRegion); } -bool EglMultiBackend::scanout(int screenId, KWaylandServer::SurfaceInterface *surface) +bool EglMultiBackend::scanout(int screenId, SurfaceItem *surfaceItem) { int internalScreenId; AbstractEglBackend *backend = findBackend(screenId, internalScreenId); Q_ASSERT(backend != nullptr); - return backend->scanout(internalScreenId, surface); + return backend->scanout(internalScreenId, surfaceItem); } bool EglMultiBackend::makeCurrent() diff --git a/src/plugins/platforms/drm/egl_multi_backend.h b/src/plugins/platforms/drm/egl_multi_backend.h index cae9c006de..d5d4201aec 100644 --- a/src/plugins/platforms/drm/egl_multi_backend.h +++ b/src/plugins/platforms/drm/egl_multi_backend.h @@ -25,7 +25,7 @@ public: QRegion beginFrame(int screenId) override; void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; - bool scanout(int screenId, KWaylandServer::SurfaceInterface *surface) override; + bool scanout(int screenId, SurfaceItem *surfaceItem) override; bool makeCurrent() override; void doneCurrent() override; diff --git a/src/plugins/scenes/opengl/scene_opengl.cpp b/src/plugins/scenes/opengl/scene_opengl.cpp index 5790207a01..cdfb570241 100644 --- a/src/plugins/scenes/opengl/scene_opengl.cpp +++ b/src/plugins/scenes/opengl/scene_opengl.cpp @@ -670,10 +670,10 @@ void SceneOpenGL::paint(int screenId, const QRegion &damage, const QListisOpaque() && !pixmap->opaque().contains(QRect(0, 0, window->width(), window->height()))) { + if (!window->isOpaque() && !topMost->opaque().contains(QRect(0, 0, window->width(), window->height()))) { break; } - directScanout = m_backend->scanout(screenId, pixmap->surface()); + directScanout = m_backend->scanout(screenId, topMost); break; } }