Only call active effects in the effect chain

Each effect is able to declare itself as currently being active,
that is transforming windows or painting or screen or doing anything
during the current rendered frame.

This change eliminates the hottest path inside KWin identified by
callgrind.

REVIEW: 102449
This commit is contained in:
Martin Gräßlin 2011-08-27 11:21:31 +02:00
parent 5b0d1739c2
commit fe4329a252
82 changed files with 308 additions and 53 deletions

View file

@ -97,7 +97,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
, fullscreen_effect(0)
, next_window_quad_type(EFFECT_QUAD_TYPE_START)
, mouse_poll_ref_count(0)
, current_paint_effectframe(0)
{
Workspace *ws = Workspace::self();
connect(ws, SIGNAL(currentDesktopChanged(int)), this, SLOT(slotDesktopChanged(int)));
@ -203,54 +202,54 @@ void EffectsHandlerImpl::reconfigure()
// the idea is that effects call this function again which calls the next one
void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
{
if (current_paint_screen < loaded_effects.size()) {
loaded_effects[current_paint_screen++].second->prePaintScreen(data, time);
--current_paint_screen;
if (m_currentPaintScreenIterator != m_activeEffects.end()) {
(*m_currentPaintScreenIterator++)->prePaintScreen(data, time);
--m_currentPaintScreenIterator;
}
// no special final code
}
void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
if (current_paint_screen < loaded_effects.size()) {
loaded_effects[current_paint_screen++].second->paintScreen(mask, region, data);
--current_paint_screen;
if (m_currentPaintScreenIterator != m_activeEffects.end()) {
(*m_currentPaintScreenIterator++)->paintScreen(mask, region, data);
--m_currentPaintScreenIterator;
} else
scene->finalPaintScreen(mask, region, data);
}
void EffectsHandlerImpl::postPaintScreen()
{
if (current_paint_screen < loaded_effects.size()) {
loaded_effects[current_paint_screen++].second->postPaintScreen();
--current_paint_screen;
if (m_currentPaintScreenIterator != m_activeEffects.end()) {
(*m_currentPaintScreenIterator++)->postPaintScreen();
--m_currentPaintScreenIterator;
}
// no special final code
}
void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (current_paint_window < loaded_effects.size()) {
loaded_effects[current_paint_window++].second->prePaintWindow(w, data, time);
--current_paint_window;
if (m_currentPaintWindowIterator != m_activeEffects.end()) {
(*m_currentPaintWindowIterator++)->prePaintWindow(w, data, time);
--m_currentPaintWindowIterator;
}
// no special final code
}
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (current_paint_window < loaded_effects.size()) {
loaded_effects[current_paint_window++].second->paintWindow(w, mask, region, data);
--current_paint_window;
if (m_currentPaintWindowIterator != m_activeEffects.end()) {
(*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data);
--m_currentPaintWindowIterator;
} else
scene->finalPaintWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
}
void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
{
if (current_paint_effectframe < loaded_effects.size()) {
loaded_effects[current_paint_effectframe++].second->paintEffectFrame(frame, region, opacity, frameOpacity);
--current_paint_effectframe;
if (m_currentPaintEffectFrameIterator != m_activeEffects.end()) {
(*m_currentPaintEffectFrameIterator++)->paintEffectFrame(frame, region, opacity, frameOpacity);
--m_currentPaintEffectFrameIterator;
} else {
const EffectFrameImpl* frameImpl = static_cast<const EffectFrameImpl*>(frame);
frameImpl->finalRender(region, opacity, frameOpacity);
@ -259,9 +258,9 @@ void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, do
void EffectsHandlerImpl::postPaintWindow(EffectWindow* w)
{
if (current_paint_window < loaded_effects.size()) {
loaded_effects[current_paint_window++].second->postPaintWindow(w);
--current_paint_window;
if (m_currentPaintWindowIterator != m_activeEffects.end()) {
(*m_currentPaintWindowIterator++)->postPaintWindow(w);
--m_currentPaintWindowIterator;
}
// no special final code
}
@ -276,18 +275,18 @@ bool EffectsHandlerImpl::provides(Effect::Feature ef)
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (current_draw_window < loaded_effects.size()) {
loaded_effects[current_draw_window++].second->drawWindow(w, mask, region, data);
--current_draw_window;
if (m_currentDrawWindowIterator != m_activeEffects.end()) {
(*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data);
--m_currentDrawWindowIterator;
} else
scene->finalDrawWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
}
void EffectsHandlerImpl::buildQuads(EffectWindow* w, WindowQuadList& quadList)
{
if (current_build_quads < loaded_effects.size()) {
loaded_effects[current_build_quads++].second->buildQuads(w, quadList);
--current_build_quads;
if (m_currentBuildQuadsIterator != m_activeEffects.end()) {
(*m_currentBuildQuadsIterator++)->buildQuads(w, quadList);
--m_currentBuildQuadsIterator;
}
}
@ -309,10 +308,17 @@ bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
// start another painting pass
void EffectsHandlerImpl::startPaint()
{
assert(current_paint_screen == 0);
assert(current_paint_window == 0);
assert(current_draw_window == 0);
assert(current_build_quads == 0);
m_activeEffects.clear();
for(QVector< KWin::EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it) {
if (it->second->isActive()) {
m_activeEffects << it->second;
}
}
m_currentDrawWindowIterator = m_activeEffects.begin();
m_currentPaintWindowIterator = m_activeEffects.begin();
m_currentPaintScreenIterator = m_activeEffects.begin();
m_currentPaintEffectFrameIterator = m_activeEffects.begin();
m_currentBuildQuadsIterator = m_activeEffects.begin();
}
void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, KDecorationDefines::MaximizeMode maxMode)
@ -1087,10 +1093,6 @@ QStringList EffectsHandlerImpl::listOfEffects() const
bool EffectsHandlerImpl::loadEffect(const QString& name, bool checkDefault)
{
Workspace::self()->addRepaintFull();
assert(current_paint_screen == 0);
assert(current_paint_window == 0);
assert(current_draw_window == 0);
assert(current_build_quads == 0);
if (!name.startsWith(QLatin1String("kwin4_effect_")))
kWarning(1212) << "Effect names usually have kwin4_effect_ prefix" ;
@ -1201,10 +1203,6 @@ bool EffectsHandlerImpl::loadEffect(const QString& name, bool checkDefault)
void EffectsHandlerImpl::unloadEffect(const QString& name)
{
Workspace::self()->addRepaintFull();
assert(current_paint_screen == 0);
assert(current_paint_window == 0);
assert(current_draw_window == 0);
assert(current_build_quads == 0);
for (QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it) {
if (it.value().first == name) {

View file

@ -208,7 +208,14 @@ protected:
QHash< long, int > registered_atoms;
int next_window_quad_type;
int mouse_poll_ref_count;
int current_paint_effectframe;
private:
QList< Effect* > m_activeEffects;
QList< Effect* >::iterator m_currentDrawWindowIterator;
QList< Effect* >::iterator m_currentPaintWindowIterator;
QList< Effect* >::iterator m_currentPaintEffectFrameIterator;
QList< Effect* >::iterator m_currentPaintScreenIterator;
QList< Effect* >::iterator m_currentBuildQuadsIterator;
};
class EffectWindowImpl : public EffectWindow

View file

@ -947,6 +947,11 @@ void BoxSwitchEffect::activateFromProxy(int mode, bool animate, bool showText, f
}
}
bool BoxSwitchEffect::isActive() const
{
return mActivated;
}
BoxSwitchEffect::ItemInfo::ItemInfo()
: iconFrame(NULL)
{

View file

@ -55,6 +55,7 @@ public:
virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void* proxy();
virtual bool isActive() const;
void activateFromProxy(int mode, bool animate, bool showText, float positioningFactor);
void paintWindowsBox(const QRegion& region);

View file

@ -995,4 +995,9 @@ void CoverSwitchEffect::slotWindowClosed(EffectWindow* c)
}
}
bool CoverSwitchEffect::isActive() const
{
return mActivated || stop || stopRequested;
}
} // namespace

View file

@ -48,6 +48,7 @@ public:
virtual void postPaintScreen();
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual bool isActive() const;
static bool supported();

View file

@ -2087,4 +2087,9 @@ void CubeEffect::unregisterCubeInsideEffect(CubeInsideEffect* effect)
m_cubeInsideEffects.removeAll(effect);
}
bool CubeEffect::isActive() const
{
return activated;
}
} // namespace

View file

@ -50,6 +50,7 @@ public:
virtual bool borderActivated(ElectricBorder border);
virtual void grabbedKeyboardEvent(QKeyEvent* e);
virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual bool isActive() const;
// proxy functions
virtual void* proxy();

View file

@ -617,4 +617,9 @@ void CubeSlideEffect::windowMovingChanged(float progress, RotationDirection dire
effects->addRepaintFull();
}
bool CubeSlideEffect::isActive() const
{
return !slideRotations.isEmpty();
}
} // namespace

View file

@ -42,6 +42,7 @@ public:
virtual void postPaintScreen();
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
static bool supported();

View file

@ -199,4 +199,9 @@ void DashboardEffect::slotWindowClosed(EffectWindow* w)
}
}
bool DashboardEffect::isActive() const
{
return transformWindow;
}
} // namespace

View file

@ -43,6 +43,7 @@ public:
virtual void propagate();
virtual void reconfigure(ReconfigureFlags);
virtual void unpropagate();
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowAdded(EffectWindow* c);

View file

@ -1221,10 +1221,10 @@ void DesktopGridEffect::globalShortcutChanged(const QKeySequence& seq)
shortcut = KShortcut(seq);
}
bool DesktopGridEffect::isMotionManagerMovingWindows()
bool DesktopGridEffect::isMotionManagerMovingWindows() const
{
if (isUsingPresentWindows()) {
QList<WindowMotionManager>::iterator it;
QList<WindowMotionManager>::const_iterator it;
for (it = m_managers.begin(); it != m_managers.end(); ++it) {
if ((*it).areWindowsMoving())
return true;
@ -1372,6 +1372,11 @@ void DesktopGridEffect::desktopsRemoved(int old)
effects->addRepaintFull();
}
bool DesktopGridEffect::isActive() const
{
return timeline.currentValue() != 0 || (isUsingPresentWindows() && isMotionManagerMovingWindows());
}
/************************************************
* DesktopButtonView
************************************************/

View file

@ -75,6 +75,7 @@ public:
virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void grabbedKeyboardEvent(QKeyEvent* e);
virtual bool borderActivated(ElectricBorder border);
virtual bool isActive() const;
enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes
@ -106,7 +107,7 @@ private:
void setup();
void setupGrid();
void finish();
bool isMotionManagerMovingWindows();
bool isMotionManagerMovingWindows() const;
bool isUsingPresentWindows() const;
QRectF moveGeometryToDesktop(int desktop) const;
void desktopsAdded(int old);

View file

@ -95,4 +95,9 @@ void DialogParentEffect::slotWindowClosed(EffectWindow* w)
effectStrength.remove(w);
}
bool DialogParentEffect::isActive() const
{
return !effectStrength.isEmpty();
}
} // namespace

View file

@ -46,6 +46,8 @@ public:
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow(EffectWindow* w);
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowClosed(EffectWindow *c);
void slotWindowActivated(EffectWindow *c);

View file

@ -108,4 +108,10 @@ void DimScreenEffect::slotWindowActivated(EffectWindow *w)
}
}
}
bool DimScreenEffect::isActive() const
{
return mActivated;
}
} // namespace

View file

@ -39,6 +39,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen();
virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowActivated(EffectWindow *w);

View file

@ -202,5 +202,10 @@ void ExplosionEffect::slotWindowDeleted(EffectWindow* c)
mWindows.remove(c);
}
bool ExplosionEffect::isActive() const
{
return mActiveAnimations > 0;
}
} // namespace

View file

@ -47,6 +47,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();

View file

@ -199,4 +199,9 @@ bool FadeEffect::isFadeWindow(EffectWindow* w)
return (!w->isDesktop() && !w->isUtility());
}
bool FadeEffect::isActive() const
{
return !windows.isEmpty();
}
} // namespace

View file

@ -36,6 +36,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
// TODO react also on virtual desktop changes

View file

@ -107,6 +107,11 @@ void FadeDesktopEffect::slotDesktopChanged(int old)
effects->addRepaintFull();
}
bool FadeDesktopEffect::isActive() const
{
return m_fading;
}
} // namespace
#include "fadedesktop.moc"

View file

@ -39,6 +39,7 @@ public:
virtual void postPaintScreen();
virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time);
virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
virtual bool isActive() const;
private Q_SLOTS:
void slotDesktopChanged(int old);

View file

@ -160,4 +160,9 @@ void FallApartEffect::slotWindowDeleted(EffectWindow* c)
windows.remove(c);
}
bool FallApartEffect::isActive() const
{
return !windows.isEmpty();
}
} // namespace

View file

@ -37,6 +37,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowClosed(EffectWindow *c);

View file

@ -934,6 +934,11 @@ void FlipSwitchEffect::grabbedKeyboardEvent(QKeyEvent* e)
}
}
bool FlipSwitchEffect::isActive() const
{
return m_active;
}
//*************************************************************
// Item Info
//*************************************************************

View file

@ -47,6 +47,7 @@ public:
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool borderActivated(ElectricBorder border);
virtual void grabbedKeyboardEvent(QKeyEvent* e);
virtual bool isActive() const;
static bool supported();
private Q_SLOTS:

View file

@ -226,6 +226,11 @@ bool GlideEffect::isGlideWindow(EffectWindow* w)
return true;
}
bool GlideEffect::isActive() const
{
return !windows.isEmpty();
}
GlideEffect::WindowInfo::WindowInfo()
: deleted(false)
, added(false)

View file

@ -41,6 +41,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow(EffectWindow* w);
virtual bool isActive() const;
static bool supported();
public Q_SLOTS:

View file

@ -257,4 +257,9 @@ void HighlightWindowEffect::finishHighlighting()
m_windowOpacity.constBegin().key()->addRepaintFull();
}
bool HighlightWindowEffect::isActive() const
{
return !m_windowOpacity.isEmpty();
}
} // namespace

View file

@ -36,6 +36,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowAdded(EffectWindow* w);

View file

@ -161,6 +161,11 @@ void InvertEffect::toggleWindow()
effects->activeWindow()->addRepaintFull();
}
bool InvertEffect::isActive() const
{
return m_valid && (m_allWindows || !m_windows.isEmpty());
}
} // namespace
#include "invert.moc"

View file

@ -44,6 +44,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData &data, int time);
virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time);
virtual void paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity);
virtual bool isActive() const;
static bool supported();

View file

@ -117,4 +117,9 @@ bool LoginEffect::isLoginSplash(EffectWindow* w)
return false;
}
bool LoginEffect::isActive() const
{
return login_window != NULL;
}
} // namespace

View file

@ -38,6 +38,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void reconfigure(ReconfigureFlags);
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowClosed(EffectWindow *w);

View file

@ -400,4 +400,9 @@ void LogoutEffect::slotPropertyNotify(EffectWindow* w, long a)
canDoPersistent = true;
}
bool LogoutEffect::isActive() const
{
return progress != 0;
}
} // namespace

View file

@ -44,6 +44,7 @@ public:
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen();
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowAdded(EffectWindow* w);
void slotWindowClosed(EffectWindow *w);

View file

@ -247,6 +247,11 @@ void LookingGlassEffect::postPaintScreen()
}
}
bool LookingGlassEffect::isActive() const
{
return m_valid && m_enabled;
}
} // namespace
#include "lookingglass.moc"

View file

@ -48,6 +48,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();

View file

@ -353,4 +353,9 @@ void MagicLampEffect::slotWindowUnminimized(EffectWindow* w)
mTimeLineWindows[w]->setCurrentTime(mAnimationDuration);
}
bool MagicLampEffect::isActive() const
{
return !mTimeLineWindows.isEmpty();
}
} // namespace

View file

@ -40,6 +40,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();

View file

@ -232,6 +232,11 @@ void MagnifierEffect::slotMouseChanged(const QPoint& pos, const QPoint& old,
effects->addRepaintFull();
}
bool MagnifierEffect::isActive() const
{
return zoom != 1.0 || zoom != target_zoom;
}
} // namespace
#include "magnifier.moc"

View file

@ -41,6 +41,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();
private slots:
void zoomIn();

View file

@ -148,5 +148,10 @@ void MinimizeAnimationEffect::slotWindowUnminimized(EffectWindow* w)
timeline->setCurrentTime(timeline->duration());
}
bool MinimizeAnimationEffect::isActive() const
{
return !mTimeLineWindows.isEmpty();
}
} // namespace

View file

@ -43,6 +43,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowDeleted(EffectWindow *w);

View file

@ -186,6 +186,12 @@ MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPoint arrow_start, QPoint ar
return ret;
}
bool MouseMarkEffect::isActive() const
{
return !marks.isEmpty() || !drawing.isEmpty();
}
} // namespace
#include "mousemark.moc"

View file

@ -36,6 +36,7 @@ public:
~MouseMarkEffect();
virtual void reconfigure(ReconfigureFlags);
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual bool isActive() const;
private slots:
void clear();
void clearLast();

View file

@ -75,4 +75,9 @@ void OutlineEffect::slotShowOutline(const QRect& geometry)
effects->addRepaint(geometry);
}
bool OutlineEffect::isActive() const
{
return m_active;
}
} // namespace

View file

@ -35,6 +35,7 @@ public:
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual bool provides(Feature feature);
virtual bool isActive() const;
public Q_SLOTS:
void slotShowOutline(const QRect &geometry);

View file

@ -2043,6 +2043,11 @@ void PresentWindowsEffect::globalShortcutChangedClass(const QKeySequence& seq)
shortcutClass = KShortcut(seq);
}
bool PresentWindowsEffect::isActive() const
{
return m_activated || m_motionManager.managingWindows();
}
/************************************************
* CloseWindowView
************************************************/

View file

@ -104,6 +104,7 @@ public:
virtual bool borderActivated(ElectricBorder border);
virtual void windowInputMouseEvent(Window w, QEvent *e);
virtual void grabbedKeyboardEvent(QKeyEvent *e);
virtual bool isActive() const;
enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
enum PresentWindowsMode {

View file

@ -95,4 +95,9 @@ void ScaleInEffect::slotWindowClosed(EffectWindow* c)
delete mTimeLineWindows.take(c);
}
bool ScaleInEffect::isActive() const
{
return !mTimeLineWindows.isEmpty();
}
} // namespace

View file

@ -38,6 +38,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow(EffectWindow* w);
virtual bool isActive() const;
// TODO react also on virtual desktop changes
public Q_SLOTS:
void slotWindowAdded(EffectWindow* c);

View file

@ -258,4 +258,9 @@ void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h)
img = img.mirrored();
}
bool ScreenShotEffect::isActive() const
{
return m_scheduledScreenshot != NULL;
}
} // namespace

View file

@ -40,6 +40,7 @@ public:
ScreenShotEffect();
virtual ~ScreenShotEffect();
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();
static void convertFromGLImage(QImage &img, int w, int h);

View file

@ -186,6 +186,11 @@ bool SheetEffect::isSheetWindow(EffectWindow* w)
return (w->isModal() || w->data(IsSheetWindow).toBool());
}
bool SheetEffect::isActive() const
{
return !windows.isEmpty();
}
SheetEffect::WindowInfo::WindowInfo()
: deleted(false)
, added(false)

View file

@ -40,6 +40,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow(EffectWindow* w);
virtual bool isActive() const;
static bool supported();

View file

@ -230,6 +230,11 @@ void SlideEffect::slotDesktopChanged(int old, int current)
effects->addRepaintFull();
}
bool SlideEffect::isActive() const
{
return slide;
}
} // namespace
#include "slide.moc"

View file

@ -41,6 +41,7 @@ public:
virtual void postPaintScreen();
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
private Q_SLOTS:
void slotDesktopChanged(int old, int current);

View file

@ -376,4 +376,9 @@ QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w)
return modalGroupGeometry;
}
bool SlideBackEffect::isActive() const
{
return motionManager.managingWindows();
}
} //Namespace

View file

@ -40,6 +40,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData &data, int time);
virtual void postPaintScreen();
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowAdded(EffectWindow *w);

View file

@ -246,4 +246,10 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
}
mWindowsData[ w ] = animData;
}
bool SlidingPopupsEffect::isActive() const
{
return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty();
}
} // namespace

View file

@ -41,6 +41,7 @@ public:
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow(EffectWindow* w);
virtual void reconfigure(ReconfigureFlags flags);
virtual bool isActive() const;
// TODO react also on virtual desktop changes
public Q_SLOTS:

View file

@ -216,4 +216,9 @@ void SnapHelperEffect::slotWindowFinishUserMovedResized(EffectWindow *w)
}
}
bool SnapHelperEffect::isActive() const
{
return m_timeline.currentValue() != 0.0;
}
} // namespace

View file

@ -39,6 +39,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData &data, int time);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();

View file

@ -417,4 +417,9 @@ QRect StartupFeedbackEffect::feedbackRect() const
return rect;
}
bool StartupFeedbackEffect::isActive() const
{
return m_active;
}
} // namespace

View file

@ -41,6 +41,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
static bool supported();

View file

@ -154,4 +154,9 @@ void TaskbarThumbnailEffect::slotPropertyNotify(EffectWindow* w, long a)
}
}
bool TaskbarThumbnailEffect::isActive() const
{
return !thumbnails.isEmpty();
}
} // namespace

View file

@ -38,6 +38,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual bool isActive() const;
public Q_SLOTS:
void slotWindowAdded(EffectWindow *w);

View file

@ -172,6 +172,11 @@ void ThumbnailAsideEffect::repaintAll()
effects->addRepaint(d.rect);
}
bool ThumbnailAsideEffect::isActive() const
{
return !windows.isEmpty();
}
} // namespace
#include "thumbnailaside.moc"

View file

@ -48,6 +48,7 @@ private slots:
void slotWindowClosed(EffectWindow *w);
void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old);
void slotWindowDamaged(EffectWindow* w, const QRect& damage);
virtual bool isActive() const;
private:
void addThumbnail(EffectWindow* w);
void removeThumbnail(EffectWindow* w);

View file

@ -209,4 +209,9 @@ void TrackMouseEffect::loadTexture()
textureSize = im.size();
}
bool TrackMouseEffect::isActive() const
{
return active;
}
} // namespace

View file

@ -41,6 +41,7 @@ public:
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen();
virtual void reconfigure(ReconfigureFlags);
virtual bool isActive() const;
private slots:
void toggle();
void slotMouseChanged(const QPoint& pos, const QPoint& old,

View file

@ -178,3 +178,7 @@ void WindowGeometry::slotWindowStepUserMovedResized(EffectWindow *w, const QRect
}
}
bool WindowGeometry::isActive() const
{
return iAmActive;
}

View file

@ -38,6 +38,7 @@ public:
}
void reconfigure(ReconfigureFlags);
void paintScreen(int mask, QRegion region, ScreenPaintData &data);
virtual bool isActive() const;
private slots:
void toggle();

View file

@ -1218,6 +1218,10 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly
wwi.buffer = tmp;
}
bool WobblyWindowsEffect::isActive() const
{
return !windows.isEmpty();
}
} // namespace KWin

View file

@ -35,6 +35,7 @@ public:
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
// Wobbly model parameters
void setStiffness(qreal stiffness);

View file

@ -492,6 +492,11 @@ void ZoomEffect::focusChanged(int px, int py, int rx, int ry, int rwidth, int rh
}
}
bool ZoomEffect::isActive() const
{
return zoom != 1.0 || zoom != target_zoom;
}
} // namespace
#include "zoom.moc"

View file

@ -43,6 +43,7 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
virtual void postPaintScreen();
virtual bool isActive() const;
private slots:
void zoomIn();
void zoomOut();

View file

@ -171,6 +171,11 @@ bool Effect::provides(Feature)
return false;
}
bool Effect::isActive() const
{
return true;
}
void Effect::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
effects->drawWindow(w, mask, region, data);
@ -229,11 +234,7 @@ double Effect::animationTime(int defaultTime)
//****************************************
EffectsHandler::EffectsHandler(CompositingType type)
: current_paint_screen(0)
, current_paint_window(0)
, current_draw_window(0)
, current_build_quads(0)
, compositing_type(type)
: compositing_type(type)
{
if (compositing_type == NoCompositing)
return;

View file

@ -447,6 +447,23 @@ public:
virtual bool borderActivated(ElectricBorder border);
/**
* Overwrite this method to indicate whether your effect will be doing something in
* the next frame to be rendered. If the method returns @c false the effect will be
* excluded from the chained methods in the next rendered frame.
*
* This method is called always directly before the paint loop begins. So it is totally
* fine to e.g. react on a window event, issue a repaint to trigger an animation and
* change a flag to indicate that this method returns @c true.
*
* As the method is called each frame, you should not perform complex calculations.
* Best use just a boolean flag.
*
* The default implementation of this method returns @c true.
* @since 4.8
**/
virtual bool isActive() const;
static int displayWidth();
static int displayHeight();
static QPoint cursorPos();
@ -1023,10 +1040,6 @@ protected:
QHash< QString, KLibrary* > effect_libraries;
QList< InputWindowPair > input_windows;
//QHash< QString, EffectFactory* > effect_factories;
int current_paint_screen;
int current_paint_window;
int current_draw_window;
int current_build_quads;
CompositingType compositing_type;
};