From 485c71c64f2c3a8177b8a5211a52b6a345f46986 Mon Sep 17 00:00:00 2001 From: Antonio Napolitano Date: Fri, 24 Mar 2023 00:43:22 +0100 Subject: [PATCH] Revert "Merge pull request #11052 from ronso0/vumetergl-init-paint-fix" This reverts commit dfa313f468d6de4443e2a32d36c9eb107aac62b8, reversing changes made to dba50e2ac4cd7a13a3970f77b4b5edc0ceccf13b. --- src/widget/wvumetergl.cpp | 17 +++++++---------- src/widget/wvumetergl.h | 5 ++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/widget/wvumetergl.cpp b/src/widget/wvumetergl.cpp index 565034514fb..d973286eb2b 100644 --- a/src/widget/wvumetergl.cpp +++ b/src/widget/wvumetergl.cpp @@ -16,7 +16,7 @@ WVuMeterGL::WVuMeterGL(QWidget* parent) : QGLWidget(parent, SharedGLContext::getWidget()), WBaseWidget(this), - m_iPendingRenders(0), + m_bHasRendered(false), m_bSwapNeeded(false), m_dParameter(0), m_dPeakParameter(0), @@ -156,10 +156,10 @@ void WVuMeterGL::updateState(mixxx::Duration elapsed) { void WVuMeterGL::paintEvent(QPaintEvent* e) { Q_UNUSED(e); - // Force rerendering when render is called from the vsync thread, e.g. to + // Force a rerender when render is called from the vsync thread, e.g. to // git rid artifacts after hiding and showing the mixer or incomplete - // initial drawing. Use 2 passes, in case triple buffering is used. - m_iPendingRenders = 2; + // initial drawing. + m_bHasRendered = false; } void WVuMeterGL::showEvent(QShowEvent* e) { @@ -173,11 +173,8 @@ void WVuMeterGL::render(VSyncThread* vSyncThread) { updateState(vSyncThread->sinceLastSwap()); - if (m_dParameter != m_dLastParameter || m_dPeakParameter != m_dLastPeakParameter) { - m_iPendingRenders = 2; - } - - if (m_iPendingRenders == 0) { + if (m_bHasRendered && m_dParameter == m_dLastParameter && + m_dPeakParameter == m_dLastPeakParameter) { return; } @@ -297,7 +294,7 @@ void WVuMeterGL::render(VSyncThread* vSyncThread) { m_dLastParameter = m_dParameter; m_dLastPeakParameter = m_dPeakParameter; - m_iPendingRenders--; + m_bHasRendered = true; m_bSwapNeeded = true; } diff --git a/src/widget/wvumetergl.h b/src/widget/wvumetergl.h index eb3993b3357..43437489d80 100644 --- a/src/widget/wvumetergl.h +++ b/src/widget/wvumetergl.h @@ -38,9 +38,8 @@ class WVuMeterGL : public QGLWidget, public WBaseWidget { void showEvent(QShowEvent* /*unused*/) override; void setPeak(double parameter); - // To make sure we render at least N times even when we have no signal, - // for example after showEvent() - int m_iPendingRenders; + // To make sure we render at least once even when we have no signal + bool m_bHasRendered; // To indicate that we rendered so we need to swap bool m_bSwapNeeded; // Current parameter and peak parameter.