From 70e744fe26d60770740d72f2518743c3fd345467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 16 Oct 2015 18:19:10 +0200 Subject: [PATCH] [backends/hwcomposer] Add a failsafe timer for vsync events Apparently we don't get a vsync event for the first frame during startup which blocks the compositor till the end of days. Thus a timer is added which calls vsync after 1 sec if we didn't get an event. --- backends/hwcomposer/hwcomposer_backend.cpp | 8 ++++++++ backends/hwcomposer/hwcomposer_backend.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/backends/hwcomposer/hwcomposer_backend.cpp b/backends/hwcomposer/hwcomposer_backend.cpp index 87f6a2f5e0..691749e6f4 100644 --- a/backends/hwcomposer/hwcomposer_backend.cpp +++ b/backends/hwcomposer/hwcomposer_backend.cpp @@ -28,6 +28,8 @@ along with this program. If not, see . #include #include #include +// Qt +#include // hybris/android #include #include @@ -41,8 +43,12 @@ namespace KWin HwcomposerBackend::HwcomposerBackend(QObject *parent) : AbstractBackend(parent) + , m_vsyncFailSafeTimer(new QTimer(this)) { handleOutputs(); + m_vsyncFailSafeTimer->setSingleShot(true); + m_vsyncFailSafeTimer->setInterval(1000); + connect(m_vsyncFailSafeTimer, &QTimer::timeout, this, &HwcomposerBackend::vsync); } HwcomposerBackend::~HwcomposerBackend() @@ -192,12 +198,14 @@ void HwcomposerBackend::present() } m_pageFlipPending = true; if (Compositor::self()) { + m_vsyncFailSafeTimer->start(); Compositor::self()->aboutToSwapBuffers(); } } void HwcomposerBackend::vsync() { + m_vsyncFailSafeTimer->stop(); if (m_pageFlipPending) { m_pageFlipPending = false; if (Compositor::self()) { diff --git a/backends/hwcomposer/hwcomposer_backend.h b/backends/hwcomposer/hwcomposer_backend.h index 2e1633aef4..ca3da143ac 100644 --- a/backends/hwcomposer/hwcomposer_backend.h +++ b/backends/hwcomposer/hwcomposer_backend.h @@ -32,6 +32,8 @@ typedef struct hwc_composer_device_1 hwc_composer_device_1_t; class HWComposerNativeWindowBuffer; +class QTimer; + namespace KWin { @@ -76,6 +78,7 @@ private: bool m_outputBlank = true; bool m_pageFlipPending = false; int m_refreshRate = 60000; + QTimer *m_vsyncFailSafeTimer; }; class HwcomposerWindow : public HWComposerNativeWindow