platform: Make OpenGLBackend::scanout take SurfaceItem

This allows removing SurfaceInterface::trackedDamage().
This commit is contained in:
Vlad Zahorodnii 2021-02-04 10:40:20 +02:00
parent 36b55261da
commit 2ade92d69b
7 changed files with 21 additions and 17 deletions

View file

@ -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;
}

View file

@ -14,11 +14,6 @@
#include <kwin_export.h>
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.

View file

@ -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<SurfaceItemWayland *>(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());

View file

@ -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<GLTexture> textureForOutput(AbstractOutput *requestedOutput) const override;

View file

@ -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()

View file

@ -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;

View file

@ -670,10 +670,10 @@ void SceneOpenGL::paint(int screenId, const QRegion &damage, const QList<Topleve
break;
}
// and it has to be completely opaque
if (!window->isOpaque() && !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;
}
}