diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fddb27134b..52e1265a36b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1210,12 +1210,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 @@ -1242,16 +1238,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 @@ -1377,6 +1369,7 @@ set(MIXXX_LIB_PRECOMPILED_HEADER src/track/tracknumbers.h src/track/trackrecord.h src/track/trackref.h + src/util/always_false_v.h src/util/alphabetafilter.h src/util/battery/battery.h src/util/cache.h @@ -1473,6 +1466,7 @@ set(MIXXX_LIB_PRECOMPILED_HEADER src/util/statmodel.h src/util/statsmanager.h src/util/string.h + src/util/stringformat.h src/util/tapfilter.h src/util/task.h src/util/taskmonitor.h @@ -1522,7 +1516,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/waveformrenderertextured.cpp @@ -1530,16 +1523,7 @@ 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/lrrgbwaveformwidget.cpp - src/waveform/widgets/allshader/rgbwaveformwidget.cpp - src/waveform/widgets/allshader/rgbstackedwaveformwidget.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 @@ -1552,11 +1536,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() @@ -2195,6 +2174,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 ) find_package(GTest CONFIG REQUIRED) 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/analyzer/analyzerebur128.cpp b/src/analyzer/analyzerebur128.cpp index f03de72791a..5c5510f8416 100644 --- a/src/analyzer/analyzerebur128.cpp +++ b/src/analyzer/analyzerebur128.cpp @@ -49,7 +49,7 @@ bool AnalyzerEbur128::processSamples(const CSAMPLE* pIn, SINT count) { VERIFY_OR_DEBUG_ASSERT(m_pState) { return false; } - ScopedTimer t(u"AnalyzerEbur128::processSamples()"); + ScopedTimer t(QStringLiteral("AnalyzerEbur128::processSamples()")); size_t frames = count / mixxx::kAnalysisChannels; int e = ebur128_add_frames_float(m_pState, pIn, frames); VERIFY_OR_DEBUG_ASSERT(e == EBUR128_SUCCESS) { diff --git a/src/analyzer/analyzergain.cpp b/src/analyzer/analyzergain.cpp index 52192c58dae..16315baa35d 100644 --- a/src/analyzer/analyzergain.cpp +++ b/src/analyzer/analyzergain.cpp @@ -37,7 +37,7 @@ void AnalyzerGain::cleanup() { } bool AnalyzerGain::processSamples(const CSAMPLE* pIn, SINT count) { - ScopedTimer t(u"AnalyzerGain::process()"); + ScopedTimer t(QStringLiteral("AnalyzerGain::process()")); SINT numFrames = count / mixxx::kAnalysisChannels; if (numFrames > static_cast(m_pLeftTempBuffer.size())) { diff --git a/src/coreservices.cpp b/src/coreservices.cpp index e1b57089f90..82af9c68f6e 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -113,7 +113,7 @@ CoreServices::CoreServices(const CmdlineArgs& args, QApplication* pApp) m_isInitialized(false) { m_runtime_timer.start(); mixxx::Time::start(); - ScopedTimer t(u"CoreServices::CoreServices"); + ScopedTimer t(QStringLiteral("CoreServices::CoreServices")); // All this here is running without without start up screen // Defer long initializations to CoreServices::initialize() which is // called after the GUI is initialized @@ -213,7 +213,7 @@ void CoreServices::initialize(QApplication* pApp) { return; } - ScopedTimer t(u"CoreServices::initialize"); + ScopedTimer t(QStringLiteral("CoreServices::initialize")); VERIFY_OR_DEBUG_ASSERT(SoundSourceProxy::registerProviders()) { qCritical() << "Failed to register any SoundSource providers"; diff --git a/src/engine/channelmixer.cpp b/src/engine/channelmixer.cpp index 0e214f00120..3662095474b 100644 --- a/src/engine/channelmixer.cpp +++ b/src/engine/channelmixer.cpp @@ -23,7 +23,7 @@ void ChannelMixer::applyEffectsAndMixChannels(const EngineMixer::GainCalculator& // D) Mixes the temporary buffer into pOutput // The original channel input buffers are not modified. SampleUtil::clear(pOutput, iBufferSize); - ScopedTimer t(u"EngineMixer::applyEffectsAndMixChannels"); + ScopedTimer t(QStringLiteral("EngineMixer::applyEffectsAndMixChannels")); for (auto* pChannelInfo : activeChannels) { EngineMixer::GainCache& gainCache = (*channelGainCache)[pChannelInfo->m_index]; CSAMPLE_GAIN oldGain = gainCache.m_gain; @@ -68,7 +68,7 @@ void ChannelMixer::applyEffectsInPlaceAndMixChannels( // A) Applies the calculated gain to the channel buffer, modifying the original input buffer // B) Applies effects to the buffer, modifying the original input buffer // 4. Mix the channel buffers together to make pOutput, overwriting the pOutput buffer from the last engine callback - ScopedTimer t(u"EngineMixer::applyEffectsInPlaceAndMixChannels"); + ScopedTimer t(QStringLiteral("EngineMixer::applyEffectsInPlaceAndMixChannels")); SampleUtil::clear(pOutput, iBufferSize); for (auto* pChannelInfo : activeChannels) { EngineMixer::GainCache& gainCache = (*channelGainCache)[pChannelInfo->m_index]; diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index 94ce10eb52a..42a3ca5a870 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -844,7 +844,7 @@ void EngineBuffer::slotKeylockEngineChanged(double dIndex) { void EngineBuffer::processTrackLocked( CSAMPLE* pOutput, const int iBufferSize, mixxx::audio::SampleRate sampleRate) { - ScopedTimer t(u"EngineBuffer::process_pauselock"); + ScopedTimer t(QStringLiteral("EngineBuffer::process_pauselock")); m_trackSampleRateOld = mixxx::audio::SampleRate::fromDouble(m_pTrackSampleRate->get()); m_trackEndPositionOld = getTrackEndPosition(); diff --git a/src/engine/enginemixer.cpp b/src/engine/enginemixer.cpp index fb9afd981c9..fe68d85f0b9 100644 --- a/src/engine/enginemixer.cpp +++ b/src/engine/enginemixer.cpp @@ -281,7 +281,7 @@ void EngineMixer::processChannels(int iBufferSize) { m_activeTalkoverChannels.clear(); m_activeChannels.clear(); - // ScopedTimer timer(u"EngineMixer::processChannels"); + // ScopedTimer timer(QStringLiteral("EngineMixer::processChannels")); EngineChannel* pLeaderChannel = m_pEngineSync->getLeaderChannel(); // Reserve the first place for the main channel which // should be processed first diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp index 4e53cce203e..8bb46450c2b 100644 --- a/src/library/dao/trackdao.cpp +++ b/src/library/dao/trackdao.cpp @@ -1368,7 +1368,7 @@ TrackPointer TrackDAO::getTrackById(TrackId trackId) const { // be executed with a lock on the GlobalTrackCache. The GlobalTrackCache // will be locked again after the query has been executed (see below) // and potential race conditions will be resolved. - ScopedTimer t(u"TrackDAO::getTrackById"); + ScopedTimer t(QStringLiteral("TrackDAO::getTrackById")); QSqlRecord queryRecord; { diff --git a/src/library/scanner/importfilestask.cpp b/src/library/scanner/importfilestask.cpp index 1d997a92f6d..0d8311b2db1 100644 --- a/src/library/scanner/importfilestask.cpp +++ b/src/library/scanner/importfilestask.cpp @@ -21,7 +21,7 @@ ImportFilesTask::ImportFilesTask(LibraryScanner* pScanner, } void ImportFilesTask::run() { - ScopedTimer timer(u"ImportFilesTask::run"); + ScopedTimer timer(QStringLiteral("ImportFilesTask::run")); for (const QFileInfo& fileInfo: m_filesToImport) { // If a flag was raised telling us to cancel the library scan then stop. if (m_scannerGlobal->shouldCancel()) { diff --git a/src/library/scanner/libraryscanner.cpp b/src/library/scanner/libraryscanner.cpp index cc0bf94bac5..fe60f2be499 100644 --- a/src/library/scanner/libraryscanner.cpp +++ b/src/library/scanner/libraryscanner.cpp @@ -489,7 +489,7 @@ void LibraryScanner::cancel() { void LibraryScanner::queueTask(ScannerTask* pTask) { //kLogger.debug() << "queueTask" << pTask; - ScopedTimer timer(u"LibraryScanner::queueTask"); + ScopedTimer timer(QStringLiteral("LibraryScanner::queueTask")); if (m_scannerGlobal.isNull() || m_scannerGlobal->shouldCancel()) { return; } @@ -531,7 +531,7 @@ void LibraryScanner::queueTask(ScannerTask* pTask) { void LibraryScanner::slotDirectoryHashedAndScanned(const QString& directoryPath, bool newDirectory, mixxx::cache_key_t hash) { - ScopedTimer timer(u"LibraryScanner::slotDirectoryHashedAndScanned"); + ScopedTimer timer(QStringLiteral("LibraryScanner::slotDirectoryHashedAndScanned")); //kLogger.debug() << "sloDirectoryHashedAndScanned" << directoryPath // << newDirectory << hash; @@ -550,7 +550,7 @@ void LibraryScanner::slotDirectoryHashedAndScanned(const QString& directoryPath, } void LibraryScanner::slotDirectoryUnchanged(const QString& directoryPath) { - ScopedTimer timer(u"LibraryScanner::slotDirectoryUnchanged"); + ScopedTimer timer(QStringLiteral("LibraryScanner::slotDirectoryUnchanged")); //kLogger.debug() << "slotDirectoryUnchanged" << directoryPath; if (m_scannerGlobal) { m_scannerGlobal->addVerifiedDirectory(directoryPath); @@ -560,7 +560,7 @@ void LibraryScanner::slotDirectoryUnchanged(const QString& directoryPath) { void LibraryScanner::slotTrackExists(const QString& trackPath) { //kLogger.debug() << "slotTrackExists" << trackPath; - ScopedTimer timer(u"LibraryScanner::slotTrackExists"); + ScopedTimer timer(QStringLiteral("LibraryScanner::slotTrackExists")); if (m_scannerGlobal) { m_scannerGlobal->addVerifiedTrack(trackPath); } @@ -568,7 +568,7 @@ void LibraryScanner::slotTrackExists(const QString& trackPath) { void LibraryScanner::slotAddNewTrack(const QString& trackPath) { //kLogger.debug() << "slotAddNewTrack" << trackPath; - ScopedTimer timer(u"LibraryScanner::addNewTrack"); + ScopedTimer timer(QStringLiteral("LibraryScanner::addNewTrack")); // For statistics tracking and to detect moved tracks TrackPointer pTrack = m_trackDao.addTracksAddFile( trackPath, diff --git a/src/library/scanner/recursivescandirectorytask.cpp b/src/library/scanner/recursivescandirectorytask.cpp index df93b6e038d..5a2a4e97592 100644 --- a/src/library/scanner/recursivescandirectorytask.cpp +++ b/src/library/scanner/recursivescandirectorytask.cpp @@ -20,7 +20,7 @@ RecursiveScanDirectoryTask::RecursiveScanDirectoryTask( } void RecursiveScanDirectoryTask::run() { - ScopedTimer timer(u"RecursiveScanDirectoryTask::run"); + ScopedTimer timer(QStringLiteral("RecursiveScanDirectoryTask::run")); if (m_scannerGlobal->shouldCancel()) { setSuccess(false); return; diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index 3d5d8f1cc07..12191664660 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -774,7 +774,7 @@ void MixxxMainWindow::slotUpdateWindowTitle(TrackPointer pTrack) { void MixxxMainWindow::createMenuBar() { qWarning() << " $ createMenuBar"; - ScopedTimer t(u"MixxxMainWindow::createMenuBar"); + ScopedTimer t(QStringLiteral("MixxxMainWindow::createMenuBar")); DEBUG_ASSERT(m_pCoreServices->getKeyboardConfig()); m_pMenuBar = make_parented( this, m_pCoreServices->getSettings(), m_pCoreServices->getKeyboardConfig().get()); @@ -789,7 +789,7 @@ void MixxxMainWindow::connectMenuBar() { // so all connections must be unique! qWarning() << " $ connectMenuBar"; - ScopedTimer t(u"MixxxMainWindow::connectMenuBar"); + ScopedTimer t(QStringLiteral("MixxxMainWindow::connectMenuBar")); connect(this, &MixxxMainWindow::skinLoaded, m_pMenuBar, diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index 15e0daf6c0b..e43e5b6c9b5 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -19,17 +19,20 @@ 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(); // 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) { + if (types[i].getType() == WaveformWidgetType::Empty) { + continue; + } + waveformTypeComboBox->addItem(types[i].getDisplayName(), types[i].getType()); } // Sort the combobox items alphabetically waveformTypeComboBox->model()->sort(0); @@ -88,10 +91,28 @@ DlgPrefWaveform::DlgPrefWaveform( beatGridAlphaSlider, &QSlider::setValue); + connect(useWaveformCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformEnabled); + connect(waveformTypeComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &DlgPrefWaveform::slotSetWaveformType); + + connect(useAccelerationCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformAcceleration); + connect(splitLeftRightCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformOptionSplitStereoSignal); + connect(highDetailCheckBox, + &QCheckBox::clicked, + this, + &DlgPrefWaveform::slotSetWaveformOptionHighDetail); connect(defaultZoomComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -159,21 +180,59 @@ DlgPrefWaveform::DlgPrefWaveform( DlgPrefWaveform::~DlgPrefWaveform() { } +void DlgPrefWaveform::slotSetWaveformOptions( + allshader::WaveformRendererSignalBase::Option option, bool enabled) { + allshader::WaveformRendererSignalBase::Options currentOption = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::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(); + bool isAccelerationEnabled = false; if (factory->isOpenGlAvailable() || factory->isOpenGlesAvailable()) { openGlStatusData->setText(factory->getOpenGLVersion()); + useAccelerationCheckBox->setEnabled(true); + isAccelerationEnabled = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()) != + WaveformWidgetBackend::None; + useAccelerationCheckBox->setChecked(isAccelerationEnabled); } 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); } + bool useWaveform = factory->getType() != WaveformWidgetType::Empty; + useWaveformCheckBox->setChecked(useWaveform); + + allshader::WaveformRendererSignalBase::Options currentOptions = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::None); + WaveformWidgetBackend backend = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()); + updateWaveformAcceleration(factory->getType(), backend); + updateWaveformOption(useWaveform, backend, currentOptions); + waveformTypeComboBox->setEnabled(useWaveform); updateEnableUntilMark(); frameRateSpinBox->setValue(factory->getFrameRate()); @@ -227,13 +286,26 @@ 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(factory->autoChooseWidgetType())); + WaveformWidgetFactory::defaultType()); if (defaultIndex != -1 && waveformTypeComboBox->currentIndex() != defaultIndex) { waveformTypeComboBox->setCurrentIndex(defaultIndex); } + auto defaultBackend = factory->preferredBackend(); + useWaveformCheckBox->setChecked(true); + waveformTypeComboBox->setEnabled(true); + updateWaveformAcceleration(WaveformWidgetFactory::defaultType(), defaultBackend); + updateWaveformOption(true, defaultBackend, allshader::WaveformRendererSignalBase::Option::None); + + // Restore waveform backend and option setting instantly + m_pConfig->setValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::None); + m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"), + defaultBackend); + factory->setWidgetTypeFromHandle( + factory->findHandleIndexFromType( + WaveformWidgetFactory::defaultType()), + true); allVisualGain->setValue(1.0); lowVisualGain->setValue(1.0); @@ -280,14 +352,139 @@ 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)); + + auto backend = m_pConfig->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + factory->preferredBackend()); + useAccelerationCheckBox->setChecked(backend != + WaveformWidgetBackend::None); + + allshader::WaveformRendererSignalBase::Options currentOptions = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::None); + updateWaveformAcceleration(type, backend); + updateWaveformOption(true, backend, currentOptions); + updateEnableUntilMark(); +} + +void DlgPrefWaveform::slotSetWaveformEnabled(bool 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) { + WaveformWidgetBackend backend = WaveformWidgetBackend::None; + if (checked) { + backend = +#ifdef MIXXX_USE_QOPENGL + WaveformWidgetBackend::AllShader +#else + WaveformWidgetBackend::GL +#endif + ; + } + 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); + allshader::WaveformRendererSignalBase::Options currentOptions = m_pConfig->getValue( + ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::None); + updateWaveformOption(true, backend, currentOptions); updateEnableUntilMark(); } +void DlgPrefWaveform::updateWaveformAcceleration( + WaveformWidgetType::Type type, WaveformWidgetBackend backend) { + auto* factory = WaveformWidgetFactory::instance(); + int handleIdx = factory->findHandleIndexFromType(type); + + bool supportAcceleration = false, supportSoftware = true; + if (handleIdx != -1) { + const auto& handle = factory->getAvailableTypes()[handleIdx]; + supportAcceleration = handle.supportAcceleration(); + supportSoftware = handle.supportSoftware(); + } + useAccelerationCheckBox->blockSignals(true); + + 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 && type != WaveformWidgetType::Empty); + + useAccelerationCheckBox->blockSignals(false); +} +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(); + allshader::WaveformRendererSignalBase::Options supportedOption = + allshader::WaveformRendererSignalBase::Option::None; + + auto type = static_cast(waveformTypeComboBox->currentData().toInt()); + int handleIdx = factory->findHandleIndexFromType(type); + + if (handleIdx != -1) { + supportedOption = factory->getAvailableTypes()[handleIdx].supportedOptions(backend); + } + + splitLeftRightCheckBox->setEnabled(useWaveform && + supportedOption & + allshader::WaveformRendererSignalBase::Option::SplitStereoSignal); + highDetailCheckBox->setEnabled(useWaveform && + supportedOption & + allshader::WaveformRendererSignalBase::Option::HighDetail); + splitLeftRightCheckBox->setChecked(splitLeftRightCheckBox->isEnabled() && + currentOptions & + allshader::WaveformRendererSignalBase::Option::SplitStereoSignal); + highDetailCheckBox->setChecked(highDetailCheckBox->isEnabled() && + currentOptions & allshader::WaveformRendererSignalBase::Option::HighDetail); +#else + splitLeftRightCheckBox->setVisible(false); + highDetailCheckBox->setVisible(false); +#endif + + splitLeftRightCheckBox->blockSignals(false); + highDetailCheckBox->blockSignals(false); +} + void DlgPrefWaveform::updateEnableUntilMark() { - const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark(); +#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"), + factory->preferredBackend()) != + WaveformWidgetBackend::None; +#endif untilMarkShowBeatsCheckBox->setEnabled(enabled); untilMarkShowTimeCheckBox->setEnabled(enabled); untilMarkAlignLabel->setEnabled(enabled); @@ -298,7 +495,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 e141c17f996..1ff32284de4 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -5,6 +5,10 @@ #include "preferences/dialog/dlgpreferencepage.h" #include "preferences/dialog/ui_dlgprefwaveformdlg.h" #include "preferences/usersettings.h" +#include "waveform/widgets/waveformwidgettype.h" +#ifdef MIXXX_USE_QOPENGL +#include "waveform/renderers/allshader/waveformrenderersignalbase.h" +#endif class Library; @@ -26,6 +30,19 @@ 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); +#ifdef MIXXX_USE_QOPENGL + void slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option option, bool enabled); + void slotSetWaveformOptionSplitStereoSignal(bool checked) { + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option:: + SplitStereoSignal, + checked); + } + void slotSetWaveformOptionHighDetail(bool checked) { + slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option::HighDetail, checked); + } +#endif void slotSetWaveformOverviewType(int index); void slotSetDefaultZoom(int index); void slotSetZoomSynchronization(bool checked); @@ -50,6 +67,11 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void calculateCachedWaveformDiskUsage(); void notifyRebootNecessary(); void updateEnableUntilMark(); + void updateWaveformOption(bool useWaveform, + WaveformWidgetBackend backend, + allshader::WaveformRendererSignalBase::Options currentOption); + void updateWaveformAcceleration( + WaveformWidgetType::Type type, WaveformWidgetBackend backend); UserSettingsPointer m_pConfig; std::shared_ptr m_pLibrary; diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 6c42b4bf020..33174e79b17 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -6,83 +6,36 @@ 0 0 - 677 - 528 + 1110 + 939 Waveform Preferences - - - - - - - 0 - 0 - - - - - - - Waveform type - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - waveformTypeComboBox - - - - - - - - - - - Waveform overview type - - + + - - + + - 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. + - - - - - - - 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. + + 6 - - - - - - Frame rate + Beat grid opacity Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - frameRateSlider - - + @@ -110,27 +63,145 @@ Select from different types of displays for the waveform, which differ primarily - - - - + + + + Default zoom level - - fps + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - 10 + + defaultZoomComboBox - - 60 + + + + + + + + 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 - - 30 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + 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. + + + + + + + - - + + + + Caching + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + End of track warning @@ -143,112 +214,61 @@ Select from different types of displays for the waveform, which differ primarily - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 0 - - - 60 - - - 30 - - - Qt::Horizontal + + + + Play marker position - - - - Highlight the waveforms when the last seconds of a track remains. - - - seconds - - - 0 + + + + Visual gain - - 60 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - 30 + + allVisualGain - - - - - - - - 6 - + + - Beat grid opacity + This functionality requires waveform acceleration. Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - 100 - - - 90 - + + - Qt::Horizontal + Qt::Vertical - + + + 20 + 40 + + + - - + + - Set amount of opacity on beat grid lines. - - - % - - - 100 + Synchronize zoom level across all waveform displays. - - 90 + + Synchronize zoom level across all waveforms - - - - - Play marker position - - - - - - - Moves the play marker position on the waveforms to the left, right or center (default). - + + 0 @@ -265,67 +285,84 @@ Select from different types of displays for the waveform, which differ primarily 0 - 100 + 60 - 50 + 30 Qt::Horizontal - - - + + - Default zoom level + Font size Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - defaultZoomComboBox + untilMarkTextPointSizeSpinBox - - - - - - + + - Synchronize zoom level across all waveform displays. + 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 waveforms + Frame rate + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + frameRateSlider - - - + + - Normalize waveform overview + Time until next marker - - - - - Visual gain + + + + Highlight the waveforms when the last seconds of a track remains. - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + seconds - - allVisualGain + + 0 + + + 60 + + + 30 - + + + + Beats until next marker + + + + @@ -457,61 +494,104 @@ Select from different types of displays for the waveform, which differ primarily - - - + + - Play marker hints + Stereo coloration - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 100 + + + 90 + + + Qt::Horizontal - - - - Beats until next marker + + + + Set amount of opacity on beat grid lines. + + + % + + + 100 + + + 90 - - - - Time until next marker + + + + + + + fps + + + 10 + + + 60 + + + 30 - - + + + + + 0 + 0 + + + + + - Placement + Waveform Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - untilMarkAlignComboBox + waveformTypeComboBox - - + + + + Normalize waveform overview + + - - + + - Font size + Placement Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - untilMarkTextPointSizeSpinBox + untilMarkAlignComboBox - + @@ -530,156 +610,110 @@ Select from different types of displays for the waveform, which differ primarily - - + + + + + - This functionality requires a waveform type marked "(GLSL)". + Waveform overview type - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Moves the play marker position on the waveforms to the left, right or center (default). + + + 0 + + + 100 + + + 50 + + + Qt::Horizontal - - + + - Caching - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Enabled - - - - - - Clear Cached 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. - - - - 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. + + + + Qt::Horizontal - - true + + QSizePolicy::Maximum - - - - - - PLACEHOLDER FOR DISK USAGE - z - - true + + + 20 + 20 + + + + + - + 0 0 - - - - - Enable waveform caching - - - - - - - Generate waveforms when analyzing library + Use acceleration - - - - - OpenGL status + + + + High details - - - - - - Displays which OpenGL version is supported by the current platform. - - - - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - true - - - - 0 - 0 - - - - - - - - - - - - Average frame rate - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Displays the actual frame rate. - - - - - - - - - - + + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - waveformTypeComboBox waveformOverviewComboBox frameRateSlider frameRateSpinBox diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index 0517192f048..1d7704a6da4 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" @@ -19,7 +20,9 @@ #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/waveformwidgetfactory.h" #include "waveform/widgets/waveformwidgettype.h" Upgrade::Upgrade() @@ -32,47 +35,106 @@ Upgrade::~Upgrade() { namespace { // mapping to proactively move users to the new all-shader waveform types -WaveformWidgetType::Type upgradeToAllShaders(WaveformWidgetType::Type waveformType) { +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; - 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::AllShaderRGBStackedWaveform: - case WWT::AllShaderSimpleWaveform: - case WWT::AllShaderHSVWaveform: - case WWT::AllShaderTexturedFiltered: - case WWT::AllShaderTexturedRGB: - case WWT::AllShaderTexturedStacked: - case WWT::Count_WaveformwidgetType: - return waveformType; - case WWT::QtSimpleWaveform: - case WWT::GLSimpleWaveform: - return WaveformWidgetType::AllShaderSimpleWaveform; - case WWT::GLFilteredWaveform: - return WaveformWidgetType::AllShaderFilteredWaveform; - case WWT::GLSLFilteredWaveform: - return WaveformWidgetType::AllShaderTexturedFiltered; - case WWT::QtWaveform: - case WWT::RGBWaveform: - case WWT::GLRGBWaveform: - case WWT::QtRGBWaveform: - return WWT::AllShaderRGBWaveform; - case WWT::GLSLRGBWaveform: - return WWT::AllShaderTexturedRGB; - case WWT::GLSLRGBStackedWaveform: - return WWT::AllShaderTexturedStacked; - case WWT::HSVWaveform: - case WWT::QtHSVWaveform: - return WWT::AllShaderHSVWaveform; + + if (static_cast(WaveformWidgetBackend::AllShader) == unsafeWaveformBackend) { + allshader::WaveformRendererSignalBase::Options waveformOption = + static_cast( + unsafeWaveformOption) & + allshader::WaveformRendererSignalBase::Option::AllOptionsCombined; + 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}; + } } - return WWT::AllShaderRGBWaveform; + + // Reset the options + allshader::WaveformRendererSignalBase::Options waveformOption = + allshader::WaveformRendererSignalBase::Option::None; + WaveformWidgetType::Type waveformType = + static_cast(unsafeWaveformType); + WaveformWidgetBackend waveformBackend = WaveformWidgetBackend::AllShader; + + // The switch includes raw values that have been removed from the enum + switch (unsafeWaveformType) { + // None or test waveforms + case WWT::Empty: + // Not supported by AllShader + 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; + + // Filtered waveforms + case WWT::Filtered: // GLSLFilteredWaveform + case 22: // AllShaderTexturedFiltered + waveformOption = allshader::WaveformRendererSignalBase::Option::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; + + // Stacked waveform + case 24: // AllShaderTexturedStacked + case WWT::Stacked: // GLSLRGBStackedWaveform + waveformOption = allshader::WaveformRendererSignalBase::Option::HighDetail; + [[fallthrough]]; + case 26: // AllShaderRGBStackedWaveform + waveformType = WaveformWidgetType::Stacked; + break; + + // RGB waveform (preferred) + case 18: // AllShaderLRRGBWaveform + case 23: // AllShaderTexturedRGB + case 12: // GLSLRGBWaveform + waveformOption = unsafeWaveformType == 18 + ? allshader::WaveformRendererSignalBase::Option::SplitStereoSignal + : allshader::WaveformRendererSignalBase::Option::HighDetail; + [[fallthrough]]; + default: + waveformType = WaveformWidgetFactory::defaultType(); + break; + } + return {waveformType, waveformBackend, waveformOption}; } VSyncThread::VSyncMode upgradeDeprecatedVSyncModes(int configVSyncMode) { @@ -515,28 +577,38 @@ 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.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.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 - bool ok = false; - auto waveformType = - config->getValueString(ConfigKey("[Waveform]", "WaveformType")) - .toInt(&ok); - if (ok) { - config->set(ConfigKey("[Waveform]", "WaveformType"), - ConfigValue(upgradeToAllShaders( - static_cast( - waveformType)))); - } - 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.4.0"; + configVersion = "2.6.0"; config->set(ConfigKey("[Config]", "Version"), ConfigValue(configVersion)); } @@ -544,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, 4, 0); + const QVersionNumber cleanVersion(2, 6, 0); if (QVersionNumber::fromString(configVersion) >= cleanVersion) { // No special upgrade required, just update the value. configVersion = VersionStore::version(); diff --git a/src/skin/legacy/legacyskinparser.cpp b/src/skin/legacy/legacyskinparser.cpp index 9bc4f0fcd5d..fcec0893903 100644 --- a/src/skin/legacy/legacyskinparser.cpp +++ b/src/skin/legacy/legacyskinparser.cpp @@ -318,7 +318,7 @@ Qt::MouseButton LegacySkinParser::parseButtonState(const QDomNode& node, } QWidget* LegacySkinParser::parseSkin(const QString& skinPath, QWidget* pParent) { - ScopedTimer timer(u"SkinLoader::parseSkin"); + ScopedTimer timer(QStringLiteral("SkinLoader::parseSkin")); qDebug() << "LegacySkinParser loading skin:" << skinPath; m_pContext = std::make_unique(m_pConfig, skinPath + "/skin.xml"); diff --git a/src/skin/skinloader.cpp b/src/skin/skinloader.cpp index 48500757fc3..a91a2fda62b 100644 --- a/src/skin/skinloader.cpp +++ b/src/skin/skinloader.cpp @@ -131,7 +131,7 @@ QString SkinLoader::getDefaultSkinName() const { QWidget* SkinLoader::loadConfiguredSkin(QWidget* pParent, QSet* pSkinCreatedControls, mixxx::CoreServices* pCoreServices) { - ScopedTimer timer(u"SkinLoader::loadConfiguredSkin"); + ScopedTimer timer(QStringLiteral("SkinLoader::loadConfiguredSkin")); SkinPointer pSkin = getConfiguredSkin(); // If we don't have a skin then fail. This makes sense here, because the diff --git a/src/soundio/sounddevicenetwork.cpp b/src/soundio/sounddevicenetwork.cpp index 0c74aaf126f..680bed9b462 100644 --- a/src/soundio/sounddevicenetwork.cpp +++ b/src/soundio/sounddevicenetwork.cpp @@ -497,7 +497,7 @@ void SoundDeviceNetwork::callbackProcessClkRef() { m_pSoundManager->readProcess(framesPerBuffer); { - ScopedTimer t(u"SoundDevicePortAudio::callbackProcess prepare %1", + ScopedTimer t(QStringLiteral("SoundDevicePortAudio::callbackProcess prepare %1"), m_deviceId.name); m_pSoundManager->onDeviceOutputCallback(framesPerBuffer); } diff --git a/src/soundio/sounddeviceportaudio.cpp b/src/soundio/sounddeviceportaudio.cpp index 5b413ac6012..c7989336c13 100644 --- a/src/soundio/sounddeviceportaudio.cpp +++ b/src/soundio/sounddeviceportaudio.cpp @@ -984,7 +984,7 @@ int SoundDevicePortAudio::callbackProcessClkRef( // Send audio from the soundcard's input off to the SoundManager... if (in) { - ScopedTimer t(u"SoundDevicePortAudio::callbackProcess input %1", + ScopedTimer t(QStringLiteral("SoundDevicePortAudio::callbackProcess input %1"), m_deviceId.debugName()); composeInputBuffer(in, framesPerBuffer, 0, m_inputParams.channelCount); m_pSoundManager->pushInputBuffers(m_audioInputs, framesPerBuffer); @@ -993,13 +993,13 @@ int SoundDevicePortAudio::callbackProcessClkRef( m_pSoundManager->readProcess(framesPerBuffer); { - ScopedTimer t(u"SoundDevicePortAudio::callbackProcess prepare %1", + ScopedTimer t(QStringLiteral("SoundDevicePortAudio::callbackProcess prepare %1"), m_deviceId.debugName()); m_pSoundManager->onDeviceOutputCallback(framesPerBuffer); } if (out) { - ScopedTimer t(u"SoundDevicePortAudio::callbackProcess output %1", + ScopedTimer t(QStringLiteral("SoundDevicePortAudio::callbackProcess output %1"), m_deviceId.debugName()); if (m_outputParams.channelCount <= 0) { diff --git a/src/sources/soundsourcemodplug.cpp b/src/sources/soundsourcemodplug.cpp index 670895f82ac..f747e8b3db9 100644 --- a/src/sources/soundsourcemodplug.cpp +++ b/src/sources/soundsourcemodplug.cpp @@ -118,7 +118,7 @@ SoundSourceModPlug::importTrackMetadataAndCoverImage( SoundSource::OpenResult SoundSourceModPlug::tryOpen( OpenMode /*mode*/, const OpenParams& /*config*/) { - ScopedTimer t(u"SoundSourceModPlug::open()"); + ScopedTimer t(QStringLiteral("SoundSourceModPlug::open()")); // read module file to byte array const QString fileName(getLocalFileName()); diff --git a/src/test/waveform_upgrade_test.cpp b/src/test/waveform_upgrade_test.cpp new file mode 100644 index 00000000000..44387755bca --- /dev/null +++ b/src/test/waveform_upgrade_test.cpp @@ -0,0 +1,174 @@ +#include +#include + +#include +#include + +// Importing CPP file since testing function in anonymous namespace +#include "preferences/configobject.h" +#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::Option::None}, + test_case{"SoftwareWaveform", + 2, // Filtered + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"QtSimpleWaveform", + 3, // Simple Qt + WaveformWidgetType::Simple, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"QtWaveform", + 4, // Filtered Qt + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLSimpleWaveform", + 5, // Simple GL + WaveformWidgetType::Simple, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLFilteredWaveform", + 6, // Filtered GL + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLSLFilteredWaveform", + 7, // Filtered GLSL + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::HighDetail}, + test_case{"HSVWaveform", + 8, // HSV + WaveformWidgetType::HSV, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLVSyncTest", + 9, // VSync GL + WaveformWidgetType::VSyncTest, + WaveformWidgetBackend::None, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"RGBWaveform", + 10, // RGB + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLRGBWaveform", + 11, // RGB GL + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLSLRGBWaveform", + 12, // RGB GLSL + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::HighDetail}, + test_case{"QtVSyncTest", + 13, // VSync Qt + WaveformWidgetType::VSyncTest, + WaveformWidgetBackend::None, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"QtHSVWaveform", + 14, // HSV Qt + WaveformWidgetType::HSV, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"QtRGBWaveform", + 15, // RGB Qt + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"GLSLRGBStackedWaveform", + 16, // RGB Stacked + WaveformWidgetType::Stacked, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::HighDetail}, + test_case{"AllShaderRGBWaveform", + 17, // RGB (all-shaders) + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"AllShaderLRRGBWaveform", + 18, // L/R RGB (all-shaders) + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::SplitStereoSignal}, + test_case{"AllShaderFilteredWaveform", + 19, // Filtered (all-shaders) + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"AllShaderSimpleWaveform", + 20, // Simple (all-shaders) + WaveformWidgetType::Simple, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"AllShaderHSVWaveform", + 21, // HSV (all-shaders) + WaveformWidgetType::HSV, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"AllShaderTexturedFiltered", + 22, // Filtered (textured) (all-shaders) + WaveformWidgetType::Filtered, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::HighDetail}, + test_case{"AllShaderTexturedRGB", + 23, // RGB (textured) (all-shaders) + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::HighDetail}, + test_case{"AllShaderTexturedStacked", + 24, // Stacked (textured) (all-shaders) + WaveformWidgetType::Stacked, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::HighDetail}, + test_case{"AllShaderRGBStackedWaveform", + 26, // Stacked (all-shaders) + WaveformWidgetType::Stacked, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}, + test_case{"Count_WaveformwidgetType", + 27, // Also used as invalid value + WaveformWidgetType::RGB, + WaveformWidgetBackend::AllShader, + allshader::WaveformRendererSignalBase::Option::None}}; + + for (const auto& testCase : testCases) { + int waveformType = testCase.oldTypeId; + int waveformBackend = -1; + int waveformOptions = -1; + + qDebug() << "Testing upgrade for" << testCase.waveformName; + + 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/util/timer.h b/src/util/timer.h index 3118d218f9c..e20d3195601 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -8,6 +8,7 @@ #include "util/duration.h" #include "util/performancetimer.h" #include "util/stat.h" +#include "util/stringformat.h" static constexpr Stat::ComputeFlags kDefaultComputeFlags = Stat::COUNT | Stat::SUM | Stat::AVERAGE | Stat::MAX | Stat::MIN | Stat::SAMPLE_VARIANCE; @@ -39,40 +40,49 @@ class Timer { // TODO: replace with std::experimental::scope_exit once stabilized class ScopedTimer { public: - ScopedTimer(QStringView key, - Stat::ComputeFlags compute = kDefaultComputeFlags) - : ScopedTimer(key, QStringView(), compute) { - } - ScopedTimer(QStringView key, - int i, - Stat::ComputeFlags compute = kDefaultComputeFlags) - : ScopedTimer(key, - CmdlineArgs::Instance().getDeveloper() - ? QString::number(i) - : QStringView(), - compute) { - } - - ScopedTimer(QStringView key, QStringView arg, Stat::ComputeFlags compute = kDefaultComputeFlags) + // Allows the timer to contain a format string which is only assembled + // when we're not in `--developer` mode. + /// @param compute Flags to use for the Stat::ComputeFlags (can be omitted) + /// @param key The format string as QStringLiteral to identify the timer + /// @param args The arguments to pass to the format string + template + ScopedTimer(Stat::ComputeFlags compute, T&& key, Ts&&... args) : m_maybeTimer(std::nullopt) { + // we take a T here so we can detect the type and warn the user accordingly + // instead of paying for an implicit runtime conversion at the call site + static_assert(std::is_same_v, + "only QString is supported as key type. Wrap it in u\"\"" + "_s or QStringLiteral() " + "to avoid runtime UTF-16 conversion."); + // we can now assume that T is a QString. if (!CmdlineArgs::Instance().getDeveloper()) { - return; + return; // leave timer in cancelled state } -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QString strKey = arg.isEmpty() ? key.toString() : key.arg(arg); -#else - QString strKey = arg.isEmpty() ? key.toString() : key.toString().arg(arg); -#endif - m_maybeTimer = std::make_optional(std::move(strKey), compute); + DEBUG_ASSERT(key.capacity() == 0); + m_maybeTimer = std::make_optional(([&]() { + // only try to call QString::arg when we've been given parameters + if constexpr (sizeof...(args) > 0) { + return key.arg(convertToQStringConvertible(std::forward(args))...); + } else { + return key; + } + })(), + compute); m_maybeTimer->start(); } + template + ScopedTimer(T&& key, Ts&&... args) + : ScopedTimer(kDefaultComputeFlags, std::forward(key), std::forward(args)...) { + } + ~ScopedTimer() noexcept { if (m_maybeTimer) { m_maybeTimer->elapsed(true); } } + // copying would technically be possible, but likely not intended ScopedTimer(const ScopedTimer&) = delete; ScopedTimer& operator=(const ScopedTimer&) = delete; diff --git a/src/vinylcontrol/vinylcontrolprocessor.cpp b/src/vinylcontrol/vinylcontrolprocessor.cpp index e6231d6042d..0c8ae04b6ba 100644 --- a/src/vinylcontrol/vinylcontrolprocessor.cpp +++ b/src/vinylcontrol/vinylcontrolprocessor.cpp @@ -204,7 +204,7 @@ bool VinylControlProcessor::deckConfigured(int index) const { void VinylControlProcessor::receiveBuffer(const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { - ScopedTimer t(u"VinylControlProcessor::receiveBuffer"); + ScopedTimer t(QStringLiteral("VinylControlProcessor::receiveBuffer")); if (input.getType() != AudioPathType::VinylControl) { qDebug() << "WARNING: AudioInput type is not VINYLCONTROL. Ignoring incoming buffer."; return; diff --git a/src/vinylcontrol/vinylcontrolxwax.cpp b/src/vinylcontrol/vinylcontrolxwax.cpp index 762d3cb1f60..f4a03333e6c 100644 --- a/src/vinylcontrol/vinylcontrolxwax.cpp +++ b/src/vinylcontrol/vinylcontrolxwax.cpp @@ -202,7 +202,7 @@ bool VinylControlXwax::writeQualityReport(VinylSignalQualityReport* pReport) { void VinylControlXwax::analyzeSamples(CSAMPLE* pSamples, size_t nFrames) { - ScopedTimer t(u"VinylControlXwax::analyzeSamples"); + ScopedTimer t(QStringLiteral("VinylControlXwax::analyzeSamples")); auto gain = static_cast(m_pVinylControlInputGain->get()); // We only support amplifying with the VC pre-amp. 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 8fe58e0383b..0b01af34c1a 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, + WaveformRendererSignalBase::Options options) : WaveformRendererSignalBase(waveformWidget), - m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) { + m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip), + m_options(options) { } void WaveformRendererRGB::onSetup(const QDomNode& node) { @@ -76,7 +78,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::Option::SplitStereoSignal; const float low_r = static_cast(m_rgbLowColor_r); const float mid_r = static_cast(m_rgbMidColor_r); @@ -94,7 +98,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); @@ -128,113 +134,132 @@ 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])}; - - float ghostLow = maxLow; - float ghostMid = maxMid; - float ghostHigh = maxHigh; float maxAllChn_ghost[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 (non-ghosted version only) - 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); - const float sumGained_ghost = math_pow2(ghostLow) + - math_pow2(ghostMid) + math_pow2(ghostHigh); - - // 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; - - const float factor_ghost = std::sqrt(sumGained_ghost / sum); - maxAllChn_ghost[0] *= factor_ghost; - maxAllChn_ghost[1] *= factor_ghost; - } - // 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; - } + // 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; + 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]); + + float ghostLow = maxLow; + float ghostMid = maxMid; + float ghostHigh = maxHigh; + // 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 (non-ghosted version only) + 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); + const float sumGained_ghost = math_pow2(ghostLow) + + math_pow2(ghostMid) + math_pow2(ghostHigh); + + // 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; + } + const float factor_ghost = std::sqrt(sumGained_ghost / sum); + maxAllChn_ghost[chn] *= factor; + if (!splitLeftRight) { + maxAllChn_ghost[chn + 1] *= factor_ghost; + } + } - float red_ghost = ghostLow * low_r + ghostMid * mid_r + ghostHigh * high_r; - float green_ghost = ghostLow * low_g + ghostMid * mid_g + ghostHigh * high_g; - float blue_ghost = ghostLow * low_b + ghostMid * mid_b + ghostHigh * high_b; - const float maxComponent_ghost = math_max3(red_ghost, green_ghost, blue_ghost); - if (maxComponent_ghost == 0.f) { - // Avoid division by 0 - red_ghost = 0.f; - green_ghost = 0.f; - blue_ghost = 0.f; - } else { - const float normFactor_ghost = 1.f / maxComponent_ghost; - red_ghost *= normFactor_ghost; - green_ghost *= normFactor_ghost; - blue_ghost *= normFactor_ghost; - } + // 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; + + float red_ghost = ghostLow * low_r + ghostMid * mid_r + ghostHigh * high_r; + float green_ghost = ghostLow * low_g + ghostMid * mid_g + ghostHigh * high_g; + float blue_ghost = ghostLow * low_b + ghostMid * mid_b + ghostHigh * high_b; + const float maxComponent_ghost = math_max3(red_ghost, green_ghost, blue_ghost); + + // 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; + } + if (maxComponent_ghost == 0.f) { + // Avoid division by 0 + red_ghost = 0.f; + green_ghost = 0.f; + blue_ghost = 0.f; + } else { + const float normFactor_ghost = 1.f / maxComponent_ghost; + red_ghost *= normFactor_ghost; + green_ghost *= normFactor_ghost; + blue_ghost *= normFactor_ghost; + } - // 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); - - m_vertices_ghost.addRectangle(fpos - 0.5f, - halfBreadth - heightFactor * maxAllChn_ghost[0], - fpos + 0.5f, - halfBreadth + heightFactor * maxAllChn_ghost[1]); - m_colors_ghost.addForRectangle(red_ghost, green_ghost, blue_ghost, ghost_alpha); + // 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 78ce5067602..6ed9d7f3e70 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.h +++ b/src/waveform/renderers/allshader/waveformrendererrgb.h @@ -16,7 +16,8 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS public: explicit WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, ::WaveformRendererAbstract::PositionSource type = - ::WaveformRendererAbstract::Play); + ::WaveformRendererAbstract::Play, + WaveformRendererSignalBase::Options options = WaveformRendererSignalBase::Option::None); // override ::WaveformRendererSignalBase void onSetup(const QDomNode& node) override; @@ -24,6 +25,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; mixxx::RGBAShader m_shader_ghost; @@ -35,6 +40,7 @@ class allshader::WaveformRendererRGB final : public allshader::WaveformRendererS const float ghost_alpha = 0.25f; bool m_isSlipRenderer; + WaveformRendererSignalBase::Options 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..0e72d9364c7 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,10 +16,22 @@ class WaveformRendererSignalBase; class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBase, public allshader::WaveformRendererAbstract { public: + enum class Option { + None = 0b0, + SplitStereoSignal = 0b1, + HighDetail = 0b10, + AllOptionsCombined = SplitStereoSignal | HighDetail, + }; + Q_DECLARE_FLAGS(Options, Option) + static constexpr float m_maxValue{static_cast(std::numeric_limits::max())}; 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/renderers/allshader/waveformrenderertextured.cpp b/src/waveform/renderers/allshader/waveformrenderertextured.cpp index 142ebe2584c..404ae9202b5 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::Option::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 7cbc6ae88b5..2d5fa4b253d 100644 --- a/src/waveform/renderers/allshader/waveformrenderertextured.h +++ b/src/waveform/renderers/allshader/waveformrenderertextured.h @@ -6,6 +6,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; @@ -19,13 +20,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::Option::None); ~WaveformRendererTextured() override; // override ::WaveformRendererSignalBase @@ -41,7 +41,7 @@ class allshader::WaveformRendererTextured : public QObject, void slotWaveformUpdated(); private: - static QString fragShaderForType(Type t); + static QString fragShaderForType(WaveformWidgetType::Type t); bool loadShaders(); bool loadTexture(); @@ -58,8 +58,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/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/renderers/waveformrendererendoftrack.cpp b/src/waveform/renderers/waveformrendererendoftrack.cpp index e512b7a783d..330d0101fcc 100644 --- a/src/waveform/renderers/waveformrendererendoftrack.cpp +++ b/src/waveform/renderers/waveformrendererendoftrack.cpp @@ -57,7 +57,7 @@ void WaveformRendererEndOfTrack::draw(QPainter* painter, return; } - // ScopedTimer t(u"WaveformRendererEndOfTrack::draw"); + // ScopedTimer t(QStringLiteral("WaveformRendererEndOfTrack::draw")); const int elapsed = m_timer.elapsed().toIntegerMillis() % kBlinkingPeriodMillis; diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 4fc216b0589..961d816bff3 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -24,27 +24,10 @@ #include "waveform/visualsmanager.h" #include "waveform/vsyncthread.h" #ifdef MIXXX_USE_QOPENGL -#include "waveform/widgets/allshader/filteredwaveformwidget.h" -#include "waveform/widgets/allshader/hsvwaveformwidget.h" -#include "waveform/widgets/allshader/lrrgbwaveformwidget.h" -#include "waveform/widgets/allshader/rgbstackedwaveformwidget.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" -#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/renderers/allshader/waveformrenderersignalbase.h" +#include "waveform/widgets/allshader/waveformwidget.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" @@ -55,26 +38,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 || @@ -99,7 +62,7 @@ const QRegularExpression openGLVersionRegex(QStringLiteral("^(\\d+)\\.(\\d+).*$" /////////////////////////////////////////// WaveformWidgetAbstractHandle::WaveformWidgetAbstractHandle() - : m_type(WaveformWidgetType::Count_WaveformwidgetType) { + : m_type(WaveformWidgetType::Invalid) { } /////////////////////////////////////////// @@ -126,8 +89,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), @@ -405,7 +368,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++) { @@ -427,7 +390,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); @@ -576,9 +539,10 @@ 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; + // TODO do not set "Empty"? m_config->setValue( ConfigKey("[Waveform]", "WaveformType"), *pCurrentType); } @@ -587,23 +551,15 @@ 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: + case WaveformWidgetType::HSV: return true; - case WaveformWidgetType::AllShaderHSVWaveform: - 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; @@ -612,7 +568,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" @@ -628,7 +584,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; } @@ -757,7 +713,7 @@ void WaveformWidgetFactory::notifyZoomChange(WWaveformViewer* viewer) { } void WaveformWidgetFactory::renderSelf() { - ScopedTimer t(u"WaveformWidgetFactory::render() %1waveforms", + ScopedTimer t(QStringLiteral("WaveformWidgetFactory::render() %1waveforms"), static_cast(m_waveformWidgetHolders.size())); if (!m_skipRender) { @@ -831,7 +787,7 @@ void WaveformWidgetFactory::render() { } void WaveformWidgetFactory::swapSelf() { - ScopedTimer t(u"WaveformWidgetFactory::swap() %1waveforms", + ScopedTimer t(QStringLiteral("WaveformWidgetFactory::swap() %1waveforms"), static_cast(m_waveformWidgetHolders.size())); // Do this in an extra slot to be sure to hit the desired interval @@ -895,228 +851,261 @@ void WaveformWidgetFactory::slotFrameSwapped() { #endif } -WaveformWidgetType::Type WaveformWidgetFactory::autoChooseWidgetType() const { - if (isOpenGlShaderAvailable()) { -#ifndef MIXXX_USE_QOPENGL - return WaveformWidgetType::GLSLRGBWaveform; -#else - return WaveformWidgetType::AllShaderRGBWaveform; +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 (vars.m_category == WaveformWidgetCategory::DeveloperOnly && + !CmdlineArgs::Instance().getDeveloper()) { + active = false; + } +#ifdef MIXXX_USE_QOPENGL + else if (vars.m_category == WaveformWidgetCategory::AllShader) { + backend = WaveformWidgetBackend::AllShader; + } #endif + else if (vars.m_category == WaveformWidgetCategory::Legacy && vars.m_useGLSL) { + backend = WaveformWidgetBackend::GLSL; + } else if (vars.m_category == WaveformWidgetCategory::Legacy) { + backend = WaveformWidgetBackend::GL; } - if (isOpenGlAvailable() || isOpenGlesAvailable()) { - return WaveformWidgetType::GLRGBWaveform; + + if (active) { + if (collectedHandles.contains(type)) { + collectedHandles[type].push_back(backend); + } else { + collectedHandles.insert(type, + QList{backend}); + } } - return WaveformWidgetType::RGBWaveform; } +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(); - for (int type = 0; type < WaveformWidgetType::Count_WaveformwidgetType; type++) { - QString widgetName; - bool useOpenGl; - bool useOpenGles; - bool useOpenGLShaders; - WaveformWidgetCategory category; - - // this lambda needs its type specified explicitly, - // requiring it to be called with via `.operator()()` - auto setWaveformVarsByType = [&]() { - widgetName = buildWidgetDisplayName(); - useOpenGl = WaveformT::useOpenGl(); - useOpenGles = WaveformT::useOpenGles(); - useOpenGLShaders = WaveformT::useOpenGLShaders(); - category = WaveformT::category(); - }; - - switch(type) { - case WaveformWidgetType::EmptyWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::SoftwareSimpleWaveform: - continue; // //TODO(vrince): - case WaveformWidgetType::SoftwareWaveform: -#ifdef __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()(); + QHash> collectedHandles; + QHash + supportedOptions; + for (WaveformWidgetType::Type type : WaveformWidgetType::kValues) { + switch (type) { + case WaveformWidgetType::Empty: + addHandle(collectedHandles, type, waveformWidgetVars()); break; + case WaveformWidgetType::Simple: +#ifdef MIXXX_USE_QOPENGL + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #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: + case WaveformWidgetType::Filtered: #ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #endif - case WaveformWidgetType::QtWaveform: -#ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, waveformWidgetVars()); break; + case WaveformWidgetType::VSyncTest: +#ifdef MIXXX_USE_QOPENGL + addHandle(collectedHandles, type, waveformWidgetVars()); #endif - case WaveformWidgetType::GLSimpleWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLFilteredWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLSLFilteredWaveform: - setWaveformVarsByType.operator()(); break; - case WaveformWidgetType::GLSLRGBWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLSLRGBStackedWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLVSyncTest: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::GLRGBWaveform: - setWaveformVarsByType.operator()(); - break; - case WaveformWidgetType::QtVSyncTest: + case WaveformWidgetType::RGB: #ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #endif + addHandle(collectedHandles, type, waveformWidgetVars()); break; - case WaveformWidgetType::QtHSVWaveform: + case WaveformWidgetType::HSV: + addHandle(collectedHandles, type, waveformWidgetVars()); #ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #endif - case WaveformWidgetType::QtRGBWaveform: -#ifdef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); break; + case WaveformWidgetType::Stacked: +#ifdef MIXXX_USE_QOPENGL + addHandle(collectedHandles, type, allshader::WaveformWidget::vars()); + supportedOptions[type] = allshader::WaveformWidget::supportedOptions(type); #endif - case WaveformWidgetType::AllShaderRGBWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); break; -#endif - case WaveformWidgetType::AllShaderLRRGBWaveform: -#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(); + const auto& type = handleIter.key(); + const auto& backends = handleIter.value(); #endif - case WaveformWidgetType::AllShaderFilteredWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + m_waveformWidgetHandles.push_back(WaveformWidgetAbstractHandle(type, backends +#ifdef MIXXX_USE_QOPENGL + , + supportedOptions.value(type, allshader::WaveformRendererSignalBase::Option::None) #endif - case WaveformWidgetType::AllShaderRGBStackedWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + )); + } +} + +WaveformWidgetAbstract* WaveformWidgetFactory::createAllshaderWaveformWidget( + WaveformWidgetType::Type type, WWaveformViewer* viewer) { + allshader::WaveformRendererSignalBase::Options options = + m_config->getValue(ConfigKey("[Waveform]", "waveform_options"), + allshader::WaveformRendererSignalBase::Option::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 + // => 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) { +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: { + return createAllshaderWaveformWidget(WaveformWidgetType::Type::Filtered, viewer); + } #endif - case WaveformWidgetType::AllShaderSimpleWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + 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. + WaveformWidgetBackend backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + preferredBackend()); + + switch (backend) { +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: + return createAllshaderWaveformWidget(WaveformWidgetType::HSV, viewer); #endif - case WaveformWidgetType::AllShaderHSVWaveform: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + 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. + WaveformWidgetBackend backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + preferredBackend()); + + switch (backend) { +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: + return createAllshaderWaveformWidget(WaveformWidgetType::Type::RGB, viewer); #endif - case WaveformWidgetType::AllShaderTexturedFiltered: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + default: + return new RGBWaveformWidget(viewer->getGroup(), viewer); + } +} + +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::AllShader: + return createAllshaderWaveformWidget(WaveformWidgetType::Type::Stacked, viewer); #endif - case WaveformWidgetType::AllShaderTexturedRGB: -#ifndef MIXXX_USE_QOPENGL - continue; -#else - setWaveformVarsByType.operator()(); - break; + default: + return new EmptyWaveformWidget(viewer->getGroup(), viewer); + } +} + +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. + WaveformWidgetBackend backend = m_config->getValue( + ConfigKey("[Waveform]", "use_hardware_acceleration"), + preferredBackend()); + + switch (backend) { +#ifdef MIXXX_USE_QOPENGL + case WaveformWidgetBackend::AllShader: + return createAllshaderWaveformWidget(WaveformWidgetType::Type::Simple, viewer); #endif - case WaveformWidgetType::AllShaderTexturedStacked: -#ifndef MIXXX_USE_QOPENGL - continue; + default: + return new EmptyWaveformWidget(viewer->getGroup(), viewer); + } +} + +WaveformWidgetAbstract* WaveformWidgetFactory::createVSyncTestWaveformWidget( + WWaveformViewer* viewer) { +#ifdef MIXXX_USE_QOPENGL + return new GLVSyncTestWidget(viewer->getGroup(), viewer); #else - setWaveformVarsByType.operator()(); - break; + return new EmptyWaveformWidget(viewer->getGroup(), viewer); #endif - default: - DEBUG_ASSERT(!"Unexpected WaveformWidgetType"); - continue; - } - - bool active = !isDeprecated(static_cast(type)); - 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; - } - - if (active) { - // add new handle for each available widget type - WaveformWidgetAbstractHandle handle; - handle.m_displayString = widgetName; - handle.m_type = static_cast(type); - - m_waveformWidgetHandles.push_back(handle); - } - } } WaveformWidgetAbstract* WaveformWidgetFactory::createWaveformWidget( @@ -1124,94 +1113,35 @@ WaveformWidgetAbstract* WaveformWidgetFactory::createWaveformWidget( 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); - break; - case WaveformWidgetType::GLSimpleWaveform: - widget = new GLSimpleWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::GLFilteredWaveform: - widget = new GLWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::GLRGBWaveform: - widget = new GLRGBWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::GLSLFilteredWaveform: - widget = new GLSLFilteredWaveformWidget(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::GLSLRGBWaveform: - widget = new GLSLRGBWaveformWidget(viewer->getGroup(), 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); + switch (type) { + case WaveformWidgetType::Simple: + widget = createSimpleWaveformWidget(viewer); break; - case WaveformWidgetType::AllShaderLRRGBWaveform: - widget = new allshader::LRRGBWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::Filtered: + widget = createFilteredWaveformWidget(viewer); break; - case WaveformWidgetType::AllShaderFilteredWaveform: - widget = new allshader::FilteredWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::HSV: + widget = createHSVWaveformWidget(viewer); break; - case WaveformWidgetType::AllShaderRGBStackedWaveform: - widget = new allshader::RGBStackedWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::VSyncTest: + widget = createVSyncTestWaveformWidget(viewer); break; - case WaveformWidgetType::AllShaderSimpleWaveform: - widget = new allshader::SimpleWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::RGB: + widget = createRGBWaveformWidget(viewer); break; - case WaveformWidgetType::AllShaderHSVWaveform: - widget = new allshader::HSVWaveformWidget(viewer->getGroup(), viewer); + case WaveformWidgetType::Stacked: + widget = createStackedWaveformWidget(viewer); break; - case WaveformWidgetType::AllShaderTexturedFiltered: - widget = new allshader::WaveformWidgetTexturedFiltered(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::AllShaderTexturedRGB: - widget = new allshader::WaveformWidgetTexturedRGB(viewer->getGroup(), viewer); - break; - case WaveformWidgetType::AllShaderTexturedStacked: - widget = new allshader::WaveformWidgetTexturedStacked(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: 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(); @@ -1277,7 +1207,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; } @@ -1285,53 +1215,49 @@ 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; } -QString WaveformWidgetFactory::getDisplayNameFromType(WaveformWidgetType::Type type) { - for (const auto& handle : std::as_const(m_waveformWidgetHandles)) { - if (handle.m_type == type) { - return handle.m_displayString; - } +WaveformWidgetBackend WaveformWidgetFactory::preferredBackend() const { +#ifdef MIXXX_USE_QOPENGL + if (m_openGlAvailable || m_openGlesAvailable) { + return WaveformWidgetBackend::AllShader; } - return QString(); +#endif + if (m_openGlAvailable && m_openGLShaderAvailable) { + return WaveformWidgetBackend::GLSL; + } else if (m_openGlAvailable) { + return WaveformWidgetBackend::GL; + } + return WaveformWidgetBackend::None; } -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")); - } - } - if (WaveformT::useTextureForWaveform()) { - extras.push_back(QStringLiteral("high detail")); - } - 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 aa2c1cccac8..17dadc391f3 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -9,7 +9,9 @@ #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" class WVuMeterLegacy; class WVuMeterBase; @@ -22,13 +24,60 @@ class VisualsManager; class WaveformWidgetAbstractHandle { public: WaveformWidgetAbstractHandle(); + WaveformWidgetAbstractHandle(WaveformWidgetType::Type type, + 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;} - QString getDisplayName() const { return m_displayString;} + 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); + } + +#ifdef MIXXX_USE_QOPENGL + allshader::WaveformRendererSignalBase::Options supportedOptions( + WaveformWidgetBackend backend) const { + return backend == WaveformWidgetBackend::AllShader + ? m_supportedOption + : allshader::WaveformRendererSignalBase::Option::None; + } +#endif + + QString getDisplayName() const; private: WaveformWidgetType::Type m_type; - QString m_displayString; + QList m_backends; +#ifdef MIXXX_USE_QOPENGL + // Only relevant for Allshader (accelerated) backend. Other backends don't implement options + allshader::WaveformRendererSignalBase::Options m_supportedOption; +#endif friend class WaveformWidgetFactory; }; @@ -83,6 +132,11 @@ 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; WaveformWidgetType::Type findTypeFromHandleIndex(int index); - QString getDisplayNameFromType(WaveformWidgetType::Type type); //All type of available widgets @@ -230,6 +287,14 @@ class WaveformWidgetFactory : public QObject, public Singleton(); - addRenderer(); - addRenderer(); - addRenderer(); - 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 adc55239beb..00000000000 --- a/src/waveform/widgets/allshader/filteredwaveformwidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "util/class.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::AllShaderFilteredWaveform; - } - - 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 false; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - FilteredWaveformWidget(const QString& group, QWidget* parent); - 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 67d077a6aea..00000000000 --- a/src/waveform/widgets/allshader/hsvwaveformwidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "util/class.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::AllShaderHSVWaveform; - } - - static inline QString getWaveformWidgetName() { - return tr("HSV"); - } - 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: - HSVWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(HSVWaveformWidget); -}; 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 76a300852e2..00000000000 --- a/src/waveform/widgets/allshader/lrrgbwaveformwidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "util/class.h" -#include "waveform/widgets/allshader/waveformwidget.h" - -class WaveformWidgetFactory; - -namespace allshader { -class LRRGBWaveformWidget; -} - -class allshader::LRRGBWaveformWidget final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::AllShaderLRRGBWaveform; - } - - static inline QString getWaveformWidgetName() { - return tr("RGB L/R"); - } - 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: - LRRGBWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(LRRGBWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp b/src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp deleted file mode 100644 index 4f359cd27b8..00000000000 --- a/src/waveform/widgets/allshader/rgbstackedwaveformwidget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "waveform/widgets/allshader/rgbstackedwaveformwidget.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/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_rgbstackedwaveformwidget.cpp" - -namespace allshader { - -RGBStackedWaveformWidget::RGBStackedWaveformWidget(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(true); // true for RGB Stacked - addRenderer(); - addRenderer(); - - m_initSuccess = init(); -} - -void RGBStackedWaveformWidget::castToQWidget() { - m_widget = this; -} - -void RGBStackedWaveformWidget::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); -} - -} // namespace 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 deleted file mode 100644 index b6571435a79..00000000000 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.cpp +++ /dev/null @@ -1,42 +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/waveformrendermark.h" -#include "waveform/renderers/allshader/waveformrendermarkrange.h" -#include "waveform/widgets/allshader/moc_rgbwaveformwidget.cpp" - -namespace allshader { - -RGBWaveformWidget::RGBWaveformWidget(const QString& group, QWidget* parent) - : WaveformWidget(group, parent) { - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - addRenderer(); - 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); - 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 93d6465bbc0..00000000000 --- a/src/waveform/widgets/allshader/rgbwaveformwidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "util/class.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::AllShaderRGBWaveform; - } - - 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 false; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - RGBWaveformWidget(const QString& group, QWidget* parent); - 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 5c66f5ba5f9..00000000000 --- a/src/waveform/widgets/allshader/simplewaveformwidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "util/class.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::AllShaderSimpleWaveform; - } - - static inline QString getWaveformWidgetName() { - return tr("Simple"); - } - 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: - SimpleWaveformWidget(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(SimpleWaveformWidget); -}; diff --git a/src/waveform/widgets/allshader/waveformwidget.cpp b/src/waveform/widgets/allshader/waveformwidget.cpp index 0a64dd964ef..24f32a93fae 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::Option::HighDetail) { + return addRenderer(type, positionSource, options); + } + return addRenderer(positionSource, options); + case ::WaveformWidgetType::HSV: + return addRenderer(); + case ::WaveformWidgetType::Filtered: + if (options & allshader::WaveformRendererSignalBase::Option::HighDetail) { + return addRenderer(type, positionSource, options); + } + return addRenderer(false); + case ::WaveformWidgetType::Stacked: + if (options & allshader::WaveformRendererSignalBase::Option::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 */ +WaveformRendererSignalBase::Options WaveformWidget::supportedOptions( + WaveformWidgetType::Type type) { + switch (type) { + case WaveformWidgetType::Type::RGB: + return WaveformRendererSignalBase::Option::AllOptionsCombined; + case WaveformWidgetType::Type::Filtered: + return WaveformRendererSignalBase::Option::HighDetail; + case WaveformWidgetType::Type::Stacked: + return WaveformRendererSignalBase::Option::HighDetail; + default: + break; + } + return WaveformRendererSignalBase::Option::None; +} + +/* 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..f6c0877975e 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 WaveformRendererSignalBase::Options 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/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 diff --git a/src/waveform/widgets/allshader/waveformwidgettexturedstacked.h b/src/waveform/widgets/allshader/waveformwidgettexturedstacked.h deleted file mode 100644 index 9c903744586..00000000000 --- a/src/waveform/widgets/allshader/waveformwidgettexturedstacked.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 WaveformWidgetTexturedStacked; -} - -class allshader::WaveformWidgetTexturedStacked final : public allshader::WaveformWidget { - Q_OBJECT - public: - WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::AllShaderTexturedStacked; - } - - 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 true; - } - static constexpr WaveformWidgetCategory category() { - return WaveformWidgetCategory::AllShader; - } - - protected: - void castToQWidget() override; - void paintEvent(QPaintEvent* event) override; - - private: - WaveformWidgetTexturedStacked(const QString& group, QWidget* parent); - friend class ::WaveformWidgetFactory; - - DISALLOW_COPY_AND_ASSIGN(WaveformWidgetTexturedStacked); -}; diff --git a/src/waveform/widgets/deprecated/glrgbwaveformwidget.h b/src/waveform/widgets/deprecated/glrgbwaveformwidget.h index d46136eacaa..5db71bcf495 100644 --- a/src/waveform/widgets/deprecated/glrgbwaveformwidget.h +++ b/src/waveform/widgets/deprecated/glrgbwaveformwidget.h @@ -8,9 +8,10 @@ class GLRGBWaveformWidget : public GLWaveformWidgetAbstract { GLRGBWaveformWidget(const QString& group, QWidget* parent); virtual ~GLRGBWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::GLRGBWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::RGB; + } - static inline QString getWaveformWidgetName() { return tr("RGB"); } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return false; } diff --git a/src/waveform/widgets/deprecated/glsimplewaveformwidget.h b/src/waveform/widgets/deprecated/glsimplewaveformwidget.h index b84881060aa..b9327a01ac9 100644 --- a/src/waveform/widgets/deprecated/glsimplewaveformwidget.h +++ b/src/waveform/widgets/deprecated/glsimplewaveformwidget.h @@ -8,7 +8,9 @@ class GLSimpleWaveformWidget : public GLWaveformWidgetAbstract { GLSimpleWaveformWidget(const QString& group, QWidget* parent); virtual ~GLSimpleWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::GLSimpleWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::Simple; + } static inline QString getWaveformWidgetName() { return tr("Simple"); } static inline bool useOpenGl() { return true; } diff --git a/src/waveform/widgets/deprecated/glslwaveformwidget.h b/src/waveform/widgets/deprecated/glslwaveformwidget.h index 6cb83768cce..86563cad27a 100644 --- a/src/waveform/widgets/deprecated/glslwaveformwidget.h +++ b/src/waveform/widgets/deprecated/glslwaveformwidget.h @@ -33,9 +33,10 @@ class GLSLFilteredWaveformWidget : public GLSLWaveformWidget { GLSLFilteredWaveformWidget(const QString& group, QWidget* parent); ~GLSLFilteredWaveformWidget() override = default; - WaveformWidgetType::Type getType() const override { return WaveformWidgetType::GLSLFilteredWaveform; } + WaveformWidgetType::Type getType() const override { + return WaveformWidgetType::Filtered; + } - static inline QString getWaveformWidgetName() { return tr("Filtered"); } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return true; } @@ -53,7 +54,9 @@ class GLSLRGBWaveformWidget : public GLSLWaveformWidget { GLSLRGBWaveformWidget(const QString& group, QWidget* parent); ~GLSLRGBWaveformWidget() override = default; - WaveformWidgetType::Type getType() const override { return WaveformWidgetType::GLSLRGBWaveform; } + WaveformWidgetType::Type getType() const override { + return WaveformWidgetType::RGB; + } static inline QString getWaveformWidgetName() { return tr("RGB"); } static inline bool useOpenGl() { return true; } @@ -74,7 +77,7 @@ class GLSLRGBStackedWaveformWidget : public GLSLWaveformWidget { ~GLSLRGBStackedWaveformWidget() override = default; WaveformWidgetType::Type getType() const override { - return WaveformWidgetType::GLSLRGBStackedWaveform; + return WaveformWidgetType::Stacked; } static inline QString getWaveformWidgetName() { diff --git a/src/waveform/widgets/deprecated/glwaveformwidget.h b/src/waveform/widgets/deprecated/glwaveformwidget.h index f82875e2a44..f9178d20695 100644 --- a/src/waveform/widgets/deprecated/glwaveformwidget.h +++ b/src/waveform/widgets/deprecated/glwaveformwidget.h @@ -8,9 +8,10 @@ class GLWaveformWidget : public GLWaveformWidgetAbstract { GLWaveformWidget(const QString& group, QWidget* parent); virtual ~GLWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::GLFilteredWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::Filtered; + } - static inline QString getWaveformWidgetName() { return tr("Filtered"); } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return false; } 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 81% rename from src/waveform/widgets/qthsvwaveformwidget.h rename to src/waveform/widgets/deprecated/qthsvwaveformwidget.h index d27218376b2..8d261d9edca 100644 --- a/src/waveform/widgets/qthsvwaveformwidget.h +++ b/src/waveform/widgets/deprecated/qthsvwaveformwidget.h @@ -7,9 +7,10 @@ class QtHSVWaveformWidget : public GLWaveformWidgetAbstract { public: virtual ~QtHSVWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::QtHSVWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::HSV; + } - static inline QString getWaveformWidgetName() { return tr("HSV") + " - Qt"; } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return true; } static inline bool useOpenGLShaders() { return false; } 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 73% rename from src/waveform/widgets/qtrgbwaveformwidget.h rename to src/waveform/widgets/deprecated/qtrgbwaveformwidget.h index 0f560a3f370..2718536e499 100644 --- a/src/waveform/widgets/qtrgbwaveformwidget.h +++ b/src/waveform/widgets/deprecated/qtrgbwaveformwidget.h @@ -7,15 +7,12 @@ class QtRGBWaveformWidget : public GLWaveformWidgetAbstract { public: virtual ~QtRGBWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::QtRGBWaveform; } - - static inline QString getWaveformWidgetName() { return tr("RGB") + " - Qt"; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::RGB; + } 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 72% rename from src/waveform/widgets/qtsimplewaveformwidget.h rename to src/waveform/widgets/deprecated/qtsimplewaveformwidget.h index fc912ae5f91..76060f1bcea 100644 --- a/src/waveform/widgets/qtsimplewaveformwidget.h +++ b/src/waveform/widgets/deprecated/qtsimplewaveformwidget.h @@ -8,18 +8,13 @@ class QtSimpleWaveformWidget : public GLWaveformWidgetAbstract { QtSimpleWaveformWidget(const QString& group, QWidget* parent); virtual ~QtSimpleWaveformWidget(); - - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::GLSimpleWaveform; } - - static inline QString getWaveformWidgetName() { - return tr("Simple") + "- Qt"; + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::Simple; } + 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 73% rename from src/waveform/widgets/qtvsynctestwidget.h rename to src/waveform/widgets/deprecated/qtvsynctestwidget.h index 876cfae616a..2b986901919 100644 --- a/src/waveform/widgets/qtvsynctestwidget.h +++ b/src/waveform/widgets/deprecated/qtvsynctestwidget.h @@ -8,15 +8,13 @@ class QtVSyncTestWidget : public GLWaveformWidgetAbstract { QtVSyncTestWidget(const QString& group, QWidget* parent); virtual ~QtVSyncTestWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::QtVSyncTest; } + virtual WaveformWidgetType::Type getType() const { + 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 73% rename from src/waveform/widgets/qtwaveformwidget.h rename to src/waveform/widgets/deprecated/qtwaveformwidget.h index 9dd1881b0d7..5db32b34266 100644 --- a/src/waveform/widgets/qtwaveformwidget.h +++ b/src/waveform/widgets/deprecated/qtwaveformwidget.h @@ -8,15 +8,13 @@ class QtWaveformWidget : public GLWaveformWidgetAbstract { QtWaveformWidget(const QString& group, QWidget* parent); virtual ~QtWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::QtWaveform; } + virtual WaveformWidgetType::Type getType() const { + 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/emptywaveformwidget.h b/src/waveform/widgets/emptywaveformwidget.h index 184464661b9..b03e247ca5d 100644 --- a/src/waveform/widgets/emptywaveformwidget.h +++ b/src/waveform/widgets/emptywaveformwidget.h @@ -12,9 +12,10 @@ class EmptyWaveformWidget : public NonGLWaveformWidgetAbstract { public: virtual ~EmptyWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::EmptyWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::Empty; + } - static inline QString getWaveformWidgetName() { return tr("Empty"); } static inline bool useOpenGl() { return false; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return false; } 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 75% rename from src/waveform/widgets/deprecated/glvsynctestwidget.h rename to src/waveform/widgets/glvsynctestwidget.h index 3c9a8021cc0..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 @@ -8,9 +8,10 @@ class GLVSyncTestWidget : public GLWaveformWidgetAbstract { GLVSyncTestWidget(const QString& group, QWidget* parent); virtual ~GLVSyncTestWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::GLVSyncTest; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::VSyncTest; + } - static inline QString getWaveformWidgetName() { return tr("VSyncTest"); } static inline bool useOpenGl() { return true; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return false; } 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 diff --git a/src/waveform/widgets/hsvwaveformwidget.h b/src/waveform/widgets/hsvwaveformwidget.h index a9d210ac447..64770edaf10 100644 --- a/src/waveform/widgets/hsvwaveformwidget.h +++ b/src/waveform/widgets/hsvwaveformwidget.h @@ -9,9 +9,10 @@ class HSVWaveformWidget : public NonGLWaveformWidgetAbstract { public: virtual ~HSVWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::HSVWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::HSV; + } - static inline QString getWaveformWidgetName() { return tr("HSV"); } static inline bool useOpenGl() { return false; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return false; } diff --git a/src/waveform/widgets/rgbwaveformwidget.h b/src/waveform/widgets/rgbwaveformwidget.h index 47e56fc9147..3c925c5359d 100644 --- a/src/waveform/widgets/rgbwaveformwidget.h +++ b/src/waveform/widgets/rgbwaveformwidget.h @@ -9,9 +9,10 @@ class RGBWaveformWidget : public NonGLWaveformWidgetAbstract { public: virtual ~RGBWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::RGBWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::RGB; + } - static inline QString getWaveformWidgetName() { return tr("RGB"); } static inline bool useOpenGl() { return false; } static inline bool useOpenGles() { return false; } static inline bool useOpenGLShaders() { return false; } diff --git a/src/waveform/widgets/softwarewaveformwidget.h b/src/waveform/widgets/softwarewaveformwidget.h index 6490d70b007..c79d0a545ea 100644 --- a/src/waveform/widgets/softwarewaveformwidget.h +++ b/src/waveform/widgets/softwarewaveformwidget.h @@ -9,7 +9,9 @@ class SoftwareWaveformWidget : public NonGLWaveformWidgetAbstract { public: virtual ~SoftwareWaveformWidget(); - virtual WaveformWidgetType::Type getType() const { return WaveformWidgetType::SoftwareWaveform; } + virtual WaveformWidgetType::Type getType() const { + return WaveformWidgetType::Filtered; + } static inline QString getWaveformWidgetName() { return tr("Filtered"); } static inline bool useOpenGl() { return false; } diff --git a/src/waveform/widgets/waveformwidgettype.h b/src/waveform/widgets/waveformwidgettype.h index 9c14429b01b..6ed90df786e 100644 --- a/src/waveform/widgets/waveformwidgettype.h +++ b/src/waveform/widgets/waveformwidgettype.h @@ -1,36 +1,41 @@ #pragma once +#include +#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. - EmptyWaveform = 0, - SoftwareSimpleWaveform, // 1 TODO - SoftwareWaveform, // 2 Filtered - QtSimpleWaveform, // 3 Simple Qt - QtWaveform, // 4 Filtered Qt - GLSimpleWaveform, // 5 Simple GL - GLFilteredWaveform, // 6 Filtered GL - GLSLFilteredWaveform, // 7 Filtered GLSL - HSVWaveform, // 8 HSV - GLVSyncTest, // 9 VSync GL - RGBWaveform, // 10 RGB - GLRGBWaveform, // 11 RGB GL - GLSLRGBWaveform, // 12 RGB GLSL - QtVSyncTest, // 13 VSync Qt - QtHSVWaveform, // 14 HSV Qt - QtRGBWaveform, // 15 RGB Qt - GLSLRGBStackedWaveform, // 16 RGB Stacked - AllShaderRGBWaveform, // 17 RGB (all-shaders) - AllShaderLRRGBWaveform, // 18 L/R RGB (all-shaders) - AllShaderFilteredWaveform, // 19 Filtered (all-shaders) - AllShaderSimpleWaveform, // 20 Simple (all-shaders) - AllShaderHSVWaveform, // 21 HSV (all-shaders) - AllShaderTexturedFiltered, // 22 Filtered (textured) (all-shaders) - AllShaderTexturedRGB, // 23 RGB (textured) (all-shaders) - AllShaderTexturedStacked, // 24 Stacked (textured) (all-shaders) - AllShaderRGBStackedWaveform, // 26 Stacked (all-shaders) - Count_WaveformwidgetType // Also used as invalid value + Empty = 0, + 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, }; }; + +enum class WaveformWidgetBackend { + None = 0, + GL, + GLSL, +#ifdef MIXXX_USE_QOPENGL + AllShader, +#endif +}; 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; +}; diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 794db86a9f4..24159cbc37d 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -577,7 +577,7 @@ void WOverview::leaveEvent(QEvent* pEvent) { void WOverview::paintEvent(QPaintEvent* pEvent) { Q_UNUSED(pEvent); - ScopedTimer t(u"WOverview::paintEvent"); + ScopedTimer t(QStringLiteral("WOverview::paintEvent")); QPainter painter(this); painter.fillRect(rect(), m_backgroundColor); diff --git a/src/widget/woverviewhsv.cpp b/src/widget/woverviewhsv.cpp index 8f20884b1d2..c818bcf7094 100644 --- a/src/widget/woverviewhsv.cpp +++ b/src/widget/woverviewhsv.cpp @@ -18,7 +18,7 @@ WOverviewHSV::WOverviewHSV( } bool WOverviewHSV::drawNextPixmapPart() { - ScopedTimer t(u"WOverviewHSV::drawNextPixmapPart"); + ScopedTimer t(QStringLiteral("WOverviewHSV::drawNextPixmapPart")); //qDebug() << "WOverview::drawNextPixmapPart()"; diff --git a/src/widget/woverviewlmh.cpp b/src/widget/woverviewlmh.cpp index 72ad03124a5..30f2f4aad01 100644 --- a/src/widget/woverviewlmh.cpp +++ b/src/widget/woverviewlmh.cpp @@ -18,7 +18,7 @@ WOverviewLMH::WOverviewLMH( } bool WOverviewLMH::drawNextPixmapPart() { - ScopedTimer t(u"WOverviewLMH::drawNextPixmapPart"); + ScopedTimer t(QStringLiteral("WOverviewLMH::drawNextPixmapPart")); //qDebug() << "WOverview::drawNextPixmapPart()"; diff --git a/src/widget/woverviewrgb.cpp b/src/widget/woverviewrgb.cpp index 5cc8ced168e..e9e03145377 100644 --- a/src/widget/woverviewrgb.cpp +++ b/src/widget/woverviewrgb.cpp @@ -17,7 +17,7 @@ WOverviewRGB::WOverviewRGB( } bool WOverviewRGB::drawNextPixmapPart() { - ScopedTimer t(u"WOverviewRGB::drawNextPixmapPart"); + ScopedTimer t(QStringLiteral("WOverviewRGB::drawNextPixmapPart")); //qDebug() << "WOverview::drawNextPixmapPart()"; diff --git a/src/widget/wvumeterbase.cpp b/src/widget/wvumeterbase.cpp index 18ea00544c3..dca9eb122a0 100644 --- a/src/widget/wvumeterbase.cpp +++ b/src/widget/wvumeterbase.cpp @@ -181,7 +181,7 @@ void WVuMeterBase::render(VSyncThread* vSyncThread) { return; } - ScopedTimer t(u"WVuMeterBase::render"); + ScopedTimer t(QStringLiteral("WVuMeterBase::render")); updateState(vSyncThread->sinceLastSwap()); diff --git a/src/widget/wvumeterlegacy.cpp b/src/widget/wvumeterlegacy.cpp index 2d38917c793..97a065b0ae9 100644 --- a/src/widget/wvumeterlegacy.cpp +++ b/src/widget/wvumeterlegacy.cpp @@ -165,7 +165,7 @@ void WVuMeterLegacy::showEvent(QShowEvent* e) { } void WVuMeterLegacy::paintEvent(QPaintEvent* /*unused*/) { - ScopedTimer t(u"WVuMeterLegacy::paintEvent"); + ScopedTimer t(QStringLiteral("WVuMeterLegacy::paintEvent")); QPainter p(this); diff --git a/src/widget/wwaveformviewer.cpp b/src/widget/wwaveformviewer.cpp index a381fba58ce..22629abc884 100644 --- a/src/widget/wwaveformviewer.cpp +++ b/src/widget/wwaveformviewer.cpp @@ -303,7 +303,7 @@ void WWaveformViewer::setWaveformWidget(WaveformWidgetAbstract* waveformWidget) #endif // Make connection to show "Passthrough" label on the waveform, except for // "Empty" waveform type - if (m_waveformWidget->getType() == WaveformWidgetType::EmptyWaveform) { + if (m_waveformWidget->getType() == WaveformWidgetType::Empty) { return; } connect(this,