Skip to content

Commit

Permalink
Merge pull request mixxxdj#11052 from ronso0/vumetergl-init-paint-fix
Browse files Browse the repository at this point in the history
WVUMeterGL: fix initial rendering of meters invisble after skin load
  • Loading branch information
daschuer authored Nov 10, 2022
2 parents dba50e2 + d053d42 commit dfa313f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/widget/wvumetergl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
WVuMeterGL::WVuMeterGL(QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
WBaseWidget(this),
m_bHasRendered(false),
m_iPendingRenders(0),
m_bSwapNeeded(false),
m_dParameter(0),
m_dPeakParameter(0),
Expand Down Expand Up @@ -156,10 +156,10 @@ void WVuMeterGL::updateState(mixxx::Duration elapsed) {

void WVuMeterGL::paintEvent(QPaintEvent* e) {
Q_UNUSED(e);
// Force a rerender when render is called from the vsync thread, e.g. to
// Force rerendering when render is called from the vsync thread, e.g. to
// git rid artifacts after hiding and showing the mixer or incomplete
// initial drawing.
m_bHasRendered = false;
// initial drawing. Use 2 passes, in case triple buffering is used.
m_iPendingRenders = 2;
}

void WVuMeterGL::showEvent(QShowEvent* e) {
Expand All @@ -173,8 +173,11 @@ void WVuMeterGL::render(VSyncThread* vSyncThread) {

updateState(vSyncThread->sinceLastSwap());

if (m_bHasRendered && m_dParameter == m_dLastParameter &&
m_dPeakParameter == m_dLastPeakParameter) {
if (m_dParameter != m_dLastParameter || m_dPeakParameter != m_dLastPeakParameter) {
m_iPendingRenders = 2;
}

if (m_iPendingRenders == 0) {
return;
}

Expand Down Expand Up @@ -294,7 +297,7 @@ void WVuMeterGL::render(VSyncThread* vSyncThread) {

m_dLastParameter = m_dParameter;
m_dLastPeakParameter = m_dPeakParameter;
m_bHasRendered = true;
m_iPendingRenders--;
m_bSwapNeeded = true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/widget/wvumetergl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class WVuMeterGL : public QGLWidget, public WBaseWidget {
void showEvent(QShowEvent* /*unused*/) override;
void setPeak(double parameter);

// To make sure we render at least once even when we have no signal
bool m_bHasRendered;
// To make sure we render at least N times even when we have no signal,
// for example after showEvent()
int m_iPendingRenders;
// To indicate that we rendered so we need to swap
bool m_bSwapNeeded;
// Current parameter and peak parameter.
Expand Down

0 comments on commit dfa313f

Please sign in to comment.