Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WVUMeterGL: fix initial rendering of meters invisble after skin load #11052

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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