From kde-commits Tue Jan 06 06:55:04 2015 From: =?utf-8?q?Fredrik_H=C3=B6glund?= Date: Tue, 06 Jan 2015 06:55:04 +0000 To: kde-commits Subject: [kwin] /: Use swap events to drive repaints Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=142052731322500 Git commit 38f1945c6c437cad14e9c22929ab7947009de8e5 by Fredrik H=C3=B6glund. Committed on 13/12/2014 at 13:26. Pushed by fredrik into branch 'master'. Use swap events to drive repaints Don't start the composite timer at the end of performPaint() when a buffer swap is pending and vsync is enabled. Instead set m_composeAtSwapCompletion to true so performPaint() gets called again as soon as the swap completes. This makes the repaint cycle look like this: scene->paint() SwapBuffers() Process events =C2=B7 =C2=B7 Swap completes Fetch and reset damage (if applicable) scene->paint() SwapBuffers() Process events =C2=B7 =C2=B7 Swap completes ... This results in a noticeable improvement in animation smoothness with drivers that support GLX_INTEL_swap_event, since we're now able to consistently render at the monitor refresh rate. M +5 -1 composite.cpp http://commits.kde.org/kwin/38f1945c6c437cad14e9c22929ab7947009de8e5 diff --git a/composite.cpp b/composite.cpp index c4145a3..1ded8e9 100644 --- a/composite.cpp +++ b/composite.cpp @@ -663,7 +663,11 @@ void Compositor::performCompositing() // is called the next time. If there would be nothing pending, it will= not restart the timer and // scheduleRepaint() would restart it again somewhen later, called fro= m functions that // would again add something pending. - scheduleRepaint(); + if (m_bufferSwapPending && m_scene->syncsToVBlank()) { + m_composeAtSwapCompletion =3D true; + } else { + scheduleRepaint(); + } } = bool Compositor::windowRepaintsPending() const