From d065b8c4c67831954f6425b31b517416800405ee Mon Sep 17 00:00:00 2001 From: Antoine C Date: Tue, 7 May 2024 23:12:44 +0100 Subject: [PATCH 01/16] feat: simplify waveform combobox --- src/preferences/dialog/dlgprefwaveform.cpp | 87 ++- src/preferences/dialog/dlgprefwaveform.h | 1 + src/preferences/dialog/dlgprefwaveformdlg.ui | 613 +++++++++--------- src/preferences/upgrade.cpp | 61 +- src/waveform/waveformwidgetfactory.cpp | 532 ++++++++------- src/waveform/waveformwidgetfactory.h | 23 +- .../allshader/filteredwaveformwidget.h | 5 +- .../widgets/allshader/hsvwaveformwidget.h | 5 +- .../widgets/allshader/lrrgbwaveformwidget.h | 6 +- .../widgets/allshader/rgbwaveformwidget.h | 5 +- .../widgets/allshader/simplewaveformwidget.h | 5 +- src/waveform/widgets/emptywaveformwidget.h | 5 +- src/waveform/widgets/glrgbwaveformwidget.h | 5 +- src/waveform/widgets/glsimplewaveformwidget.h | 4 +- src/waveform/widgets/glslwaveformwidget.h | 11 +- src/waveform/widgets/glvsynctestwidget.h | 5 +- src/waveform/widgets/glwaveformwidget.h | 5 +- src/waveform/widgets/hsvwaveformwidget.h | 5 +- src/waveform/widgets/qthsvwaveformwidget.h | 5 +- src/waveform/widgets/qtrgbwaveformwidget.h | 4 +- src/waveform/widgets/qtsimplewaveformwidget.h | 5 +- src/waveform/widgets/qtvsynctestwidget.h | 4 +- src/waveform/widgets/qtwaveformwidget.h | 4 +- src/waveform/widgets/rgbwaveformwidget.h | 5 +- src/waveform/widgets/softwarewaveformwidget.h | 4 +- src/waveform/widgets/waveformwidgettype.h | 44 +- src/widget/wwaveformviewer.cpp | 2 +- 27 files changed, 788 insertions(+), 672 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 15e0daf6c0b..13beb8dd3ac 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -8,6 +8,30 @@ #include "waveform/renderers/waveformwidgetrenderer.h" #include "waveform/waveformwidgetfactory.h" +namespace { +constexpr WaveformWidgetType::Type kDefaultWaveform = WaveformWidgetType::RGB; +const QList kWaveformWithOnlyAcceleration = { + WaveformWidgetType::Simple, + WaveformWidgetType::Stacked}; +const QList kWaveformWithoutAcceleration = { + WaveformWidgetType::VSyncTest, + WaveformWidgetType::Empty}; + +void setAccelerationCheckboxProperty(WaveformWidgetType::Type type, QCheckBox* checkbox) { + checkbox->blockSignals(true); + if (kWaveformWithOnlyAcceleration.contains(type)) { + checkbox->setEnabled(false); + checkbox->setChecked(true); + } else if (kWaveformWithoutAcceleration.contains(type)) { + checkbox->setEnabled(false); + checkbox->setChecked(false); + } else { + checkbox->setEnabled(true); + } + checkbox->blockSignals(false); +} +} // anonymous namespace + DlgPrefWaveform::DlgPrefWaveform( QWidget* pParent, UserSettingsPointer pConfig, @@ -27,9 +51,9 @@ DlgPrefWaveform::DlgPrefWaveform( // We assume that the original type list order remains constant. // We will use the type index later on to set waveform types and to // update the combobox. - QVector handles = factory->getAvailableTypes(); - for (int i = 0; i < handles.size(); ++i) { - waveformTypeComboBox->addItem(handles[i].getDisplayName(), i); + QVector types = factory->getAvailableTypes(); + for (int i = 0; i < types.size(); ++i) { + waveformTypeComboBox->addItem(types[i].getDisplayName(), types[i].getType()); } // Sort the combobox items alphabetically waveformTypeComboBox->model()->sort(0); @@ -92,6 +116,11 @@ DlgPrefWaveform::DlgPrefWaveform( QOverload::of(&QComboBox::currentIndexChanged), this, &DlgPrefWaveform::slotSetWaveformType); + + connect(useAccelerationCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformAcceleration); connect(defaultZoomComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -164,16 +193,25 @@ void DlgPrefWaveform::slotUpdate() { if (factory->isOpenGlAvailable() || factory->isOpenGlesAvailable()) { openGlStatusData->setText(factory->getOpenGLVersion()); + useAccelerationCheckBox->setEnabled(true); + useAccelerationCheckBox->setChecked( + m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + WaveformWidgetBackend::AllShader) != + WaveformWidgetBackend::None); } else { openGlStatusData->setText(tr("OpenGL not available") + ": " + factory->getOpenGLVersion()); + useAccelerationCheckBox->setEnabled(false); + useAccelerationCheckBox->setChecked(false); } // The combobox holds a list of [handle name, handle index] - int currentIndex = waveformTypeComboBox->findData(factory->getHandleIndex()); + int currentIndex = waveformTypeComboBox->findData(factory->getType()); if (currentIndex != -1 && waveformTypeComboBox->currentIndex() != currentIndex) { waveformTypeComboBox->setCurrentIndex(currentIndex); } + setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox); updateEnableUntilMark(); frameRateSpinBox->setValue(factory->getFrameRate()); @@ -230,7 +268,7 @@ void DlgPrefWaveform::slotResetToDefaults() { // Get the default we ought to use based on whether the user has OpenGL or not. // Select the combobox index that holds the default handle's index in data column. int defaultIndex = waveformTypeComboBox->findData( - factory->findHandleIndexFromType(factory->autoChooseWidgetType())); + factory->findHandleIndexFromType(kDefaultWaveform)); if (defaultIndex != -1 && waveformTypeComboBox->currentIndex() != defaultIndex) { waveformTypeComboBox->setCurrentIndex(defaultIndex); } @@ -280,14 +318,47 @@ void DlgPrefWaveform::slotSetWaveformType(int index) { if (index < 0) { return; } - int handleIndex = waveformTypeComboBox->itemData(index).toInt(); - WaveformWidgetFactory::instance()->setWidgetTypeFromHandle(handleIndex); + auto type = static_cast( + waveformTypeComboBox->itemData(index).toInt()); + auto factory = WaveformWidgetFactory::instance(); + factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type)); + + setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox); + updateEnableUntilMark(); +} + +void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { + if (checked) { + m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), +#ifdef MIXXX_USE_QOPENGL + WaveformWidgetBackend::AllShader +#else + WaveformWidgetBackend::GL +#endif + ); + } else { + m_pConfig->setValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + WaveformWidgetBackend::None); + } + auto type = static_cast(waveformTypeComboBox->currentData().toInt()); + auto factory = WaveformWidgetFactory::instance(); + factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); updateEnableUntilMark(); } void DlgPrefWaveform::updateEnableUntilMark() { - const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark(); +#ifndef MIXXX_USE_QOPENGL + const bool enabled = false; +#else + const bool enabled = + WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark() && + m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + WaveformWidgetBackend::AllShader) != + WaveformWidgetBackend::None; +#endif untilMarkShowBeatsCheckBox->setEnabled(enabled); untilMarkShowTimeCheckBox->setEnabled(enabled); untilMarkAlignLabel->setEnabled(enabled); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index e141c17f996..8307998a31d 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -26,6 +26,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg private slots: void slotSetFrameRate(int frameRate); void slotSetWaveformType(int index); + void slotSetWaveformAcceleration(bool checked); void slotSetWaveformOverviewType(int index); void slotSetDefaultZoom(int index); void slotSetZoomSynchronization(bool checked); diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 6c42b4bf020..5440254d3f9 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -6,70 +6,69 @@ 0 0 - 677 - 528 + 697 + 673 Waveform Preferences - + + + + Qt::Vertical + + + + 20 + 40 + + + + - - - - - - 0 - 0 - - + + - + The waveform overview shows the waveform envelope of the entire track. +Select from different types of displays for the waveform overview, which differ primarily in the level of detail shown in the waveform. + + + + - Waveform type - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - waveformTypeComboBox + Beats until next marker - - - - - - + + - Waveform overview type + Time until next marker - - + + - The waveform overview shows the waveform envelope of the entire track. -Select from different types of displays for the waveform overview, which differ primarily in the level of detail shown in the waveform. + Synchronize zoom level across all waveform displays. + + + Synchronize zoom level across all waveforms - - - - - The waveform shows the waveform envelope of the track near the current playback position. -Select from different types of displays for the waveform, which differ primarily in the level of detail shown in the waveform. + + + + Normalize waveform overview - - + Frame rate @@ -82,68 +81,113 @@ Select from different types of displays for the waveform, which differ primarily - - - - - 0 - 0 - + + + + + + + Play marker hints - - - 16777215 - 16777215 - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - 10 + + + + + + Placement - - 60 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - 30 + + untilMarkAlignComboBox - - Qt::Horizontal + + + + + + OpenGL status + + + + + + 0 + 0 + + + + Displays which OpenGL version is supported by the current platform. + + + + + + true + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + Average frame rate + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Displays the actual frame rate. + + + + + + + - - + + - - - - fps - - - 10 - - - 60 + - - 30 + + Waveform overview type - - - - - End of track warning + + + + Set amount of opacity on beat grid lines. - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + % - - endOfTrackWarningTimeSlider + + 100 + + + 90 - + @@ -171,43 +215,38 @@ Select from different types of displays for the waveform, which differ primarily - - - - Highlight the waveforms when the last seconds of a track remains. + + + + + 0 + 0 + - - seconds + + + 16777215 + 16777215 + + + + Moves the play marker position on the waveforms to the left, right or center (default). 0 - 60 + 100 - 30 - - - - - - - - - - - 6 - - - Beat grid opacity + 50 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + Qt::Horizontal - + 100 @@ -220,35 +259,40 @@ Select from different types of displays for the waveform, which differ primarily - - + + + + Default zoom level + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + defaultZoomComboBox + + + + + - Set amount of opacity on beat grid lines. + - % + pt + + + 10 - 100 + 50 - 90 + 30 - - - - - Play marker position - - - - - - - Moves the play marker position on the waveforms to the left, right or center (default). - + + 0 @@ -262,70 +306,110 @@ Select from different types of displays for the waveform, which differ primarily - 0 + 10 - 100 + 60 - 50 + 30 Qt::Horizontal - - - + + + + + - Default zoom level + Caching - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Visual gain + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - defaultZoomComboBox + allVisualGain - - - - - - - - Synchronize zoom level across all waveform displays. - + + - Synchronize zoom level across all waveforms + This functionality requires waveform acceleration "(GLSL)". + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - + + - Normalize waveform overview + End of track warning + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + endOfTrackWarningTimeSlider - - - + + + + + 0 + 0 + + + + + - Visual gain + Waveform type - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - allVisualGain + waveformTypeComboBox - + + + + Highlight the waveforms when the last seconds of a track remains. + + + seconds + + + 0 + + + 60 + + + 30 + + + + @@ -457,100 +541,26 @@ Select from different types of displays for the waveform, which differ primarily - - - - - Play marker hints - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Beats until next marker - - - - - - - Time until next marker - - - - - - - Placement - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - untilMarkAlignComboBox - - - - - - - - - - Font size - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - untilMarkTextPointSizeSpinBox - - - - - + + - pt + fps 10 - 50 + 60 30 - - - - This functionality requires a waveform type marked "(GLSL)". - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Caching - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - + @@ -571,18 +581,18 @@ Select from different types of displays for the waveform, which differ primarily - - PLACEHOLDER FOR DISK USAGE - z - - true - 0 0 + + PLACEHOLDER FOR DISK USAGE + + + true + @@ -601,85 +611,88 @@ Select from different types of displays for the waveform, which differ primarily - - - - - OpenGL status + + + + - - - - + + 6 + + + Beat grid opacity + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Play marker position + + + + + + + Font size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkTextPointSizeSpinBox + + + + + + + - Displays which OpenGL version is supported by the current platform. + The waveform shows the waveform envelope of the track near the current playback position. +Select from different types of displays for the waveform, which differ primarily in the level of detail shown in the waveform. - - + + + + + + Qt::Horizontal - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + QSizePolicy::Maximum - - true + + + 20 + 20 + + + + + - + 0 0 - - - - - - - - - - Average frame rate - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Displays the actual frame rate. - - + Use acceleration - - - + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - waveformTypeComboBox waveformOverviewComboBox frameRateSlider frameRateSpinBox diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index f9b33f81a7a..b99383a7714 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -32,40 +32,21 @@ Upgrade::~Upgrade() { namespace { // mapping to proactively move users to the new all-shader waveform types -WaveformWidgetType::Type upgradeToAllShaders(WaveformWidgetType::Type waveformType) { +void upgradeToAllShaders(WaveformWidgetType::Type* waveformType, + WaveformWidgetBackend::Backend* waveformBackend) { + if (*waveformBackend == WaveformWidgetBackend::AllShader) { + return; + } // TODO: convert `WaveformWidgetType::Type` to an enum class then shorten more `using enum ...` using WWT = WaveformWidgetType; - switch (waveformType) { - case WWT::EmptyWaveform: - case WWT::SoftwareSimpleWaveform: - case WWT::SoftwareWaveform: - case WWT::GLVSyncTest: - case WWT::QtVSyncTest: - case WWT::AllShaderRGBWaveform: - case WWT::AllShaderLRRGBWaveform: - case WWT::AllShaderFilteredWaveform: - case WWT::AllShaderSimpleWaveform: - case WWT::AllShaderHSVWaveform: - case WWT::Count_WaveformwidgetType: - return waveformType; - case WWT::QtSimpleWaveform: - case WWT::GLSimpleWaveform: - return WaveformWidgetType::AllShaderSimpleWaveform; - case WWT::GLFilteredWaveform: - case WWT::GLSLFilteredWaveform: - return WaveformWidgetType::AllShaderFilteredWaveform; - case WWT::QtWaveform: - case WWT::RGBWaveform: - case WWT::GLRGBWaveform: - case WWT::GLSLRGBWaveform: - case WWT::QtRGBWaveform: - case WWT::GLSLRGBStackedWaveform: - return WWT::AllShaderRGBWaveform; - case WWT::HSVWaveform: - case WWT::QtHSVWaveform: - return WWT::AllShaderHSVWaveform; + switch (*waveformType) { + case WWT::Empty: + case WWT::VSyncTest: + // Not supported by AllShader + return; + default: + *waveformBackend = WaveformWidgetBackend::AllShader; } - return WWT::AllShaderRGBWaveform; } VSyncThread::VSyncMode upgradeDeprecatedVSyncModes(int configVSyncMode) { @@ -514,15 +495,21 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { configVersion.startsWith("2.4.0-"))) { // Proactively move users to an all-shader waveform widget type and set the // framerate to 60 fps - bool ok = false; + bool okType = false, okBackend = false; auto waveformType = config->getValueString(ConfigKey("[Waveform]", "WaveformType")) - .toInt(&ok); - if (ok) { + .toInt(&okType); + auto waveformBackend = + config->getValueString(ConfigKey("[Waveform]", "use_hardware_acceleration")) + .toInt(&okBackend); + if (okType && okBackend) { + upgradeToAllShaders( + (WaveformWidgetType::Type*)&waveformType, + (WaveformWidgetBackend::Backend*)&waveformBackend); config->set(ConfigKey("[Waveform]", "WaveformType"), - ConfigValue(upgradeToAllShaders( - static_cast( - waveformType)))); + ConfigValue(waveformType)); + config->set(ConfigKey("[Waveform]", "use_hardware_acceleration"), + ConfigValue(waveformBackend)); } config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60)); diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index a01452b8fdb..f7b607f53e7 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -75,7 +75,7 @@ const QRegularExpression openGLVersionRegex(QStringLiteral("^(\\d+)\\.(\\d+).*$" /////////////////////////////////////////// WaveformWidgetAbstractHandle::WaveformWidgetAbstractHandle() - : m_type(WaveformWidgetType::Count_WaveformwidgetType) { + : m_type(WaveformWidgetType::Count_WaveformWidgetType) { } /////////////////////////////////////////// @@ -102,8 +102,8 @@ WaveformWidgetFactory::WaveformWidgetFactory() // Set an empty waveform initially. We will set the correct one when skin load finishes. // Concretely, we want to set a non-GL waveform when loading the skin so that the window // loads correctly. - : m_type(WaveformWidgetType::EmptyWaveform), - m_configType(WaveformWidgetType::EmptyWaveform), + : m_type(WaveformWidgetType::Empty), + m_configType(WaveformWidgetType::Empty), m_config(nullptr), m_skipRender(false), m_frameRate(60), @@ -381,7 +381,7 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { // Store the widget type on m_configType for later initialization. // We will initialize the objects later because of a problem with GL on QT 5.14.2 on Windows if (!ok || !setWidgetType(type, &m_configType)) { - setWidgetType(autoChooseWidgetType(), &m_configType); + setWidgetType(WaveformWidgetType::RGB, &m_configType); } for (int i = 0; i < FilterCount; i++) { @@ -552,7 +552,7 @@ bool WaveformWidgetFactory::setWidgetType( // check if type is acceptable int index = findHandleIndexFromType(type); bool isAcceptable = index > -1; - *pCurrentType = isAcceptable ? type : WaveformWidgetType::EmptyWaveform; + *pCurrentType = isAcceptable ? type : WaveformWidgetType::Empty; if (m_config) { m_configType = *pCurrentType; m_config->setValue( @@ -563,15 +563,13 @@ bool WaveformWidgetFactory::setWidgetType( bool WaveformWidgetFactory::widgetTypeSupportsUntilMark() const { switch (m_configType) { - case WaveformWidgetType::AllShaderRGBWaveform: + case WaveformWidgetType::RGB: return true; - case WaveformWidgetType::AllShaderLRRGBWaveform: + case WaveformWidgetType::Filtered: return true; - case WaveformWidgetType::AllShaderFilteredWaveform: + case WaveformWidgetType::Simple: return true; - case WaveformWidgetType::AllShaderSimpleWaveform: - return true; - case WaveformWidgetType::AllShaderHSVWaveform: + case WaveformWidgetType::HSV: return true; default: break; @@ -580,7 +578,7 @@ bool WaveformWidgetFactory::widgetTypeSupportsUntilMark() const { } bool WaveformWidgetFactory::setWidgetTypeFromConfig() { - int empty = findHandleIndexFromType(WaveformWidgetType::EmptyWaveform); + int empty = findHandleIndexFromType(WaveformWidgetType::Empty); int desired = findHandleIndexFromType(m_configType); if (desired == -1) { qDebug() << "WaveformWidgetFactory::setWidgetTypeFromConfig" @@ -596,7 +594,7 @@ bool WaveformWidgetFactory::setWidgetTypeFromHandle(int handleIndex, bool force) qDebug() << "WaveformWidgetFactory::setWidgetTypeFromHandle" " - invalid handle --> using 'EmptyWaveform'"; // fallback empty type - setWidgetType(WaveformWidgetType::EmptyWaveform); + setWidgetType(WaveformWidgetType::Empty); return false; } @@ -863,283 +861,327 @@ void WaveformWidgetFactory::slotFrameSwapped() { #endif } -WaveformWidgetType::Type WaveformWidgetFactory::autoChooseWidgetType() const { - if (isOpenGlShaderAvailable()) { -#ifndef MIXXX_USE_QOPENGL - return WaveformWidgetType::GLSLRGBWaveform; -#else - return WaveformWidgetType::AllShaderRGBWaveform; -#endif - } - if (isOpenGlAvailable() || isOpenGlesAvailable()) { - return WaveformWidgetType::GLRGBWaveform; - } - return WaveformWidgetType::RGBWaveform; -} - void WaveformWidgetFactory::evaluateWidgets() { m_waveformWidgetHandles.clear(); - for (int type = 0; type < WaveformWidgetType::Count_WaveformwidgetType; type++) { - QString widgetName; - bool useOpenGl; - bool useOpenGles; - bool useOpenGLShaders; - WaveformWidgetCategory category; - + QHash> collectedHandles; + for (int type = WaveformWidgetType::Empty; + type < WaveformWidgetType::Count_WaveformWidgetType; + type++) { // this lambda needs its type specified explicitly, // requiring it to be called with via `.operator()()` + collectedHandles.insert(static_cast(type), + QList()); auto setWaveformVarsByType = [&]() { - widgetName = buildWidgetDisplayName(); - useOpenGl = WaveformT::useOpenGl(); - useOpenGles = WaveformT::useOpenGles(); - useOpenGLShaders = WaveformT::useOpenGLShaders(); - category = WaveformT::category(); + bool useOpenGl = WaveformT::useOpenGl(); + bool useOpenGles = WaveformT::useOpenGles(); + bool useOpenGLShaders = WaveformT::useOpenGLShaders(); + WaveformWidgetCategory category = WaveformT::category(); + WaveformWidgetBackend::Backend backend = WaveformWidgetBackend::None; + + bool active = true; + if (isOpenGlAvailable()) { + if (useOpenGles && !useOpenGl) { + active = false; + } else if (useOpenGLShaders && !isOpenGlShaderAvailable()) { + active = false; + } + } else if (isOpenGlesAvailable()) { + if (useOpenGl && !useOpenGles) { + active = false; + } else if (useOpenGLShaders && !isOpenGlShaderAvailable()) { + active = false; + } + } else { + // No sufficient GL support + if (useOpenGles || useOpenGl || useOpenGLShaders) { + active = false; + } + } + + if (category == WaveformWidgetCategory::DeveloperOnly && + !CmdlineArgs::Instance().getDeveloper()) { + active = false; + } +#ifdef MIXXX_USE_QOPENGL + else if (category == WaveformWidgetCategory::AllShader) { + backend = WaveformWidgetBackend::AllShader; + } +#endif + else if (category == WaveformWidgetCategory::Legacy && useOpenGLShaders) { + backend = WaveformWidgetBackend::GLSL; + } else if (category == WaveformWidgetCategory::Legacy) { + backend = WaveformWidgetBackend::GL; + } + + if (active) { + collectedHandles[static_cast(type)].push_back(backend); + } }; switch(type) { - case WaveformWidgetType::EmptyWaveform: + case WaveformWidgetType::Empty: setWaveformVarsByType.operator()(); break; - case WaveformWidgetType::SoftwareSimpleWaveform: - continue; // //TODO(vrince): - case WaveformWidgetType::SoftwareWaveform: -#ifdef __APPLE__ + case WaveformWidgetType::Simple: + setWaveformVarsByType.operator()(); +#ifdef MIXXX_USE_QOPENGL + setWaveformVarsByType.operator()(); +#else + setWaveformVarsByType.operator()(); + break; +#endif + case WaveformWidgetType::Filtered: +#ifndef __APPLE__ // Don't offer the simple renderers on macOS, they do not work with skins // that load GL widgets (spinnies, waveforms) in singletons. // Also excluded in enum WaveformWidgetType // https://bugs.launchpad.net/bugs/1928772 - continue; -#else setWaveformVarsByType.operator()(); - break; -#endif - case WaveformWidgetType::HSVWaveform: -#ifdef __APPLE__ - continue; -#else - setWaveformVarsByType.operator()(); - break; #endif - case WaveformWidgetType::RGBWaveform: -#ifdef __APPLE__ - continue; -#else - setWaveformVarsByType.operator()(); - break; -#endif - case WaveformWidgetType::QtSimpleWaveform: -#ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; -#endif - case WaveformWidgetType::QtWaveform: + setWaveformVarsByType.operator()(); + setWaveformVarsByType.operator()(); #ifdef MIXXX_USE_QOPENGL - continue; + setWaveformVarsByType.operator()(); #else setWaveformVarsByType.operator()(); - break; #endif - case WaveformWidgetType::GLSimpleWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLFilteredWaveform: - setWaveformVarsByType.operator()(); break; - case WaveformWidgetType::GLSLFilteredWaveform: - setWaveformVarsByType.operator()(); + case WaveformWidgetType::VSyncTest: + setWaveformVarsByType.operator()(); +#ifndef MIXXX_USE_QOPENGL + setWaveformVarsByType.operator()(); +#endif break; - case WaveformWidgetType::GLSLRGBWaveform: + case WaveformWidgetType::RGB: setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLSLRGBStackedWaveform: setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLVSyncTest: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLRGBWaveform: setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::QtVSyncTest: +#ifndef __APPLE__ + // Don't offer the simple renderers on macOS, they do not work with skins + // that load GL widgets (spinnies, waveforms) in singletons. + // Also excluded in enum WaveformWidgetType + // https://bugs.launchpad.net/bugs/1928772 + setWaveformVarsByType.operator()(); +#endif #ifdef MIXXX_USE_QOPENGL - continue; + setWaveformVarsByType.operator()(); #else - setWaveformVarsByType.operator()(); + setWaveformVarsByType.operator()(); #endif break; - case WaveformWidgetType::QtHSVWaveform: + case WaveformWidgetType::HSV: +#ifndef __APPLE__ + // Don't offer the simple renderers on macOS, they do not work with skins + // that load GL widgets (spinnies, waveforms) in singletons. + // Also excluded in enum WaveformWidgetType + // https://bugs.launchpad.net/bugs/1928772 + setWaveformVarsByType.operator()(); +#endif #ifdef MIXXX_USE_QOPENGL - continue; + setWaveformVarsByType.operator()(); #else setWaveformVarsByType.operator()(); - break; #endif - case WaveformWidgetType::QtRGBWaveform: -#ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); + case WaveformWidgetType::Stacked: + setWaveformVarsByType.operator()(); break; -#endif - case WaveformWidgetType::AllShaderRGBWaveform: -#ifndef MIXXX_USE_QOPENGL + default: + DEBUG_ASSERT(!"Unexpected WaveformWidgetType"); continue; + } + } +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + for (auto [type, backends] : collectedHandles.asKeyValueRange()) { #else - setWaveformVarsByType.operator()(); - break; + QHashIterator> + handleIter(collectedHandles); + while (handleIter.hasNext()) { + handleIter.next(); + auto& type = handleIter.key(); + auto& backends = handleIter.value(); #endif - case WaveformWidgetType::AllShaderLRRGBWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; + m_waveformWidgetHandles.push_back(WaveformWidgetAbstractHandle(type, backends)); + } +} + +WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( + WWaveformViewer* viewer) { + // On the UI, hardware acceleration is a boolean (0 => software rendering, 1 + // => hardware acceleration), but in the setting, we keep the granularity so + // in case of issue when we release, we can communicate workaround on + // editing the INI file to target a specific rendering backend. If no + // complains come back, we can convert this safely to a backend eventually. + int backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + isOpenGlAvailable() || isOpenGlesAvailable() + ? +#ifdef MIXXX_USE_QOPENGL + WaveformWidgetBackend::AllShader #else - setWaveformVarsByType.operator()(); - break; + WaveformWidgetBackend::GL #endif - case WaveformWidgetType::AllShaderFilteredWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; + : WaveformWidgetBackend::None); + + switch (backend) { + case WaveformWidgetBackend::GL: + return new GLWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetBackend::GLSL: + return new GLSLFilteredWaveformWidget(viewer->getGroup(), viewer); +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: + return new allshader::FilteredWaveformWidget(viewer->getGroup(), viewer); #else - setWaveformVarsByType.operator()(); - break; + case WaveformWidgetBackend::Qt: + return new QtWaveformWidget(viewer->getGroup(), viewer); #endif - case WaveformWidgetType::AllShaderSimpleWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; + default: + return new SoftwareWaveformWidget(viewer->getGroup(), viewer); + } +} + +WaveformWidgetAbstract* WaveformWidgetFactory::createHSVWaveformWidget(WWaveformViewer* viewer) { + // On the UI, hardware acceleration is a boolean (0 => software rendering, 1 + // => hardware acceleration), but in the setting, we keep the granularity so + // in case of issue when we release, we can communicate workaround on + // editing the INI file to target a specific rendering backend. If no + // complains come back, we can convert this safely to a backend eventually. + int backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + isOpenGlAvailable() || isOpenGlesAvailable() + ? +#ifdef MIXXX_USE_QOPENGL + WaveformWidgetBackend::AllShader #else - setWaveformVarsByType.operator()(); - break; + WaveformWidgetBackend::GL #endif - case WaveformWidgetType::AllShaderHSVWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; + : WaveformWidgetBackend::None); + + switch (backend) { +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: + return new allshader::HSVWaveformWidget(viewer->getGroup(), viewer); +#endif + default: + return new HSVWaveformWidget(viewer->getGroup(), viewer); + } +} + +WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveformViewer* viewer) { + // On the UI, hardware acceleration is a boolean (0 => software rendering, 1 + // => hardware acceleration), but in the setting, we keep the granularity so + // in case of issue when we release, we can communicate workaround on + // editing the INI file to target a specific rendering backend. If no + // complains come back, we can convert this safely to a backend eventually. + int backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + isOpenGlAvailable() || isOpenGlesAvailable() + ? +#ifdef MIXXX_USE_QOPENGL + WaveformWidgetBackend::AllShader #else - setWaveformVarsByType.operator()(); - break; + WaveformWidgetBackend::GL #endif - default: - DEBUG_ASSERT(!"Unexpected WaveformWidgetType"); - continue; - } + : WaveformWidgetBackend::None); - bool active = true; - if (isOpenGlAvailable()) { - if (useOpenGles && !useOpenGl) { - active = false; - } else if (useOpenGLShaders && !isOpenGlShaderAvailable()) { - active = false; - } - } else if (isOpenGlesAvailable()) { - if (useOpenGl && !useOpenGles) { - active = false; - } else if (useOpenGLShaders && !isOpenGlShaderAvailable()) { - active = false; - } - } else { - // No sufficient GL support - if (useOpenGles || useOpenGl || useOpenGLShaders) { - active = false; - } - } + switch (backend) { + case WaveformWidgetBackend::GL: + return new GLRGBWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetBackend::GLSL: + return new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: + return new allshader::RGBWaveformWidget(viewer->getGroup(), viewer); +#else + case WaveformWidgetBackend::Qt: + return new QtRGBWaveformWidget(viewer->getGroup(), viewer); +#endif + default: + return new RGBWaveformWidget(viewer->getGroup(), viewer); + } +} - if (category == WaveformWidgetCategory::DeveloperOnly && - !CmdlineArgs::Instance().getDeveloper()) { - active = false; - } +WaveformWidgetAbstract* WaveformWidgetFactory::createStackedWaveformWidget( + WWaveformViewer* viewer) { + return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); +} - if (active) { - // add new handle for each available widget type - WaveformWidgetAbstractHandle handle; - handle.m_displayString = widgetName; - handle.m_type = static_cast(type); +WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWaveformViewer* viewer) { + // On the UI, hardware acceleration is a boolean (0 => software rendering, 1 + // => hardware acceleration), but in the setting, we keep the granularity so + // in case of issue when we release, we can communicate workaround on + // editing the INI file to target a specific rendering backend. If no + // complains come back, we can convert this safely to a backend eventually. + int backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + isOpenGlAvailable() || isOpenGlesAvailable() + ? +#ifdef MIXXX_USE_QOPENGL + WaveformWidgetBackend::AllShader +#else + WaveformWidgetBackend::GL +#endif + : WaveformWidgetBackend::None); - m_waveformWidgetHandles.push_back(handle); - } + switch (backend) { +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::GL: + return new GLSimpleWaveformWidget(viewer->getGroup(), viewer); + default: + return new allshader::SimpleWaveformWidget(viewer->getGroup(), viewer); +#else + case WaveformWidgetBackend::Qt: + return new QtSimpleWaveformWidget(viewer->getGroup(), viewer); + default: + return new GLSimpleWaveformWidget(viewer->getGroup(), viewer); +#endif } } +WaveformWidgetAbstract* WaveformWidgetFactory::createVSyncTestWaveformWidget( + WWaveformViewer* viewer) { +#ifdef MIXXX_USE_QOPENGL + return new GLVSyncTestWidget(viewer->getGroup(), viewer); +#else + return new QtVSyncTest(viewer->getGroup(), viewer); +#endif +} + WaveformWidgetAbstract* WaveformWidgetFactory::createWaveformWidget( WaveformWidgetType::Type type, WWaveformViewer* viewer) { WaveformWidgetAbstract* widget = nullptr; if (viewer) { if (CmdlineArgs::Instance().getSafeMode()) { - type = WaveformWidgetType::EmptyWaveform; + type = WaveformWidgetType::Empty; } switch(type) { - case WaveformWidgetType::SoftwareWaveform: - widget = new SoftwareWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::HSVWaveform: - widget = new HSVWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::RGBWaveform: - widget = new RGBWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::Simple: + widget = createSimpleWaveformWidget(viewer); break; - case WaveformWidgetType::GLSimpleWaveform: - widget = new GLSimpleWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::Filtered: + widget = createFilteredWaveformWidget(viewer); break; - case WaveformWidgetType::GLFilteredWaveform: - widget = new GLWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::HSV: + widget = createHSVWaveformWidget(viewer); break; - case WaveformWidgetType::GLRGBWaveform: - widget = new GLRGBWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::VSyncTest: + widget = createVSyncTestWaveformWidget(viewer); break; - case WaveformWidgetType::GLSLFilteredWaveform: - widget = new GLSLFilteredWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::RGB: + widget = createRGBWaveformWidget(viewer); break; - case WaveformWidgetType::GLSLRGBWaveform: - widget = new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::Stacked: + widget = createStackedWaveformWidget(viewer); break; - case WaveformWidgetType::GLSLRGBStackedWaveform: - widget = new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::GLVSyncTest: - widget = new GLVSyncTestWidget(viewer->getGroup(), viewer); - break; -#ifdef MIXXX_USE_QOPENGL - case WaveformWidgetType::AllShaderRGBWaveform: - widget = new allshader::RGBWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::AllShaderLRRGBWaveform: - widget = new allshader::LRRGBWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::AllShaderFilteredWaveform: - widget = new allshader::FilteredWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::AllShaderSimpleWaveform: - widget = new allshader::SimpleWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::AllShaderHSVWaveform: - widget = new allshader::HSVWaveformWidget(viewer->getGroup(), viewer); - break; -#else - case WaveformWidgetType::QtSimpleWaveform: - widget = new QtSimpleWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::QtWaveform: - widget = new QtWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::QtVSyncTest: - widget = new QtVSyncTestWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::QtHSVWaveform: - widget = new QtHSVWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::QtRGBWaveform: - widget = new QtRGBWaveformWidget(viewer->getGroup(), viewer); - break; -#endif - default: - //case WaveformWidgetType::SoftwareSimpleWaveform: TODO: (vrince) //case WaveformWidgetType::EmptyWaveform: + default: widget = new EmptyWaveformWidget(viewer->getGroup(), viewer); break; } widget->castToQWidget(); if (!widget->isValid()) { - qWarning() << "failed to init WafeformWidget" << type << "fall back to \"Empty\""; + qWarning() << "failed to init WaveformWidget" << type << "fall back to \"Empty\""; delete widget; widget = new EmptyWaveformWidget(viewer->getGroup(), viewer); widget->castToQWidget(); @@ -1205,7 +1247,7 @@ void WaveformWidgetFactory::getAvailableVSyncTypes(QList>* p } WaveformWidgetType::Type WaveformWidgetFactory::findTypeFromHandleIndex(int index) { - WaveformWidgetType::Type type = WaveformWidgetType::Count_WaveformwidgetType; + WaveformWidgetType::Type type = WaveformWidgetType::Count_WaveformWidgetType; if (index >= 0 && index < m_waveformWidgetHandles.size()) { type = m_waveformWidgetHandles[index].m_type; } @@ -1223,40 +1265,26 @@ int WaveformWidgetFactory::findHandleIndexFromType(WaveformWidgetType::Type type return index; } -QString WaveformWidgetFactory::getDisplayNameFromType(WaveformWidgetType::Type type) { - for (const auto& handle : std::as_const(m_waveformWidgetHandles)) { - if (handle.m_type == type) { - return handle.m_displayString; - } - } - return QString(); -} - -template -QString WaveformWidgetFactory::buildWidgetDisplayName() const { - const bool isLegacy = WaveformT::category() == WaveformWidgetCategory::Legacy; - QStringList extras; - if (isLegacy) { - extras.push_back(tr("legacy")); - } - if (isOpenGlesAvailable()) { - if (WaveformT::useOpenGLShaders()) { - extras.push_back(QStringLiteral("GLSL ES")); - } else if (WaveformT::useOpenGles()) { - extras.push_back(QStringLiteral("GLES")); - } - } else if (isOpenGlAvailable()) { - if (WaveformT::useOpenGLShaders()) { - extras.push_back(QStringLiteral("GLSL")); - } else if (WaveformT::useOpenGl()) { - extras.push_back(QStringLiteral("GL")); - } - } - QString name = WaveformT::getWaveformWidgetName(); - if (extras.isEmpty()) { - return name; +// Static +QString WaveformWidgetAbstractHandle::getDisplayName() const { + switch (m_type) { + case WaveformWidgetType::Empty: + return QObject::tr("Empty"); + case WaveformWidgetType::Simple: + return QObject::tr("Simple"); + case WaveformWidgetType::Filtered: + return QObject::tr("Filtered"); + case WaveformWidgetType::HSV: + return QObject::tr("HSV"); + case WaveformWidgetType::VSyncTest: + return QObject::tr("VSyncTest"); + case WaveformWidgetType::RGB: + return QObject::tr("RGB"); + case WaveformWidgetType::Stacked: + return QObject::tr("Stacked"); + default: + return QObject::tr("Unknown"); } - return QStringLiteral("%1 (%2)").arg(name, extras.join(QStringLiteral(", "))); } // static diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index 1c00cff50b6..98fcecb16c2 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -22,13 +22,21 @@ class VisualsManager; class WaveformWidgetAbstractHandle { public: WaveformWidgetAbstractHandle(); + WaveformWidgetAbstractHandle(WaveformWidgetType::Type type, + QList backends) + : m_type(type), m_backends(std::move(backends)) { + } WaveformWidgetType::Type getType() const { return m_type;} - QString getDisplayName() const { return m_displayString;} + const QList& getBackend() const { + return m_backends; + } + + QString getDisplayName() const; private: WaveformWidgetType::Type m_type; - QString m_displayString; + QList m_backends; friend class WaveformWidgetFactory; }; @@ -157,9 +165,6 @@ class WaveformWidgetFactory : public QObject, public SingletongetType() == WaveformWidgetType::EmptyWaveform) { + if (m_waveformWidget->getType() == WaveformWidgetType::Empty) { return; } connect(this, From 0ace13eb51c62046f6e49b37e7f32f3e295752c4 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Wed, 8 May 2024 17:57:26 +0100 Subject: [PATCH 02/16] Merge RGB and LRRGB into a single renderer with options --- CMakeLists.txt | 2 - .../allshader/waveformrendererlrrgb.cpp | 226 ------------------ .../allshader/waveformrendererlrrgb.h | 29 --- .../allshader/waveformrendererrgb.cpp | 158 +++++++----- .../renderers/allshader/waveformrendererrgb.h | 4 +- .../allshader/waveformrenderersignalbase.h | 5 + src/waveform/waveformwidgetfactory.cpp | 12 +- .../widgets/allshader/lrrgbwaveformwidget.cpp | 35 --- .../widgets/allshader/lrrgbwaveformwidget.h | 42 ---- .../widgets/allshader/rgbwaveformwidget.cpp | 6 +- .../widgets/allshader/rgbwaveformwidget.h | 5 +- 11 files changed, 118 insertions(+), 406 deletions(-) delete mode 100644 src/waveform/renderers/allshader/waveformrendererlrrgb.cpp delete mode 100644 src/waveform/renderers/allshader/waveformrendererlrrgb.h delete mode 100644 src/waveform/widgets/allshader/lrrgbwaveformwidget.cpp delete mode 100644 src/waveform/widgets/allshader/lrrgbwaveformwidget.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2061926f158..2d021ce858b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1520,7 +1520,6 @@ if(QOPENGL) src/waveform/renderers/allshader/waveformrendererslipmode.cpp src/waveform/renderers/allshader/waveformrendererfiltered.cpp src/waveform/renderers/allshader/waveformrendererhsv.cpp - src/waveform/renderers/allshader/waveformrendererlrrgb.cpp src/waveform/renderers/allshader/waveformrendererpreroll.cpp src/waveform/renderers/allshader/waveformrendererrgb.cpp src/waveform/renderers/allshader/waveformrenderersignalbase.cpp @@ -1529,7 +1528,6 @@ if(QOPENGL) src/waveform/renderers/allshader/waveformrendermarkrange.cpp src/waveform/widgets/allshader/filteredwaveformwidget.cpp src/waveform/widgets/allshader/hsvwaveformwidget.cpp - src/waveform/widgets/allshader/lrrgbwaveformwidget.cpp src/waveform/widgets/allshader/rgbwaveformwidget.cpp src/waveform/widgets/allshader/simplewaveformwidget.cpp src/waveform/widgets/allshader/waveformwidget.cpp diff --git a/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp b/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp deleted file mode 100644 index d599704e99a..00000000000 --- a/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include "waveform/renderers/allshader/waveformrendererlrrgb.h" - -#include "track/track.h" -#include "util/math.h" -#include "waveform/renderers/allshader/matrixforwidgetgeometry.h" -#include "waveform/renderers/waveformwidgetrenderer.h" -#include "waveform/waveform.h" - -namespace allshader { - -namespace { -inline float math_pow2(float x) { - return x * x; -} -} // namespace - -WaveformRendererLRRGB::WaveformRendererLRRGB( - WaveformWidgetRenderer* waveformWidget) - : WaveformRendererSignalBase(waveformWidget) { -} - -void WaveformRendererLRRGB::onSetup(const QDomNode& node) { - Q_UNUSED(node); -} - -void WaveformRendererLRRGB::initializeGL() { - WaveformRendererSignalBase::initializeGL(); - m_shader.init(); -} - -void WaveformRendererLRRGB::paintGL() { - TrackPointer pTrack = m_waveformRenderer->getTrackInfo(); - if (!pTrack) { - return; - } - - ConstWaveformPointer waveform = pTrack->getWaveform(); - if (waveform.isNull()) { - return; - } - - const int dataSize = waveform->getDataSize(); - if (dataSize <= 1) { - return; - } - - const WaveformData* data = waveform->data(); - if (data == nullptr) { - return; - } - - const float devicePixelRatio = m_waveformRenderer->getDevicePixelRatio(); - const int length = static_cast(m_waveformRenderer->getLength() * devicePixelRatio); - - // See waveformrenderersimple.cpp for a detailed explanation of the frame and index calculation - const int visualFramesSize = dataSize / 2; - const double firstVisualFrame = - m_waveformRenderer->getFirstDisplayedPosition() * visualFramesSize; - const double lastVisualFrame = - m_waveformRenderer->getLastDisplayedPosition() * visualFramesSize; - - // Represents the # of visual frames per horizontal pixel. - const double visualIncrementPerPixel = - (lastVisualFrame - firstVisualFrame) / static_cast(length); - - // Per-band gain from the EQ knobs. - float allGain(1.0), lowGain(1.0), midGain(1.0), highGain(1.0); - // applyCompensation = false, as we scale to match filtered.all - getGains(&allGain, false, &lowGain, &midGain, &highGain); - - const float breadth = static_cast(m_waveformRenderer->getBreadth()) * devicePixelRatio; - const float halfBreadth = breadth / 2.0f; - - const float heightFactorAbs = allGain * halfBreadth / m_maxValue; - const float heightFactor[2] = {-heightFactorAbs, heightFactorAbs}; - - const float low_r = static_cast(m_rgbLowColor_r); - const float mid_r = static_cast(m_rgbMidColor_r); - const float high_r = static_cast(m_rgbHighColor_r); - const float low_g = static_cast(m_rgbLowColor_g); - const float mid_g = static_cast(m_rgbMidColor_g); - const float high_g = static_cast(m_rgbHighColor_g); - const float low_b = static_cast(m_rgbLowColor_b); - const float mid_b = static_cast(m_rgbMidColor_b); - const float high_b = static_cast(m_rgbHighColor_b); - - // Effective visual frame for x - double xVisualFrame = qRound(firstVisualFrame / visualIncrementPerPixel) * - visualIncrementPerPixel; - - const int numVerticesPerLine = 6; // 2 triangles - - const int reserved = numVerticesPerLine * (length * 2 + 1); - - m_vertices.clear(); - m_vertices.reserve(reserved); - m_colors.clear(); - m_colors.reserve(reserved); - - m_vertices.addRectangle(0.f, - halfBreadth - 0.5f * devicePixelRatio, - static_cast(length), - halfBreadth + 0.5f * devicePixelRatio); - m_colors.addForRectangle( - static_cast(m_axesColor_r), - static_cast(m_axesColor_g), - static_cast(m_axesColor_b)); - - const double maxSamplingRange = visualIncrementPerPixel / 2.0; - - for (int pos = 0; pos < length; ++pos) { - const int visualFrameStart = std::lround(xVisualFrame - maxSamplingRange); - const int visualFrameStop = std::lround(xVisualFrame + maxSamplingRange); - - const int visualIndexStart = std::max(visualFrameStart * 2, 0); - const int visualIndexStop = - std::min(std::max(visualFrameStop, visualFrameStart + 1) * 2, dataSize - 1); - - const float fpos = static_cast(pos); - - for (int chn = 0; chn < 2; chn++) { - // Find the max values for low, mid, high and all in the waveform data - uchar u8maxLow{}; - uchar u8maxMid{}; - uchar u8maxHigh{}; - uchar u8maxAll{}; - // data is interleaved left / right - for (int i = visualIndexStart + chn; i < visualIndexStop + chn; i += 2) { - const WaveformData& waveformData = data[i]; - - u8maxLow = math_max(u8maxLow, waveformData.filtered.low); - u8maxMid = math_max(u8maxMid, waveformData.filtered.mid); - u8maxHigh = math_max(u8maxHigh, waveformData.filtered.high); - u8maxAll = math_max(u8maxAll, waveformData.filtered.all); - } - - // Cast to float - float maxLow = static_cast(u8maxLow); - float maxMid = static_cast(u8maxMid); - float maxHigh = static_cast(u8maxHigh); - float maxAll = static_cast(u8maxAll); - // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h - // float maxAll = unscale(u8maxAll); - - // Calculate the squared magnitude of the maxLow, maxMid and maxHigh values. - // We take the square root to get the magnitude below. - const float sum = math_pow2(maxLow) + math_pow2(maxMid) + math_pow2(maxHigh); - - // Apply the gains - maxLow *= lowGain; - maxMid *= midGain; - maxHigh *= highGain; - - // Calculate the squared magnitude of the gained maxLow, maxMid and maxHigh values - // We take the square root to get the magnitude below. - const float sumGained = math_pow2(maxLow) + math_pow2(maxMid) + math_pow2(maxHigh); - - // The maxAll value will be used to draw the amplitude. We scale them according to - // magnitude of the gained maxLow, maxMid and maxHigh values - if (sum != 0.f) { - // magnitude = sqrt(sum) and magnitudeGained = sqrt(sumGained), and - // factor = magnitudeGained / magnitude, but we can do with a single sqrt: - const float factor = std::sqrt(sumGained / sum); - maxAll *= factor; - } - - // Use the gained maxLow, maxMid and maxHigh values to calculate the color components - float red = maxLow * low_r + maxMid * mid_r + maxHigh * high_r; - float green = maxLow * low_g + maxMid * mid_g + maxHigh * high_g; - float blue = maxLow * low_b + maxMid * mid_b + maxHigh * high_b; - - // Normalize the color components using the maximum of the three - const float maxComponent = math_max3(red, green, blue); - if (maxComponent == 0.f) { - // Avoid division by 0 - red = 0.f; - green = 0.f; - blue = 0.f; - } else { - const float normFactor = 1.f / maxComponent; - red *= normFactor; - green *= normFactor; - blue *= normFactor; - } - - // lines are thin rectangles - // note: heightFactor is the same for left and right, - // but negative for left (chn 0) and positive for right (chn 1) - m_vertices.addRectangle(fpos - 0.5f, - halfBreadth, - fpos + 0.5f, - halfBreadth + heightFactor[chn] * maxAll); - m_colors.addForRectangle(red, green, blue); - } - - xVisualFrame += visualIncrementPerPixel; - } - - DEBUG_ASSERT(reserved == m_vertices.size()); - DEBUG_ASSERT(reserved == m_colors.size()); - - const QMatrix4x4 matrix = matrixForWidgetGeometry(m_waveformRenderer, true); - - const int matrixLocation = m_shader.matrixLocation(); - const int positionLocation = m_shader.positionLocation(); - const int colorLocation = m_shader.colorLocation(); - - m_shader.bind(); - m_shader.enableAttributeArray(positionLocation); - m_shader.enableAttributeArray(colorLocation); - - m_shader.setUniformValue(matrixLocation, matrix); - - m_shader.setAttributeArray( - positionLocation, GL_FLOAT, m_vertices.constData(), 2); - m_shader.setAttributeArray( - colorLocation, GL_FLOAT, m_colors.constData(), 3); - - glDrawArrays(GL_TRIANGLES, 0, m_vertices.size()); - - m_shader.disableAttributeArray(positionLocation); - m_shader.disableAttributeArray(colorLocation); - m_shader.release(); -} - -} // namespace allshader diff --git a/src/waveform/renderers/allshader/waveformrendererlrrgb.h b/src/waveform/renderers/allshader/waveformrendererlrrgb.h deleted file mode 100644 index e1d55071739..00000000000 --- a/src/waveform/renderers/allshader/waveformrendererlrrgb.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "shaders/rgbshader.h" -#include "util/class.h" -#include "waveform/renderers/allshader/rgbdata.h" -#include "waveform/renderers/allshader/vertexdata.h" -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" - -namespace allshader { -class WaveformRendererLRRGB; -} - -class allshader::WaveformRendererLRRGB final : public allshader::WaveformRendererSignalBase { - public: - explicit WaveformRendererLRRGB(WaveformWidgetRenderer* waveformWidget); - - // override ::WaveformRendererSignalBase - void onSetup(const QDomNode& node) override; - - void initializeGL() override; - void paintGL() override; - - private: - mixxx::RGBShader m_shader; - VertexData m_vertices; - RGBData m_colors; - - DISALLOW_COPY_AND_ASSIGN(WaveformRendererLRRGB); -}; diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.cpp b/src/waveform/renderers/allshader/waveformrendererrgb.cpp index 20c4d12a484..1460394e602 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererrgb.cpp @@ -15,9 +15,11 @@ inline float math_pow2(float x) { } // namespace WaveformRendererRGB::WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::PositionSource type) + ::WaveformRendererAbstract::PositionSource type, + int options) : WaveformRendererSignalBase(waveformWidget), - m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) { + m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip), + m_options(options) { } void WaveformRendererRGB::onSetup(const QDomNode& node) { @@ -75,7 +77,9 @@ void WaveformRendererRGB::paintGL() { const float breadth = static_cast(m_waveformRenderer->getBreadth()) * devicePixelRatio; const float halfBreadth = breadth / 2.0f; - const float heightFactor = allGain * halfBreadth / m_maxValue; + const float heightFactorAbs = allGain * halfBreadth / m_maxValue; + const float heightFactor[2] = {-heightFactorAbs, heightFactorAbs}; + const bool splitLeftRight = m_options & WaveformRendererSignalBase::SplitStereoSignal; const float low_r = static_cast(m_rgbLowColor_r); const float mid_r = static_cast(m_rgbMidColor_r); @@ -93,7 +97,9 @@ void WaveformRendererRGB::paintGL() { const int numVerticesPerLine = 6; // 2 triangles - const int reserved = numVerticesPerLine * (length + 1); + const int reserved = numVerticesPerLine * + // Slip rendere only render a single channel, so the vertices count doesn't change + ((splitLeftRight && !m_isSlipRenderer ? length * 2 : length) + 1); m_vertices.clear(); m_vertices.reserve(reserved); @@ -123,79 +129,103 @@ void WaveformRendererRGB::paintGL() { // Find the max values for low, mid, high and all in the waveform data. // - Max of left and right - uchar u8maxLow{}; - uchar u8maxMid{}; - uchar u8maxHigh{}; + uchar u8maxLow[2]{}; + uchar u8maxMid[2]{}; + uchar u8maxHigh[2]{}; // - Per channel uchar u8maxAllChn[2]{}; for (int chn = 0; chn < 2; chn++) { + // In case we don't render individual color per channel, we use only + // the first field of the arrays to perform signal max + int signalChn = splitLeftRight ? chn : 0; // data is interleaved left / right for (int i = visualIndexStart + chn; i < visualIndexStop + chn; i += 2) { const WaveformData& waveformData = data[i]; - u8maxLow = math_max(u8maxLow, waveformData.filtered.low); - u8maxMid = math_max(u8maxMid, waveformData.filtered.mid); - u8maxHigh = math_max(u8maxHigh, waveformData.filtered.high); + u8maxLow[signalChn] = math_max(u8maxLow[signalChn], waveformData.filtered.low); + u8maxMid[signalChn] = math_max(u8maxMid[signalChn], waveformData.filtered.mid); + u8maxHigh[signalChn] = math_max(u8maxHigh[signalChn], waveformData.filtered.high); u8maxAllChn[chn] = math_max(u8maxAllChn[chn], waveformData.filtered.all); } } - - // Cast to float - float maxLow = static_cast(u8maxLow); - float maxMid = static_cast(u8maxMid); - float maxHigh = static_cast(u8maxHigh); float maxAllChn[2]{static_cast(u8maxAllChn[0]), static_cast(u8maxAllChn[1])}; - // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h - // float maxAllChn[2]{unscale(u8maxAllChn[0]), unscale(u8maxAllChn[1])}; - - // Calculate the squared magnitude of the maxLow, maxMid and maxHigh values. - // We take the square root to get the magnitude below. - const float sum = math_pow2(maxLow) + math_pow2(maxMid) + math_pow2(maxHigh); - - // Apply the gains - maxLow *= lowGain; - maxMid *= midGain; - maxHigh *= highGain; - - // Calculate the squared magnitude of the gained maxLow, maxMid and maxHigh values - // We take the square root to get the magnitude below. - const float sumGained = math_pow2(maxLow) + math_pow2(maxMid) + math_pow2(maxHigh); - - // The maxAll values will be used to draw the amplitude. We scale them according to - // magnitude of the gained maxLow, maxMid and maxHigh values - if (sum != 0.f) { - // magnitude = sqrt(sum) and magnitudeGained = sqrt(sumGained), and - // factor = magnitudeGained / magnitude, but we can do with a single sqrt: - const float factor = std::sqrt(sumGained / sum); - maxAllChn[0] *= factor; - maxAllChn[1] *= factor; - } - // Use the gained maxLow, maxMid and maxHigh values to calculate the color components - float red = maxLow * low_r + maxMid * mid_r + maxHigh * high_r; - float green = maxLow * low_g + maxMid * mid_g + maxHigh * high_g; - float blue = maxLow * low_b + maxMid * mid_b + maxHigh * high_b; - - // Normalize the color components using the maximum of the three - const float maxComponent = math_max3(red, green, blue); - if (maxComponent == 0.f) { - // Avoid division by 0 - red = 0.f; - green = 0.f; - blue = 0.f; - } else { - const float normFactor = 1.f / maxComponent; - red *= normFactor; - green *= normFactor; - blue *= normFactor; - } + for (int chn = 0; + // In case we don't render individual color per channel, all the + // signal information is in the first field of each array. If + // this is the split render, we only render the left channel + // anyway. + chn < (splitLeftRight && !m_isSlipRenderer ? 2 : 1); + chn++) { + // Cast to float + float maxLow = static_cast(u8maxLow[chn]); + float maxMid = static_cast(u8maxMid[chn]); + float maxHigh = static_cast(u8maxHigh[chn]); + // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h + // float maxAllChn[2]{unscale(u8maxAllChn[0]), unscale(u8maxAllChn[1])}; + + // Calculate the squared magnitude of the maxLow, maxMid and maxHigh values. + // We take the square root to get the magnitude below. + const float sum = math_pow2(maxLow) + math_pow2(maxMid) + math_pow2(maxHigh); + + // Apply the gains + maxLow *= lowGain; + maxMid *= midGain; + maxHigh *= highGain; + + // Calculate the squared magnitude of the gained maxLow, maxMid and maxHigh values + // We take the square root to get the magnitude below. + const float sumGained = math_pow2(maxLow) + math_pow2(maxMid) + math_pow2(maxHigh); + + // The maxAll values will be used to draw the amplitude. We scale them according to + // magnitude of the gained maxLow, maxMid and maxHigh values + if (sum != 0.f) { + // magnitude = sqrt(sum) and magnitudeGained = sqrt(sumGained), and + // factor = magnitudeGained / magnitude, but we can do with a single sqrt: + const float factor = std::sqrt(sumGained / sum); + maxAllChn[chn] *= factor; + if (!splitLeftRight) { + maxAllChn[chn + 1] *= factor; + } + } - // Lines are thin rectangles - m_vertices.addRectangle(fpos - 0.5f, - halfBreadth - heightFactor * maxAllChn[0], - fpos + 0.5f, - m_isSlipRenderer ? halfBreadth : halfBreadth + heightFactor * maxAllChn[1]); - m_colors.addForRectangle(red, green, blue); + // Use the gained maxLow, maxMid and maxHigh values to calculate the color components + float red = maxLow * low_r + maxMid * mid_r + maxHigh * high_r; + float green = maxLow * low_g + maxMid * mid_g + maxHigh * high_g; + float blue = maxLow * low_b + maxMid * mid_b + maxHigh * high_b; + + // Normalize the color components using the maximum of the three + const float maxComponent = math_max3(red, green, blue); + if (maxComponent == 0.f) { + // Avoid division by 0 + red = 0.f; + green = 0.f; + blue = 0.f; + } else { + const float normFactor = 1.f / maxComponent; + red *= normFactor; + green *= normFactor; + blue *= normFactor; + } + + // Lines are thin rectangles + if (!splitLeftRight) { + m_vertices.addRectangle(fpos - 0.5f, + halfBreadth - heightFactorAbs * maxAllChn[0], + fpos + 0.5f, + m_isSlipRenderer + ? halfBreadth + : halfBreadth + heightFactorAbs * maxAllChn[1]); + } else { + // note: heightFactor is the same for left and right, + // but negative for left (chn 0) and positive for right (chn 1) + m_vertices.addRectangle(fpos - 0.5f, + halfBreadth, + fpos + 0.5f, + halfBreadth + heightFactor[chn] * maxAllChn[chn]); + } + m_colors.addForRectangle(red, green, blue); + } xVisualFrame += visualIncrementPerPixel; } diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.h b/src/waveform/renderers/allshader/waveformrendererrgb.h index d9b2d5a65d2..ebbeb8037e9 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.h +++ b/src/waveform/renderers/allshader/waveformrendererrgb.h @@ -14,7 +14,8 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS public: explicit WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, ::WaveformRendererAbstract::PositionSource type = - ::WaveformRendererAbstract::Play); + ::WaveformRendererAbstract::Play, + int options = WaveformRendererSignalBase::None); // override ::WaveformRendererSignalBase void onSetup(const QDomNode& node) override; @@ -28,6 +29,7 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS RGBData m_colors; bool m_isSlipRenderer; + int m_options; DISALLOW_COPY_AND_ASSIGN(WaveformRendererRGB); }; diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index 1b0e53d0758..d6d1cedafee 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -15,6 +15,11 @@ class WaveformRendererSignalBase; class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBase, public allshader::WaveformRendererAbstract { public: + enum Options { + None = 0, + SplitStereoSignal = 0x1, + }; + static constexpr float m_maxValue{static_cast(std::numeric_limits::max())}; explicit WaveformRendererSignalBase(WaveformWidgetRenderer* waveformWidget); diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index f7b607f53e7..6258bbdbd23 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -24,9 +24,9 @@ #include "waveform/visualsmanager.h" #include "waveform/vsyncthread.h" #ifdef MIXXX_USE_QOPENGL +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/widgets/allshader/filteredwaveformwidget.h" #include "waveform/widgets/allshader/hsvwaveformwidget.h" -#include "waveform/widgets/allshader/lrrgbwaveformwidget.h" #include "waveform/widgets/allshader/rgbwaveformwidget.h" #include "waveform/widgets/allshader/simplewaveformwidget.h" #else @@ -1090,8 +1090,14 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform case WaveformWidgetBackend::GLSL: return new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL - case WaveformWidgetBackend::AllShader: - return new allshader::RGBWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetBackend::AllShader: { + int options = allshader::WaveformRendererSignalBase::None; + if (m_config->getValue( + ConfigKey("[Waveform]", "split_stereo_signal"), false)) { + options |= allshader::WaveformRendererSignalBase::SplitStereoSignal; + } + return new allshader::RGBWaveformWidget(viewer->getGroup(), viewer, options); + } #else case WaveformWidgetBackend::Qt: return new QtRGBWaveformWidget(viewer->getGroup(), viewer); diff --git a/src/waveform/widgets/allshader/lrrgbwaveformwidget.cpp b/src/waveform/widgets/allshader/lrrgbwaveformwidget.cpp deleted file mode 100644 index 8620285a2cd..00000000000 --- a/src/waveform/widgets/allshader/lrrgbwaveformwidget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "waveform/widgets/allshader/lrrgbwaveformwidget.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererlrrgb.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_lrrgbwaveformwidget.cpp" - -namespace allshader { - -LRRGBWaveformWidget::LRRGBWaveformWidget(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void LRRGBWaveformWidget::castToQWidget() { - m_widget = this; -} - -void LRRGBWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/lrrgbwaveformwidget.h b/src/waveform/widgets/allshader/lrrgbwaveformwidget.h deleted file mode 100644 index 1a3dca4cf5c..00000000000 --- a/src/waveform/widgets/allshader/lrrgbwaveformwidget.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class LRRGBWaveformWidget; -} - -/// This waveform type isn't used anymore! -class allshader::LRRGBWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::RGB; - } - - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - LRRGBWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(LRRGBWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp index b6571435a79..101448017eb 100644 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp @@ -12,19 +12,19 @@ namespace allshader { -RGBWaveformWidget::RGBWaveformWidget(const QString& group, QWidget* parent) +RGBWaveformWidget::RGBWaveformWidget(const QString& group, QWidget* parent, int options) : WaveformWidget(group, parent) { addRenderer(); addRenderer(); addRenderer(); addRenderer(); - addRenderer(); + addRenderer(::WaveformRendererAbstract::Play, options); addRenderer(); addRenderer(); // The following renderer will add an overlay waveform if a slip is in progress addRenderer(); addRenderer(::WaveformRendererAbstract::Slip); - addRenderer(::WaveformRendererAbstract::Slip); + addRenderer(::WaveformRendererAbstract::Slip, options); addRenderer(::WaveformRendererAbstract::Slip); addRenderer(::WaveformRendererAbstract::Slip); diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.h b/src/waveform/widgets/allshader/rgbwaveformwidget.h index d775536f603..b4e3035154c 100644 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.h +++ b/src/waveform/widgets/allshader/rgbwaveformwidget.h @@ -1,6 +1,7 @@ #pragma once #include "util/class.h" +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/widgets/allshader/waveformwidget.h" class WaveformWidgetFactory; @@ -34,7 +35,9 @@ class allshader::RGBWaveformWidget final : public allshader::WaveformWidget { void paintEvent(QPaintEvent* event) override; private: - RGBWaveformWidget(const QString& group, QWidget* parent); + RGBWaveformWidget(const QString& group, + QWidget* parent, + int options = WaveformRendererSignalBase::None); friend class ::WaveformWidgetFactory; DISALLOW_COPY_AND_ASSIGN(RGBWaveformWidget); From 0907c2e39b6ca99a1913cf4620a8799e305598ea Mon Sep 17 00:00:00 2001 From: Antoine C Date: Wed, 8 May 2024 17:58:31 +0100 Subject: [PATCH 03/16] Add option to for signal split waveform --- src/preferences/dialog/dlgprefwaveform.cpp | 48 +- src/preferences/dialog/dlgprefwaveform.h | 1 + src/preferences/dialog/dlgprefwaveformdlg.ui | 777 ++++++++++--------- src/preferences/upgrade.cpp | 1 + src/waveform/waveformwidgetfactory.cpp | 3 +- 5 files changed, 437 insertions(+), 393 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 13beb8dd3ac..0cf510c11c5 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -16,6 +16,8 @@ const QList kWaveformWithOnlyAcceleration = { const QList kWaveformWithoutAcceleration = { WaveformWidgetType::VSyncTest, WaveformWidgetType::Empty}; +const QList kWaveformWithSplitSignalSupport = { + WaveformWidgetType::RGB}; void setAccelerationCheckboxProperty(WaveformWidgetType::Type type, QCheckBox* checkbox) { checkbox->blockSignals(true); @@ -30,6 +32,13 @@ void setAccelerationCheckboxProperty(WaveformWidgetType::Type type, QCheckBox* c } checkbox->blockSignals(false); } +void updateStereoSplitVisibility(WaveformWidgetType::Type type, + bool isAccelerationEnabled, + QCheckBox* checkbox) { + checkbox->blockSignals(true); + checkbox->setVisible(isAccelerationEnabled && kWaveformWithSplitSignalSupport.contains(type)); + checkbox->blockSignals(false); +} } // anonymous namespace DlgPrefWaveform::DlgPrefWaveform( @@ -121,6 +130,10 @@ DlgPrefWaveform::DlgPrefWaveform( &QCheckBox::clicked, this, &DlgPrefWaveform::slotSetWaveformAcceleration); + connect(splitLeftRightCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformSplitSignal); connect(defaultZoomComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -191,14 +204,15 @@ DlgPrefWaveform::~DlgPrefWaveform() { void DlgPrefWaveform::slotUpdate() { WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); + bool isAccelerationEnabled = false; if (factory->isOpenGlAvailable() || factory->isOpenGlesAvailable()) { openGlStatusData->setText(factory->getOpenGLVersion()); useAccelerationCheckBox->setEnabled(true); - useAccelerationCheckBox->setChecked( - m_pConfig->getValue( - ConfigKey("[Waveform]", "use_hardware_acceleration"), - WaveformWidgetBackend::AllShader) != - WaveformWidgetBackend::None); + isAccelerationEnabled = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + WaveformWidgetBackend::AllShader) != + WaveformWidgetBackend::None; + useAccelerationCheckBox->setChecked(isAccelerationEnabled); } else { openGlStatusData->setText(tr("OpenGL not available") + ": " + factory->getOpenGLVersion()); useAccelerationCheckBox->setEnabled(false); @@ -210,8 +224,13 @@ void DlgPrefWaveform::slotUpdate() { if (currentIndex != -1 && waveformTypeComboBox->currentIndex() != currentIndex) { waveformTypeComboBox->setCurrentIndex(currentIndex); } + splitLeftRightCheckBox->setChecked( + m_pConfig->getValue( + ConfigKey("[Waveform]", "split_stereo_signal"), + false)); setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox); + updateStereoSplitVisibility(factory->getType(), isAccelerationEnabled, splitLeftRightCheckBox); updateEnableUntilMark(); frameRateSpinBox->setValue(factory->getFrameRate()); @@ -320,10 +339,16 @@ void DlgPrefWaveform::slotSetWaveformType(int index) { } auto type = static_cast( waveformTypeComboBox->itemData(index).toInt()); - auto factory = WaveformWidgetFactory::instance(); + auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type)); setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox); + bool isAccelerationEnabled = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + WaveformWidgetBackend::AllShader) != + WaveformWidgetBackend::None; + useAccelerationCheckBox->setChecked(isAccelerationEnabled); + updateStereoSplitVisibility(factory->getType(), isAccelerationEnabled, splitLeftRightCheckBox); updateEnableUntilMark(); } @@ -342,12 +367,21 @@ void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { WaveformWidgetBackend::None); } auto type = static_cast(waveformTypeComboBox->currentData().toInt()); - auto factory = WaveformWidgetFactory::instance(); + auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); + updateStereoSplitVisibility(type, checked, splitLeftRightCheckBox); updateEnableUntilMark(); } +void DlgPrefWaveform::slotSetWaveformSplitSignal(bool checked) { + m_pConfig->setValue(ConfigKey("[Waveform]", "split_stereo_signal"), + checked); + auto type = static_cast(waveformTypeComboBox->currentData().toInt()); + auto* factory = WaveformWidgetFactory::instance(); + factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); +} + void DlgPrefWaveform::updateEnableUntilMark() { #ifndef MIXXX_USE_QOPENGL const bool enabled = false; diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index 8307998a31d..4b2ad36805f 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -27,6 +27,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void slotSetFrameRate(int frameRate); void slotSetWaveformType(int index); void slotSetWaveformAcceleration(bool checked); + void slotSetWaveformSplitSignal(bool checked); void slotSetWaveformOverviewType(int index); void slotSetDefaultZoom(int index); void slotSetZoomSynchronization(bool checked); diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 5440254d3f9..bab82472265 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -6,65 +6,119 @@ 0 0 - 697 - 673 + 1110 + 939 Waveform Preferences - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + - The waveform overview shows the waveform envelope of the entire track. -Select from different types of displays for the waveform overview, which differ primarily in the level of detail shown in the waveform. + Synchronize zoom level across all waveform displays. + + + Synchronize zoom level across all waveforms - - + + - Beats until next marker + This functionality requires waveform acceleration "(GLSL)". + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - + + + + Set amount of opacity on beat grid lines. + + + % + + + 100 + + + 90 + + + + + - Time until next marker + Font size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkTextPointSizeSpinBox - - + + + + + - Synchronize zoom level across all waveform displays. + + + + fps + + + 10 + + + 60 + + + 30 + + + + - Synchronize zoom level across all waveforms + Placement + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkAlignComboBox - - + + + + + 0 + 0 + + + + + - Normalize waveform overview + Waveform type + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + waveformTypeComboBox @@ -81,29 +135,89 @@ Select from different types of displays for the waveform overview, which differ - - - - - - - Play marker hints + + + + + 0 + 0 + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 16777215 + 16777215 + + + + 10 + + + 60 + + + 30 + + + Qt::Horizontal - - + + + + + + The waveform shows the waveform envelope of the track near the current playback position. +Select from different types of displays for the waveform, which differ primarily in the level of detail shown in the waveform. + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Use acceleration + + + + + + + - Placement + Caching - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - untilMarkAlignComboBox + + + + + + Play marker position @@ -161,6 +275,57 @@ Select from different types of displays for the waveform overview, which differ + + + + + + Clear Cached Waveforms + + + + + + + Mixxx caches the waveforms of your tracks on disk the first time you load a track. This reduces CPU usage when you are playing live but requires extra disk space. + + + true + + + + + + + + 0 + 0 + + + + PLACEHOLDER FOR DISK USAGE + + + true + + + + + + + Enable waveform caching + + + + + + + Generate waveforms when analyzing library + + + + + @@ -171,242 +336,20 @@ Select from different types of displays for the waveform overview, which differ - - + + - Set amount of opacity on beat grid lines. - - - % + - - 100 - - - 90 - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 0 - - - 60 - - - 30 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Moves the play marker position on the waveforms to the left, right or center (default). - - - 0 - - - 100 - - - 50 - - - Qt::Horizontal - - - - - - - 100 - - - 90 - - - Qt::Horizontal - - - - - - - Default zoom level - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - defaultZoomComboBox - - - - - - - - - - pt - - - 10 - - - 50 - - - 30 - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 10 - - - 60 - - - 30 - - - Qt::Horizontal - - - - - - - - - - Caching - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Visual gain - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - allVisualGain - - - - - - - This functionality requires waveform acceleration "(GLSL)". - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - End of track warning - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - endOfTrackWarningTimeSlider - - - - - - - - 0 - 0 - - - - + + 6 - Waveform type + Beat grid opacity Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - waveformTypeComboBox - - - - - - - Highlight the waveforms when the last seconds of a track remains. - - - seconds - - - 0 - - - 60 - - - 30 - @@ -541,16 +484,74 @@ Select from different types of displays for the waveform overview, which differ - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + - + Moves the play marker position on the waveforms to the left, right or center (default). + + + 0 + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + 100 + + + 90 + + + Qt::Horizontal + + + + + + + Time until next marker + + + + + + + Normalize waveform overview + + + + + + + Highlight the waveforms when the last seconds of a track remains. - fps + seconds - 10 + 0 60 @@ -560,133 +561,139 @@ Select from different types of displays for the waveform overview, which differ - - - - - - Clear Cached Waveforms - - - - - - - Mixxx caches the waveforms of your tracks on disk the first time you load a track. This reduces CPU usage when you are playing live but requires extra disk space. - - - true - - - - - - - - 0 - 0 - - - - PLACEHOLDER FOR DISK USAGE - - - true - - - - - - - Enable waveform caching - - - - - - - Generate waveforms when analyzing library - - - - - - - - - + + + + Play marker hints - - 6 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + - Beat grid opacity + Default zoom level Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + defaultZoomComboBox + - - + + - Play marker position + Beats until next marker - - + + + + + + + + + + pt + + + 10 + + + 50 + + + 30 + + + + + - Font size + Visual gain + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + allVisualGain + + + + + + + End of track warning Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - untilMarkTextPointSizeSpinBox + endOfTrackWarningTimeSlider - - - - - - The waveform shows the waveform envelope of the track near the current playback position. -Select from different types of displays for the waveform, which differ primarily in the level of detail shown in the waveform. - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Use acceleration - - - - + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 0 + + + 60 + + + 30 + + + Qt::Horizontal + + + + + + + The waveform overview shows the waveform envelope of the entire track. +Select from different types of displays for the waveform overview, which differ primarily in the level of detail shown in the waveform. + + + + + + + Split the left and right channel + + + + + + + Qt::Vertical + + + + 20 + 40 + + + diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index b99383a7714..4205e8a3b3b 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -45,6 +45,7 @@ void upgradeToAllShaders(WaveformWidgetType::Type* waveformType, // Not supported by AllShader return; default: + *waveformType = WaveformWidgetType::RGB; *waveformBackend = WaveformWidgetBackend::AllShader; } } diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 6258bbdbd23..e55d3ac8e84 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -928,8 +928,8 @@ void WaveformWidgetFactory::evaluateWidgets() { setWaveformVarsByType.operator()(); #else setWaveformVarsByType.operator()(); - break; #endif + break; case WaveformWidgetType::Filtered: #ifndef __APPLE__ // Don't offer the simple renderers on macOS, they do not work with skins @@ -982,6 +982,7 @@ void WaveformWidgetFactory::evaluateWidgets() { #else setWaveformVarsByType.operator()(); #endif + break; case WaveformWidgetType::Stacked: setWaveformVarsByType.operator()(); break; From 10c4e51b47ef31023c779e63b978a26be7e42f11 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Sat, 11 May 2024 19:24:19 +0100 Subject: [PATCH 04/16] Add waveform option detection and change UI --- src/preferences/dialog/dlgprefwaveform.cpp | 172 +++-- src/preferences/dialog/dlgprefwaveform.h | 11 +- src/preferences/dialog/dlgprefwaveformdlg.ui | 640 +++++++++--------- .../allshader/waveformrendererrgb.cpp | 8 +- .../allshader/waveformrenderersignalbase.h | 1 + src/waveform/waveformwidgetfactory.cpp | 80 ++- src/waveform/waveformwidgetfactory.h | 44 +- .../allshader/filteredwaveformwidget.cpp | 1 + .../allshader/filteredwaveformwidget.h | 4 + .../widgets/allshader/hsvwaveformwidget.h | 4 + .../widgets/allshader/rgbwaveformwidget.h | 3 + .../widgets/allshader/simplewaveformwidget.h | 4 + 12 files changed, 567 insertions(+), 405 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 0cf510c11c5..e6c8777f4e8 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -8,37 +8,28 @@ #include "waveform/renderers/waveformwidgetrenderer.h" #include "waveform/waveformwidgetfactory.h" +#ifdef MIXXX_USE_QOPENGL +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" +#define IMPL_SLOT_WAVEFORM_OPTION(opt) \ + void DlgPrefWaveform::slotSetWaveformOption##opt(bool checked) { \ + int currentOption = m_pConfig->getValue( \ + ConfigKey("[Waveform]", "waveform_options"), \ + allshader::WaveformRendererSignalBase::None); \ + m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), \ + checked ? currentOption | \ + allshader::WaveformRendererSignalBase::opt \ + : currentOption ^ \ + allshader::WaveformRendererSignalBase::opt); \ + auto type = static_cast( \ + waveformTypeComboBox->currentData().toInt()); \ + auto* factory = WaveformWidgetFactory::instance(); \ + factory->setWidgetTypeFromHandle( \ + factory->findHandleIndexFromType(type), true); \ + } +#endif + namespace { constexpr WaveformWidgetType::Type kDefaultWaveform = WaveformWidgetType::RGB; -const QList kWaveformWithOnlyAcceleration = { - WaveformWidgetType::Simple, - WaveformWidgetType::Stacked}; -const QList kWaveformWithoutAcceleration = { - WaveformWidgetType::VSyncTest, - WaveformWidgetType::Empty}; -const QList kWaveformWithSplitSignalSupport = { - WaveformWidgetType::RGB}; - -void setAccelerationCheckboxProperty(WaveformWidgetType::Type type, QCheckBox* checkbox) { - checkbox->blockSignals(true); - if (kWaveformWithOnlyAcceleration.contains(type)) { - checkbox->setEnabled(false); - checkbox->setChecked(true); - } else if (kWaveformWithoutAcceleration.contains(type)) { - checkbox->setEnabled(false); - checkbox->setChecked(false); - } else { - checkbox->setEnabled(true); - } - checkbox->blockSignals(false); -} -void updateStereoSplitVisibility(WaveformWidgetType::Type type, - bool isAccelerationEnabled, - QCheckBox* checkbox) { - checkbox->blockSignals(true); - checkbox->setVisible(isAccelerationEnabled && kWaveformWithSplitSignalSupport.contains(type)); - checkbox->blockSignals(false); -} } // anonymous namespace DlgPrefWaveform::DlgPrefWaveform( @@ -62,6 +53,9 @@ DlgPrefWaveform::DlgPrefWaveform( // update the combobox. QVector types = factory->getAvailableTypes(); for (int i = 0; i < types.size(); ++i) { + if (types[i].getType() == WaveformWidgetType::Empty) { + continue; + } waveformTypeComboBox->addItem(types[i].getDisplayName(), types[i].getType()); } // Sort the combobox items alphabetically @@ -121,6 +115,11 @@ DlgPrefWaveform::DlgPrefWaveform( beatGridAlphaSlider, &QSlider::setValue); + connect(useWaveformCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformEnabled); + connect(waveformTypeComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -133,7 +132,11 @@ DlgPrefWaveform::DlgPrefWaveform( connect(splitLeftRightCheckBox, &QCheckBox::clicked, this, - &DlgPrefWaveform::slotSetWaveformSplitSignal); + &DlgPrefWaveform::slotSetWaveformOptionSplitStereoSignal); + connect(highDetailsCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformOptionHighDetails); connect(defaultZoomComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -210,7 +213,7 @@ void DlgPrefWaveform::slotUpdate() { useAccelerationCheckBox->setEnabled(true); isAccelerationEnabled = m_pConfig->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - WaveformWidgetBackend::AllShader) != + factory->preferredBackend()) != WaveformWidgetBackend::None; useAccelerationCheckBox->setChecked(isAccelerationEnabled); } else { @@ -229,8 +232,11 @@ void DlgPrefWaveform::slotUpdate() { ConfigKey("[Waveform]", "split_stereo_signal"), false)); - setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox); - updateStereoSplitVisibility(factory->getType(), isAccelerationEnabled, splitLeftRightCheckBox); + bool useWaveform = m_pConfig->getValue(ConfigKey("[Waveform]", "enabled"), true); + useWaveformCheckBox->setChecked(useWaveform); + updateWaveformAcceleration(); + updateWaveformOption(); + waveformTypeComboBox->setEnabled(useWaveform); updateEnableUntilMark(); frameRateSpinBox->setValue(factory->getFrameRate()); @@ -342,16 +348,31 @@ void DlgPrefWaveform::slotSetWaveformType(int index) { auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type)); - setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox); + updateWaveformAcceleration(); bool isAccelerationEnabled = m_pConfig->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - WaveformWidgetBackend::AllShader) != + factory->preferredBackend()) != WaveformWidgetBackend::None; useAccelerationCheckBox->setChecked(isAccelerationEnabled); - updateStereoSplitVisibility(factory->getType(), isAccelerationEnabled, splitLeftRightCheckBox); + updateWaveformOption(); updateEnableUntilMark(); } +void DlgPrefWaveform::slotSetWaveformEnabled(bool checked) { + m_pConfig->setValue(ConfigKey("[Waveform]", "enabled"), checked); + auto* factory = WaveformWidgetFactory::instance(); + if (!checked) { + factory->setWidgetTypeFromHandle( + factory->findHandleIndexFromType(WaveformWidgetType::Empty), + true); + } else { + auto type = static_cast( + waveformTypeComboBox->currentData().toInt()); + factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); + } + slotUpdate(); +} + void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { if (checked) { m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), @@ -369,28 +390,91 @@ void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { auto type = static_cast(waveformTypeComboBox->currentData().toInt()); auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); - updateStereoSplitVisibility(type, checked, splitLeftRightCheckBox); - + updateWaveformOption(); updateEnableUntilMark(); } -void DlgPrefWaveform::slotSetWaveformSplitSignal(bool checked) { - m_pConfig->setValue(ConfigKey("[Waveform]", "split_stereo_signal"), - checked); +#ifdef MIXXX_USE_QOPENGL +IMPL_SLOT_WAVEFORM_OPTION(SplitStereoSignal) +IMPL_SLOT_WAVEFORM_OPTION(HighDetails) +#endif + +void DlgPrefWaveform::updateWaveformAcceleration() { auto type = static_cast(waveformTypeComboBox->currentData().toInt()); auto* factory = WaveformWidgetFactory::instance(); - factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); + int handleIdx = factory->findHandleIndexFromType(type); + + bool supportAcceleration = false, supportSoftware = true, + useWaveform = + m_pConfig->getValue(ConfigKey("[Waveform]", "enabled"), true); + if (handleIdx != -1) { + const auto& handle = factory->getAvailableTypes()[handleIdx]; + supportAcceleration = handle.supportAcceleration(); + supportSoftware = handle.supportSoftware(); + } + WaveformWidgetBackend::Backend backend = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()); + + useAccelerationCheckBox->blockSignals(true); + + if (supportSoftware ^ supportAcceleration) { + useAccelerationCheckBox->setChecked(!supportSoftware || supportAcceleration); + } else { + useAccelerationCheckBox->setChecked(backend != WaveformWidgetBackend::None); + } + + useAccelerationCheckBox->setEnabled(supportAcceleration && supportSoftware && useWaveform); + + useAccelerationCheckBox->blockSignals(false); +} +void DlgPrefWaveform::updateWaveformOption() { + WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); + int supportedOption = allshader::WaveformRendererSignalBase::None; + int currentOption = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + WaveformWidgetBackend::Backend backend = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()); + bool useWaveform = m_pConfig->getValue(ConfigKey("[Waveform]", "enabled"), true); + + auto type = static_cast(waveformTypeComboBox->currentData().toInt()); + int handleIdx = factory->findHandleIndexFromType(type); + + if (handleIdx != -1) { + supportedOption = factory->getAvailableTypes()[handleIdx].supportedOptions(backend); + } + + splitLeftRightCheckBox->blockSignals(true); + highDetailsCheckBox->blockSignals(true); + + splitLeftRightCheckBox->setEnabled(useWaveform && + supportedOption & + allshader::WaveformRendererSignalBase::SplitStereoSignal); + highDetailsCheckBox->setEnabled(useWaveform && + supportedOption & + allshader::WaveformRendererSignalBase::HighDetails); + splitLeftRightCheckBox->setChecked(splitLeftRightCheckBox->isEnabled() && + currentOption & + allshader::WaveformRendererSignalBase::SplitStereoSignal); + highDetailsCheckBox->setChecked(highDetailsCheckBox->isEnabled() && + currentOption & allshader::WaveformRendererSignalBase::HighDetails); + + splitLeftRightCheckBox->blockSignals(false); + highDetailsCheckBox->blockSignals(false); } void DlgPrefWaveform::updateEnableUntilMark() { #ifndef MIXXX_USE_QOPENGL const bool enabled = false; #else + WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark() && m_pConfig->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - WaveformWidgetBackend::AllShader) != + factory->preferredBackend()) != WaveformWidgetBackend::None; #endif untilMarkShowBeatsCheckBox->setEnabled(enabled); @@ -403,7 +487,7 @@ void DlgPrefWaveform::updateEnableUntilMark() { } void DlgPrefWaveform::slotSetWaveformOverviewType(int index) { - m_pConfig->set(ConfigKey("[Waveform]","WaveformOverviewType"), ConfigValue(index)); + m_pConfig->set(ConfigKey("[Waveform]", "WaveformOverviewType"), ConfigValue(index)); emit reloadUserInterface(); } diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index 4b2ad36805f..b199dd811c0 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -5,6 +5,9 @@ #include "preferences/dialog/dlgpreferencepage.h" #include "preferences/dialog/ui_dlgprefwaveformdlg.h" #include "preferences/usersettings.h" +#ifdef MIXXX_USE_QOPENGL +#define DECL_SLOT_WAVEFORM_OPTION(opt) void slotSetWaveformOption##opt(bool checked) +#endif class Library; @@ -26,8 +29,12 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg private slots: void slotSetFrameRate(int frameRate); void slotSetWaveformType(int index); + void slotSetWaveformEnabled(bool checked); void slotSetWaveformAcceleration(bool checked); - void slotSetWaveformSplitSignal(bool checked); +#ifdef MIXXX_USE_QOPENGL + DECL_SLOT_WAVEFORM_OPTION(SplitStereoSignal); + DECL_SLOT_WAVEFORM_OPTION(HighDetails); +#endif void slotSetWaveformOverviewType(int index); void slotSetDefaultZoom(int index); void slotSetZoomSynchronization(bool checked); @@ -52,6 +59,8 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void calculateCachedWaveformDiskUsage(); void notifyRebootNecessary(); void updateEnableUntilMark(); + void updateWaveformOption(); + void updateWaveformAcceleration(); UserSettingsPointer m_pConfig; std::shared_ptr m_pLibrary; diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index bab82472265..931b446d12a 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -16,126 +16,26 @@ - - - - Synchronize zoom level across all waveform displays. - - - Synchronize zoom level across all waveforms - - - - - - - This functionality requires waveform acceleration "(GLSL)". - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Set amount of opacity on beat grid lines. - - - % - - - 100 - - - 90 - - - - - - - Font size - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - untilMarkTextPointSizeSpinBox - - - - - + + - - + + - - fps - - - 10 - - - 60 - - - 30 - - - - - - - Placement - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - untilMarkAlignComboBox - - - - - - - - 0 - 0 - - - - - - - Waveform type - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - waveformTypeComboBox + + 6 - - - - - Frame rate + Beat grid opacity Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - frameRateSlider - - + @@ -163,65 +63,81 @@ - - - - - - The waveform shows the waveform envelope of the track near the current playback position. -Select from different types of displays for the waveform, which differ primarily in the level of detail shown in the waveform. + + + + Default zoom level + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + defaultZoomComboBox + + + + + + + + + Clear Cached Waveforms - - - - Qt::Horizontal - - - QSizePolicy::Maximum + + + + Mixxx caches the waveforms of your tracks on disk the first time you load a track. This reduces CPU usage when you are playing live but requires extra disk space. - - - 20 - 20 - + + true - + - - + + - + 0 0 - Use acceleration + PLACEHOLDER FOR DISK USAGE + + + true + + + + + + + Enable waveform caching + + + + + + + Generate waveforms when analyzing library - - + + - Caching + Play marker hints - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Play marker position + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + OpenGL status @@ -275,84 +191,178 @@ Select from different types of displays for the waveform, which differ primarily - - - - - - Clear Cached Waveforms - - - - - - - Mixxx caches the waveforms of your tracks on disk the first time you load a track. This reduces CPU usage when you are playing live but requires extra disk space. - - - true - - - - - - - - 0 - 0 - - - - PLACEHOLDER FOR DISK USAGE - - - true - - - - - - - Enable waveform caching - - - - - - - Generate waveforms when analyzing library - - - - + + + + Caching + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + - - + + + + End of track warning + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + endOfTrackWarningTimeSlider + + + + + + + Play marker position + + + + + + + Visual gain + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + allVisualGain + + + + + + + This functionality requires waveform acceleration "(GLSL)". + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + - + Synchronize zoom level across all waveform displays. + + + Synchronize zoom level across all waveforms + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 0 + + + 60 + + 30 + + + Qt::Horizontal + + + + + - Waveform overview type + Font size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkTextPointSizeSpinBox - - + + - - - - 6 + The waveform overview shows the waveform envelope of the entire track. +Select from different types of displays for the waveform overview, which differ primarily in the level of detail shown in the waveform. + + + + - Beat grid opacity + Frame rate Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + frameRateSlider + + + + + + + Time until next marker + + + + + + + Highlight the waveforms when the last seconds of a track remains. + + + seconds + + + 0 + + + 60 + + + 30 + + + + + + + Beats until next marker + - + @@ -484,38 +494,14 @@ Select from different types of displays for the waveform, which differ primarily - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Moves the play marker position on the waveforms to the left, right or center (default). - - - 0 - - - 100 - - - 50 - - - Qt::Horizontal + + + + Stereo coloration - + 100 @@ -528,30 +514,32 @@ Select from different types of displays for the waveform, which differ primarily - - - - Time until next marker + + + + Set amount of opacity on beat grid lines. - - - - - - Normalize waveform overview + + % + + + 100 + + + 90 - - + + - Highlight the waveforms when the last seconds of a track remains. + - seconds + fps - 0 + 10 60 @@ -561,40 +549,49 @@ Select from different types of displays for the waveform, which differ primarily - - - - Play marker hints + + + + + 0 + 0 + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + - - - - - Default zoom level + Waveform type Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - defaultZoomComboBox + waveformTypeComboBox - + - Beats until next marker + Normalize waveform overview - - + + + + Placement + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkAlignComboBox + + - + @@ -613,34 +610,21 @@ Select from different types of displays for the waveform, which differ primarily - - - - Visual gain - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - allVisualGain - - - - - - End of track warning - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + - - endOfTrackWarningTimeSlider + + Waveform overview type - - + + + + + 0 @@ -653,48 +637,78 @@ Select from different types of displays for the waveform, which differ primarily 16777215 + + Moves the play marker position on the waveforms to the left, right or center (default). + 0 - 60 + 100 - 30 + 50 Qt::Horizontal - - - - The waveform overview shows the waveform envelope of the entire track. -Select from different types of displays for the waveform overview, which differ primarily in the level of detail shown in the waveform. + + + + Enabled - - + + + + + + The waveform shows the waveform envelope of the track near the current playback position. +Select from different types of displays for the waveform, which differ primarily in the level of detail shown in the waveform. + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Use acceleration + + + + + + + - Split the left and right channel + High details - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.cpp b/src/waveform/renderers/allshader/waveformrendererrgb.cpp index 1460394e602..d987cf70bfd 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererrgb.cpp @@ -150,11 +150,11 @@ void WaveformRendererRGB::paintGL() { } float maxAllChn[2]{static_cast(u8maxAllChn[0]), static_cast(u8maxAllChn[1])}; + // In case we don't render individual color per channel, all the + // signal information is in the first field of each array. If + // this is the split render, we only render the left channel + // anyway. for (int chn = 0; - // In case we don't render individual color per channel, all the - // signal information is in the first field of each array. If - // this is the split render, we only render the left channel - // anyway. chn < (splitLeftRight && !m_isSlipRenderer ? 2 : 1); chn++) { // Cast to float diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index d6d1cedafee..b3fca0d672f 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -18,6 +18,7 @@ class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBas enum Options { None = 0, SplitStereoSignal = 0x1, + HighDetails = 0x2, }; static constexpr float m_maxValue{static_cast(std::numeric_limits::max())}; diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index e55d3ac8e84..8cb14a1ccd3 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -555,6 +555,7 @@ bool WaveformWidgetFactory::setWidgetType( *pCurrentType = isAcceptable ? type : WaveformWidgetType::Empty; if (m_config) { m_configType = *pCurrentType; + // TODO do not set "Empty"? m_config->setValue( ConfigKey("[Waveform]", "WaveformType"), *pCurrentType); } @@ -864,6 +865,7 @@ void WaveformWidgetFactory::slotFrameSwapped() { void WaveformWidgetFactory::evaluateWidgets() { m_waveformWidgetHandles.clear(); QHash> collectedHandles; + QHash supportedOptions; for (int type = WaveformWidgetType::Empty; type < WaveformWidgetType::Count_WaveformWidgetType; type++) { @@ -926,6 +928,8 @@ void WaveformWidgetFactory::evaluateWidgets() { setWaveformVarsByType.operator()(); #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); + supportedOptions[static_cast(type)] = + allshader::SimpleWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); #endif @@ -942,6 +946,8 @@ void WaveformWidgetFactory::evaluateWidgets() { setWaveformVarsByType.operator()(); #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); + supportedOptions[static_cast(type)] = + allshader::FilteredWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); #endif @@ -965,6 +971,8 @@ void WaveformWidgetFactory::evaluateWidgets() { #endif #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); + supportedOptions[static_cast(type)] = + allshader::RGBWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); #endif @@ -979,6 +987,8 @@ void WaveformWidgetFactory::evaluateWidgets() { #endif #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); + supportedOptions[static_cast(type)] = + allshader::HSVWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); #endif @@ -1002,7 +1012,12 @@ void WaveformWidgetFactory::evaluateWidgets() { auto& type = handleIter.key(); auto& backends = handleIter.value(); #endif - m_waveformWidgetHandles.push_back(WaveformWidgetAbstractHandle(type, backends)); + m_waveformWidgetHandles.push_back(WaveformWidgetAbstractHandle(type, backends +#ifdef MIXXX_USE_QOPENGL + , + supportedOptions.value(type, allshader::WaveformRendererSignalBase::None) +#endif + )); } } @@ -1015,14 +1030,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( // complains come back, we can convert this safely to a backend eventually. int backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - isOpenGlAvailable() || isOpenGlesAvailable() - ? -#ifdef MIXXX_USE_QOPENGL - WaveformWidgetBackend::AllShader -#else - WaveformWidgetBackend::GL -#endif - : WaveformWidgetBackend::None); + preferredBackend()); switch (backend) { case WaveformWidgetBackend::GL: @@ -1049,14 +1057,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createHSVWaveformWidget(WWaveform // complains come back, we can convert this safely to a backend eventually. int backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - isOpenGlAvailable() || isOpenGlesAvailable() - ? -#ifdef MIXXX_USE_QOPENGL - WaveformWidgetBackend::AllShader -#else - WaveformWidgetBackend::GL -#endif - : WaveformWidgetBackend::None); + preferredBackend()); switch (backend) { #ifdef MIXXX_USE_QOPENGL @@ -1076,14 +1077,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform // complains come back, we can convert this safely to a backend eventually. int backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - isOpenGlAvailable() || isOpenGlesAvailable() - ? -#ifdef MIXXX_USE_QOPENGL - WaveformWidgetBackend::AllShader -#else - WaveformWidgetBackend::GL -#endif - : WaveformWidgetBackend::None); + preferredBackend()); switch (backend) { case WaveformWidgetBackend::GL: @@ -1092,11 +1086,9 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform return new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL case WaveformWidgetBackend::AllShader: { - int options = allshader::WaveformRendererSignalBase::None; - if (m_config->getValue( - ConfigKey("[Waveform]", "split_stereo_signal"), false)) { - options |= allshader::WaveformRendererSignalBase::SplitStereoSignal; - } + int options = + m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); return new allshader::RGBWaveformWidget(viewer->getGroup(), viewer, options); } #else @@ -1121,14 +1113,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWavef // complains come back, we can convert this safely to a backend eventually. int backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), - isOpenGlAvailable() || isOpenGlesAvailable() - ? -#ifdef MIXXX_USE_QOPENGL - WaveformWidgetBackend::AllShader -#else - WaveformWidgetBackend::GL -#endif - : WaveformWidgetBackend::None); + preferredBackend()); switch (backend) { #ifdef MIXXX_USE_QOPENGL @@ -1262,14 +1247,27 @@ WaveformWidgetType::Type WaveformWidgetFactory::findTypeFromHandleIndex(int inde } int WaveformWidgetFactory::findHandleIndexFromType(WaveformWidgetType::Type type) { - int index = -1; for (int i = 0; i < m_waveformWidgetHandles.size(); i++) { const WaveformWidgetAbstractHandle& handle = m_waveformWidgetHandles[i]; if (handle.m_type == type) { - index = i; + return i; } } - return index; + return -1; +} + +WaveformWidgetBackend::Backend WaveformWidgetFactory::preferredBackend() const { +#ifdef MIXXX_USE_QOPENGL + if (m_openGlAvailable || m_openGlesAvailable) { + return WaveformWidgetBackend::AllShader; + } +#endif + if (m_openGlAvailable && m_openGLShaderAvailable) { + return WaveformWidgetBackend::GLSL; + } else if (m_openGlAvailable) { + return WaveformWidgetBackend::GL; + } + return WaveformWidgetBackend::None; } // Static diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index 98fcecb16c2..40bc26f5465 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -23,20 +23,58 @@ class WaveformWidgetAbstractHandle { public: WaveformWidgetAbstractHandle(); WaveformWidgetAbstractHandle(WaveformWidgetType::Type type, - QList backends) - : m_type(type), m_backends(std::move(backends)) { + QList backends +#ifdef MIXXX_USE_QOPENGL + , + int supportedOptions +#endif + ) + : m_type(type), m_backends(std::move(backends)) +#ifdef MIXXX_USE_QOPENGL + , + m_supportedOption(supportedOptions) +#endif + { } WaveformWidgetType::Type getType() const { return m_type;} const QList& getBackend() const { return m_backends; } + bool supportAcceleration() const { + for (auto backend : m_backends) { + if (backend == WaveformWidgetBackend::GL || + backend == WaveformWidgetBackend::GLSL +#ifdef MIXXX_USE_QOPENGL + || backend == WaveformWidgetBackend::AllShader +#endif + ) { + return true; + } + } + return false; + } + bool supportSoftware() const { + return m_backends.contains(WaveformWidgetBackend::None); + } + + int supportedOptions(WaveformWidgetBackend::Backend backend) const { +#ifdef MIXXX_USE_QOPENGL + return backend == WaveformWidgetBackend::AllShader ? m_supportedOption : 0; +#else + return 0; +#endif + } QString getDisplayName() const; private: WaveformWidgetType::Type m_type; QList m_backends; +#ifdef MIXXX_USE_QOPENGL + // Only relevant for Allshader (accelerated) backend. Other backends don't implement options + int m_supportedOption; +#endif friend class WaveformWidgetFactory; }; @@ -91,6 +129,8 @@ class WaveformWidgetFactory : public QObject, public Singleton Date: Sun, 12 May 2024 18:05:39 +0100 Subject: [PATCH 05/16] Update the restore slot and remove useless config key --- src/preferences/dialog/dlgprefwaveform.cpp | 109 +++++++++++-------- src/preferences/dialog/dlgprefwaveform.h | 7 +- src/preferences/dialog/dlgprefwaveformdlg.ui | 2 +- 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index e6c8777f4e8..53d70891cea 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -227,15 +227,18 @@ void DlgPrefWaveform::slotUpdate() { if (currentIndex != -1 && waveformTypeComboBox->currentIndex() != currentIndex) { waveformTypeComboBox->setCurrentIndex(currentIndex); } - splitLeftRightCheckBox->setChecked( - m_pConfig->getValue( - ConfigKey("[Waveform]", "split_stereo_signal"), - false)); - bool useWaveform = m_pConfig->getValue(ConfigKey("[Waveform]", "enabled"), true); + bool useWaveform = factory->getType() != WaveformWidgetType::Empty; useWaveformCheckBox->setChecked(useWaveform); - updateWaveformAcceleration(); - updateWaveformOption(); + + int currentOptions = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + WaveformWidgetBackend::Backend backend = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()); + updateWaveformAcceleration(factory->getType(), backend); + updateWaveformOption(useWaveform, backend, currentOptions); waveformTypeComboBox->setEnabled(useWaveform); updateEnableUntilMark(); @@ -290,13 +293,23 @@ void DlgPrefWaveform::slotApply() { void DlgPrefWaveform::slotResetToDefaults() { WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); - // Get the default we ought to use based on whether the user has OpenGL or not. - // Select the combobox index that holds the default handle's index in data column. int defaultIndex = waveformTypeComboBox->findData( - factory->findHandleIndexFromType(kDefaultWaveform)); + kDefaultWaveform); if (defaultIndex != -1 && waveformTypeComboBox->currentIndex() != defaultIndex) { waveformTypeComboBox->setCurrentIndex(defaultIndex); } + auto defaultBackend = factory->preferredBackend(); + useWaveformCheckBox->setChecked(true); + waveformTypeComboBox->setEnabled(true); + updateWaveformAcceleration(kDefaultWaveform, defaultBackend); + updateWaveformOption(true, defaultBackend, allshader::WaveformRendererSignalBase::None); + + // Restore waveform backend and option setting instantly + m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), + defaultBackend); + factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(kDefaultWaveform), true); allVisualGain->setValue(1.0); lowVisualGain->setValue(1.0); @@ -348,18 +361,21 @@ void DlgPrefWaveform::slotSetWaveformType(int index) { auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type)); - updateWaveformAcceleration(); - bool isAccelerationEnabled = m_pConfig->getValue( - ConfigKey("[Waveform]", "use_hardware_acceleration"), - factory->preferredBackend()) != - WaveformWidgetBackend::None; - useAccelerationCheckBox->setChecked(isAccelerationEnabled); - updateWaveformOption(); + auto backend = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()); + useAccelerationCheckBox->setChecked(backend != + WaveformWidgetBackend::None); + + int currentOptions = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + updateWaveformAcceleration(type, backend); + updateWaveformOption(true, backend, currentOptions); updateEnableUntilMark(); } void DlgPrefWaveform::slotSetWaveformEnabled(bool checked) { - m_pConfig->setValue(ConfigKey("[Waveform]", "enabled"), checked); auto* factory = WaveformWidgetFactory::instance(); if (!checked) { factory->setWidgetTypeFromHandle( @@ -374,23 +390,26 @@ void DlgPrefWaveform::slotSetWaveformEnabled(bool checked) { } void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { + WaveformWidgetBackend::Backend backend = WaveformWidgetBackend::None; if (checked) { - m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), + backend = #ifdef MIXXX_USE_QOPENGL WaveformWidgetBackend::AllShader #else WaveformWidgetBackend::GL #endif - ); - } else { - m_pConfig->setValue( - ConfigKey("[Waveform]", "use_hardware_acceleration"), - WaveformWidgetBackend::None); + ; } + m_pConfig->setValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + backend); auto type = static_cast(waveformTypeComboBox->currentData().toInt()); auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); - updateWaveformOption(); + int currentOptions = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + updateWaveformOption(true, backend, currentOptions); updateEnableUntilMark(); } @@ -399,45 +418,40 @@ IMPL_SLOT_WAVEFORM_OPTION(SplitStereoSignal) IMPL_SLOT_WAVEFORM_OPTION(HighDetails) #endif -void DlgPrefWaveform::updateWaveformAcceleration() { - auto type = static_cast(waveformTypeComboBox->currentData().toInt()); +void DlgPrefWaveform::updateWaveformAcceleration( + WaveformWidgetType::Type type, WaveformWidgetBackend::Backend backend) { auto* factory = WaveformWidgetFactory::instance(); int handleIdx = factory->findHandleIndexFromType(type); - bool supportAcceleration = false, supportSoftware = true, - useWaveform = - m_pConfig->getValue(ConfigKey("[Waveform]", "enabled"), true); + bool supportAcceleration = false, supportSoftware = true; if (handleIdx != -1) { const auto& handle = factory->getAvailableTypes()[handleIdx]; supportAcceleration = handle.supportAcceleration(); supportSoftware = handle.supportSoftware(); } - WaveformWidgetBackend::Backend backend = m_pConfig->getValue( - ConfigKey("[Waveform]", "use_hardware_acceleration"), - factory->preferredBackend()); - useAccelerationCheckBox->blockSignals(true); - if (supportSoftware ^ supportAcceleration) { + if (type == WaveformWidgetType::Empty) { + useAccelerationCheckBox->setChecked(false); + } else if (supportSoftware ^ supportAcceleration) { useAccelerationCheckBox->setChecked(!supportSoftware || supportAcceleration); } else { useAccelerationCheckBox->setChecked(backend != WaveformWidgetBackend::None); } - useAccelerationCheckBox->setEnabled(supportAcceleration && supportSoftware && useWaveform); + useAccelerationCheckBox->setEnabled(supportAcceleration && + supportSoftware && type != WaveformWidgetType::Empty); useAccelerationCheckBox->blockSignals(false); } -void DlgPrefWaveform::updateWaveformOption() { +void DlgPrefWaveform::updateWaveformOption( + bool useWaveform, WaveformWidgetBackend::Backend backend, int currentOption) { + splitLeftRightCheckBox->blockSignals(true); + highDetailsCheckBox->blockSignals(true); + +#ifdef MIXXX_USE_QOPENGL WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); int supportedOption = allshader::WaveformRendererSignalBase::None; - int currentOption = m_pConfig->getValue( - ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); - WaveformWidgetBackend::Backend backend = m_pConfig->getValue( - ConfigKey("[Waveform]", "use_hardware_acceleration"), - factory->preferredBackend()); - bool useWaveform = m_pConfig->getValue(ConfigKey("[Waveform]", "enabled"), true); auto type = static_cast(waveformTypeComboBox->currentData().toInt()); int handleIdx = factory->findHandleIndexFromType(type); @@ -446,9 +460,6 @@ void DlgPrefWaveform::updateWaveformOption() { supportedOption = factory->getAvailableTypes()[handleIdx].supportedOptions(backend); } - splitLeftRightCheckBox->blockSignals(true); - highDetailsCheckBox->blockSignals(true); - splitLeftRightCheckBox->setEnabled(useWaveform && supportedOption & allshader::WaveformRendererSignalBase::SplitStereoSignal); @@ -460,6 +471,10 @@ void DlgPrefWaveform::updateWaveformOption() { allshader::WaveformRendererSignalBase::SplitStereoSignal); highDetailsCheckBox->setChecked(highDetailsCheckBox->isEnabled() && currentOption & allshader::WaveformRendererSignalBase::HighDetails); +#else + splitLeftRightCheckBox->setVisible(false); + highDetailsCheckBox->setVisible(false); +#endif splitLeftRightCheckBox->blockSignals(false); highDetailsCheckBox->blockSignals(false); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index b199dd811c0..6e00b4a35a9 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -5,6 +5,7 @@ #include "preferences/dialog/dlgpreferencepage.h" #include "preferences/dialog/ui_dlgprefwaveformdlg.h" #include "preferences/usersettings.h" +#include "waveform/widgets/waveformwidgettype.h" #ifdef MIXXX_USE_QOPENGL #define DECL_SLOT_WAVEFORM_OPTION(opt) void slotSetWaveformOption##opt(bool checked) #endif @@ -59,8 +60,10 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void calculateCachedWaveformDiskUsage(); void notifyRebootNecessary(); void updateEnableUntilMark(); - void updateWaveformOption(); - void updateWaveformAcceleration(); + void updateWaveformOption( + bool useWaveform, WaveformWidgetBackend::Backend backend, int currentOptions); + void updateWaveformAcceleration( + WaveformWidgetType::Type type, WaveformWidgetBackend::Backend backend); UserSettingsPointer m_pConfig; std::shared_ptr m_pLibrary; diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 931b446d12a..05cd544296d 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -561,7 +561,7 @@ Select from different types of displays for the waveform overview, which differ - Waveform type + Waveform Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter From 503cd7cbebc9717420e4ce1723357d04325fbc38 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Mon, 20 May 2024 19:06:49 +0100 Subject: [PATCH 06/16] Code style update --- src/preferences/dialog/dlgprefwaveform.cpp | 8 ++-- src/preferences/dialog/dlgprefwaveform.h | 4 +- src/preferences/upgrade.cpp | 4 +- .../allshader/waveformrenderersignalbase.h | 10 +++-- src/waveform/waveformwidgetfactory.cpp | 42 +++++++++--------- src/waveform/waveformwidgetfactory.h | 10 ++--- src/waveform/widgets/waveformwidgettype.h | 43 ++++++++++++------- 7 files changed, 66 insertions(+), 55 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 53d70891cea..fe79396a9a7 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -234,7 +234,7 @@ void DlgPrefWaveform::slotUpdate() { int currentOptions = m_pConfig->getValue( ConfigKey("[Waveform]", "waveform_options"), allshader::WaveformRendererSignalBase::None); - WaveformWidgetBackend::Backend backend = m_pConfig->getValue( + WaveformWidgetBackend backend = m_pConfig->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), factory->preferredBackend()); updateWaveformAcceleration(factory->getType(), backend); @@ -390,7 +390,7 @@ void DlgPrefWaveform::slotSetWaveformEnabled(bool checked) { } void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { - WaveformWidgetBackend::Backend backend = WaveformWidgetBackend::None; + WaveformWidgetBackend backend = WaveformWidgetBackend::None; if (checked) { backend = #ifdef MIXXX_USE_QOPENGL @@ -419,7 +419,7 @@ IMPL_SLOT_WAVEFORM_OPTION(HighDetails) #endif void DlgPrefWaveform::updateWaveformAcceleration( - WaveformWidgetType::Type type, WaveformWidgetBackend::Backend backend) { + WaveformWidgetType::Type type, WaveformWidgetBackend backend) { auto* factory = WaveformWidgetFactory::instance(); int handleIdx = factory->findHandleIndexFromType(type); @@ -445,7 +445,7 @@ void DlgPrefWaveform::updateWaveformAcceleration( useAccelerationCheckBox->blockSignals(false); } void DlgPrefWaveform::updateWaveformOption( - bool useWaveform, WaveformWidgetBackend::Backend backend, int currentOption) { + bool useWaveform, WaveformWidgetBackend backend, int currentOption) { splitLeftRightCheckBox->blockSignals(true); highDetailsCheckBox->blockSignals(true); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index 6e00b4a35a9..b4b4bea947b 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -61,9 +61,9 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void notifyRebootNecessary(); void updateEnableUntilMark(); void updateWaveformOption( - bool useWaveform, WaveformWidgetBackend::Backend backend, int currentOptions); + bool useWaveform, WaveformWidgetBackend backend, int currentOptions); void updateWaveformAcceleration( - WaveformWidgetType::Type type, WaveformWidgetBackend::Backend backend); + WaveformWidgetType::Type type, WaveformWidgetBackend backend); UserSettingsPointer m_pConfig; std::shared_ptr m_pLibrary; diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index 4205e8a3b3b..e3df38c1e83 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -33,7 +33,7 @@ Upgrade::~Upgrade() { namespace { // mapping to proactively move users to the new all-shader waveform types void upgradeToAllShaders(WaveformWidgetType::Type* waveformType, - WaveformWidgetBackend::Backend* waveformBackend) { + WaveformWidgetBackend* waveformBackend) { if (*waveformBackend == WaveformWidgetBackend::AllShader) { return; } @@ -506,7 +506,7 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { if (okType && okBackend) { upgradeToAllShaders( (WaveformWidgetType::Type*)&waveformType, - (WaveformWidgetBackend::Backend*)&waveformBackend); + (WaveformWidgetBackend*)&waveformBackend); config->set(ConfigKey("[Waveform]", "WaveformType"), ConfigValue(waveformType)); config->set(ConfigKey("[Waveform]", "use_hardware_acceleration"), diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index b3fca0d672f..3938002d83e 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "util/class.h" @@ -15,11 +16,12 @@ class WaveformRendererSignalBase; class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBase, public allshader::WaveformRendererAbstract { public: - enum Options { - None = 0, - SplitStereoSignal = 0x1, - HighDetails = 0x2, + enum Option { + None = 0b0, + SplitStereoSignal = 0b1, + HighDetails = 0b10, }; + Q_DECLARE_FLAGS(Options, Option) static constexpr float m_maxValue{static_cast(std::numeric_limits::max())}; diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 8cb14a1ccd3..25fd328a3d6 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -75,7 +75,7 @@ const QRegularExpression openGLVersionRegex(QStringLiteral("^(\\d+)\\.(\\d+).*$" /////////////////////////////////////////// WaveformWidgetAbstractHandle::WaveformWidgetAbstractHandle() - : m_type(WaveformWidgetType::Count_WaveformWidgetType) { + : m_type(WaveformWidgetType::Invalid) { } /////////////////////////////////////////// @@ -864,21 +864,19 @@ void WaveformWidgetFactory::slotFrameSwapped() { void WaveformWidgetFactory::evaluateWidgets() { m_waveformWidgetHandles.clear(); - QHash> collectedHandles; + QHash> collectedHandles; QHash supportedOptions; - for (int type = WaveformWidgetType::Empty; - type < WaveformWidgetType::Count_WaveformWidgetType; - type++) { + for (WaveformWidgetType::Type type : WaveformWidgetType::kValues) { // this lambda needs its type specified explicitly, // requiring it to be called with via `.operator()()` - collectedHandles.insert(static_cast(type), - QList()); + collectedHandles.insert(type, + QList()); auto setWaveformVarsByType = [&]() { bool useOpenGl = WaveformT::useOpenGl(); bool useOpenGles = WaveformT::useOpenGles(); bool useOpenGLShaders = WaveformT::useOpenGLShaders(); WaveformWidgetCategory category = WaveformT::category(); - WaveformWidgetBackend::Backend backend = WaveformWidgetBackend::None; + WaveformWidgetBackend backend = WaveformWidgetBackend::None; bool active = true; if (isOpenGlAvailable()) { @@ -916,7 +914,7 @@ void WaveformWidgetFactory::evaluateWidgets() { } if (active) { - collectedHandles[static_cast(type)].push_back(backend); + collectedHandles[type].push_back(backend); } }; @@ -928,7 +926,7 @@ void WaveformWidgetFactory::evaluateWidgets() { setWaveformVarsByType.operator()(); #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); - supportedOptions[static_cast(type)] = + supportedOptions[type] = allshader::SimpleWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); @@ -946,7 +944,7 @@ void WaveformWidgetFactory::evaluateWidgets() { setWaveformVarsByType.operator()(); #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); - supportedOptions[static_cast(type)] = + supportedOptions[type] = allshader::FilteredWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); @@ -971,7 +969,7 @@ void WaveformWidgetFactory::evaluateWidgets() { #endif #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); - supportedOptions[static_cast(type)] = + supportedOptions[type] = allshader::RGBWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); @@ -987,7 +985,7 @@ void WaveformWidgetFactory::evaluateWidgets() { #endif #ifdef MIXXX_USE_QOPENGL setWaveformVarsByType.operator()(); - supportedOptions[static_cast(type)] = + supportedOptions[type] = allshader::HSVWaveformWidget::supportedOptions(); #else setWaveformVarsByType.operator()(); @@ -1005,12 +1003,12 @@ void WaveformWidgetFactory::evaluateWidgets() { for (auto [type, backends] : collectedHandles.asKeyValueRange()) { #else QHashIterator> + QList> handleIter(collectedHandles); while (handleIter.hasNext()) { handleIter.next(); - auto& type = handleIter.key(); - auto& backends = handleIter.value(); + const auto& type = handleIter.key(); + const auto& backends = handleIter.value(); #endif m_waveformWidgetHandles.push_back(WaveformWidgetAbstractHandle(type, backends #ifdef MIXXX_USE_QOPENGL @@ -1028,7 +1026,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( // in case of issue when we release, we can communicate workaround on // editing the INI file to target a specific rendering backend. If no // complains come back, we can convert this safely to a backend eventually. - int backend = m_config->getValue( + WaveformWidgetBackend backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), preferredBackend()); @@ -1055,7 +1053,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createHSVWaveformWidget(WWaveform // in case of issue when we release, we can communicate workaround on // editing the INI file to target a specific rendering backend. If no // complains come back, we can convert this safely to a backend eventually. - int backend = m_config->getValue( + WaveformWidgetBackend backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), preferredBackend()); @@ -1075,7 +1073,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform // in case of issue when we release, we can communicate workaround on // editing the INI file to target a specific rendering backend. If no // complains come back, we can convert this safely to a backend eventually. - int backend = m_config->getValue( + WaveformWidgetBackend backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), preferredBackend()); @@ -1111,7 +1109,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWavef // in case of issue when we release, we can communicate workaround on // editing the INI file to target a specific rendering backend. If no // complains come back, we can convert this safely to a backend eventually. - int backend = m_config->getValue( + WaveformWidgetBackend backend = m_config->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), preferredBackend()); @@ -1239,7 +1237,7 @@ void WaveformWidgetFactory::getAvailableVSyncTypes(QList>* p } WaveformWidgetType::Type WaveformWidgetFactory::findTypeFromHandleIndex(int index) { - WaveformWidgetType::Type type = WaveformWidgetType::Count_WaveformWidgetType; + WaveformWidgetType::Type type = WaveformWidgetType::Invalid; if (index >= 0 && index < m_waveformWidgetHandles.size()) { type = m_waveformWidgetHandles[index].m_type; } @@ -1256,7 +1254,7 @@ int WaveformWidgetFactory::findHandleIndexFromType(WaveformWidgetType::Type type return -1; } -WaveformWidgetBackend::Backend WaveformWidgetFactory::preferredBackend() const { +WaveformWidgetBackend WaveformWidgetFactory::preferredBackend() const { #ifdef MIXXX_USE_QOPENGL if (m_openGlAvailable || m_openGlesAvailable) { return WaveformWidgetBackend::AllShader; diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index 40bc26f5465..db4f94c450e 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -23,7 +23,7 @@ class WaveformWidgetAbstractHandle { public: WaveformWidgetAbstractHandle(); WaveformWidgetAbstractHandle(WaveformWidgetType::Type type, - QList backends + QList backends #ifdef MIXXX_USE_QOPENGL , int supportedOptions @@ -38,7 +38,7 @@ class WaveformWidgetAbstractHandle { } WaveformWidgetType::Type getType() const { return m_type;} - const QList& getBackend() const { + const QList& getBackend() const { return m_backends; } bool supportAcceleration() const { @@ -58,7 +58,7 @@ class WaveformWidgetAbstractHandle { return m_backends.contains(WaveformWidgetBackend::None); } - int supportedOptions(WaveformWidgetBackend::Backend backend) const { + int supportedOptions(WaveformWidgetBackend backend) const { #ifdef MIXXX_USE_QOPENGL return backend == WaveformWidgetBackend::AllShader ? m_supportedOption : 0; #else @@ -70,7 +70,7 @@ class WaveformWidgetAbstractHandle { private: WaveformWidgetType::Type m_type; - QList m_backends; + QList m_backends; #ifdef MIXXX_USE_QOPENGL // Only relevant for Allshader (accelerated) backend. Other backends don't implement options int m_supportedOption; @@ -129,7 +129,7 @@ class WaveformWidgetFactory : public QObject, public Singleton +#include +// required for Qt-Macros +#include + class WaveformWidgetType { public: enum Type { // The order must not be changed because the waveforms are referenced // from the sorted preferences by a number. Empty = 0, - Simple, // 5 Simple GL - Filtered, // 7 Filtered GLSL - HSV, // 8 HSV - VSyncTest, // 9 VSync GL - RGB, // 12 RGB GLSL - Stacked, // 16 RGB Stacked - Count_WaveformWidgetType // Also used as invalid value + Simple = 5, // 5 Simple GL + Filtered = 7, // 7 Filtered GLSL + HSV = 8, // 8 HSV + VSyncTest = 9, // 9 VSync GL + RGB = 12, // 12 RGB GLSL + Stacked = 16, // 16 RGB Stacked + Invalid, // Don't use! Used to indicate invalid/unknown type, as + // Count_WaveformWidgetType used to. + }; + static constexpr std::array kValues = { + WaveformWidgetType::Empty, + WaveformWidgetType::Simple, + WaveformWidgetType::Filtered, + WaveformWidgetType::HSV, + WaveformWidgetType::VSyncTest, + WaveformWidgetType::RGB, + WaveformWidgetType::Stacked, }; }; -class WaveformWidgetBackend { - public: - enum Backend { - None = 0, - GL, - GLSL, +enum class WaveformWidgetBackend : int { + None = 0, + GL, + GLSL, #ifdef MIXXX_USE_QOPENGL - AllShader, + AllShader, #endif - Count_WaveformWidgetBackend - }; }; From b79a6252370f1b5300cde678c06aaf8e8215ded9 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Mon, 20 May 2024 20:54:28 +0100 Subject: [PATCH 07/16] Add support for newly introduced filtered waveforms --- CMakeLists.txt | 5 +- res/shaders/rgbsignal.frag | 7 +- src/preferences/upgrade.cpp | 1 + .../allshader/waveformrendererrgb.cpp | 2 +- .../renderers/allshader/waveformrendererrgb.h | 4 +- .../allshader/waveformrenderertextured.cpp | 40 +++++++--- .../allshader/waveformrenderertextured.h | 20 ++--- src/waveform/waveformwidgetfactory.cpp | 74 ++++++++++--------- .../allshader/filteredwaveformwidget.cpp | 11 ++- .../allshader/filteredwaveformwidget.h | 10 +-- .../widgets/allshader/hsvwaveformwidget.h | 3 - .../allshader/rgbstackedwaveformwidget.h | 47 ------------ .../widgets/allshader/rgbwaveformwidget.cpp | 13 +++- .../widgets/allshader/rgbwaveformwidget.h | 8 +- .../widgets/allshader/simplewaveformwidget.h | 3 - ...rmwidget.cpp => stackedwaveformwidget.cpp} | 19 +++-- ...turedstacked.h => stackedwaveformwidget.h} | 19 +++-- .../waveformwidgettexturedfiltered.cpp | 36 --------- .../waveformwidgettexturedfiltered.h | 48 ------------ .../allshader/waveformwidgettexturedrgb.cpp | 35 --------- .../allshader/waveformwidgettexturedrgb.h | 48 ------------ .../waveformwidgettexturedstacked.cpp | 35 --------- 22 files changed, 139 insertions(+), 349 deletions(-) delete mode 100644 src/waveform/widgets/allshader/rgbstackedwaveformwidget.h rename src/waveform/widgets/allshader/{rgbstackedwaveformwidget.cpp => stackedwaveformwidget.cpp} (56%) rename src/waveform/widgets/allshader/{waveformwidgettexturedstacked.h => stackedwaveformwidget.h} (63%) delete mode 100644 src/waveform/widgets/allshader/waveformwidgettexturedfiltered.cpp delete mode 100644 src/waveform/widgets/allshader/waveformwidgettexturedfiltered.h delete mode 100644 src/waveform/widgets/allshader/waveformwidgettexturedrgb.cpp delete mode 100644 src/waveform/widgets/allshader/waveformwidgettexturedrgb.h delete mode 100644 src/waveform/widgets/allshader/waveformwidgettexturedstacked.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 620c50fb46e..ffc9f14f650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1531,12 +1531,9 @@ if(QOPENGL) src/waveform/widgets/allshader/filteredwaveformwidget.cpp src/waveform/widgets/allshader/hsvwaveformwidget.cpp src/waveform/widgets/allshader/rgbwaveformwidget.cpp - src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp + src/waveform/widgets/allshader/stackedwaveformwidget.cpp src/waveform/widgets/allshader/simplewaveformwidget.cpp src/waveform/widgets/allshader/waveformwidget.cpp - src/waveform/widgets/allshader/waveformwidgettexturedfiltered.cpp - src/waveform/widgets/allshader/waveformwidgettexturedrgb.cpp - src/waveform/widgets/allshader/waveformwidgettexturedstacked.cpp src/widget/openglwindow.cpp src/widget/tooltipqopengl.cpp src/widget/wglwidgetqopengl.cpp diff --git a/res/shaders/rgbsignal.frag b/res/shaders/rgbsignal.frag index 23d1375b68c..f60dd9e3774 100644 --- a/res/shaders/rgbsignal.frag +++ b/res/shaders/rgbsignal.frag @@ -5,6 +5,7 @@ uniform vec4 axesColor; uniform vec4 lowColor; uniform vec4 midColor; uniform vec4 highColor; +uniform bool splitStereoSignal; uniform int waveformLength; uniform int textureSize; @@ -21,8 +22,8 @@ uniform sampler2D waveformDataTexture; vec4 getWaveformData(float index) { vec2 uv_data; - uv_data.y = floor(index / float(textureStride)); - uv_data.x = floor(index - uv_data.y * float(textureStride)); + uv_data.y = splitStereoSignal ? floor(index / float(textureStride)) : max(floor(index / float(textureStride)), floor((index + 1) / float(textureStride))); + uv_data.x = splitStereoSignal ? floor(index - uv_data.y * float(textureStride)) : max(floor(index - uv_data.y * float(textureStride)), floor((index + 1) - uv_data.y * float(textureStride))); // Divide again to convert to normalized UV coordinates. return texture2D(waveformDataTexture, uv_data / float(textureStride)); } @@ -36,7 +37,7 @@ void main(void) { // Texture coordinates put (0,0) at the bottom left, so show the right // channel if we are in the bottom half. - if (uv.y < 0.5) { + if (uv.y < 0.5 && splitStereoSignal) { new_currentIndex += 1; } diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index bcc81343442..a25650c339b 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -53,6 +53,7 @@ void upgradeToAllShaders(WaveformWidgetType::Type* waveformType, case WWT::HSV: *waveformType = WaveformWidgetType::HSV; break; + case WWT::Invalid: case WWT::RGB: *waveformType = WaveformWidgetType::RGB; break; diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.cpp b/src/waveform/renderers/allshader/waveformrendererrgb.cpp index d987cf70bfd..df730ce94b8 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererrgb.cpp @@ -16,7 +16,7 @@ inline float math_pow2(float x) { WaveformRendererRGB::WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, ::WaveformRendererAbstract::PositionSource type, - int options) + WaveformRendererSignalBase::Options options) : WaveformRendererSignalBase(waveformWidget), m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip), m_options(options) { diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.h b/src/waveform/renderers/allshader/waveformrendererrgb.h index ebbeb8037e9..0abc0b60083 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.h +++ b/src/waveform/renderers/allshader/waveformrendererrgb.h @@ -15,7 +15,7 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS explicit WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play, - int options = WaveformRendererSignalBase::None); + WaveformRendererSignalBase::Options options = WaveformRendererSignalBase::None); // override ::WaveformRendererSignalBase void onSetup(const QDomNode& node) override; @@ -29,7 +29,7 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS RGBData m_colors; bool m_isSlipRenderer; - int m_options; + WaveformRendererSignalBase::Options m_options; DISALLOW_COPY_AND_ASSIGN(WaveformRendererRGB); }; diff --git a/src/waveform/renderers/allshader/waveformrenderertextured.cpp b/src/waveform/renderers/allshader/waveformrenderertextured.cpp index 142ebe2584c..16e1fe0ee13 100644 --- a/src/waveform/renderers/allshader/waveformrenderertextured.cpp +++ b/src/waveform/renderers/allshader/waveformrenderertextured.cpp @@ -11,14 +11,13 @@ namespace allshader { // static -QString WaveformRendererTextured::fragShaderForType(WaveformRendererTextured::Type t) { - using Type = WaveformRendererTextured::Type; +QString WaveformRendererTextured::fragShaderForType(::WaveformWidgetType::Type t) { switch (t) { - case Type::Filtered: + case ::WaveformWidgetType::Filtered: return QLatin1String(":/shaders/filteredsignal.frag"); - case Type::RGB: + case ::WaveformWidgetType::RGB: return QLatin1String(":/shaders/rgbsignal.frag"); - case Type::Stacked: + case ::WaveformWidgetType::Stacked: return QLatin1String(":/shaders/stackedsignal.frag"); default: break; @@ -27,12 +26,17 @@ QString WaveformRendererTextured::fragShaderForType(WaveformRendererTextured::Ty return QString(); } -WaveformRendererTextured::WaveformRendererTextured(WaveformWidgetRenderer* waveformWidget, - Type t) +WaveformRendererTextured::WaveformRendererTextured( + WaveformWidgetRenderer* waveformWidget, + ::WaveformWidgetType::Type t, + ::WaveformRendererAbstract::PositionSource type, + WaveformRendererSignalBase::Options options) : WaveformRendererSignalBase(waveformWidget), m_unitQuadListId(-1), m_textureId(0), m_textureRenderedWaveformCompletion(0), + m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip), + m_options(options), m_shadersValid(false), m_type(t), m_pFragShader(fragShaderForType(t)) { @@ -267,6 +271,14 @@ void WaveformRendererTextured::slotWaveformUpdated() { } void WaveformRendererTextured::paintGL() { + TrackPointer pTrack = m_waveformRenderer->getTrackInfo(); + if (!pTrack || (m_isSlipRenderer && !m_waveformRenderer->isSlipActive())) { + return; + } + + auto positionType = m_isSlipRenderer ? ::WaveformRendererAbstract::Slip + : ::WaveformRendererAbstract::Play; + ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform(); if (pWaveform.isNull()) { return; @@ -305,10 +317,11 @@ void WaveformRendererTextured::paintGL() { getGains(&allGain, true, &lowGain, &midGain, &highGain); const auto firstVisualIndex = static_cast( - m_waveformRenderer->getFirstDisplayedPosition() * trackSamples / + m_waveformRenderer->getFirstDisplayedPosition(positionType) * trackSamples / audioVisualRatio / 2.0); const auto lastVisualIndex = static_cast( - m_waveformRenderer->getLastDisplayedPosition() * trackSamples / audioVisualRatio / 2.0); + m_waveformRenderer->getLastDisplayedPosition(positionType) * + trackSamples / audioVisualRatio / 2.0); // const int firstIndex = int(firstVisualIndex+0.5); // firstVisualIndex = firstIndex - firstIndex%2; @@ -352,13 +365,18 @@ void WaveformRendererTextured::paintGL() { m_frameShaderProgram->setUniformValue("midGain", midGain); m_frameShaderProgram->setUniformValue("highGain", highGain); + if (m_type == ::WaveformWidgetType::RGB) { + m_frameShaderProgram->setUniformValue("splitStereoSignal", + m_options & WaveformRendererSignalBase::SplitStereoSignal); + } + m_frameShaderProgram->setUniformValue("axesColor", QVector4D(static_cast(m_axesColor_r), static_cast(m_axesColor_g), static_cast(m_axesColor_b), static_cast(m_axesColor_a))); - if (m_type == Type::Stacked) { + if (m_type == ::WaveformWidgetType::Stacked) { m_frameShaderProgram->setUniformValue("lowFilteredColor", QVector4D(static_cast(m_rgbLowFilteredColor_r), static_cast(m_rgbLowFilteredColor_g), @@ -375,7 +393,7 @@ void WaveformRendererTextured::paintGL() { static_cast(m_rgbHighFilteredColor_b), 1.0)); } - if (m_type == Type::RGB || m_type == Type::Stacked) { + if (m_type == ::WaveformWidgetType::RGB || m_type == ::WaveformWidgetType::Stacked) { m_frameShaderProgram->setUniformValue("lowColor", QVector4D(static_cast(m_rgbLowColor_r), static_cast(m_rgbLowColor_g), diff --git a/src/waveform/renderers/allshader/waveformrenderertextured.h b/src/waveform/renderers/allshader/waveformrenderertextured.h index b2bf9772697..3e17c31c524 100644 --- a/src/waveform/renderers/allshader/waveformrenderertextured.h +++ b/src/waveform/renderers/allshader/waveformrenderertextured.h @@ -7,6 +7,7 @@ #include "waveform/renderers/allshader/rgbdata.h" #include "waveform/renderers/allshader/vertexdata.h" #include "waveform/renderers/allshader/waveformrenderersignalbase.h" +#include "waveform/widgets/waveformwidgettype.h" class QOpenGLFramebufferObject; class QOpenGLShaderProgram; @@ -20,13 +21,12 @@ class allshader::WaveformRendererTextured : public QObject, public allshader::WaveformRendererSignalBase { Q_OBJECT public: - enum class Type { - Filtered, - RGB, - Stacked, // was RGBFiltered, - }; - - explicit WaveformRendererTextured(WaveformWidgetRenderer* waveformWidget, Type t); + explicit WaveformRendererTextured(WaveformWidgetRenderer* waveformWidget, + WaveformWidgetType::Type t, + ::WaveformRendererAbstract::PositionSource type = + ::WaveformRendererAbstract::Play, + WaveformRendererSignalBase::Options options = + WaveformRendererSignalBase::None); ~WaveformRendererTextured() override; // override ::WaveformRendererSignalBase @@ -42,7 +42,7 @@ class allshader::WaveformRendererTextured : public QObject, void slotWaveformUpdated(); private: - static QString fragShaderForType(Type t); + static QString fragShaderForType(WaveformWidgetType::Type t); bool loadShaders(); bool loadTexture(); @@ -59,8 +59,10 @@ class allshader::WaveformRendererTextured : public QObject, std::unique_ptr m_framebuffer; // shaders + bool m_isSlipRenderer; + WaveformRendererSignalBase::Options m_options; bool m_shadersValid; - Type m_type; + WaveformWidgetType::Type m_type; const QString m_pFragShader; std::unique_ptr m_frameShaderProgram; }; diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index cfd13b0413a..b3a7b26ce29 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -29,9 +29,7 @@ #include "waveform/widgets/allshader/hsvwaveformwidget.h" #include "waveform/widgets/allshader/rgbwaveformwidget.h" #include "waveform/widgets/allshader/simplewaveformwidget.h" -#include "waveform/widgets/allshader/waveformwidgettexturedfiltered.h" -#include "waveform/widgets/allshader/waveformwidgettexturedrgb.h" -#include "waveform/widgets/allshader/waveformwidgettexturedstacked.h" +#include "waveform/widgets/allshader/stackedwaveformwidget.h" #else #include "waveform/widgets/qthsvwaveformwidget.h" #include "waveform/widgets/qtrgbwaveformwidget.h" @@ -54,26 +52,6 @@ #include "widget/wwaveformviewer.h" namespace { -bool isDeprecated(WaveformWidgetType::Type t) { - switch (t) { - case WaveformWidgetType::GLRGBWaveform: - return true; - case WaveformWidgetType::GLSimpleWaveform: - return true; - case WaveformWidgetType::GLSLFilteredWaveform: - return true; - case WaveformWidgetType::GLSLRGBWaveform: - return true; - case WaveformWidgetType::GLSLRGBStackedWaveform: - return true; - case WaveformWidgetType::GLVSyncTest: - return true; - case WaveformWidgetType::GLFilteredWaveform: - return true; - default: - return false; - } -} // Returns true if the given waveform should be rendered. bool shouldRenderWaveform(WaveformWidgetAbstract* pWaveformWidget) { if (pWaveformWidget == nullptr || @@ -426,7 +404,7 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { m_config->set(ConfigKey("[Waveform]","OverviewNormalized"), ConfigValue(m_overviewNormalized)); } - m_playMarkerPosition = m_config->getValue(ConfigKey("[Waveform]","PlayMarkerPosition"), + m_playMarkerPosition = m_config->getValue(ConfigKey("[Waveform]", "PlayMarkerPosition"), WaveformWidgetRenderer::s_defaultPlayMarkerPosition); setPlayMarkerPosition(m_playMarkerPosition); @@ -595,13 +573,7 @@ bool WaveformWidgetFactory::widgetTypeSupportsUntilMark() const { return true; case WaveformWidgetType::HSV: return true; - case WaveformWidgetType::AllShaderRGBStackedWaveform: - return true; - case WaveformWidgetType::AllShaderTexturedFiltered: - return true; - case WaveformWidgetType::AllShaderTexturedRGB: - return true; - case WaveformWidgetType::AllShaderTexturedStacked: + case WaveformWidgetType::Stacked: return true; default: break; @@ -949,7 +921,7 @@ void WaveformWidgetFactory::evaluateWidgets() { } }; - switch(type) { + switch (type) { case WaveformWidgetType::Empty: setWaveformVarsByType.operator()(); break; @@ -1024,6 +996,11 @@ void WaveformWidgetFactory::evaluateWidgets() { break; case WaveformWidgetType::Stacked: setWaveformVarsByType.operator()(); +#ifdef MIXXX_USE_QOPENGL + setWaveformVarsByType.operator()(); + supportedOptions[type] = + allshader::StackedWaveformWidget::supportedOptions(); +#endif break; default: DEBUG_ASSERT(!"Unexpected WaveformWidgetType"); @@ -1067,8 +1044,12 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( case WaveformWidgetBackend::GLSL: return new GLSLFilteredWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL - case WaveformWidgetBackend::AllShader: - return new allshader::FilteredWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetBackend::AllShader: { + allshader::WaveformRendererSignalBase::Options options = + m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + return new allshader::FilteredWaveformWidget(viewer->getGroup(), viewer, options); + } #else case WaveformWidgetBackend::Qt: return new QtWaveformWidget(viewer->getGroup(), viewer); @@ -1115,7 +1096,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform return new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL case WaveformWidgetBackend::AllShader: { - int options = + allshader::WaveformRendererSignalBase::Options options = m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), allshader::WaveformRendererSignalBase::None); return new allshader::RGBWaveformWidget(viewer->getGroup(), viewer, options); @@ -1131,7 +1112,28 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform WaveformWidgetAbstract* WaveformWidgetFactory::createStackedWaveformWidget( WWaveformViewer* viewer) { +#ifdef MIXXX_USE_QOPENGL + // On the UI, hardware acceleration is a boolean (0 => software rendering, 1 + // => hardware acceleration), but in the setting, we keep the granularity so + // in case of issue when we release, we can communicate workaround on + // editing the INI file to target a specific rendering backend. If no + // complains come back, we can convert this safely to a backend eventually. + WaveformWidgetBackend backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + preferredBackend()); + switch (backend) { + case WaveformWidgetBackend::GL: + return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); + default: { + allshader::WaveformRendererSignalBase::Options options = + m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + return new allshader::StackedWaveformWidget(viewer->getGroup(), viewer, options); + } + } +#else return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); +#endif } WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWaveformViewer* viewer) { @@ -1176,7 +1178,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createWaveformWidget( type = WaveformWidgetType::Empty; } - switch(type) { + switch (type) { case WaveformWidgetType::Simple: widget = createSimpleWaveformWidget(viewer); break; diff --git a/src/waveform/widgets/allshader/filteredwaveformwidget.cpp b/src/waveform/widgets/allshader/filteredwaveformwidget.cpp index b33c1d54c46..4691eb0fca3 100644 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/filteredwaveformwidget.cpp @@ -6,19 +6,26 @@ #include "waveform/renderers/allshader/waveformrendererfiltered.h" #include "waveform/renderers/allshader/waveformrendererpreroll.h" #include "waveform/renderers/allshader/waveformrenderersignalbase.h" +#include "waveform/renderers/allshader/waveformrenderertextured.h" #include "waveform/renderers/allshader/waveformrendermark.h" #include "waveform/renderers/allshader/waveformrendermarkrange.h" #include "waveform/widgets/allshader/moc_filteredwaveformwidget.cpp" namespace allshader { -FilteredWaveformWidget::FilteredWaveformWidget(const QString& group, QWidget* parent) +FilteredWaveformWidget::FilteredWaveformWidget(const QString& group, + QWidget* parent, + WaveformRendererSignalBase::Options options) : WaveformWidget(group, parent) { addRenderer(); addRenderer(); addRenderer(); addRenderer(); - addRenderer(false); + if (options & allshader::WaveformRendererSignalBase::HighDetails) { + addRenderer(::WaveformWidgetType::Filtered); + } else { + addRenderer(false); + } addRenderer(); addRenderer(); diff --git a/src/waveform/widgets/allshader/filteredwaveformwidget.h b/src/waveform/widgets/allshader/filteredwaveformwidget.h index 9cd56cd0ae8..88248c1a690 100644 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.h +++ b/src/waveform/widgets/allshader/filteredwaveformwidget.h @@ -26,14 +26,11 @@ class allshader::FilteredWaveformWidget final : public allshader::WaveformWidget static constexpr bool useOpenGLShaders() { return true; } - static constexpr bool useTextureForWaveform() { - return false; - } static constexpr WaveformWidgetCategory category() { return WaveformWidgetCategory::AllShader; } static constexpr int supportedOptions() { - return WaveformRendererSignalBase::None; + return WaveformRendererSignalBase::HighDetails; } protected: @@ -41,7 +38,10 @@ class allshader::FilteredWaveformWidget final : public allshader::WaveformWidget void paintEvent(QPaintEvent* event) override; private: - FilteredWaveformWidget(const QString& group, QWidget* parent); + FilteredWaveformWidget(const QString& group, + QWidget* parent, + WaveformRendererSignalBase::Options options = + WaveformRendererSignalBase::None); friend class ::WaveformWidgetFactory; DISALLOW_COPY_AND_ASSIGN(FilteredWaveformWidget); diff --git a/src/waveform/widgets/allshader/hsvwaveformwidget.h b/src/waveform/widgets/allshader/hsvwaveformwidget.h index a2c79a32d3f..c0315f23b25 100644 --- a/src/waveform/widgets/allshader/hsvwaveformwidget.h +++ b/src/waveform/widgets/allshader/hsvwaveformwidget.h @@ -26,9 +26,6 @@ class allshader::HSVWaveformWidget final : public allshader::WaveformWidget { static constexpr bool useOpenGLShaders() { return true; } - static constexpr bool useTextureForWaveform() { - return false; - } static constexpr WaveformWidgetCategory category() { return WaveformWidgetCategory::AllShader; } diff --git a/src/waveform/widgets/allshader/rgbstackedwaveformwidget.h b/src/waveform/widgets/allshader/rgbstackedwaveformwidget.h deleted file mode 100644 index 031a5ef960e..00000000000 --- a/src/waveform/widgets/allshader/rgbstackedwaveformwidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class RGBStackedWaveformWidget; -} - -class allshader::RGBStackedWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::AllShaderRGBStackedWaveform; - } - - static inline QString getWaveformWidgetName() { - return tr("RGB Stacked"); - } - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr bool useTextureForWaveform() { - return false; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - RGBStackedWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(RGBStackedWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp index 101448017eb..a532bf3d7ec 100644 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp @@ -6,19 +6,28 @@ #include "waveform/renderers/allshader/waveformrendererpreroll.h" #include "waveform/renderers/allshader/waveformrendererrgb.h" #include "waveform/renderers/allshader/waveformrendererslipmode.h" +#include "waveform/renderers/allshader/waveformrenderertextured.h" #include "waveform/renderers/allshader/waveformrendermark.h" #include "waveform/renderers/allshader/waveformrendermarkrange.h" #include "waveform/widgets/allshader/moc_rgbwaveformwidget.cpp" namespace allshader { -RGBWaveformWidget::RGBWaveformWidget(const QString& group, QWidget* parent, int options) +RGBWaveformWidget::RGBWaveformWidget(const QString& group, + QWidget* parent, + WaveformRendererSignalBase::Options options) : WaveformWidget(group, parent) { addRenderer(); addRenderer(); addRenderer(); addRenderer(); - addRenderer(::WaveformRendererAbstract::Play, options); + if (options & allshader::WaveformRendererSignalBase::HighDetails) { + addRenderer(::WaveformWidgetType::RGB, + ::WaveformRendererAbstract::Play, + options); + } else { + addRenderer(::WaveformRendererAbstract::Play, options); + } addRenderer(); addRenderer(); // The following renderer will add an overlay waveform if a slip is in progress diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.h b/src/waveform/widgets/allshader/rgbwaveformwidget.h index 3b6e53fed69..67c92cdab5a 100644 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.h +++ b/src/waveform/widgets/allshader/rgbwaveformwidget.h @@ -26,14 +26,12 @@ class allshader::RGBWaveformWidget final : public allshader::WaveformWidget { static constexpr bool useOpenGLShaders() { return true; } - static constexpr bool useTextureForWaveform() { - return false; - } static constexpr WaveformWidgetCategory category() { return WaveformWidgetCategory::AllShader; } static constexpr int supportedOptions() { - return WaveformRendererSignalBase::SplitStereoSignal; + return WaveformRendererSignalBase::SplitStereoSignal | + WaveformRendererSignalBase::HighDetails; } protected: @@ -43,7 +41,7 @@ class allshader::RGBWaveformWidget final : public allshader::WaveformWidget { private: RGBWaveformWidget(const QString& group, QWidget* parent, - int options = WaveformRendererSignalBase::None); + WaveformRendererSignalBase::Options options = WaveformRendererSignalBase::None); friend class ::WaveformWidgetFactory; DISALLOW_COPY_AND_ASSIGN(RGBWaveformWidget); diff --git a/src/waveform/widgets/allshader/simplewaveformwidget.h b/src/waveform/widgets/allshader/simplewaveformwidget.h index 795231bc27c..bd6d67753f8 100644 --- a/src/waveform/widgets/allshader/simplewaveformwidget.h +++ b/src/waveform/widgets/allshader/simplewaveformwidget.h @@ -26,9 +26,6 @@ class allshader::SimpleWaveformWidget final : public allshader::WaveformWidget { static constexpr bool useOpenGLShaders() { return true; } - static constexpr bool useTextureForWaveform() { - return false; - } static constexpr WaveformWidgetCategory category() { return WaveformWidgetCategory::AllShader; } diff --git a/src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp b/src/waveform/widgets/allshader/stackedwaveformwidget.cpp similarity index 56% rename from src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp rename to src/waveform/widgets/allshader/stackedwaveformwidget.cpp index 4f359cd27b8..ac390c39679 100644 --- a/src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/stackedwaveformwidget.cpp @@ -1,34 +1,41 @@ -#include "waveform/widgets/allshader/rgbstackedwaveformwidget.h" +#include "waveform/widgets/allshader/stackedwaveformwidget.h" #include "waveform/renderers/allshader/waveformrenderbackground.h" #include "waveform/renderers/allshader/waveformrenderbeat.h" #include "waveform/renderers/allshader/waveformrendererendoftrack.h" #include "waveform/renderers/allshader/waveformrendererfiltered.h" #include "waveform/renderers/allshader/waveformrendererpreroll.h" +#include "waveform/renderers/allshader/waveformrenderertextured.h" #include "waveform/renderers/allshader/waveformrendermark.h" #include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_rgbstackedwaveformwidget.cpp" +#include "waveform/widgets/allshader/moc_stackedwaveformwidget.cpp" namespace allshader { -RGBStackedWaveformWidget::RGBStackedWaveformWidget(const QString& group, QWidget* parent) +StackedWaveformWidget::StackedWaveformWidget(const QString& group, + QWidget* parent, + WaveformRendererSignalBase::Options options) : WaveformWidget(group, parent) { addRenderer(); addRenderer(); addRenderer(); addRenderer(); - addRenderer(true); // true for RGB Stacked + if (options & allshader::WaveformRendererSignalBase::HighDetails) { + addRenderer(::WaveformWidgetType::Stacked); + } else { + addRenderer(true); // true for RGB Stacked + } addRenderer(); addRenderer(); m_initSuccess = init(); } -void RGBStackedWaveformWidget::castToQWidget() { +void StackedWaveformWidget::castToQWidget() { m_widget = this; } -void RGBStackedWaveformWidget::paintEvent(QPaintEvent* event) { +void StackedWaveformWidget::paintEvent(QPaintEvent* event) { Q_UNUSED(event); } diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedstacked.h b/src/waveform/widgets/allshader/stackedwaveformwidget.h similarity index 63% rename from src/waveform/widgets/allshader/waveformwidgettexturedstacked.h rename to src/waveform/widgets/allshader/stackedwaveformwidget.h index 9c903744586..6c83b56a32d 100644 --- a/src/waveform/widgets/allshader/waveformwidgettexturedstacked.h +++ b/src/waveform/widgets/allshader/stackedwaveformwidget.h @@ -7,14 +7,14 @@ class WaveformWidgetFactory; namespace allshader { -class WaveformWidgetTexturedStacked; +class StackedWaveformWidget; } -class allshader::WaveformWidgetTexturedStacked final : public allshader::WaveformWidget { +class allshader::StackedWaveformWidget final : public allshader::WaveformWidget { Q_OBJECT public: WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::AllShaderTexturedStacked; + return WaveformWidgetType::Stacked; } static inline QString getWaveformWidgetName() { @@ -29,20 +29,23 @@ class allshader::WaveformWidgetTexturedStacked final : public allshader::Wavefor static constexpr bool useOpenGLShaders() { return true; } - static constexpr bool useTextureForWaveform() { - return true; - } static constexpr WaveformWidgetCategory category() { return WaveformWidgetCategory::AllShader; } + static constexpr int supportedOptions() { + return WaveformRendererSignalBase::HighDetails; + } protected: void castToQWidget() override; void paintEvent(QPaintEvent* event) override; private: - WaveformWidgetTexturedStacked(const QString& group, QWidget* parent); + StackedWaveformWidget(const QString& group, + QWidget* parent, + WaveformRendererSignalBase::Options options = + WaveformRendererSignalBase::None); friend class ::WaveformWidgetFactory; - DISALLOW_COPY_AND_ASSIGN(WaveformWidgetTexturedStacked); + DISALLOW_COPY_AND_ASSIGN(StackedWaveformWidget); }; diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedfiltered.cpp b/src/waveform/widgets/allshader/waveformwidgettexturedfiltered.cpp deleted file mode 100644 index ae986ce0cae..00000000000 --- a/src/waveform/widgets/allshader/waveformwidgettexturedfiltered.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "waveform/widgets/allshader/waveformwidgettexturedfiltered.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_waveformwidgettexturedfiltered.cpp" - -namespace allshader { - -WaveformWidgetTexturedFiltered::WaveformWidgetTexturedFiltered( - const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(WaveformRendererTextured::Type::Filtered); - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void WaveformWidgetTexturedFiltered::castToQWidget() { - m_widget = this; -} - -void WaveformWidgetTexturedFiltered::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedfiltered.h b/src/waveform/widgets/allshader/waveformwidgettexturedfiltered.h deleted file mode 100644 index f56a6ef6555..00000000000 --- a/src/waveform/widgets/allshader/waveformwidgettexturedfiltered.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class WaveformWidgetTexturedFiltered; -} - -class allshader::WaveformWidgetTexturedFiltered final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::AllShaderTexturedFiltered; - } - - static inline QString getWaveformWidgetName() { - return tr("Filtered"); - } - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr bool useTextureForWaveform() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - WaveformWidgetTexturedFiltered(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(WaveformWidgetTexturedFiltered); -}; diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedrgb.cpp b/src/waveform/widgets/allshader/waveformwidgettexturedrgb.cpp deleted file mode 100644 index 2508619bf65..00000000000 --- a/src/waveform/widgets/allshader/waveformwidgettexturedrgb.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "waveform/widgets/allshader/waveformwidgettexturedrgb.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_waveformwidgettexturedrgb.cpp" - -namespace allshader { - -WaveformWidgetTexturedRGB::WaveformWidgetTexturedRGB(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(WaveformRendererTextured::Type::RGB); - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void WaveformWidgetTexturedRGB::castToQWidget() { - m_widget = this; -} - -void WaveformWidgetTexturedRGB::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedrgb.h b/src/waveform/widgets/allshader/waveformwidgettexturedrgb.h deleted file mode 100644 index ff1acdb39ff..00000000000 --- a/src/waveform/widgets/allshader/waveformwidgettexturedrgb.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class WaveformWidgetTexturedRGB; -} - -class allshader::WaveformWidgetTexturedRGB final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::AllShaderTexturedRGB; - } - - static inline QString getWaveformWidgetName() { - return tr("RGB"); - } - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr bool useTextureForWaveform() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - WaveformWidgetTexturedRGB(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(WaveformWidgetTexturedRGB); -}; diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedstacked.cpp b/src/waveform/widgets/allshader/waveformwidgettexturedstacked.cpp deleted file mode 100644 index 69591545917..00000000000 --- a/src/waveform/widgets/allshader/waveformwidgettexturedstacked.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "waveform/widgets/allshader/waveformwidgettexturedstacked.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_waveformwidgettexturedstacked.cpp" - -namespace allshader { - -WaveformWidgetTexturedStacked::WaveformWidgetTexturedStacked(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(WaveformRendererTextured::Type::Stacked); - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void WaveformWidgetTexturedStacked::castToQWidget() { - m_widget = this; -} - -void WaveformWidgetTexturedStacked::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader From 7bc930a574ce981a44cd66b384f6bafb0eec5d56 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Mon, 20 May 2024 21:04:44 +0100 Subject: [PATCH 08/16] Reduce the code in macro and use a generic option modifier --- src/preferences/dialog/dlgprefwaveform.cpp | 46 +++++++++------------- src/preferences/dialog/dlgprefwaveform.h | 11 +++++- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index fe79396a9a7..3aa3f734f9f 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -8,26 +8,6 @@ #include "waveform/renderers/waveformwidgetrenderer.h" #include "waveform/waveformwidgetfactory.h" -#ifdef MIXXX_USE_QOPENGL -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#define IMPL_SLOT_WAVEFORM_OPTION(opt) \ - void DlgPrefWaveform::slotSetWaveformOption##opt(bool checked) { \ - int currentOption = m_pConfig->getValue( \ - ConfigKey("[Waveform]", "waveform_options"), \ - allshader::WaveformRendererSignalBase::None); \ - m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), \ - checked ? currentOption | \ - allshader::WaveformRendererSignalBase::opt \ - : currentOption ^ \ - allshader::WaveformRendererSignalBase::opt); \ - auto type = static_cast( \ - waveformTypeComboBox->currentData().toInt()); \ - auto* factory = WaveformWidgetFactory::instance(); \ - factory->setWidgetTypeFromHandle( \ - factory->findHandleIndexFromType(type), true); \ - } -#endif - namespace { constexpr WaveformWidgetType::Type kDefaultWaveform = WaveformWidgetType::RGB; } // anonymous namespace @@ -43,8 +23,8 @@ DlgPrefWaveform::DlgPrefWaveform( // Waveform overview init waveformOverviewComboBox->addItem(tr("Filtered")); // "0" - waveformOverviewComboBox->addItem(tr("HSV")); // "1" - waveformOverviewComboBox->addItem(tr("RGB")); // "2" + waveformOverviewComboBox->addItem(tr("HSV")); // "1" + waveformOverviewComboBox->addItem(tr("RGB")); // "2" // Populate waveform options. WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); @@ -204,6 +184,23 @@ DlgPrefWaveform::DlgPrefWaveform( DlgPrefWaveform::~DlgPrefWaveform() { } +void DlgPrefWaveform::slotSetWaveformOptions( + allshader::WaveformRendererSignalBase::Option option, bool enabled) { + int currentOption = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), + enabled ? currentOption | + option + : currentOption ^ + option); + auto type = static_cast( + waveformTypeComboBox->currentData().toInt()); + auto* factory = WaveformWidgetFactory::instance(); + factory->setWidgetTypeFromHandle( + factory->findHandleIndexFromType(type), true); +} + void DlgPrefWaveform::slotUpdate() { WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); @@ -413,11 +410,6 @@ void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { updateEnableUntilMark(); } -#ifdef MIXXX_USE_QOPENGL -IMPL_SLOT_WAVEFORM_OPTION(SplitStereoSignal) -IMPL_SLOT_WAVEFORM_OPTION(HighDetails) -#endif - void DlgPrefWaveform::updateWaveformAcceleration( WaveformWidgetType::Type type, WaveformWidgetBackend backend) { auto* factory = WaveformWidgetFactory::instance(); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index b4b4bea947b..3e5ca94e897 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -7,7 +7,11 @@ #include "preferences/usersettings.h" #include "waveform/widgets/waveformwidgettype.h" #ifdef MIXXX_USE_QOPENGL -#define DECL_SLOT_WAVEFORM_OPTION(opt) void slotSetWaveformOption##opt(bool checked) +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" +#define DECL_SLOT_WAVEFORM_OPTION(opt) \ + void slotSetWaveformOption##opt(bool checked) { \ + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::opt, checked); \ + } #endif class Library; @@ -33,6 +37,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void slotSetWaveformEnabled(bool checked); void slotSetWaveformAcceleration(bool checked); #ifdef MIXXX_USE_QOPENGL + void slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option option, bool enabled); DECL_SLOT_WAVEFORM_OPTION(SplitStereoSignal); DECL_SLOT_WAVEFORM_OPTION(HighDetails); #endif @@ -68,3 +73,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg UserSettingsPointer m_pConfig; std::shared_ptr m_pLibrary; }; + +#ifdef DECL_SLOT_WAVEFORM_OPTION +#undef DECL_SLOT_WAVEFORM_OPTION +#endif From 49158652608c4fa8ee89919ffd8e885eab0e8218 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Mon, 20 May 2024 21:15:41 +0100 Subject: [PATCH 09/16] Add TODO for new code --- src/waveform/waveformwidgetfactory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index 986493e49a8..aef77dcdd29 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -274,6 +274,7 @@ class WaveformWidgetFactory : public QObject, public Singleton Date: Tue, 21 May 2024 16:21:03 +0100 Subject: [PATCH 10/16] Fix the update path and add tests --- CMakeLists.txt | 1 + src/preferences/dialog/dlgprefwaveform.cpp | 18 +- src/preferences/dialog/dlgprefwaveform.h | 2 +- src/preferences/dialog/dlgprefwaveformdlg.ui | 2 +- src/preferences/upgrade.cpp | 109 ++++++++--- src/test/waveform_upgrade_test.cpp | 173 ++++++++++++++++++ .../allshader/waveformrenderersignalbase.h | 2 +- .../allshader/filteredwaveformwidget.cpp | 2 +- .../allshader/filteredwaveformwidget.h | 2 +- .../widgets/allshader/rgbwaveformwidget.cpp | 2 +- .../widgets/allshader/rgbwaveformwidget.h | 2 +- .../allshader/stackedwaveformwidget.cpp | 2 +- .../widgets/allshader/stackedwaveformwidget.h | 2 +- 13 files changed, 273 insertions(+), 46 deletions(-) create mode 100644 src/test/waveform_upgrade_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ffc9f14f650..50197669d29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2189,6 +2189,7 @@ add_executable(mixxx-test src/test/wbatterytest.cpp src/test/wpushbutton_test.cpp src/test/wwidgetstack_test.cpp + src/test/waveform_upgrade_test.cpp src/util/moc_included_test.cpp ) target_precompile_headers(mixxx-test REUSE_FROM mixxx-lib) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 3aa3f734f9f..83e3ff632fd 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -113,10 +113,10 @@ DlgPrefWaveform::DlgPrefWaveform( &QCheckBox::clicked, this, &DlgPrefWaveform::slotSetWaveformOptionSplitStereoSignal); - connect(highDetailsCheckBox, + connect(highDetailCheckBox, &QCheckBox::clicked, this, - &DlgPrefWaveform::slotSetWaveformOptionHighDetails); + &DlgPrefWaveform::slotSetWaveformOptionHighDetail); connect(defaultZoomComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -439,7 +439,7 @@ void DlgPrefWaveform::updateWaveformAcceleration( void DlgPrefWaveform::updateWaveformOption( bool useWaveform, WaveformWidgetBackend backend, int currentOption) { splitLeftRightCheckBox->blockSignals(true); - highDetailsCheckBox->blockSignals(true); + highDetailCheckBox->blockSignals(true); #ifdef MIXXX_USE_QOPENGL WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); @@ -455,21 +455,21 @@ void DlgPrefWaveform::updateWaveformOption( splitLeftRightCheckBox->setEnabled(useWaveform && supportedOption & allshader::WaveformRendererSignalBase::SplitStereoSignal); - highDetailsCheckBox->setEnabled(useWaveform && + highDetailCheckBox->setEnabled(useWaveform && supportedOption & - allshader::WaveformRendererSignalBase::HighDetails); + allshader::WaveformRendererSignalBase::HighDetail); splitLeftRightCheckBox->setChecked(splitLeftRightCheckBox->isEnabled() && currentOption & allshader::WaveformRendererSignalBase::SplitStereoSignal); - highDetailsCheckBox->setChecked(highDetailsCheckBox->isEnabled() && - currentOption & allshader::WaveformRendererSignalBase::HighDetails); + highDetailCheckBox->setChecked(highDetailCheckBox->isEnabled() && + currentOption & allshader::WaveformRendererSignalBase::HighDetail); #else splitLeftRightCheckBox->setVisible(false); - highDetailsCheckBox->setVisible(false); + highDetailCheckBox->setVisible(false); #endif splitLeftRightCheckBox->blockSignals(false); - highDetailsCheckBox->blockSignals(false); + highDetailCheckBox->blockSignals(false); } void DlgPrefWaveform::updateEnableUntilMark() { diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index 3e5ca94e897..cde58e60d95 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -39,7 +39,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg #ifdef MIXXX_USE_QOPENGL void slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option option, bool enabled); DECL_SLOT_WAVEFORM_OPTION(SplitStereoSignal); - DECL_SLOT_WAVEFORM_OPTION(HighDetails); + DECL_SLOT_WAVEFORM_OPTION(HighDetail); #endif void slotSetWaveformOverviewType(int index); void slotSetDefaultZoom(int index); diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 05cd544296d..0959bf34c17 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -703,7 +703,7 @@ Select from different types of displays for the waveform, which differ primarily - + High details diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index a25650c339b..11a1fb098c7 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -19,6 +19,7 @@ #include "util/db/dbconnectionpooler.h" #include "util/math.h" #include "util/versionstore.h" +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/vsyncthread.h" #include "waveform/widgets/waveformwidgettype.h" @@ -32,36 +33,78 @@ Upgrade::~Upgrade() { namespace { // mapping to proactively move users to the new all-shader waveform types -void upgradeToAllShaders(WaveformWidgetType::Type* waveformType, - WaveformWidgetBackend* waveformBackend) { +void upgradeToAllShaders(int* waveformType, + WaveformWidgetBackend* waveformBackend, + allshader::WaveformRendererSignalBase::Options* waveformOptions) { if (*waveformBackend == WaveformWidgetBackend::AllShader) { return; } + *waveformOptions = allshader::WaveformRendererSignalBase::None; + *waveformBackend = WaveformWidgetBackend::AllShader; // TODO: convert `WaveformWidgetType::Type` to an enum class then shorten more `using enum ...` using WWT = WaveformWidgetType; + + // The switch includes raw values that have been removed from the enum switch (*waveformType) { + // None or test waveforms case WWT::Empty: - case WWT::VSyncTest: // Not supported by AllShader - return; + *waveformBackend = WaveformWidgetBackend::None; + break; + case WWT::VSyncTest: // GLVSyncTest + case 13: // QtVSyncTest + // Not supported by AllShader + *waveformBackend = WaveformWidgetBackend::None; + *waveformType = WaveformWidgetType::VSyncTest; + break; + + // Simple waveforms + case 3: // QtSimpleWaveform + case 20: // AllShaderSimpleWaveform case WWT::Simple: *waveformType = WaveformWidgetType::Simple; break; - case WWT::Filtered: + + // Filtered waveforms + case WWT::Filtered: // GLSLFilteredWaveform + case 22: // AllShaderTexturedFiltered + *waveformOptions = allshader::WaveformRendererSignalBase::HighDetail; + [[fallthrough]]; + case 2: // SoftwareWaveform + case 4: // QtWaveform + case 6: // GLFilteredWaveform + case 19: // AllShaderFilteredWaveform *waveformType = WaveformWidgetType::Filtered; break; + + // HSV waveforms + case 14: // QtHSVWaveform + case 21: // AllShaderHSVWaveform case WWT::HSV: *waveformType = WaveformWidgetType::HSV; break; - case WWT::Invalid: - case WWT::RGB: - *waveformType = WaveformWidgetType::RGB; - break; - case WWT::Stacked: + + // Stacked waveform + case 24: // AllShaderTexturedStacked + case WWT::Stacked: // GLSLRGBStackedWaveform + *waveformOptions = allshader::WaveformRendererSignalBase::HighDetail; + [[fallthrough]]; + case 26: // AllShaderRGBStackedWaveform *waveformType = WaveformWidgetType::Stacked; break; + + // RGB waveform (preferred) + case 18: // AllShaderLRRGBWaveform + case 23: // AllShaderTexturedRGB + case 12: // GLSLRGBWaveform + *waveformOptions = *waveformType == 18 + ? allshader::WaveformRendererSignalBase::SplitStereoSignal + : allshader::WaveformRendererSignalBase::HighDetail; + [[fallthrough]]; + default: + *waveformType = WaveformWidgetType::RGB; + break; } - *waveformBackend = WaveformWidgetBackend::AllShader; } VSyncThread::VSyncMode upgradeDeprecatedVSyncModes(int configVSyncMode) { @@ -505,33 +548,43 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { const auto configFileVersion = QVersionNumber::fromString(configVersion); - // When upgrading from 2.3.x or older to 2.4, or when upgrading - // from 2.4.0-beta once we are out of beta - if (QVersionNumber::fromString(configVersion) < QVersionNumber(2, 4, 0) || - (VersionStore::version() != "2.4.0-beta" && - configVersion.startsWith("2.4.0-"))) { + // When upgrading from 2.3.x or older to 2.5, or when upgrading + // from 2.5.0-beta once we are out of beta + if (configFileVersion < QVersionNumber(2, 5, 0) || + (VersionStore::version() != "2.5.0-beta" && + configVersion.startsWith("2.5.0-"))) { // Proactively move users to an all-shader waveform widget type and set the // framerate to 60 fps - bool okType = false, okBackend = false; + bool okType = false, okBackend = false, okOptions = false; auto waveformType = config->getValueString(ConfigKey("[Waveform]", "WaveformType")) .toInt(&okType); auto waveformBackend = config->getValueString(ConfigKey("[Waveform]", "use_hardware_acceleration")) .toInt(&okBackend); - if (okType && okBackend) { - upgradeToAllShaders( - (WaveformWidgetType::Type*)&waveformType, - (WaveformWidgetBackend*)&waveformBackend); - config->set(ConfigKey("[Waveform]", "WaveformType"), - ConfigValue(waveformType)); - config->set(ConfigKey("[Waveform]", "use_hardware_acceleration"), - ConfigValue(waveformBackend)); + auto waveformOption = + config->getValueString(ConfigKey("[Waveform]", "waveform_options")) + .toInt(&okOptions); + if (okType && (!okBackend || !okOptions)) { + upgradeToAllShaders(&waveformType, + reinterpret_cast(&waveformBackend), + reinterpret_cast< + allshader::WaveformRendererSignalBase::Options*>( + &waveformBackend)); + config->setValue(ConfigKey("[Waveform]", "WaveformType"), + waveformType); + config->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), + waveformBackend); + config->setValue(ConfigKey("[Waveform]", "waveform_options"), + waveformOption); + } + // Only update the framerate if the version we are migrating from is less than 2.4.0. + if (QVersionNumber::fromString(configVersion) < QVersionNumber(2, 4, 0)) { + config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60)); } - config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60)); // mark the configuration as updated - configVersion = "2.4.0"; + configVersion = "2.5.0"; config->set(ConfigKey("[Config]", "Version"), ConfigValue(configVersion)); } @@ -539,7 +592,7 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { // This variable indicates the first known version that requires no changes. // If additional upgrades are added for later versions, they should go before // this block and cleanVersion should be bumped to the latest version. - const QVersionNumber cleanVersion(2, 4, 0); + const QVersionNumber cleanVersion(2, 5, 0); if (QVersionNumber::fromString(configVersion) >= cleanVersion) { // No special upgrade required, just update the value. configVersion = VersionStore::version(); diff --git a/src/test/waveform_upgrade_test.cpp b/src/test/waveform_upgrade_test.cpp new file mode 100644 index 00000000000..71ba98bbdcc --- /dev/null +++ b/src/test/waveform_upgrade_test.cpp @@ -0,0 +1,173 @@ +#include +#include + +#include +#include + +// Importing CPP file since testing function in anonymous namespace +#include "preferences/upgrade.cpp" +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" + +class UpgradeTest : public testing::Test { + protected: + void SetUp() override { + } + void TearDown() override { + } +}; + +TEST_F(UpgradeTest, useCorrectWaveformType) { + struct test_case { + QString waveformName; + int oldTypeId; + WaveformWidgetType::Type expectedType; + WaveformWidgetBackend expectedBackend; + allshader::WaveformRendererSignalBase::Options expectedOptions; + }; + + QList testCases = { + test_case{"EmptyWaveform", + 0, + WaveformWidgetType::Empty, + WaveformWidgetBackend::None, + allshader::WaveformRendererSignalBase::None}, + test_case{"SoftwareWaveform", + 2, // Filtered + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"QtSimpleWaveform", + 3, // Simple Qt + WaveformWidgetType::Simple, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"QtWaveform", + 4, // Filtered Qt + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLSimpleWaveform", + 5, // Simple GL + WaveformWidgetType::Simple, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLFilteredWaveform", + 6, // Filtered GL + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLSLFilteredWaveform", + 7, // Filtered GLSL + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::HighDetail}, + test_case{"HSVWaveform", + 8, // HSV + WaveformWidgetType::HSV, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLVSyncTest", + 9, // VSync GL + WaveformWidgetType::VSyncTest, + WaveformWidgetBackend::None, + allshader::WaveformRendererSignalBase::None}, + test_case{"RGBWaveform", + 10, // RGB + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLRGBWaveform", + 11, // RGB GL + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLSLRGBWaveform", + 12, // RGB GLSL + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::HighDetail}, + test_case{"QtVSyncTest", + 13, // VSync Qt + WaveformWidgetType::VSyncTest, + WaveformWidgetBackend::None, + allshader::WaveformRendererSignalBase::None}, + test_case{"QtHSVWaveform", + 14, // HSV Qt + WaveformWidgetType::HSV, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"QtRGBWaveform", + 15, // RGB Qt + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"GLSLRGBStackedWaveform", + 16, // RGB Stacked + WaveformWidgetType::Stacked, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::HighDetail}, + test_case{"AllShaderRGBWaveform", + 17, // RGB (all-shaders) + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"AllShaderLRRGBWaveform", + 18, // L/R RGB (all-shaders) + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::SplitStereoSignal}, + test_case{"AllShaderFilteredWaveform", + 19, // Filtered (all-shaders) + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"AllShaderSimpleWaveform", + 20, // Simple (all-shaders) + WaveformWidgetType::Simple, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"AllShaderHSVWaveform", + 21, // HSV (all-shaders) + WaveformWidgetType::HSV, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"AllShaderTexturedFiltered", + 22, // Filtered (textured) (all-shaders) + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::HighDetail}, + test_case{"AllShaderTexturedRGB", + 23, // RGB (textured) (all-shaders) + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::HighDetail}, + test_case{"AllShaderTexturedStacked", + 24, // Stacked (textured) (all-shaders) + WaveformWidgetType::Stacked, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::HighDetail}, + test_case{"AllShaderRGBStackedWaveform", + 26, // Stacked (all-shaders) + WaveformWidgetType::Stacked, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}, + test_case{"Count_WaveformwidgetType", + 27, // Also used as invalid value + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::None}}; + + for (const auto& testCase : testCases) { + int waveformType = testCase.oldTypeId; + WaveformWidgetBackend waveformBackend = WaveformWidgetBackend::None; + allshader::WaveformRendererSignalBase::Options options = + allshader::WaveformRendererSignalBase::None; + + qDebug() << "Testing upgrade for" << testCase.waveformName; + + upgradeToAllShaders(&waveformType, &waveformBackend, &options); + ASSERT_EQ(waveformType, testCase.expectedType); + ASSERT_EQ(waveformBackend, testCase.expectedBackend); + ASSERT_EQ(options, testCase.expectedOptions); + } +} diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index 3938002d83e..0b2ac203cbd 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -19,7 +19,7 @@ class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBas enum Option { None = 0b0, SplitStereoSignal = 0b1, - HighDetails = 0b10, + HighDetail = 0b10, }; Q_DECLARE_FLAGS(Options, Option) diff --git a/src/waveform/widgets/allshader/filteredwaveformwidget.cpp b/src/waveform/widgets/allshader/filteredwaveformwidget.cpp index 4691eb0fca3..4e77cff5823 100644 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/filteredwaveformwidget.cpp @@ -21,7 +21,7 @@ FilteredWaveformWidget::FilteredWaveformWidget(const QString& group, addRenderer(); addRenderer(); addRenderer(); - if (options & allshader::WaveformRendererSignalBase::HighDetails) { + if (options & allshader::WaveformRendererSignalBase::HighDetail) { addRenderer(::WaveformWidgetType::Filtered); } else { addRenderer(false); diff --git a/src/waveform/widgets/allshader/filteredwaveformwidget.h b/src/waveform/widgets/allshader/filteredwaveformwidget.h index 88248c1a690..257c2cd8bc9 100644 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.h +++ b/src/waveform/widgets/allshader/filteredwaveformwidget.h @@ -30,7 +30,7 @@ class allshader::FilteredWaveformWidget final : public allshader::WaveformWidget return WaveformWidgetCategory::AllShader; } static constexpr int supportedOptions() { - return WaveformRendererSignalBase::HighDetails; + return WaveformRendererSignalBase::HighDetail; } protected: diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp index a532bf3d7ec..e34f9ecf73e 100644 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp @@ -21,7 +21,7 @@ RGBWaveformWidget::RGBWaveformWidget(const QString& group, addRenderer(); addRenderer(); addRenderer(); - if (options & allshader::WaveformRendererSignalBase::HighDetails) { + if (options & allshader::WaveformRendererSignalBase::HighDetail) { addRenderer(::WaveformWidgetType::RGB, ::WaveformRendererAbstract::Play, options); diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.h b/src/waveform/widgets/allshader/rgbwaveformwidget.h index 67c92cdab5a..f3e16b13b7e 100644 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.h +++ b/src/waveform/widgets/allshader/rgbwaveformwidget.h @@ -31,7 +31,7 @@ class allshader::RGBWaveformWidget final : public allshader::WaveformWidget { } static constexpr int supportedOptions() { return WaveformRendererSignalBase::SplitStereoSignal | - WaveformRendererSignalBase::HighDetails; + WaveformRendererSignalBase::HighDetail; } protected: diff --git a/src/waveform/widgets/allshader/stackedwaveformwidget.cpp b/src/waveform/widgets/allshader/stackedwaveformwidget.cpp index ac390c39679..92063166c4a 100644 --- a/src/waveform/widgets/allshader/stackedwaveformwidget.cpp +++ b/src/waveform/widgets/allshader/stackedwaveformwidget.cpp @@ -20,7 +20,7 @@ StackedWaveformWidget::StackedWaveformWidget(const QString& group, addRenderer(); addRenderer(); addRenderer(); - if (options & allshader::WaveformRendererSignalBase::HighDetails) { + if (options & allshader::WaveformRendererSignalBase::HighDetail) { addRenderer(::WaveformWidgetType::Stacked); } else { addRenderer(true); // true for RGB Stacked diff --git a/src/waveform/widgets/allshader/stackedwaveformwidget.h b/src/waveform/widgets/allshader/stackedwaveformwidget.h index 6c83b56a32d..c7f6873a2a3 100644 --- a/src/waveform/widgets/allshader/stackedwaveformwidget.h +++ b/src/waveform/widgets/allshader/stackedwaveformwidget.h @@ -33,7 +33,7 @@ class allshader::StackedWaveformWidget final : public allshader::WaveformWidget return WaveformWidgetCategory::AllShader; } static constexpr int supportedOptions() { - return WaveformRendererSignalBase::HighDetails; + return WaveformRendererSignalBase::HighDetail; } protected: From 9536d1317cc2da77851ba870d3ab127066e9eae5 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Tue, 21 May 2024 16:30:03 +0100 Subject: [PATCH 11/16] Don't show VSync if not in developer mode --- src/waveform/waveformwidgetfactory.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index b3a7b26ce29..0b3536ecb51 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -872,8 +872,6 @@ void WaveformWidgetFactory::evaluateWidgets() { for (WaveformWidgetType::Type type : WaveformWidgetType::kValues) { // this lambda needs its type specified explicitly, // requiring it to be called with via `.operator()()` - collectedHandles.insert(type, - QList()); auto setWaveformVarsByType = [&]() { bool useOpenGl = WaveformT::useOpenGl(); bool useOpenGles = WaveformT::useOpenGles(); @@ -917,7 +915,12 @@ void WaveformWidgetFactory::evaluateWidgets() { } if (active) { - collectedHandles[type].push_back(backend); + if (collectedHandles.contains(type)) { + collectedHandles[type].push_back(backend); + } else { + collectedHandles.insert(type, + QList{backend}); + } } }; From 5c3551dc7db3cfe1837711d96ecdd6e8b8ff650e Mon Sep 17 00:00:00 2001 From: m0dB Date: Wed, 22 May 2024 01:37:46 +0200 Subject: [PATCH 12/16] single waveformwidget class for all allshader waveform widget types, some cleanup in waveformwidgetfactory --- CMakeLists.txt | 5 - .../renderers/allshader/waveformrendererrgb.h | 4 + .../allshader/waveformrenderersignalbase.h | 4 + src/waveform/waveformwidgetfactory.cpp | 216 +++++++++--------- src/waveform/waveformwidgetfactory.h | 8 + .../allshader/filteredwaveformwidget.cpp | 43 ---- .../allshader/filteredwaveformwidget.h | 48 ---- .../widgets/allshader/hsvwaveformwidget.cpp | 35 --- .../widgets/allshader/hsvwaveformwidget.h | 45 ---- .../widgets/allshader/rgbwaveformwidget.cpp | 51 ----- .../widgets/allshader/rgbwaveformwidget.h | 48 ---- .../allshader/simplewaveformwidget.cpp | 35 --- .../widgets/allshader/simplewaveformwidget.h | 45 ---- .../allshader/stackedwaveformwidget.cpp | 42 ---- .../widgets/allshader/stackedwaveformwidget.h | 51 ----- .../widgets/allshader/waveformwidget.cpp | 110 ++++++++- .../widgets/allshader/waveformwidget.h | 30 ++- src/waveform/widgets/waveformwidgetvars.h | 10 + 18 files changed, 266 insertions(+), 564 deletions(-) delete mode 100644 src/waveform/widgets/allshader/filteredwaveformwidget.cpp delete mode 100644 src/waveform/widgets/allshader/filteredwaveformwidget.h delete mode 100644 src/waveform/widgets/allshader/hsvwaveformwidget.cpp delete mode 100644 src/waveform/widgets/allshader/hsvwaveformwidget.h delete mode 100644 src/waveform/widgets/allshader/rgbwaveformwidget.cpp delete mode 100644 src/waveform/widgets/allshader/rgbwaveformwidget.h delete mode 100644 src/waveform/widgets/allshader/simplewaveformwidget.cpp delete mode 100644 src/waveform/widgets/allshader/simplewaveformwidget.h delete mode 100644 src/waveform/widgets/allshader/stackedwaveformwidget.cpp delete mode 100644 src/waveform/widgets/allshader/stackedwaveformwidget.h create mode 100644 src/waveform/widgets/waveformwidgetvars.h diff --git a/CMakeLists.txt b/CMakeLists.txt index eeacb3aaf92..ee58f799000 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1528,11 +1528,6 @@ if(QOPENGL) src/waveform/renderers/allshader/waveformrenderersimple.cpp src/waveform/renderers/allshader/waveformrendermark.cpp src/waveform/renderers/allshader/waveformrendermarkrange.cpp - src/waveform/widgets/allshader/filteredwaveformwidget.cpp - src/waveform/widgets/allshader/hsvwaveformwidget.cpp - src/waveform/widgets/allshader/rgbwaveformwidget.cpp - src/waveform/widgets/allshader/stackedwaveformwidget.cpp - src/waveform/widgets/allshader/simplewaveformwidget.cpp src/waveform/widgets/allshader/waveformwidget.cpp src/widget/openglwindow.cpp src/widget/tooltipqopengl.cpp diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.h b/src/waveform/renderers/allshader/waveformrendererrgb.h index 0abc0b60083..56da5d3f61c 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.h +++ b/src/waveform/renderers/allshader/waveformrendererrgb.h @@ -23,6 +23,10 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS void initializeGL() override; void paintGL() override; + bool supportsSlip() const override { + return true; + } + private: mixxx::RGBShader m_shader; VertexData m_vertices; diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index 0b2ac203cbd..7e1b5ec411e 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -27,6 +27,10 @@ class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBas explicit WaveformRendererSignalBase(WaveformWidgetRenderer* waveformWidget); + virtual bool supportsSlip() const { + return false; + } + void draw(QPainter* painter, QPaintEvent* event) override { Q_UNUSED(painter); Q_UNUSED(event); diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 0b3536ecb51..3a3f4bf82bd 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -25,11 +25,7 @@ #include "waveform/vsyncthread.h" #ifdef MIXXX_USE_QOPENGL #include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#include "waveform/widgets/allshader/filteredwaveformwidget.h" -#include "waveform/widgets/allshader/hsvwaveformwidget.h" -#include "waveform/widgets/allshader/rgbwaveformwidget.h" -#include "waveform/widgets/allshader/simplewaveformwidget.h" -#include "waveform/widgets/allshader/stackedwaveformwidget.h" +#include "waveform/widgets/allshader/waveformwidget.h" #else #include "waveform/widgets/qthsvwaveformwidget.h" #include "waveform/widgets/qtrgbwaveformwidget.h" @@ -865,77 +861,86 @@ void WaveformWidgetFactory::slotFrameSwapped() { #endif } -void WaveformWidgetFactory::evaluateWidgets() { - m_waveformWidgetHandles.clear(); - QHash> collectedHandles; - QHash supportedOptions; - for (WaveformWidgetType::Type type : WaveformWidgetType::kValues) { - // this lambda needs its type specified explicitly, - // requiring it to be called with via `.operator()()` - auto setWaveformVarsByType = [&]() { - bool useOpenGl = WaveformT::useOpenGl(); - bool useOpenGles = WaveformT::useOpenGles(); - bool useOpenGLShaders = WaveformT::useOpenGLShaders(); - WaveformWidgetCategory category = WaveformT::category(); - WaveformWidgetBackend backend = WaveformWidgetBackend::None; - - bool active = true; - if (isOpenGlAvailable()) { - if (useOpenGles && !useOpenGl) { - active = false; - } else if (useOpenGLShaders && !isOpenGlShaderAvailable()) { - active = false; - } - } else if (isOpenGlesAvailable()) { - if (useOpenGl && !useOpenGles) { - active = false; - } else if (useOpenGLShaders && !isOpenGlShaderAvailable()) { - active = false; - } - } else { - // No sufficient GL support - if (useOpenGles || useOpenGl || useOpenGLShaders) { - active = false; - } - } +void WaveformWidgetFactory::addHandle( + QHash>& + collectedHandles, + WaveformWidgetType::Type type, + const WaveformWidgetVars& vars) const { + WaveformWidgetBackend backend = WaveformWidgetBackend::None; + bool active = true; + if (isOpenGlAvailable()) { + if (vars.m_useGLES && !vars.m_useGL) { + active = false; + } else if (vars.m_useGLSL && !isOpenGlShaderAvailable()) { + active = false; + } + } else if (isOpenGlesAvailable()) { + if (vars.m_useGL && !vars.m_useGLES) { + active = false; + } else if (vars.m_useGLSL && !isOpenGlShaderAvailable()) { + active = false; + } + } else { + // No sufficient GL support + if (vars.m_useGLES || vars.m_useGL || vars.m_useGLSL) { + active = false; + } + } - if (category == WaveformWidgetCategory::DeveloperOnly && - !CmdlineArgs::Instance().getDeveloper()) { - active = false; - } + if (vars.m_category == WaveformWidgetCategory::DeveloperOnly && + !CmdlineArgs::Instance().getDeveloper()) { + active = false; + } #ifdef MIXXX_USE_QOPENGL - else if (category == WaveformWidgetCategory::AllShader) { - backend = WaveformWidgetBackend::AllShader; - } + else if (vars.m_category == WaveformWidgetCategory::AllShader) { + backend = WaveformWidgetBackend::AllShader; + } #endif - else if (category == WaveformWidgetCategory::Legacy && useOpenGLShaders) { - backend = WaveformWidgetBackend::GLSL; - } else if (category == WaveformWidgetCategory::Legacy) { - backend = WaveformWidgetBackend::GL; - } + else if (vars.m_category == WaveformWidgetCategory::Legacy && vars.m_useGLSL) { + backend = WaveformWidgetBackend::GLSL; + } else if (vars.m_category == WaveformWidgetCategory::Legacy) { + backend = WaveformWidgetBackend::GL; + } - if (active) { - if (collectedHandles.contains(type)) { - collectedHandles[type].push_back(backend); - } else { - collectedHandles.insert(type, - QList{backend}); - } - } - }; + if (active) { + if (collectedHandles.contains(type)) { + collectedHandles[type].push_back(backend); + } else { + collectedHandles.insert(type, + QList{backend}); + } + } +} +namespace { +template +WaveformWidgetVars waveformWidgetVars() { + WaveformWidgetVars result; + result.m_useGL = WaveformT::useOpenGl(); + result.m_useGLES = WaveformT::useOpenGles(); + result.m_useGLSL = WaveformT::useOpenGLShaders(); + result.m_category = WaveformT::category(); + + return result; +} +} // namespace + +void WaveformWidgetFactory::evaluateWidgets() { + m_waveformWidgetHandles.clear(); + QHash> collectedHandles; + QHash supportedOptions; + for (WaveformWidgetType::Type type : WaveformWidgetType::kValues) { switch (type) { case WaveformWidgetType::Empty: - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); break; case WaveformWidgetType::Simple: - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL - setWaveformVarsByType.operator()(); - supportedOptions[type] = - allshader::SimpleWaveformWidget::supportedOptions(); + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #else - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::Filtered: @@ -944,41 +949,39 @@ void WaveformWidgetFactory::evaluateWidgets() { // that load GL widgets (spinnies, waveforms) in singletons. // Also excluded in enum WaveformWidgetType // https://bugs.launchpad.net/bugs/1928772 - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars(); #endif - setWaveformVarsByType.operator()(); - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); + addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL - setWaveformVarsByType.operator()(); - supportedOptions[type] = - allshader::FilteredWaveformWidget::supportedOptions(); + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #else - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::VSyncTest: - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #ifndef MIXXX_USE_QOPENGL - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::RGB: - setWaveformVarsByType.operator()(); - setWaveformVarsByType.operator()(); - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); + addHandle(collectedHandles, type, waveformWidgetVars()); + addHandle(collectedHandles, type, waveformWidgetVars()); #ifndef __APPLE__ // Don't offer the simple renderers on macOS, they do not work with skins // that load GL widgets (spinnies, waveforms) in singletons. // Also excluded in enum WaveformWidgetType // https://bugs.launchpad.net/bugs/1928772 - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif #ifdef MIXXX_USE_QOPENGL - setWaveformVarsByType.operator()(); - supportedOptions[type] = - allshader::RGBWaveformWidget::supportedOptions(); + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #else - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::HSV: @@ -987,22 +990,20 @@ void WaveformWidgetFactory::evaluateWidgets() { // that load GL widgets (spinnies, waveforms) in singletons. // Also excluded in enum WaveformWidgetType // https://bugs.launchpad.net/bugs/1928772 - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif #ifdef MIXXX_USE_QOPENGL - setWaveformVarsByType.operator()(); - supportedOptions[type] = - allshader::HSVWaveformWidget::supportedOptions(); + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #else - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::Stacked: - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL - setWaveformVarsByType.operator()(); - supportedOptions[type] = - allshader::StackedWaveformWidget::supportedOptions(); + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #endif break; default: @@ -1030,6 +1031,14 @@ void WaveformWidgetFactory::evaluateWidgets() { } } +WaveformWidgetAbstract* WaveformWidgetFactory::createAllshaderWaveformWidget( + WaveformWidgetType::Type type, WWaveformViewer* viewer) { + allshader::WaveformRendererSignalBase::Options options = + m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::None); + return new allshader::WaveformWidget(viewer, type, viewer->getGroup(), options); +} + WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( WWaveformViewer* viewer) { // On the UI, hardware acceleration is a boolean (0 => software rendering, 1 @@ -1048,10 +1057,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( return new GLSLFilteredWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL case WaveformWidgetBackend::AllShader: { - allshader::WaveformRendererSignalBase::Options options = - m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); - return new allshader::FilteredWaveformWidget(viewer->getGroup(), viewer, options); + return createAllshaderWaveformWidget(WaveformWidgetType::Type::Filtered, viewer); } #else case WaveformWidgetBackend::Qt: @@ -1075,7 +1081,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createHSVWaveformWidget(WWaveform switch (backend) { #ifdef MIXXX_USE_QOPENGL case WaveformWidgetBackend::AllShader: - return new allshader::HSVWaveformWidget(viewer->getGroup(), viewer); + return createAllshaderWaveformWidget(WaveformWidgetType::HSV, viewer); #endif default: return new HSVWaveformWidget(viewer->getGroup(), viewer); @@ -1098,12 +1104,8 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform case WaveformWidgetBackend::GLSL: return new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL - case WaveformWidgetBackend::AllShader: { - allshader::WaveformRendererSignalBase::Options options = - m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); - return new allshader::RGBWaveformWidget(viewer->getGroup(), viewer, options); - } + case WaveformWidgetBackend::AllShader: + return createAllshaderWaveformWidget(WaveformWidgetType::Type::RGB, viewer); #else case WaveformWidgetBackend::Qt: return new QtRGBWaveformWidget(viewer->getGroup(), viewer); @@ -1127,12 +1129,8 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createStackedWaveformWidget( switch (backend) { case WaveformWidgetBackend::GL: return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); - default: { - allshader::WaveformRendererSignalBase::Options options = - m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); - return new allshader::StackedWaveformWidget(viewer->getGroup(), viewer, options); - } + default: + return createAllshaderWaveformWidget(WaveformWidgetType::Type::Stacked, viewer); } #else return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); @@ -1154,7 +1152,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWavef case WaveformWidgetBackend::GL: return new GLSimpleWaveformWidget(viewer->getGroup(), viewer); default: - return new allshader::SimpleWaveformWidget(viewer->getGroup(), viewer); + return createAllshaderWaveformWidget(WaveformWidgetType::Type::Simple, viewer); #else case WaveformWidgetBackend::Qt: return new QtSimpleWaveformWidget(viewer->getGroup(), viewer); diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index aef77dcdd29..62d7dd3e66d 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -10,6 +10,7 @@ #include "util/performancetimer.h" #include "util/singleton.h" #include "waveform/widgets/waveformwidgettype.h" +#include "waveform/widgets/waveformwidgetvars.h" class WVuMeterLegacy; class WVuMeterBase; @@ -231,9 +232,16 @@ class WaveformWidgetFactory : public QObject, public Singleton>& + collectedHandles, + WaveformWidgetType::Type type, + const WaveformWidgetVars& vars) const; void evaluateWidgets(); template QString buildWidgetDisplayName() const; + WaveformWidgetAbstract* createAllshaderWaveformWidget( + WaveformWidgetType::Type type, WWaveformViewer* viewer); WaveformWidgetAbstract* createWaveformWidget(WaveformWidgetType::Type type, WWaveformViewer* viewer); int findIndexOf(WWaveformViewer* viewer) const; diff --git a/src/waveform/widgets/allshader/filteredwaveformwidget.cpp b/src/waveform/widgets/allshader/filteredwaveformwidget.cpp deleted file mode 100644 index 4e77cff5823..00000000000 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "waveform/widgets/allshader/filteredwaveformwidget.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererfiltered.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_filteredwaveformwidget.cpp" - -namespace allshader { - -FilteredWaveformWidget::FilteredWaveformWidget(const QString& group, - QWidget* parent, - WaveformRendererSignalBase::Options options) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - if (options & allshader::WaveformRendererSignalBase::HighDetail) { - addRenderer(::WaveformWidgetType::Filtered); - } else { - addRenderer(false); - } - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void FilteredWaveformWidget::castToQWidget() { - m_widget = this; -} - -void FilteredWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/filteredwaveformwidget.h b/src/waveform/widgets/allshader/filteredwaveformwidget.h deleted file mode 100644 index 257c2cd8bc9..00000000000 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class FilteredWaveformWidget; -} - -class allshader::FilteredWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::Filtered; - } - - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - static constexpr int supportedOptions() { - return WaveformRendererSignalBase::HighDetail; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - FilteredWaveformWidget(const QString& group, - QWidget* parent, - WaveformRendererSignalBase::Options options = - WaveformRendererSignalBase::None); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(FilteredWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/hsvwaveformwidget.cpp b/src/waveform/widgets/allshader/hsvwaveformwidget.cpp deleted file mode 100644 index 4d239c77059..00000000000 --- a/src/waveform/widgets/allshader/hsvwaveformwidget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "waveform/widgets/allshader/hsvwaveformwidget.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererhsv.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_hsvwaveformwidget.cpp" - -namespace allshader { - -HSVWaveformWidget::HSVWaveformWidget(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void HSVWaveformWidget::castToQWidget() { - m_widget = this; -} - -void HSVWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/hsvwaveformwidget.h b/src/waveform/widgets/allshader/hsvwaveformwidget.h deleted file mode 100644 index c0315f23b25..00000000000 --- a/src/waveform/widgets/allshader/hsvwaveformwidget.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class HSVWaveformWidget; -} - -class allshader::HSVWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::HSV; - } - - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - static constexpr int supportedOptions() { - return WaveformRendererSignalBase::None; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - HSVWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(HSVWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp b/src/waveform/widgets/allshader/rgbwaveformwidget.cpp deleted file mode 100644 index e34f9ecf73e..00000000000 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "waveform/widgets/allshader/rgbwaveformwidget.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrendererrgb.h" -#include "waveform/renderers/allshader/waveformrendererslipmode.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_rgbwaveformwidget.cpp" - -namespace allshader { - -RGBWaveformWidget::RGBWaveformWidget(const QString& group, - QWidget* parent, - WaveformRendererSignalBase::Options options) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - if (options & allshader::WaveformRendererSignalBase::HighDetail) { - addRenderer(::WaveformWidgetType::RGB, - ::WaveformRendererAbstract::Play, - options); - } else { - addRenderer(::WaveformRendererAbstract::Play, options); - } - addRenderer(); - addRenderer(); - // The following renderer will add an overlay waveform if a slip is in progress - addRenderer(); - addRenderer(::WaveformRendererAbstract::Slip); - addRenderer(::WaveformRendererAbstract::Slip, options); - addRenderer(::WaveformRendererAbstract::Slip); - addRenderer(::WaveformRendererAbstract::Slip); - - m_initSuccess = init(); -} - -void RGBWaveformWidget::castToQWidget() { - m_widget = this; -} - -void RGBWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/rgbwaveformwidget.h b/src/waveform/widgets/allshader/rgbwaveformwidget.h deleted file mode 100644 index f3e16b13b7e..00000000000 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class RGBWaveformWidget; -} - -class allshader::RGBWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::RGB; - } - - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - static constexpr int supportedOptions() { - return WaveformRendererSignalBase::SplitStereoSignal | - WaveformRendererSignalBase::HighDetail; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - RGBWaveformWidget(const QString& group, - QWidget* parent, - WaveformRendererSignalBase::Options options = WaveformRendererSignalBase::None); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(RGBWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/simplewaveformwidget.cpp b/src/waveform/widgets/allshader/simplewaveformwidget.cpp deleted file mode 100644 index 28828d6ccfe..00000000000 --- a/src/waveform/widgets/allshader/simplewaveformwidget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "waveform/widgets/allshader/simplewaveformwidget.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrenderersimple.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_simplewaveformwidget.cpp" - -namespace allshader { - -SimpleWaveformWidget::SimpleWaveformWidget(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void SimpleWaveformWidget::castToQWidget() { - m_widget = this; -} - -void SimpleWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/simplewaveformwidget.h b/src/waveform/widgets/allshader/simplewaveformwidget.h deleted file mode 100644 index bd6d67753f8..00000000000 --- a/src/waveform/widgets/allshader/simplewaveformwidget.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class SimpleWaveformWidget; -} - -class allshader::SimpleWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::Simple; - } - - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - static constexpr int supportedOptions() { - return WaveformRendererSignalBase::None; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - SimpleWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(SimpleWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/stackedwaveformwidget.cpp b/src/waveform/widgets/allshader/stackedwaveformwidget.cpp deleted file mode 100644 index 92063166c4a..00000000000 --- a/src/waveform/widgets/allshader/stackedwaveformwidget.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "waveform/widgets/allshader/stackedwaveformwidget.h" - -#include "waveform/renderers/allshader/waveformrenderbackground.h" -#include "waveform/renderers/allshader/waveformrenderbeat.h" -#include "waveform/renderers/allshader/waveformrendererendoftrack.h" -#include "waveform/renderers/allshader/waveformrendererfiltered.h" -#include "waveform/renderers/allshader/waveformrendererpreroll.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/renderers/allshader/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_stackedwaveformwidget.cpp" - -namespace allshader { - -StackedWaveformWidget::StackedWaveformWidget(const QString& group, - QWidget* parent, - WaveformRendererSignalBase::Options options) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - if (options & allshader::WaveformRendererSignalBase::HighDetail) { - addRenderer(::WaveformWidgetType::Stacked); - } else { - addRenderer(true); // true for RGB Stacked - } - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void StackedWaveformWidget::castToQWidget() { - m_widget = this; -} - -void StackedWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace allshader diff --git a/src/waveform/widgets/allshader/stackedwaveformwidget.h b/src/waveform/widgets/allshader/stackedwaveformwidget.h deleted file mode 100644 index c7f6873a2a3..00000000000 --- a/src/waveform/widgets/allshader/stackedwaveformwidget.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/renderers/allshader/waveformrenderertextured.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class StackedWaveformWidget; -} - -class allshader::StackedWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::Stacked; - } - - static inline QString getWaveformWidgetName() { - return tr("RGB Stacked"); - } - static constexpr bool useOpenGl() { - return true; - } - static constexpr bool useOpenGles() { - return true; - } - static constexpr bool useOpenGLShaders() { - return true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - static constexpr int supportedOptions() { - return WaveformRendererSignalBase::HighDetail; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - StackedWaveformWidget(const QString& group, - QWidget* parent, - WaveformRendererSignalBase::Options options = - WaveformRendererSignalBase::None); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(StackedWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/waveformwidget.cpp b/src/waveform/widgets/allshader/waveformwidget.cpp index 0a64dd964ef..95629cbd9a4 100644 --- a/src/waveform/widgets/allshader/waveformwidget.cpp +++ b/src/waveform/widgets/allshader/waveformwidget.cpp @@ -1,16 +1,55 @@ + #include "waveform/widgets/allshader/waveformwidget.h" #include #include -#include "moc_waveformwidget.cpp" +#include "waveform/renderers/allshader/waveformrenderbackground.h" +#include "waveform/renderers/allshader/waveformrenderbeat.h" #include "waveform/renderers/allshader/waveformrendererabstract.h" -#include "waveform/renderers/waveformrendererabstract.h" +#include "waveform/renderers/allshader/waveformrendererendoftrack.h" +#include "waveform/renderers/allshader/waveformrendererfiltered.h" +#include "waveform/renderers/allshader/waveformrendererhsv.h" +#include "waveform/renderers/allshader/waveformrendererpreroll.h" +#include "waveform/renderers/allshader/waveformrendererrgb.h" +#include "waveform/renderers/allshader/waveformrenderersimple.h" +#include "waveform/renderers/allshader/waveformrendererslipmode.h" +#include "waveform/renderers/allshader/waveformrenderertextured.h" +#include "waveform/renderers/allshader/waveformrendermark.h" +#include "waveform/renderers/allshader/waveformrendermarkrange.h" +#include "waveform/widgets/allshader/moc_waveformwidget.cpp" namespace allshader { -WaveformWidget::WaveformWidget(const QString& group, QWidget* parent) +WaveformWidget::WaveformWidget(QWidget* parent, + WaveformWidgetType::Type type, + const QString& group, + WaveformRendererSignalBase::Options options) : WGLWidget(parent), WaveformWidgetAbstract(group) { + addRenderer(); + addRenderer(); + addRenderer(); + addRenderer(); + + allshader::WaveformRendererSignalBase* waveformSignalRenderer = + addWaveformSignalRenderer( + type, options, ::WaveformRendererAbstract::Play); + + addRenderer(); + addRenderer(); + + // if the signal renderer supports slip, we add it again, now for slip, together with the + // other slip renderers + if (waveformSignalRenderer && waveformSignalRenderer->supportsSlip()) { + // The following renderer will add an overlay waveform if a slip is in progress + addRenderer(); + addRenderer(::WaveformRendererAbstract::Slip); + addWaveformSignalRenderer(type, options, ::WaveformRendererAbstract::Slip); + addRenderer(::WaveformRendererAbstract::Slip); + addRenderer(::WaveformRendererAbstract::Slip); + } + + m_initSuccess = init(); } WaveformWidget::~WaveformWidget() { @@ -22,6 +61,37 @@ WaveformWidget::~WaveformWidget() { doneCurrent(); } +allshader::WaveformRendererSignalBase* +WaveformWidget::addWaveformSignalRenderer(WaveformWidgetType::Type type, + WaveformRendererSignalBase::Options options, + ::WaveformRendererAbstract::PositionSource positionSource) { + switch (type) { + case ::WaveformWidgetType::Simple: + return addRenderer(); + case ::WaveformWidgetType::RGB: + if (options & allshader::WaveformRendererSignalBase::HighDetail) { + return addRenderer(type, positionSource, options); + } + return addRenderer(positionSource, options); + case ::WaveformWidgetType::HSV: + return addRenderer(); + case ::WaveformWidgetType::Filtered: + if (options & allshader::WaveformRendererSignalBase::HighDetail) { + return addRenderer(type, positionSource, options); + } + return addRenderer(false); + case ::WaveformWidgetType::Stacked: + if (options & allshader::WaveformRendererSignalBase::HighDetail) { + return addRenderer(type, positionSource, options); + } else { + return addRenderer(true); // true for RGB Stacked + } + default: + break; + } + return nullptr; +} + mixxx::Duration WaveformWidget::render() { makeCurrentIfNeeded(); paintGL(); @@ -45,6 +115,10 @@ void WaveformWidget::paintGL() { } } +void WaveformWidget::castToQWidget() { + m_widget = this; +} + void WaveformWidget::initializeGL() { for (auto* pRenderer : std::as_const(m_rendererStack)) { pRenderer->allshaderWaveformRenderer()->initializeGL(); @@ -57,6 +131,10 @@ void WaveformWidget::resizeGL(int w, int h) { } } +void WaveformWidget::paintEvent(QPaintEvent* event) { + Q_UNUSED(event); +} + void WaveformWidget::wheelEvent(QWheelEvent* pEvent) { QApplication::sendEvent(parentWidget(), pEvent); pEvent->accept(); @@ -67,4 +145,30 @@ void WaveformWidget::leaveEvent(QEvent* pEvent) { pEvent->accept(); } +/* static */ +int WaveformWidget::supportedOptions(WaveformWidgetType::Type type) { + switch (type) { + case WaveformWidgetType::Type::RGB: + return WaveformRendererSignalBase::SplitStereoSignal | + WaveformRendererSignalBase::HighDetail; + case WaveformWidgetType::Type::Filtered: + return WaveformRendererSignalBase::HighDetail; + case WaveformWidgetType::Type::Stacked: + return WaveformRendererSignalBase::HighDetail; + default: + break; + } + return 0; +} + +/* static */ +WaveformWidgetVars WaveformWidget::vars() { + WaveformWidgetVars result; + result.m_useGL = true; + result.m_useGLES = true; + result.m_useGLSL = true; + result.m_category = WaveformWidgetCategory::AllShader; + return result; +} + } // namespace allshader diff --git a/src/waveform/widgets/allshader/waveformwidget.h b/src/waveform/widgets/allshader/waveformwidget.h index 3ed27df9b1c..5933cb1f5c3 100644 --- a/src/waveform/widgets/allshader/waveformwidget.h +++ b/src/waveform/widgets/allshader/waveformwidget.h @@ -1,19 +1,28 @@ #pragma once +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/widgets/waveformwidgetabstract.h" +#include "waveform/widgets/waveformwidgetvars.h" #include "widget/wglwidget.h" namespace allshader { class WaveformWidget; } -class allshader::WaveformWidget : public ::WGLWidget, - public ::WaveformWidgetAbstract { +class allshader::WaveformWidget final : public ::WGLWidget, + public ::WaveformWidgetAbstract { Q_OBJECT public: - explicit WaveformWidget(const QString& group, QWidget* parent); + explicit WaveformWidget(QWidget* parent, + WaveformWidgetType::Type type, + const QString& group, + WaveformRendererSignalBase::Options options); ~WaveformWidget() override; + WaveformWidgetType::Type getType() const override { + return m_type; + } + // override for WaveformWidgetAbstract mixxx::Duration render() override; @@ -21,11 +30,24 @@ class allshader::WaveformWidget : public ::WGLWidget, void paintGL() override; void initializeGL() override; void resizeGL(int w, int h) override; - virtual WGLWidget* getGLWidget() override { + WGLWidget* getGLWidget() override { return this; } + static WaveformWidgetVars vars(); + static int supportedOptions(WaveformWidgetType::Type type); private: + void castToQWidget() override; + void paintEvent(QPaintEvent* event) override; void wheelEvent(QWheelEvent* event) override; void leaveEvent(QEvent* event) override; + + allshader::WaveformRendererSignalBase* addWaveformSignalRenderer( + WaveformWidgetType::Type type, + WaveformRendererSignalBase::Options options, + ::WaveformRendererAbstract::PositionSource positionSource); + + WaveformWidgetType::Type m_type; + + DISALLOW_COPY_AND_ASSIGN(WaveformWidget); }; diff --git a/src/waveform/widgets/waveformwidgetvars.h b/src/waveform/widgets/waveformwidgetvars.h new file mode 100644 index 00000000000..201aa7b5308 --- /dev/null +++ b/src/waveform/widgets/waveformwidgetvars.h @@ -0,0 +1,10 @@ +#pragma once + +#include "waveform/widgets/waveformwidgetcategory.h" + +struct WaveformWidgetVars { + bool m_useGL; + bool m_useGLES; + bool m_useGLSL; + WaveformWidgetCategory m_category; +}; From 2155dcce43a91d0e66304af95e6b3af344d2a8bf Mon Sep 17 00:00:00 2001 From: m0dB Date: Tue, 21 May 2024 10:31:14 +0200 Subject: [PATCH 13/16] restored the software renderering (non-opengl) waveforms, deprecated all qt(old qglwidget based), gl and glsl waveform widgets --- CMakeLists.txt | 21 +---- .../{deprecated => }/glvsynctestrenderer.cpp | 2 +- .../{deprecated => }/glvsynctestrenderer.h | 0 .../glwaveformrenderbackground.cpp | 2 +- .../glwaveformrenderbackground.h | 0 src/waveform/waveformwidgetfactory.cpp | 90 +++---------------- .../{ => deprecated}/qthsvwaveformwidget.cpp | 6 +- .../{ => deprecated}/qthsvwaveformwidget.h | 0 .../{ => deprecated}/qtrgbwaveformwidget.cpp | 6 +- .../{ => deprecated}/qtrgbwaveformwidget.h | 5 -- .../qtsimplewaveformwidget.cpp | 8 +- .../{ => deprecated}/qtsimplewaveformwidget.h | 6 -- .../{ => deprecated}/qtvsynctestwidget.cpp | 6 +- .../{ => deprecated}/qtvsynctestwidget.h | 4 - .../{ => deprecated}/qtwaveformwidget.cpp | 6 +- .../{ => deprecated}/qtwaveformwidget.h | 4 - .../{deprecated => }/glvsynctestwidget.cpp | 6 +- .../{deprecated => }/glvsynctestwidget.h | 2 +- .../glwaveformwidgetabstract.cpp | 2 +- .../glwaveformwidgetabstract.h | 0 20 files changed, 39 insertions(+), 137 deletions(-) rename src/waveform/renderers/{deprecated => }/glvsynctestrenderer.cpp (98%) rename src/waveform/renderers/{deprecated => }/glvsynctestrenderer.h (100%) rename src/waveform/renderers/{deprecated => }/glwaveformrenderbackground.cpp (90%) rename src/waveform/renderers/{deprecated => }/glwaveformrenderbackground.h (100%) rename src/waveform/widgets/{ => deprecated}/qthsvwaveformwidget.cpp (93%) rename src/waveform/widgets/{ => deprecated}/qthsvwaveformwidget.h (100%) rename src/waveform/widgets/{ => deprecated}/qtrgbwaveformwidget.cpp (93%) rename src/waveform/widgets/{ => deprecated}/qtrgbwaveformwidget.h (83%) rename src/waveform/widgets/{ => deprecated}/qtsimplewaveformwidget.cpp (92%) rename src/waveform/widgets/{ => deprecated}/qtsimplewaveformwidget.h (82%) rename src/waveform/widgets/{ => deprecated}/qtvsynctestwidget.cpp (92%) rename src/waveform/widgets/{ => deprecated}/qtvsynctestwidget.h (83%) rename src/waveform/widgets/{ => deprecated}/qtwaveformwidget.cpp (93%) rename src/waveform/widgets/{ => deprecated}/qtwaveformwidget.h (82%) rename src/waveform/widgets/{deprecated => }/glvsynctestwidget.cpp (88%) rename src/waveform/widgets/{deprecated => }/glvsynctestwidget.h (92%) rename src/waveform/widgets/{deprecated => }/glwaveformwidgetabstract.cpp (84%) rename src/waveform/widgets/{deprecated => }/glwaveformwidgetabstract.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee58f799000..e87010a3d70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1208,12 +1208,8 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/util/workerthreadscheduler.cpp src/util/xml.cpp src/waveform/guitick.cpp - src/waveform/renderers/deprecated/glslwaveformrenderersignal.cpp - src/waveform/renderers/deprecated/glvsynctestrenderer.cpp - src/waveform/renderers/deprecated/glwaveformrenderbackground.cpp - src/waveform/renderers/deprecated/glwaveformrendererfilteredsignal.cpp - src/waveform/renderers/deprecated/glwaveformrendererrgb.cpp - src/waveform/renderers/deprecated/glwaveformrenderersimplesignal.cpp + src/waveform/renderers/glwaveformrenderbackground.cpp + src/waveform/renderers/glvsynctestrenderer.cpp src/waveform/renderers/waveformmark.cpp src/waveform/renderers/waveformmarkrange.cpp src/waveform/renderers/waveformmarkset.cpp @@ -1240,16 +1236,12 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/waveform/waveformmarklabel.cpp src/waveform/waveformwidgetfactory.cpp src/waveform/widgets/emptywaveformwidget.cpp - src/waveform/widgets/deprecated/glrgbwaveformwidget.cpp - src/waveform/widgets/deprecated/glsimplewaveformwidget.cpp - src/waveform/widgets/deprecated/glslwaveformwidget.cpp - src/waveform/widgets/deprecated/glvsynctestwidget.cpp - src/waveform/widgets/deprecated/glwaveformwidget.cpp - src/waveform/widgets/deprecated/glwaveformwidgetabstract.cpp src/waveform/widgets/hsvwaveformwidget.cpp src/waveform/widgets/rgbwaveformwidget.cpp src/waveform/widgets/softwarewaveformwidget.cpp src/waveform/widgets/waveformwidgetabstract.cpp + src/waveform/widgets/glwaveformwidgetabstract.cpp + src/waveform/widgets/glvsynctestwidget.cpp src/widget/controlwidgetconnection.cpp src/widget/findonwebmenufactory.cpp src/widget/findonwebmenuservices/findonwebmenudiscogs.cpp @@ -1541,11 +1533,6 @@ else() src/waveform/renderers/qtvsynctestrenderer.cpp src/waveform/renderers/qtwaveformrendererfilteredsignal.cpp src/waveform/renderers/qtwaveformrenderersimplesignal.cpp - src/waveform/widgets/qthsvwaveformwidget.cpp - src/waveform/widgets/qtrgbwaveformwidget.cpp - src/waveform/widgets/qtsimplewaveformwidget.cpp - src/waveform/widgets/qtvsynctestwidget.cpp - src/waveform/widgets/qtwaveformwidget.cpp src/widget/wglwidgetqglwidget.cpp ) endif() diff --git a/src/waveform/renderers/deprecated/glvsynctestrenderer.cpp b/src/waveform/renderers/glvsynctestrenderer.cpp similarity index 98% rename from src/waveform/renderers/deprecated/glvsynctestrenderer.cpp rename to src/waveform/renderers/glvsynctestrenderer.cpp index 3f873fb7a16..a1d1cb7da27 100644 --- a/src/waveform/renderers/deprecated/glvsynctestrenderer.cpp +++ b/src/waveform/renderers/glvsynctestrenderer.cpp @@ -1,4 +1,4 @@ -#include "waveform/renderers/deprecated/glvsynctestrenderer.h" +#include "waveform/renderers/glvsynctestrenderer.h" #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) #include "util/performancetimer.h" diff --git a/src/waveform/renderers/deprecated/glvsynctestrenderer.h b/src/waveform/renderers/glvsynctestrenderer.h similarity index 100% rename from src/waveform/renderers/deprecated/glvsynctestrenderer.h rename to src/waveform/renderers/glvsynctestrenderer.h diff --git a/src/waveform/renderers/deprecated/glwaveformrenderbackground.cpp b/src/waveform/renderers/glwaveformrenderbackground.cpp similarity index 90% rename from src/waveform/renderers/deprecated/glwaveformrenderbackground.cpp rename to src/waveform/renderers/glwaveformrenderbackground.cpp index 88d63c68355..0be777514de 100644 --- a/src/waveform/renderers/deprecated/glwaveformrenderbackground.cpp +++ b/src/waveform/renderers/glwaveformrenderbackground.cpp @@ -1,4 +1,4 @@ -#include "waveform/renderers/deprecated/glwaveformrenderbackground.h" +#include "waveform/renderers/glwaveformrenderbackground.h" GLWaveformRenderBackground::GLWaveformRenderBackground( WaveformWidgetRenderer* waveformWidgetRenderer) diff --git a/src/waveform/renderers/deprecated/glwaveformrenderbackground.h b/src/waveform/renderers/glwaveformrenderbackground.h similarity index 100% rename from src/waveform/renderers/deprecated/glwaveformrenderbackground.h rename to src/waveform/renderers/glwaveformrenderbackground.h diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 3a3f4bf82bd..527f48ed850 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -26,18 +26,8 @@ #ifdef MIXXX_USE_QOPENGL #include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/widgets/allshader/waveformwidget.h" -#else -#include "waveform/widgets/qthsvwaveformwidget.h" -#include "waveform/widgets/qtrgbwaveformwidget.h" -#include "waveform/widgets/qtsimplewaveformwidget.h" -#include "waveform/widgets/qtvsynctestwidget.h" -#include "waveform/widgets/qtwaveformwidget.h" +#include "waveform/widgets/glvsynctestwidget.h" #endif -#include "waveform/widgets/deprecated/glrgbwaveformwidget.h" -#include "waveform/widgets/deprecated/glsimplewaveformwidget.h" -#include "waveform/widgets/deprecated/glslwaveformwidget.h" -#include "waveform/widgets/deprecated/glvsynctestwidget.h" -#include "waveform/widgets/deprecated/glwaveformwidget.h" #include "waveform/widgets/emptywaveformwidget.h" #include "waveform/widgets/hsvwaveformwidget.h" #include "waveform/widgets/rgbwaveformwidget.h" @@ -935,72 +925,38 @@ void WaveformWidgetFactory::evaluateWidgets() { addHandle(collectedHandles, type, waveformWidgetVars()); break; case WaveformWidgetType::Simple: - addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); -#else - addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::Filtered: -#ifndef __APPLE__ - // Don't offer the simple renderers on macOS, they do not work with skins - // that load GL widgets (spinnies, waveforms) in singletons. - // Also excluded in enum WaveformWidgetType - // https://bugs.launchpad.net/bugs/1928772 - addHandle(collectedHandles, type, waveformWidgetVars(); -#endif - addHandle(collectedHandles, type, waveformWidgetVars()); - addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); -#else - addHandle(collectedHandles, type, waveformWidgetVars()); #endif + addHandle(collectedHandles, type, waveformWidgetVars()); break; case WaveformWidgetType::VSyncTest: +#ifdef MIXXX_USE_QOPENGL addHandle(collectedHandles, type, waveformWidgetVars()); -#ifndef MIXXX_USE_QOPENGL - addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::RGB: - addHandle(collectedHandles, type, waveformWidgetVars()); - addHandle(collectedHandles, type, waveformWidgetVars()); - addHandle(collectedHandles, type, waveformWidgetVars()); -#ifndef __APPLE__ - // Don't offer the simple renderers on macOS, they do not work with skins - // that load GL widgets (spinnies, waveforms) in singletons. - // Also excluded in enum WaveformWidgetType - // https://bugs.launchpad.net/bugs/1928772 - addHandle(collectedHandles, type, waveformWidgetVars()); -#endif #ifdef MIXXX_USE_QOPENGL addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); -#else - addHandle(collectedHandles, type, waveformWidgetVars()); #endif + addHandle(collectedHandles, type, waveformWidgetVars()); break; case WaveformWidgetType::HSV: -#ifndef __APPLE__ - // Don't offer the simple renderers on macOS, they do not work with skins - // that load GL widgets (spinnies, waveforms) in singletons. - // Also excluded in enum WaveformWidgetType - // https://bugs.launchpad.net/bugs/1928772 addHandle(collectedHandles, type, waveformWidgetVars()); -#endif #ifdef MIXXX_USE_QOPENGL addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); -#else - addHandle(collectedHandles, type, waveformWidgetVars()); #endif break; case WaveformWidgetType::Stacked: - addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); @@ -1051,17 +1007,10 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createFilteredWaveformWidget( preferredBackend()); switch (backend) { - case WaveformWidgetBackend::GL: - return new GLWaveformWidget(viewer->getGroup(), viewer); - case WaveformWidgetBackend::GLSL: - return new GLSLFilteredWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL case WaveformWidgetBackend::AllShader: { return createAllshaderWaveformWidget(WaveformWidgetType::Type::Filtered, viewer); } -#else - case WaveformWidgetBackend::Qt: - return new QtWaveformWidget(viewer->getGroup(), viewer); #endif default: return new SoftwareWaveformWidget(viewer->getGroup(), viewer); @@ -1099,16 +1048,9 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createRGBWaveformWidget(WWaveform preferredBackend()); switch (backend) { - case WaveformWidgetBackend::GL: - return new GLRGBWaveformWidget(viewer->getGroup(), viewer); - case WaveformWidgetBackend::GLSL: - return new GLSLRGBWaveformWidget(viewer->getGroup(), viewer); #ifdef MIXXX_USE_QOPENGL case WaveformWidgetBackend::AllShader: return createAllshaderWaveformWidget(WaveformWidgetType::Type::RGB, viewer); -#else - case WaveformWidgetBackend::Qt: - return new QtRGBWaveformWidget(viewer->getGroup(), viewer); #endif default: return new RGBWaveformWidget(viewer->getGroup(), viewer); @@ -1127,14 +1069,12 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createStackedWaveformWidget( ConfigKey("[Waveform]", "use_hardware_acceleration"), preferredBackend()); switch (backend) { - case WaveformWidgetBackend::GL: - return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); - default: + case WaveformWidgetBackend::AllShader: return createAllshaderWaveformWidget(WaveformWidgetType::Type::Stacked, viewer); - } -#else - return new GLSLRGBStackedWaveformWidget(viewer->getGroup(), viewer); #endif + default: + return new EmptyWaveformWidget(viewer->getGroup(), viewer); + } } WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWaveformViewer* viewer) { @@ -1149,16 +1089,11 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createSimpleWaveformWidget(WWavef switch (backend) { #ifdef MIXXX_USE_QOPENGL - case WaveformWidgetBackend::GL: - return new GLSimpleWaveformWidget(viewer->getGroup(), viewer); - default: + case WaveformWidgetBackend::AllShader: return createAllshaderWaveformWidget(WaveformWidgetType::Type::Simple, viewer); -#else - case WaveformWidgetBackend::Qt: - return new QtSimpleWaveformWidget(viewer->getGroup(), viewer); - default: - return new GLSimpleWaveformWidget(viewer->getGroup(), viewer); #endif + default: + return new EmptyWaveformWidget(viewer->getGroup(), viewer); } } @@ -1167,7 +1102,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createVSyncTestWaveformWidget( #ifdef MIXXX_USE_QOPENGL return new GLVSyncTestWidget(viewer->getGroup(), viewer); #else - return new QtVSyncTest(viewer->getGroup(), viewer); + return new EmptyWaveformWidget(viewer->getGroup(), viewer); #endif } @@ -1198,7 +1133,6 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createWaveformWidget( case WaveformWidgetType::Stacked: widget = createStackedWaveformWidget(viewer); break; - //case WaveformWidgetType::EmptyWaveform: default: widget = new EmptyWaveformWidget(viewer->getGroup(), viewer); break; diff --git a/src/waveform/widgets/qthsvwaveformwidget.cpp b/src/waveform/widgets/deprecated/qthsvwaveformwidget.cpp similarity index 93% rename from src/waveform/widgets/qthsvwaveformwidget.cpp rename to src/waveform/widgets/deprecated/qthsvwaveformwidget.cpp index 179d44d48bf..0a63643a783 100644 --- a/src/waveform/widgets/qthsvwaveformwidget.cpp +++ b/src/waveform/widgets/deprecated/qthsvwaveformwidget.cpp @@ -40,14 +40,14 @@ void QtHSVWaveformWidget::paintEvent(QPaintEvent* event) { mixxx::Duration QtHSVWaveformWidget::render() { PerformanceTimer timer; mixxx::Duration t1; - //mixxx::Duration t2, t3; + // mixxx::Duration t2, t3; timer.start(); // QPainter makes QGLContext::currentContext() == context() // this may delayed until previous buffer swap finished QPainter painter(paintDevice()); t1 = timer.restart(); draw(&painter, nullptr); - //t2 = timer.restart(); - //qDebug() << "QtHSVWaveformWidget "<< t1 << t2; + // t2 = timer.restart(); + // qDebug() << "QtHSVWaveformWidget "<< t1 << t2; return t1; // return timer for painter setup } diff --git a/src/waveform/widgets/qthsvwaveformwidget.h b/src/waveform/widgets/deprecated/qthsvwaveformwidget.h similarity index 100% rename from src/waveform/widgets/qthsvwaveformwidget.h rename to src/waveform/widgets/deprecated/qthsvwaveformwidget.h diff --git a/src/waveform/widgets/qtrgbwaveformwidget.cpp b/src/waveform/widgets/deprecated/qtrgbwaveformwidget.cpp similarity index 93% rename from src/waveform/widgets/qtrgbwaveformwidget.cpp rename to src/waveform/widgets/deprecated/qtrgbwaveformwidget.cpp index e73fe5bc35d..e491d92173a 100644 --- a/src/waveform/widgets/qtrgbwaveformwidget.cpp +++ b/src/waveform/widgets/deprecated/qtrgbwaveformwidget.cpp @@ -40,14 +40,14 @@ void QtRGBWaveformWidget::paintEvent(QPaintEvent* event) { mixxx::Duration QtRGBWaveformWidget::render() { PerformanceTimer timer; mixxx::Duration t1; - //mixxx::Duration t2, t3; + // mixxx::Duration t2, t3; timer.start(); // QPainter makes QGLContext::currentContext() == context() // this may delayed until previous buffer swap finished QPainter painter(paintDevice()); t1 = timer.restart(); draw(&painter, nullptr); - //t2 = timer.restart(); - //qDebug() << "GLVSyncTestWidget "<< t1 << t2; + // t2 = timer.restart(); + // qDebug() << "GLVSyncTestWidget "<< t1 << t2; return t1; // return timer for painter setup } diff --git a/src/waveform/widgets/qtrgbwaveformwidget.h b/src/waveform/widgets/deprecated/qtrgbwaveformwidget.h similarity index 83% rename from src/waveform/widgets/qtrgbwaveformwidget.h rename to src/waveform/widgets/deprecated/qtrgbwaveformwidget.h index 1f5e3c7f146..2718536e499 100644 --- a/src/waveform/widgets/qtrgbwaveformwidget.h +++ b/src/waveform/widgets/deprecated/qtrgbwaveformwidget.h @@ -10,14 +10,9 @@ class QtRGBWaveformWidget : public GLWaveformWidgetAbstract { virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::RGB; } - - static inline QString getWaveformWidgetName() { return tr("RGB") + " - Qt"; } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return true; } static inline bool useOpenGLShaders() { return false; } - static inline bool useTextureForWaveform() { - return false; - } static inline WaveformWidgetCategory category() { return WaveformWidgetCategory::Legacy; } diff --git a/src/waveform/widgets/qtsimplewaveformwidget.cpp b/src/waveform/widgets/deprecated/qtsimplewaveformwidget.cpp similarity index 92% rename from src/waveform/widgets/qtsimplewaveformwidget.cpp rename to src/waveform/widgets/deprecated/qtsimplewaveformwidget.cpp index 8a410c65864..04824cb3c1f 100644 --- a/src/waveform/widgets/qtsimplewaveformwidget.cpp +++ b/src/waveform/widgets/deprecated/qtsimplewaveformwidget.cpp @@ -37,21 +37,21 @@ void QtSimpleWaveformWidget::castToQWidget() { } void QtSimpleWaveformWidget::paintEvent(QPaintEvent* event) { - //qDebug() << "paintEvent()"; + // qDebug() << "paintEvent()"; Q_UNUSED(event); } mixxx::Duration QtSimpleWaveformWidget::render() { PerformanceTimer timer; mixxx::Duration t1; - //mixxx::Duration t2; + // mixxx::Duration t2; timer.start(); // QPainter makes QGLContext::currentContext() == context() // this may delayed until previous buffer swap finished QPainter painter(paintDevice()); t1 = timer.restart(); draw(&painter, nullptr); - //t2 = timer.restart(); - //qDebug() << "QtSimpleWaveformWidget" << t1 << t2; + // t2 = timer.restart(); + // qDebug() << "QtSimpleWaveformWidget" << t1 << t2; return t1; // return timer for painter setup } diff --git a/src/waveform/widgets/qtsimplewaveformwidget.h b/src/waveform/widgets/deprecated/qtsimplewaveformwidget.h similarity index 82% rename from src/waveform/widgets/qtsimplewaveformwidget.h rename to src/waveform/widgets/deprecated/qtsimplewaveformwidget.h index 552befbb390..76060f1bcea 100644 --- a/src/waveform/widgets/qtsimplewaveformwidget.h +++ b/src/waveform/widgets/deprecated/qtsimplewaveformwidget.h @@ -12,15 +12,9 @@ class QtSimpleWaveformWidget : public GLWaveformWidgetAbstract { return WaveformWidgetType::Simple; } - static inline QString getWaveformWidgetName() { - return tr("Simple") + "- Qt"; - } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return true; } static inline bool useOpenGLShaders() { return false; } - static inline bool useTextureForWaveform() { - return false; - } static inline WaveformWidgetCategory category() { return WaveformWidgetCategory::Legacy; } diff --git a/src/waveform/widgets/qtvsynctestwidget.cpp b/src/waveform/widgets/deprecated/qtvsynctestwidget.cpp similarity index 92% rename from src/waveform/widgets/qtvsynctestwidget.cpp rename to src/waveform/widgets/deprecated/qtvsynctestwidget.cpp index e770ce505b6..4a6912b3a0e 100644 --- a/src/waveform/widgets/qtvsynctestwidget.cpp +++ b/src/waveform/widgets/deprecated/qtvsynctestwidget.cpp @@ -34,14 +34,14 @@ void QtVSyncTestWidget::paintEvent(QPaintEvent* event) { mixxx::Duration QtVSyncTestWidget::render() { PerformanceTimer timer; mixxx::Duration t1; - //mixxx::Duration t2, t3; + // mixxx::Duration t2, t3; timer.start(); // QPainter makes QGLContext::currentContext() == context() // this may delayed until previous buffer swap finished QPainter painter(paintDevice()); t1 = timer.restart(); draw(&painter, nullptr); - //t2 = timer.restart(); - //qDebug() << "GLVSyncTestWidget "<< t1 << t2; + // t2 = timer.restart(); + // qDebug() << "GLVSyncTestWidget "<< t1 << t2; return t1; // return timer for painter setup } diff --git a/src/waveform/widgets/qtvsynctestwidget.h b/src/waveform/widgets/deprecated/qtvsynctestwidget.h similarity index 83% rename from src/waveform/widgets/qtvsynctestwidget.h rename to src/waveform/widgets/deprecated/qtvsynctestwidget.h index c6c64ef6da1..2b986901919 100644 --- a/src/waveform/widgets/qtvsynctestwidget.h +++ b/src/waveform/widgets/deprecated/qtvsynctestwidget.h @@ -12,13 +12,9 @@ class QtVSyncTestWidget : public GLWaveformWidgetAbstract { return WaveformWidgetType::VSyncTest; } - static inline QString getWaveformWidgetName() { return tr("VSyncTest") + " - Qt"; } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return true; } static inline bool useOpenGLShaders() { return false; } - static inline bool useTextureForWaveform() { - return false; - } static inline WaveformWidgetCategory category() { return WaveformWidgetCategory::DeveloperOnly; } diff --git a/src/waveform/widgets/qtwaveformwidget.cpp b/src/waveform/widgets/deprecated/qtwaveformwidget.cpp similarity index 93% rename from src/waveform/widgets/qtwaveformwidget.cpp rename to src/waveform/widgets/deprecated/qtwaveformwidget.cpp index ccee4f3b1b1..2bbf617d0ec 100644 --- a/src/waveform/widgets/qtwaveformwidget.cpp +++ b/src/waveform/widgets/deprecated/qtwaveformwidget.cpp @@ -41,14 +41,14 @@ void QtWaveformWidget::paintEvent(QPaintEvent* event) { mixxx::Duration QtWaveformWidget::render() { PerformanceTimer timer; mixxx::Duration t1; - //mixxx::Duration t2; + // mixxx::Duration t2; timer.start(); // QPainter makes QGLContext::currentContext() == context() // this may delayed until previous buffer swap finished QPainter painter(paintDevice()); t1 = timer.restart(); draw(&painter, nullptr); - //t2 = timer.restart(); - //qDebug() << "GLVSyncTestWidget "<< t1 << t2; + // t2 = timer.restart(); + // qDebug() << "GLVSyncTestWidget "<< t1 << t2; return t1; // return timer for painter setup } diff --git a/src/waveform/widgets/qtwaveformwidget.h b/src/waveform/widgets/deprecated/qtwaveformwidget.h similarity index 82% rename from src/waveform/widgets/qtwaveformwidget.h rename to src/waveform/widgets/deprecated/qtwaveformwidget.h index c6b53005140..5db32b34266 100644 --- a/src/waveform/widgets/qtwaveformwidget.h +++ b/src/waveform/widgets/deprecated/qtwaveformwidget.h @@ -12,13 +12,9 @@ class QtWaveformWidget : public GLWaveformWidgetAbstract { return WaveformWidgetType::Filtered; } - static inline QString getWaveformWidgetName() { return tr("Filtered") + " - Qt"; } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return true; } static inline bool useOpenGLShaders() { return false; } - static inline bool useTextureForWaveform() { - return false; - } static inline WaveformWidgetCategory category() { return WaveformWidgetCategory::Legacy; } diff --git a/src/waveform/widgets/deprecated/glvsynctestwidget.cpp b/src/waveform/widgets/glvsynctestwidget.cpp similarity index 88% rename from src/waveform/widgets/deprecated/glvsynctestwidget.cpp rename to src/waveform/widgets/glvsynctestwidget.cpp index bea10b0f5ca..cbf88525cf1 100644 --- a/src/waveform/widgets/deprecated/glvsynctestwidget.cpp +++ b/src/waveform/widgets/glvsynctestwidget.cpp @@ -1,11 +1,11 @@ -#include "waveform/widgets/deprecated/glvsynctestwidget.h" +#include "waveform/widgets/glvsynctestwidget.h" #include #include "moc_glvsynctestwidget.cpp" #include "util/performancetimer.h" -#include "waveform/renderers/deprecated/glvsynctestrenderer.h" -#include "waveform/renderers/deprecated/glwaveformrenderbackground.h" +#include "waveform/renderers/glvsynctestrenderer.h" +#include "waveform/renderers/glwaveformrenderbackground.h" GLVSyncTestWidget::GLVSyncTestWidget(const QString& group, QWidget* parent) : GLWaveformWidgetAbstract(group, parent) { diff --git a/src/waveform/widgets/deprecated/glvsynctestwidget.h b/src/waveform/widgets/glvsynctestwidget.h similarity index 92% rename from src/waveform/widgets/deprecated/glvsynctestwidget.h rename to src/waveform/widgets/glvsynctestwidget.h index 8aa2f24c905..9dc7f4fa129 100644 --- a/src/waveform/widgets/deprecated/glvsynctestwidget.h +++ b/src/waveform/widgets/glvsynctestwidget.h @@ -1,6 +1,6 @@ #pragma once -#include "waveform/widgets/deprecated/glwaveformwidgetabstract.h" +#include "waveform/widgets/glwaveformwidgetabstract.h" class GLVSyncTestWidget : public GLWaveformWidgetAbstract { Q_OBJECT diff --git a/src/waveform/widgets/deprecated/glwaveformwidgetabstract.cpp b/src/waveform/widgets/glwaveformwidgetabstract.cpp similarity index 84% rename from src/waveform/widgets/deprecated/glwaveformwidgetabstract.cpp rename to src/waveform/widgets/glwaveformwidgetabstract.cpp index 2594349d4aa..62cbdb22194 100644 --- a/src/waveform/widgets/deprecated/glwaveformwidgetabstract.cpp +++ b/src/waveform/widgets/glwaveformwidgetabstract.cpp @@ -1,4 +1,4 @@ -#include "waveform/widgets/deprecated/glwaveformwidgetabstract.h" +#include "waveform/widgets/glwaveformwidgetabstract.h" #include #include diff --git a/src/waveform/widgets/deprecated/glwaveformwidgetabstract.h b/src/waveform/widgets/glwaveformwidgetabstract.h similarity index 100% rename from src/waveform/widgets/deprecated/glwaveformwidgetabstract.h rename to src/waveform/widgets/glwaveformwidgetabstract.h From af247569cd81af01909bc2c8677dbb20f0eec63c Mon Sep 17 00:00:00 2001 From: Antoine C Date: Wed, 22 May 2024 18:49:41 +0100 Subject: [PATCH 14/16] Few nits and improve upgrade procedure --- src/preferences/dialog/dlgprefwaveform.cpp | 13 +- src/preferences/dialog/dlgprefwaveform.h | 16 +-- src/preferences/dialog/dlgprefwaveformdlg.ui | 4 +- src/preferences/upgrade.cpp | 121 +++++++++++------- src/test/waveform_upgrade_test.cpp | 13 +- .../allshader/waveformrenderersignalbase.h | 1 + src/waveform/waveformwidgetfactory.h | 3 + src/waveform/widgets/waveformwidgettype.h | 2 +- 8 files changed, 99 insertions(+), 74 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 83e3ff632fd..e9df0ac3a6b 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -8,10 +8,6 @@ #include "waveform/renderers/waveformwidgetrenderer.h" #include "waveform/waveformwidgetfactory.h" -namespace { -constexpr WaveformWidgetType::Type kDefaultWaveform = WaveformWidgetType::RGB; -} // anonymous namespace - DlgPrefWaveform::DlgPrefWaveform( QWidget* pParent, UserSettingsPointer pConfig, @@ -291,14 +287,14 @@ void DlgPrefWaveform::slotResetToDefaults() { WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); int defaultIndex = waveformTypeComboBox->findData( - kDefaultWaveform); + WaveformWidgetFactory::defaultType()); if (defaultIndex != -1 && waveformTypeComboBox->currentIndex() != defaultIndex) { waveformTypeComboBox->setCurrentIndex(defaultIndex); } auto defaultBackend = factory->preferredBackend(); useWaveformCheckBox->setChecked(true); waveformTypeComboBox->setEnabled(true); - updateWaveformAcceleration(kDefaultWaveform, defaultBackend); + updateWaveformAcceleration(WaveformWidgetFactory::defaultType(), defaultBackend); updateWaveformOption(true, defaultBackend, allshader::WaveformRendererSignalBase::None); // Restore waveform backend and option setting instantly @@ -306,7 +302,10 @@ void DlgPrefWaveform::slotResetToDefaults() { allshader::WaveformRendererSignalBase::None); m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), defaultBackend); - factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(kDefaultWaveform), true); + factory->setWidgetTypeFromHandle( + factory->findHandleIndexFromType( + WaveformWidgetFactory::defaultType()), + true); allVisualGain->setValue(1.0); lowVisualGain->setValue(1.0); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index cde58e60d95..e426d50ed72 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -8,10 +8,6 @@ #include "waveform/widgets/waveformwidgettype.h" #ifdef MIXXX_USE_QOPENGL #include "waveform/renderers/allshader/waveformrenderersignalbase.h" -#define DECL_SLOT_WAVEFORM_OPTION(opt) \ - void slotSetWaveformOption##opt(bool checked) { \ - slotSetWaveformOptions(allshader::WaveformRendererSignalBase::opt, checked); \ - } #endif class Library; @@ -38,8 +34,12 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void slotSetWaveformAcceleration(bool checked); #ifdef MIXXX_USE_QOPENGL void slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option option, bool enabled); - DECL_SLOT_WAVEFORM_OPTION(SplitStereoSignal); - DECL_SLOT_WAVEFORM_OPTION(HighDetail); + void slotSetWaveformOptionSplitStereoSignal(bool checked) { + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::SplitStereoSignal, checked); + } + void slotSetWaveformOptionHighDetail(bool checked) { + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::HighDetail, checked); + } #endif void slotSetWaveformOverviewType(int index); void slotSetDefaultZoom(int index); @@ -73,7 +73,3 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg UserSettingsPointer m_pConfig; std::shared_ptr m_pLibrary; }; - -#ifdef DECL_SLOT_WAVEFORM_OPTION -#undef DECL_SLOT_WAVEFORM_OPTION -#endif diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 0959bf34c17..33174e79b17 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -237,7 +237,7 @@ - This functionality requires waveform acceleration "(GLSL)". + This functionality requires waveform acceleration. Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -672,7 +672,7 @@ Select from different types of displays for the waveform, which differ primarily - + Qt::Horizontal diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index 11a1fb098c7..dd037091f01 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "config.h" #include "controllers/defs_controllers.h" @@ -21,6 +22,7 @@ #include "util/versionstore.h" #include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/vsyncthread.h" +#include "waveform/waveformwidgetfactory.h" #include "waveform/widgets/waveformwidgettype.h" Upgrade::Upgrade() @@ -33,78 +35,107 @@ Upgrade::~Upgrade() { namespace { // mapping to proactively move users to the new all-shader waveform types -void upgradeToAllShaders(int* waveformType, - WaveformWidgetBackend* waveformBackend, - allshader::WaveformRendererSignalBase::Options* waveformOptions) { - if (*waveformBackend == WaveformWidgetBackend::AllShader) { - return; - } - *waveformOptions = allshader::WaveformRendererSignalBase::None; - *waveformBackend = WaveformWidgetBackend::AllShader; +std::tuple +upgradeToAllShaders(int unsafeWaveformType, + int unsafeWaveformBackend, + int unsafeWaveformOption) { // TODO: convert `WaveformWidgetType::Type` to an enum class then shorten more `using enum ...` using WWT = WaveformWidgetType; + if (static_cast(unsafeWaveformBackend) == + WaveformWidgetBackend::AllShader) { + allshader::WaveformRendererSignalBase::Options waveformOption = + static_cast( + unsafeWaveformOption) & + allshader::WaveformRendererSignalBase::All; + switch (unsafeWaveformType) { + case WWT::Simple: + case WWT::Filtered: + case WWT::HSV: + case WWT::Stacked: + case WWT::Empty: + return {static_cast(unsafeWaveformType), + WaveformWidgetBackend::AllShader, + waveformOption}; + ; + default: + return {WaveformWidgetFactory::defaultType(), + WaveformWidgetBackend::AllShader, + waveformOption}; + } + } + + // Reset the options + allshader::WaveformRendererSignalBase::Options waveformOption = + allshader::WaveformRendererSignalBase::None; + WaveformWidgetType::Type waveformType = + static_cast(unsafeWaveformType); + WaveformWidgetBackend waveformBackend = WaveformWidgetBackend::AllShader; + // The switch includes raw values that have been removed from the enum - switch (*waveformType) { + switch (unsafeWaveformType) { // None or test waveforms case WWT::Empty: // Not supported by AllShader - *waveformBackend = WaveformWidgetBackend::None; + waveformBackend = WaveformWidgetBackend::None; break; case WWT::VSyncTest: // GLVSyncTest case 13: // QtVSyncTest // Not supported by AllShader - *waveformBackend = WaveformWidgetBackend::None; - *waveformType = WaveformWidgetType::VSyncTest; + waveformBackend = WaveformWidgetBackend::None; + waveformType = WaveformWidgetType::VSyncTest; break; // Simple waveforms case 3: // QtSimpleWaveform case 20: // AllShaderSimpleWaveform case WWT::Simple: - *waveformType = WaveformWidgetType::Simple; + waveformType = WaveformWidgetType::Simple; break; // Filtered waveforms case WWT::Filtered: // GLSLFilteredWaveform case 22: // AllShaderTexturedFiltered - *waveformOptions = allshader::WaveformRendererSignalBase::HighDetail; + waveformOption = allshader::WaveformRendererSignalBase::HighDetail; [[fallthrough]]; case 2: // SoftwareWaveform case 4: // QtWaveform case 6: // GLFilteredWaveform case 19: // AllShaderFilteredWaveform - *waveformType = WaveformWidgetType::Filtered; + waveformType = WaveformWidgetType::Filtered; break; // HSV waveforms case 14: // QtHSVWaveform case 21: // AllShaderHSVWaveform case WWT::HSV: - *waveformType = WaveformWidgetType::HSV; + waveformType = WaveformWidgetType::HSV; break; // Stacked waveform case 24: // AllShaderTexturedStacked case WWT::Stacked: // GLSLRGBStackedWaveform - *waveformOptions = allshader::WaveformRendererSignalBase::HighDetail; + waveformOption = allshader::WaveformRendererSignalBase::HighDetail; [[fallthrough]]; case 26: // AllShaderRGBStackedWaveform - *waveformType = WaveformWidgetType::Stacked; + waveformType = WaveformWidgetType::Stacked; break; // RGB waveform (preferred) case 18: // AllShaderLRRGBWaveform case 23: // AllShaderTexturedRGB case 12: // GLSLRGBWaveform - *waveformOptions = *waveformType == 18 + waveformOption = unsafeWaveformType == 18 ? allshader::WaveformRendererSignalBase::SplitStereoSignal : allshader::WaveformRendererSignalBase::HighDetail; [[fallthrough]]; default: - *waveformType = WaveformWidgetType::RGB; + waveformType = WaveformWidgetFactory::defaultType(); break; } + return {waveformType, waveformBackend, waveformOption}; } VSyncThread::VSyncMode upgradeDeprecatedVSyncModes(int configVSyncMode) { @@ -547,6 +578,10 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { } const auto configFileVersion = QVersionNumber::fromString(configVersion); + // Only update the framerate if the version we are migrating from is less than 2.4.0. + if (configFileVersion < QVersionNumber(2, 4, 0)) { + config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60)); + } // When upgrading from 2.3.x or older to 2.5, or when upgrading // from 2.5.0-beta once we are out of beta @@ -555,34 +590,24 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { configVersion.startsWith("2.5.0-"))) { // Proactively move users to an all-shader waveform widget type and set the // framerate to 60 fps - bool okType = false, okBackend = false, okOptions = false; - auto waveformType = - config->getValueString(ConfigKey("[Waveform]", "WaveformType")) - .toInt(&okType); - auto waveformBackend = - config->getValueString(ConfigKey("[Waveform]", "use_hardware_acceleration")) - .toInt(&okBackend); - auto waveformOption = - config->getValueString(ConfigKey("[Waveform]", "waveform_options")) - .toInt(&okOptions); - if (okType && (!okBackend || !okOptions)) { - upgradeToAllShaders(&waveformType, - reinterpret_cast(&waveformBackend), - reinterpret_cast< - allshader::WaveformRendererSignalBase::Options*>( - &waveformBackend)); - config->setValue(ConfigKey("[Waveform]", "WaveformType"), - waveformType); - config->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), - waveformBackend); - config->setValue(ConfigKey("[Waveform]", "waveform_options"), - waveformOption); - } - // Only update the framerate if the version we are migrating from is less than 2.4.0. - if (QVersionNumber::fromString(configVersion) < QVersionNumber(2, 4, 0)) { - config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60)); - } - + int waveformType = + config->getValue(ConfigKey("[Waveform]", "WaveformType")); + // values might be out of range for the enum, avoid undefined + // behavior by not casting to the enum type just yet. + int waveformBackend = config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration")); + int waveformOption = config->getValue(ConfigKey("[Waveform]", "waveform_options")); + auto [correctedWaveformType, + correctedWaveformBacked, + correctedWaveformOption] = + upgradeToAllShaders( + waveformType, waveformBackend, waveformOption); + config->setValue(ConfigKey("[Waveform]", "WaveformType"), + correctedWaveformType); + config->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), + correctedWaveformBacked); + config->setValue(ConfigKey("[Waveform]", "waveform_options"), + correctedWaveformOption); // mark the configuration as updated configVersion = "2.5.0"; config->set(ConfigKey("[Config]", "Version"), diff --git a/src/test/waveform_upgrade_test.cpp b/src/test/waveform_upgrade_test.cpp index 71ba98bbdcc..1d2b03cb83b 100644 --- a/src/test/waveform_upgrade_test.cpp +++ b/src/test/waveform_upgrade_test.cpp @@ -5,6 +5,7 @@ #include // Importing CPP file since testing function in anonymous namespace +#include "preferences/configobject.h" #include "preferences/upgrade.cpp" #include "waveform/renderers/allshader/waveformrenderersignalbase.h" @@ -159,15 +160,15 @@ TEST_F(UpgradeTest, useCorrectWaveformType) { for (const auto& testCase : testCases) { int waveformType = testCase.oldTypeId; - WaveformWidgetBackend waveformBackend = WaveformWidgetBackend::None; - allshader::WaveformRendererSignalBase::Options options = - allshader::WaveformRendererSignalBase::None; + int waveformBackend = -1; + int waveformOptions = -1; qDebug() << "Testing upgrade for" << testCase.waveformName; - upgradeToAllShaders(&waveformType, &waveformBackend, &options); - ASSERT_EQ(waveformType, testCase.expectedType); - ASSERT_EQ(waveformBackend, testCase.expectedBackend); + auto [type, backend, options] = upgradeToAllShaders( + waveformType, waveformBackend, waveformOptions); + ASSERT_EQ(type, testCase.expectedType); + ASSERT_EQ(backend, testCase.expectedBackend); ASSERT_EQ(options, testCase.expectedOptions); } } diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index 7e1b5ec411e..d5a9eafd210 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -20,6 +20,7 @@ class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBas None = 0b0, SplitStereoSignal = 0b1, HighDetail = 0b10, + All = SplitStereoSignal | HighDetail, }; Q_DECLARE_FLAGS(Options, Option) diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index 62d7dd3e66d..c632408aec8 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -131,6 +131,9 @@ class WaveformWidgetFactory : public QObject, public Singleton Date: Fri, 24 May 2024 13:58:12 +0100 Subject: [PATCH 15/16] Use an enum class for WaveformOption --- src/preferences/dialog/dlgprefwaveform.cpp | 40 +++++++------- src/preferences/dialog/dlgprefwaveform.h | 11 ++-- src/preferences/upgrade.cpp | 15 +++--- src/test/waveform_upgrade_test.cpp | 52 +++++++++---------- .../allshader/waveformrendererrgb.cpp | 2 +- .../renderers/allshader/waveformrendererrgb.h | 2 +- .../allshader/waveformrenderersignalbase.h | 4 +- .../allshader/waveformrenderertextured.cpp | 2 +- .../allshader/waveformrenderertextured.h | 2 +- src/waveform/waveformwidgetfactory.cpp | 8 +-- src/waveform/waveformwidgetfactory.h | 14 ++--- .../widgets/allshader/waveformwidget.cpp | 18 +++---- .../widgets/allshader/waveformwidget.h | 2 +- 13 files changed, 90 insertions(+), 82 deletions(-) diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index e9df0ac3a6b..e43e5b6c9b5 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -182,10 +182,10 @@ DlgPrefWaveform::~DlgPrefWaveform() { void DlgPrefWaveform::slotSetWaveformOptions( allshader::WaveformRendererSignalBase::Option option, bool enabled) { - int currentOption = m_pConfig->getValue( + allshader::WaveformRendererSignalBase::Options currentOption = m_pConfig->getValue( ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); - m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::None); + m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), enabled ? currentOption | option : currentOption ^ @@ -224,9 +224,9 @@ void DlgPrefWaveform::slotUpdate() { bool useWaveform = factory->getType() != WaveformWidgetType::Empty; useWaveformCheckBox->setChecked(useWaveform); - int currentOptions = m_pConfig->getValue( + allshader::WaveformRendererSignalBase::Options currentOptions = m_pConfig->getValue( ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); + allshader::WaveformRendererSignalBase::Option::None); WaveformWidgetBackend backend = m_pConfig->getValue( ConfigKey("[Waveform]", "use_hardware_acceleration"), factory->preferredBackend()); @@ -295,11 +295,11 @@ void DlgPrefWaveform::slotResetToDefaults() { useWaveformCheckBox->setChecked(true); waveformTypeComboBox->setEnabled(true); updateWaveformAcceleration(WaveformWidgetFactory::defaultType(), defaultBackend); - updateWaveformOption(true, defaultBackend, allshader::WaveformRendererSignalBase::None); + updateWaveformOption(true, defaultBackend, allshader::WaveformRendererSignalBase::Option::None); // Restore waveform backend and option setting instantly m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); + allshader::WaveformRendererSignalBase::Option::None); m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), defaultBackend); factory->setWidgetTypeFromHandle( @@ -363,9 +363,9 @@ void DlgPrefWaveform::slotSetWaveformType(int index) { useAccelerationCheckBox->setChecked(backend != WaveformWidgetBackend::None); - int currentOptions = m_pConfig->getValue( + allshader::WaveformRendererSignalBase::Options currentOptions = m_pConfig->getValue( ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); + allshader::WaveformRendererSignalBase::Option::None); updateWaveformAcceleration(type, backend); updateWaveformOption(true, backend, currentOptions); updateEnableUntilMark(); @@ -402,9 +402,9 @@ void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) { auto type = static_cast(waveformTypeComboBox->currentData().toInt()); auto* factory = WaveformWidgetFactory::instance(); factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true); - int currentOptions = m_pConfig->getValue( + allshader::WaveformRendererSignalBase::Options currentOptions = m_pConfig->getValue( ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); + allshader::WaveformRendererSignalBase::Option::None); updateWaveformOption(true, backend, currentOptions); updateEnableUntilMark(); } @@ -435,14 +435,16 @@ void DlgPrefWaveform::updateWaveformAcceleration( useAccelerationCheckBox->blockSignals(false); } -void DlgPrefWaveform::updateWaveformOption( - bool useWaveform, WaveformWidgetBackend backend, int currentOption) { +void DlgPrefWaveform::updateWaveformOption(bool useWaveform, + WaveformWidgetBackend backend, + allshader::WaveformRendererSignalBase::Options currentOptions) { splitLeftRightCheckBox->blockSignals(true); highDetailCheckBox->blockSignals(true); #ifdef MIXXX_USE_QOPENGL WaveformWidgetFactory* factory = WaveformWidgetFactory::instance(); - int supportedOption = allshader::WaveformRendererSignalBase::None; + allshader::WaveformRendererSignalBase::Options supportedOption = + allshader::WaveformRendererSignalBase::Option::None; auto type = static_cast(waveformTypeComboBox->currentData().toInt()); int handleIdx = factory->findHandleIndexFromType(type); @@ -453,15 +455,15 @@ void DlgPrefWaveform::updateWaveformOption( splitLeftRightCheckBox->setEnabled(useWaveform && supportedOption & - allshader::WaveformRendererSignalBase::SplitStereoSignal); + allshader::WaveformRendererSignalBase::Option::SplitStereoSignal); highDetailCheckBox->setEnabled(useWaveform && supportedOption & - allshader::WaveformRendererSignalBase::HighDetail); + allshader::WaveformRendererSignalBase::Option::HighDetail); splitLeftRightCheckBox->setChecked(splitLeftRightCheckBox->isEnabled() && - currentOption & - allshader::WaveformRendererSignalBase::SplitStereoSignal); + currentOptions & + allshader::WaveformRendererSignalBase::Option::SplitStereoSignal); highDetailCheckBox->setChecked(highDetailCheckBox->isEnabled() && - currentOption & allshader::WaveformRendererSignalBase::HighDetail); + currentOptions & allshader::WaveformRendererSignalBase::Option::HighDetail); #else splitLeftRightCheckBox->setVisible(false); highDetailCheckBox->setVisible(false); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index e426d50ed72..1ff32284de4 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -35,10 +35,12 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg #ifdef MIXXX_USE_QOPENGL void slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option option, bool enabled); void slotSetWaveformOptionSplitStereoSignal(bool checked) { - slotSetWaveformOptions(allshader::WaveformRendererSignalBase::SplitStereoSignal, checked); + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option:: + SplitStereoSignal, + checked); } void slotSetWaveformOptionHighDetail(bool checked) { - slotSetWaveformOptions(allshader::WaveformRendererSignalBase::HighDetail, checked); + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option::HighDetail, checked); } #endif void slotSetWaveformOverviewType(int index); @@ -65,8 +67,9 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void calculateCachedWaveformDiskUsage(); void notifyRebootNecessary(); void updateEnableUntilMark(); - void updateWaveformOption( - bool useWaveform, WaveformWidgetBackend backend, int currentOptions); + void updateWaveformOption(bool useWaveform, + WaveformWidgetBackend backend, + allshader::WaveformRendererSignalBase::Options currentOption); void updateWaveformAcceleration( WaveformWidgetType::Type type, WaveformWidgetBackend backend); diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index dd037091f01..e2ffadbf85e 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -44,12 +44,11 @@ upgradeToAllShaders(int unsafeWaveformType, // TODO: convert `WaveformWidgetType::Type` to an enum class then shorten more `using enum ...` using WWT = WaveformWidgetType; - if (static_cast(unsafeWaveformBackend) == - WaveformWidgetBackend::AllShader) { + if (static_cast(WaveformWidgetBackend::AllShader) == unsafeWaveformBackend) { allshader::WaveformRendererSignalBase::Options waveformOption = static_cast( unsafeWaveformOption) & - allshader::WaveformRendererSignalBase::All; + allshader::WaveformRendererSignalBase::Option::AllOptionsCombined; switch (unsafeWaveformType) { case WWT::Simple: case WWT::Filtered: @@ -69,7 +68,7 @@ upgradeToAllShaders(int unsafeWaveformType, // Reset the options allshader::WaveformRendererSignalBase::Options waveformOption = - allshader::WaveformRendererSignalBase::None; + allshader::WaveformRendererSignalBase::Option::None; WaveformWidgetType::Type waveformType = static_cast(unsafeWaveformType); WaveformWidgetBackend waveformBackend = WaveformWidgetBackend::AllShader; @@ -98,7 +97,7 @@ upgradeToAllShaders(int unsafeWaveformType, // Filtered waveforms case WWT::Filtered: // GLSLFilteredWaveform case 22: // AllShaderTexturedFiltered - waveformOption = allshader::WaveformRendererSignalBase::HighDetail; + waveformOption = allshader::WaveformRendererSignalBase::Option::HighDetail; [[fallthrough]]; case 2: // SoftwareWaveform case 4: // QtWaveform @@ -117,7 +116,7 @@ upgradeToAllShaders(int unsafeWaveformType, // Stacked waveform case 24: // AllShaderTexturedStacked case WWT::Stacked: // GLSLRGBStackedWaveform - waveformOption = allshader::WaveformRendererSignalBase::HighDetail; + waveformOption = allshader::WaveformRendererSignalBase::Option::HighDetail; [[fallthrough]]; case 26: // AllShaderRGBStackedWaveform waveformType = WaveformWidgetType::Stacked; @@ -128,8 +127,8 @@ upgradeToAllShaders(int unsafeWaveformType, case 23: // AllShaderTexturedRGB case 12: // GLSLRGBWaveform waveformOption = unsafeWaveformType == 18 - ? allshader::WaveformRendererSignalBase::SplitStereoSignal - : allshader::WaveformRendererSignalBase::HighDetail; + ? allshader::WaveformRendererSignalBase::Option::SplitStereoSignal + : allshader::WaveformRendererSignalBase::Option::HighDetail; [[fallthrough]]; default: waveformType = WaveformWidgetFactory::defaultType(); diff --git a/src/test/waveform_upgrade_test.cpp b/src/test/waveform_upgrade_test.cpp index 1d2b03cb83b..44387755bca 100644 --- a/src/test/waveform_upgrade_test.cpp +++ b/src/test/waveform_upgrade_test.cpp @@ -31,132 +31,132 @@ TEST_F(UpgradeTest, useCorrectWaveformType) { 0, WaveformWidgetType::Empty, WaveformWidgetBackend::None, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"SoftwareWaveform", 2, // Filtered WaveformWidgetType::Filtered, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"QtSimpleWaveform", 3, // Simple Qt WaveformWidgetType::Simple, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"QtWaveform", 4, // Filtered Qt WaveformWidgetType::Filtered, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLSimpleWaveform", 5, // Simple GL WaveformWidgetType::Simple, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLFilteredWaveform", 6, // Filtered GL WaveformWidgetType::Filtered, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLSLFilteredWaveform", 7, // Filtered GLSL WaveformWidgetType::Filtered, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::HighDetail}, + allshader::WaveformRendererSignalBase::Option::HighDetail}, test_case{"HSVWaveform", 8, // HSV WaveformWidgetType::HSV, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLVSyncTest", 9, // VSync GL WaveformWidgetType::VSyncTest, WaveformWidgetBackend::None, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"RGBWaveform", 10, // RGB WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLRGBWaveform", 11, // RGB GL WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLSLRGBWaveform", 12, // RGB GLSL WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::HighDetail}, + allshader::WaveformRendererSignalBase::Option::HighDetail}, test_case{"QtVSyncTest", 13, // VSync Qt WaveformWidgetType::VSyncTest, WaveformWidgetBackend::None, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"QtHSVWaveform", 14, // HSV Qt WaveformWidgetType::HSV, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"QtRGBWaveform", 15, // RGB Qt WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"GLSLRGBStackedWaveform", 16, // RGB Stacked WaveformWidgetType::Stacked, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::HighDetail}, + allshader::WaveformRendererSignalBase::Option::HighDetail}, test_case{"AllShaderRGBWaveform", 17, // RGB (all-shaders) WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"AllShaderLRRGBWaveform", 18, // L/R RGB (all-shaders) WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::SplitStereoSignal}, + allshader::WaveformRendererSignalBase::Option::SplitStereoSignal}, test_case{"AllShaderFilteredWaveform", 19, // Filtered (all-shaders) WaveformWidgetType::Filtered, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"AllShaderSimpleWaveform", 20, // Simple (all-shaders) WaveformWidgetType::Simple, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"AllShaderHSVWaveform", 21, // HSV (all-shaders) WaveformWidgetType::HSV, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"AllShaderTexturedFiltered", 22, // Filtered (textured) (all-shaders) WaveformWidgetType::Filtered, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::HighDetail}, + allshader::WaveformRendererSignalBase::Option::HighDetail}, test_case{"AllShaderTexturedRGB", 23, // RGB (textured) (all-shaders) WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::HighDetail}, + allshader::WaveformRendererSignalBase::Option::HighDetail}, test_case{"AllShaderTexturedStacked", 24, // Stacked (textured) (all-shaders) WaveformWidgetType::Stacked, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::HighDetail}, + allshader::WaveformRendererSignalBase::Option::HighDetail}, test_case{"AllShaderRGBStackedWaveform", 26, // Stacked (all-shaders) WaveformWidgetType::Stacked, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}, + allshader::WaveformRendererSignalBase::Option::None}, test_case{"Count_WaveformwidgetType", 27, // Also used as invalid value WaveformWidgetType::RGB, WaveformWidgetBackend::AllShader, - allshader::WaveformRendererSignalBase::None}}; + allshader::WaveformRendererSignalBase::Option::None}}; for (const auto& testCase : testCases) { int waveformType = testCase.oldTypeId; diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.cpp b/src/waveform/renderers/allshader/waveformrendererrgb.cpp index df730ce94b8..f9aba439892 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererrgb.cpp @@ -79,7 +79,7 @@ void WaveformRendererRGB::paintGL() { const float heightFactorAbs = allGain * halfBreadth / m_maxValue; const float heightFactor[2] = {-heightFactorAbs, heightFactorAbs}; - const bool splitLeftRight = m_options & WaveformRendererSignalBase::SplitStereoSignal; + const bool splitLeftRight = m_options & WaveformRendererSignalBase::Option::SplitStereoSignal; const float low_r = static_cast(m_rgbLowColor_r); const float mid_r = static_cast(m_rgbMidColor_r); diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.h b/src/waveform/renderers/allshader/waveformrendererrgb.h index 56da5d3f61c..e9c12b52a42 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.h +++ b/src/waveform/renderers/allshader/waveformrendererrgb.h @@ -15,7 +15,7 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS explicit WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play, - WaveformRendererSignalBase::Options options = WaveformRendererSignalBase::None); + WaveformRendererSignalBase::Options options = WaveformRendererSignalBase::Option::None); // override ::WaveformRendererSignalBase void onSetup(const QDomNode& node) override; diff --git a/src/waveform/renderers/allshader/waveformrenderersignalbase.h b/src/waveform/renderers/allshader/waveformrenderersignalbase.h index d5a9eafd210..0e72d9364c7 100644 --- a/src/waveform/renderers/allshader/waveformrenderersignalbase.h +++ b/src/waveform/renderers/allshader/waveformrenderersignalbase.h @@ -16,11 +16,11 @@ class WaveformRendererSignalBase; class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBase, public allshader::WaveformRendererAbstract { public: - enum Option { + enum class Option { None = 0b0, SplitStereoSignal = 0b1, HighDetail = 0b10, - All = SplitStereoSignal | HighDetail, + AllOptionsCombined = SplitStereoSignal | HighDetail, }; Q_DECLARE_FLAGS(Options, Option) diff --git a/src/waveform/renderers/allshader/waveformrenderertextured.cpp b/src/waveform/renderers/allshader/waveformrenderertextured.cpp index 16e1fe0ee13..404ae9202b5 100644 --- a/src/waveform/renderers/allshader/waveformrenderertextured.cpp +++ b/src/waveform/renderers/allshader/waveformrenderertextured.cpp @@ -367,7 +367,7 @@ void WaveformRendererTextured::paintGL() { if (m_type == ::WaveformWidgetType::RGB) { m_frameShaderProgram->setUniformValue("splitStereoSignal", - m_options & WaveformRendererSignalBase::SplitStereoSignal); + m_options & WaveformRendererSignalBase::Option::SplitStereoSignal); } m_frameShaderProgram->setUniformValue("axesColor", diff --git a/src/waveform/renderers/allshader/waveformrenderertextured.h b/src/waveform/renderers/allshader/waveformrenderertextured.h index 8440824adba..2d5fa4b253d 100644 --- a/src/waveform/renderers/allshader/waveformrenderertextured.h +++ b/src/waveform/renderers/allshader/waveformrenderertextured.h @@ -25,7 +25,7 @@ class allshader::WaveformRendererTextured : public QObject, ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play, WaveformRendererSignalBase::Options options = - WaveformRendererSignalBase::None); + WaveformRendererSignalBase::Option::None); ~WaveformRendererTextured() override; // override ::WaveformRendererSignalBase diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 527f48ed850..a5b242fa1a0 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -918,7 +918,9 @@ WaveformWidgetVars waveformWidgetVars() { void WaveformWidgetFactory::evaluateWidgets() { m_waveformWidgetHandles.clear(); QHash> collectedHandles; - QHash supportedOptions; + QHash + supportedOptions; for (WaveformWidgetType::Type type : WaveformWidgetType::kValues) { switch (type) { case WaveformWidgetType::Empty: @@ -981,7 +983,7 @@ void WaveformWidgetFactory::evaluateWidgets() { m_waveformWidgetHandles.push_back(WaveformWidgetAbstractHandle(type, backends #ifdef MIXXX_USE_QOPENGL , - supportedOptions.value(type, allshader::WaveformRendererSignalBase::None) + supportedOptions.value(type, allshader::WaveformRendererSignalBase::Option::None) #endif )); } @@ -991,7 +993,7 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createAllshaderWaveformWidget( WaveformWidgetType::Type type, WWaveformViewer* viewer) { allshader::WaveformRendererSignalBase::Options options = m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), - allshader::WaveformRendererSignalBase::None); + allshader::WaveformRendererSignalBase::Option::None); return new allshader::WaveformWidget(viewer, type, viewer->getGroup(), options); } diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index c632408aec8..17dadc391f3 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -9,6 +9,7 @@ #include "skin/legacy/skincontext.h" #include "util/performancetimer.h" #include "util/singleton.h" +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" #include "waveform/widgets/waveformwidgettype.h" #include "waveform/widgets/waveformwidgetvars.h" @@ -59,13 +60,14 @@ class WaveformWidgetAbstractHandle { return m_backends.contains(WaveformWidgetBackend::None); } - int supportedOptions(WaveformWidgetBackend backend) const { #ifdef MIXXX_USE_QOPENGL - return backend == WaveformWidgetBackend::AllShader ? m_supportedOption : 0; -#else - return 0; -#endif + allshader::WaveformRendererSignalBase::Options supportedOptions( + WaveformWidgetBackend backend) const { + return backend == WaveformWidgetBackend::AllShader + ? m_supportedOption + : allshader::WaveformRendererSignalBase::Option::None; } +#endif QString getDisplayName() const; @@ -74,7 +76,7 @@ class WaveformWidgetAbstractHandle { QList m_backends; #ifdef MIXXX_USE_QOPENGL // Only relevant for Allshader (accelerated) backend. Other backends don't implement options - int m_supportedOption; + allshader::WaveformRendererSignalBase::Options m_supportedOption; #endif friend class WaveformWidgetFactory; diff --git a/src/waveform/widgets/allshader/waveformwidget.cpp b/src/waveform/widgets/allshader/waveformwidget.cpp index 95629cbd9a4..24f32a93fae 100644 --- a/src/waveform/widgets/allshader/waveformwidget.cpp +++ b/src/waveform/widgets/allshader/waveformwidget.cpp @@ -69,19 +69,19 @@ WaveformWidget::addWaveformSignalRenderer(WaveformWidgetType::Type type, case ::WaveformWidgetType::Simple: return addRenderer(); case ::WaveformWidgetType::RGB: - if (options & allshader::WaveformRendererSignalBase::HighDetail) { + if (options & allshader::WaveformRendererSignalBase::Option::HighDetail) { return addRenderer(type, positionSource, options); } return addRenderer(positionSource, options); case ::WaveformWidgetType::HSV: return addRenderer(); case ::WaveformWidgetType::Filtered: - if (options & allshader::WaveformRendererSignalBase::HighDetail) { + if (options & allshader::WaveformRendererSignalBase::Option::HighDetail) { return addRenderer(type, positionSource, options); } return addRenderer(false); case ::WaveformWidgetType::Stacked: - if (options & allshader::WaveformRendererSignalBase::HighDetail) { + if (options & allshader::WaveformRendererSignalBase::Option::HighDetail) { return addRenderer(type, positionSource, options); } else { return addRenderer(true); // true for RGB Stacked @@ -146,19 +146,19 @@ void WaveformWidget::leaveEvent(QEvent* pEvent) { } /* static */ -int WaveformWidget::supportedOptions(WaveformWidgetType::Type type) { +WaveformRendererSignalBase::Options WaveformWidget::supportedOptions( + WaveformWidgetType::Type type) { switch (type) { case WaveformWidgetType::Type::RGB: - return WaveformRendererSignalBase::SplitStereoSignal | - WaveformRendererSignalBase::HighDetail; + return WaveformRendererSignalBase::Option::AllOptionsCombined; case WaveformWidgetType::Type::Filtered: - return WaveformRendererSignalBase::HighDetail; + return WaveformRendererSignalBase::Option::HighDetail; case WaveformWidgetType::Type::Stacked: - return WaveformRendererSignalBase::HighDetail; + return WaveformRendererSignalBase::Option::HighDetail; default: break; } - return 0; + return WaveformRendererSignalBase::Option::None; } /* static */ diff --git a/src/waveform/widgets/allshader/waveformwidget.h b/src/waveform/widgets/allshader/waveformwidget.h index 5933cb1f5c3..f6c0877975e 100644 --- a/src/waveform/widgets/allshader/waveformwidget.h +++ b/src/waveform/widgets/allshader/waveformwidget.h @@ -34,7 +34,7 @@ class allshader::WaveformWidget final : public ::WGLWidget, return this; } static WaveformWidgetVars vars(); - static int supportedOptions(WaveformWidgetType::Type type); + static WaveformRendererSignalBase::Options supportedOptions(WaveformWidgetType::Type type); private: void castToQWidget() override; From d414a6e65a58ff6ce0d00cb0e46dea9e919c540f Mon Sep 17 00:00:00 2001 From: Antoine C Date: Thu, 30 May 2024 17:27:01 +0100 Subject: [PATCH 16/16] Bump config version upgrade to 2.6 --- src/preferences/upgrade.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index e2ffadbf85e..1d7704a6da4 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -582,11 +582,11 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60)); } - // When upgrading from 2.3.x or older to 2.5, or when upgrading - // from 2.5.0-beta once we are out of beta - if (configFileVersion < QVersionNumber(2, 5, 0) || - (VersionStore::version() != "2.5.0-beta" && - configVersion.startsWith("2.5.0-"))) { + // When upgrading from 2.5.x or older to 2.6, or when upgrading + // from 2.6.0-beta once we are out of beta + if (configFileVersion < QVersionNumber(2, 6, 0) || + (VersionStore::version() != "2.6.0-beta" && + configVersion.startsWith("2.6.0-"))) { // Proactively move users to an all-shader waveform widget type and set the // framerate to 60 fps int waveformType = @@ -608,7 +608,7 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { config->setValue(ConfigKey("[Waveform]", "waveform_options"), correctedWaveformOption); // mark the configuration as updated - configVersion = "2.5.0"; + configVersion = "2.6.0"; config->set(ConfigKey("[Config]", "Version"), ConfigValue(configVersion)); } @@ -616,7 +616,7 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { // This variable indicates the first known version that requires no changes. // If additional upgrades are added for later versions, they should go before // this block and cleanVersion should be bumped to the latest version. - const QVersionNumber cleanVersion(2, 5, 0); + const QVersionNumber cleanVersion(2, 6, 0); if (QVersionNumber::fromString(configVersion) >= cleanVersion) { // No special upgrade required, just update the value. configVersion = VersionStore::version();