From 4a681e3d471ba9eab7a98f69ccc201bd87f86f4c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 10 Jun 2020 19:40:44 +0300 Subject: [PATCH] [scene] Discard quads when the surface-to-buffer matrix is changed The surface-to-buffer matrix provides a generic mechanism for mapping things from the surface-local coordinate space to the buffer coordinate space. If it changes, we know for sure that the texture coordinates have to be re-computed. --- scene.cpp | 4 ++-- subsurfacemonitor.cpp | 4 ++++ subsurfacemonitor.h | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scene.cpp b/scene.cpp index 93e5c1db2d..c33d224144 100644 --- a/scene.cpp +++ b/scene.cpp @@ -416,9 +416,9 @@ void Scene::addToplevel(Toplevel *c) connect(monitor, &SubSurfaceMonitor::subSurfaceResized, w, &Window::discardQuads); connect(monitor, &SubSurfaceMonitor::subSurfaceMapped, w, &Window::discardQuads); connect(monitor, &SubSurfaceMonitor::subSurfaceUnmapped, w, &Window::discardQuads); + connect(monitor, &SubSurfaceMonitor::subSurfaceSurfaceToBufferMatrixChanged, w, &Window::discardQuads); - connect(c->surface(), &KWaylandServer::SurfaceInterface::scaleChanged, w, &Window::discardQuads); - connect(c->surface(), &KWaylandServer::SurfaceInterface::viewportChanged, w, &Window::discardQuads); + connect(c->surface(), &KWaylandServer::SurfaceInterface::surfaceToBufferMatrixChanged, w, &Window::discardQuads); } connect(c, &Toplevel::screenScaleChanged, w, &Window::discardQuads); diff --git a/subsurfacemonitor.cpp b/subsurfacemonitor.cpp index b9dd05c63c..e2bef1ead2 100644 --- a/subsurfacemonitor.cpp +++ b/subsurfacemonitor.cpp @@ -46,6 +46,8 @@ void SubSurfaceMonitor::registerSubSurface(SubSurfaceInterface *subSurface) this, &SubSurfaceMonitor::subSurfaceMapped); connect(surface, &SurfaceInterface::unmapped, this, &SubSurfaceMonitor::subSurfaceUnmapped); + connect(surface, &SurfaceInterface::surfaceToBufferMatrixChanged, + this, &SubSurfaceMonitor::subSurfaceSurfaceToBufferMatrixChanged); registerSurface(surface); } @@ -64,6 +66,8 @@ void SubSurfaceMonitor::unregisterSubSurface(SubSurfaceInterface *subSurface) this, &SubSurfaceMonitor::subSurfaceMapped); disconnect(surface, &SurfaceInterface::unmapped, this, &SubSurfaceMonitor::subSurfaceUnmapped); + disconnect(surface, &SurfaceInterface::surfaceToBufferMatrixChanged, + this, &SubSurfaceMonitor::subSurfaceSurfaceToBufferMatrixChanged); unregisterSurface(surface); } diff --git a/subsurfacemonitor.h b/subsurfacemonitor.h index ec537a47c6..f1e95710aa 100644 --- a/subsurfacemonitor.h +++ b/subsurfacemonitor.h @@ -70,6 +70,11 @@ Q_SIGNALS: * This signal is emitted when a sub-surface is unmapped. */ void subSurfaceUnmapped(); + /** + * This signal is emitted when the mapping between the surface-local coordinate space + * and the buffer coordinate space for a sub-surface has changed. + */ + void subSurfaceSurfaceToBufferMatrixChanged(); private: void registerSubSurface(KWaylandServer::SubSurfaceInterface *subSurface);