diff --git a/backends/hwcomposer/hwcomposer_backend.cpp b/backends/hwcomposer/hwcomposer_backend.cpp index 691749e6f4..8d5b706ac3 100644 --- a/backends/hwcomposer/hwcomposer_backend.cpp +++ b/backends/hwcomposer/hwcomposer_backend.cpp @@ -164,7 +164,10 @@ void HwcomposerBackend::toggleBlankOutput() } m_outputBlank = !m_outputBlank; m_device->blank(m_device, 0, m_outputBlank ? 1 : 0); - m_device->eventControl(m_device, 0, HWC_EVENT_VSYNC, m_outputBlank ? 0 : 1); + // only disable Vsycn, enable happens after next frame rendered + if (m_outputBlank) { + enableVSync(false); + } // enable/disable compositor repainting when blanked if (Compositor *compositor = Compositor::self()) { if (m_outputBlank) { @@ -176,6 +179,15 @@ void HwcomposerBackend::toggleBlankOutput() } } +void HwcomposerBackend::enableVSync(bool enable) +{ + if (m_hasVsync == enable) { + return; + } + const int result = m_device->eventControl(m_device, 0, HWC_EVENT_VSYNC, enable ? 1: 0); + m_hasVsync = enable && (result == 0); +} + HwcomposerWindow *HwcomposerBackend::createSurface() { return new HwcomposerWindow(this); @@ -282,6 +294,7 @@ void HwcomposerWindow::present(HWComposerNativeWindowBuffer *buffer) err = device->set(device, 1, m_list); assert(err == 0); + m_backend->enableVSync(true); setFenceBufferFd(buffer, fblayer->releaseFenceFd); if (m_list[0]->retireFenceFd != -1) { diff --git a/backends/hwcomposer/hwcomposer_backend.h b/backends/hwcomposer/hwcomposer_backend.h index ca3da143ac..54b1bfa430 100644 --- a/backends/hwcomposer/hwcomposer_backend.h +++ b/backends/hwcomposer/hwcomposer_backend.h @@ -65,6 +65,7 @@ public: int refreshRate() const { return m_refreshRate; } + void enableVSync(bool enable); public Q_SLOTS: void vsync(); @@ -79,6 +80,7 @@ private: bool m_pageFlipPending = false; int m_refreshRate = 60000; QTimer *m_vsyncFailSafeTimer; + bool m_hasVsync = false; }; class HwcomposerWindow : public HWComposerNativeWindow