Recreate lanczos filter whenever the screen size changes

The LanczosFilter has a FBO in screen size. When the screen
geometry changes this FBO has to be recreated. To go completely
sure the lanczos filter gets deleted on screen changes.

To achieve this the LanczosFilter is wrapped inside a
QWeakPointer so that we can track when it got deleted. This
brings an additional advantage by delaying the creation of the
shader till it is really needed, that is when for the first
time a window thumbnail with lanczos is rendered.

BUG: 296065
FIXED-IN: 4.9.0
REVIEW: 105479
icc-effect-5.14.5
Martin Gräßlin 2012-07-06 19:03:04 +02:00
parent 4423b961a5
commit 3746e4d7d8
2 changed files with 11 additions and 6 deletions

View File

@ -75,6 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QDesktopWidget>
#include "client.h"
#include "deleted.h"
@ -98,7 +99,6 @@ Scene::Scene(Workspace* ws)
: QObject(ws)
, wspace(ws)
, has_waitSync(false)
, lanczos_filter(new LanczosFilter())
, m_overlayWindow(new OverlayWindow())
{
last_time.invalidate(); // Initialize the timer
@ -106,7 +106,6 @@ Scene::Scene(Workspace* ws)
Scene::~Scene()
{
delete lanczos_filter;
delete m_overlayWindow;
}
@ -435,9 +434,15 @@ void Scene::finalPaintWindow(EffectWindowImpl* w, int mask, QRegion region, Wind
// will be eventually called from drawWindow()
void Scene::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data)
{
if (mask & PAINT_WINDOW_LANCZOS)
lanczos_filter->performPaint(w, mask, region, data);
else
if (mask & PAINT_WINDOW_LANCZOS) {
if (lanczos_filter.isNull()) {
lanczos_filter = new LanczosFilter(this);
// recreate the lanczos filter when the screen gets resized
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), lanczos_filter.data(), SLOT(deleteLater()));
connect(QApplication::desktop(), SIGNAL(resized(int)), lanczos_filter.data(), SLOT(deleteLater()));
}
lanczos_filter.data()->performPaint(w, mask, region, data);
} else
w->sceneWindow()->performPaint(mask, region, data);
}

View File

@ -154,7 +154,7 @@ protected:
QElapsedTimer last_time;
Workspace* wspace;
bool has_waitSync;
LanczosFilter* lanczos_filter;
QWeakPointer<LanczosFilter> lanczos_filter;
OverlayWindow* m_overlayWindow;
};