diff --git a/composite.cpp b/composite.cpp
index a10c853882..a8bb42e254 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -168,7 +168,7 @@ void Workspace::setupCompositing()
} else
vBlankInterval = 1 << 10; // no sync - DO NOT set "0", would cause div-by-zero segfaults.
vBlankPadding = 3; // vblank rounding errors... :-(
- nextPaintReference = QDateTime::currentMSecsSinceEpoch();
+ nextPaintReference.restart();
checkCompositeTimer();
XCompositeRedirectSubwindows(display(), rootWindow(), CompositeRedirectManual);
new EffectsHandlerImpl(scene->compositingType()); // sets also the 'effects' pointer
@@ -393,10 +393,10 @@ void Workspace::performCompositing()
if (scene->waitSyncAvailable()) {
// vsync: paint the scene, than rebase the timer and use the duration for next timeout estimation
scene->paint(repaints, windows);
- nextPaintReference = QDateTime::currentMSecsSinceEpoch();
+ nextPaintReference.restart();
} else {
// no vsyc -> inversion: reset the timer, then paint the scene, this way we can provide a constant framerate
- nextPaintReference = QDateTime::currentMSecsSinceEpoch();
+ nextPaintReference.restart();
scene->paint(repaints, windows);
}
// reset the roundin error corrective... :-(
@@ -436,7 +436,7 @@ void Workspace::setCompositeTimer()
return;
// interval - "time since last paint completion" - "time we need to paint"
- uint passed = (QDateTime::currentMSecsSinceEpoch() - nextPaintReference) << 10;
+ uint passed = nextPaintReference.elapsed() << 10;
uint delay = fpsInterval;
if (scene->waitSyncAvailable()) {
if (passed > fpsInterval) {
diff --git a/scene.cpp b/scene.cpp
index 8509400dd2..34062590fb 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -164,7 +164,7 @@ void Scene::paintScreen(int* mask, QRegion* region)
// Compute time since the last painting pass.
void Scene::updateTimeDiff()
{
- if (last_time.isNull()) {
+ if (!last_time.isValid()) {
// Painting has been idle (optimized out) for some time,
// which means time_diff would be huge and would break animations.
// Simply set it to one (zero would mean no change at all and could
@@ -174,14 +174,14 @@ void Scene::updateTimeDiff()
time_diff = last_time.elapsed();
if (time_diff < 0) // check time rollback
time_diff = 1;
- last_time.start();;
+ last_time.restart();;
}
// Painting pass is optimized away.
void Scene::idle()
{
// Don't break time since last paint for the next pass.
- last_time = QTime();
+ last_time.invalidate();;
}
// the function that'll be eventually called by paintScreen() above
diff --git a/scene.h b/scene.h
index 6ce39c0f4a..b9ba85aba4 100644
--- a/scene.h
+++ b/scene.h
@@ -21,8 +21,6 @@ along with this program. If not, see .
#ifndef KWIN_SCENE_H
#define KWIN_SCENE_H
-#include
-
#include "toplevel.h"
#include "utils.h"
#include "kwineffects.h"
@@ -151,11 +149,12 @@ protected:
// time since last repaint
int time_diff;
uint lastRenderTime;
- QTime last_time;
+ QElapsedTimer last_time;
Workspace* wspace;
bool has_waitSync;
LanczosFilter* lanczos_filter;
OverlayWindow* m_overlayWindow;
+ QElapsedTimer m_renderTimer;
};
// The base class for windows representations in composite backends
diff --git a/scene_opengl_egl.cpp b/scene_opengl_egl.cpp
index 4e232c2691..51961ab719 100644
--- a/scene_opengl_egl.cpp
+++ b/scene_opengl_egl.cpp
@@ -167,7 +167,7 @@ bool SceneOpenGL::initDrawableConfigs()
// the entry function for painting
void SceneOpenGL::paint(QRegion damage, ToplevelList toplevels)
{
- QTime t = QTime::currentTime();
+ m_renderTimer.restart();
foreach (Toplevel * c, toplevels) {
assert(windows.contains(c));
stacking_order.append(windows[ c ]);
@@ -179,7 +179,8 @@ void SceneOpenGL::paint(QRegion damage, ToplevelList toplevels)
ungrabXServer(); // ungrab before flushBuffer(), it may wait for vsync
if (m_overlayWindow->window()) // show the window only after the first pass, since
m_overlayWindow->show(); // that pass may take long
- lastRenderTime = t.elapsed();
+ lastRenderTime = m_renderTimer.elapsed();
+ m_renderTimer.invalidate();
flushBuffer(mask, damage);
// do cleanup
stacking_order.clear();
diff --git a/scene_opengl_glx.cpp b/scene_opengl_glx.cpp
index 43f522ce08..d28278a39e 100644
--- a/scene_opengl_glx.cpp
+++ b/scene_opengl_glx.cpp
@@ -437,7 +437,7 @@ bool SceneOpenGL::initDrawableConfigs()
// the entry function for painting
void SceneOpenGL::paint(QRegion damage, ToplevelList toplevels)
{
- QTime t = QTime::currentTime();
+ m_renderTimer.restart();
foreach (Toplevel * c, toplevels) {
assert(windows.contains(c));
stacking_order.append(windows[ c ]);
@@ -457,7 +457,8 @@ void SceneOpenGL::paint(QRegion damage, ToplevelList toplevels)
ungrabXServer(); // ungrab before flushBuffer(), it may wait for vsync
if (m_overlayWindow->window()) // show the window only after the first pass, since
m_overlayWindow->show(); // that pass may take long
- lastRenderTime = t.elapsed();
+ lastRenderTime = m_renderTimer.elapsed();
+ m_renderTimer.invalidate();
flushBuffer(mask, damage);
// do cleanup
stacking_order.clear();
diff --git a/scene_xrender.cpp b/scene_xrender.cpp
index 73dd22f685..fc08289c7d 100644
--- a/scene_xrender.cpp
+++ b/scene_xrender.cpp
@@ -161,7 +161,7 @@ void SceneXrender::createBuffer()
// the entry point for painting
void SceneXrender::paint(QRegion damage, ToplevelList toplevels)
{
- QTime t = QTime::currentTime();
+ m_renderTimer.restart();
foreach (Toplevel * c, toplevels) {
assert(windows.contains(c));
stacking_order.append(windows[ c ]);
@@ -170,7 +170,8 @@ void SceneXrender::paint(QRegion damage, ToplevelList toplevels)
paintScreen(&mask, &damage);
if (m_overlayWindow->window()) // show the window only after the first pass, since
m_overlayWindow->show(); // that pass may take long
- lastRenderTime = t.elapsed();
+ lastRenderTime = m_renderTimer.elapsed();
+ m_renderTimer.invalidate();
flushBuffer(mask, damage);
// do cleanup
stacking_order.clear();
diff --git a/workspace.h b/workspace.h
index 2cba848416..68d78d57ca 100644
--- a/workspace.h
+++ b/workspace.h
@@ -29,7 +29,7 @@ along with this program. If not, see .
#include
#include
#include
-#include
+#include
#include
#include "kactivitycontroller.h"
@@ -888,7 +888,7 @@ private:
KSelectionOwner* cm_selection;
bool compositingSuspended, compositingBlocked;
QBasicTimer compositeTimer;
- qint64 nextPaintReference;
+ QElapsedTimer nextPaintReference;
QTimer mousePollingTimer;
uint vBlankInterval, vBlankPadding, fpsInterval, estimatedRenderTime;
int xrrRefreshRate; // used only for compositing