Skip to content

Commit

Permalink
Merge pull request #11822 from m0dB/default-waveform-allshaders
Browse files Browse the repository at this point in the history
use WaveformWidgetType::AllShaderRGBWaveform as autoChooseWidgetType
  • Loading branch information
Swiftb0y authored Sep 2, 2023
2 parents 8406457 + f569ff0 commit df702f7
Show file tree
Hide file tree
Showing 53 changed files with 512 additions and 117 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ else()
src/waveform/renderers/allshader/waveformrenderer.cpp
src/waveform/renderers/allshader/waveformrendererendoftrack.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
Expand All @@ -1289,6 +1290,7 @@ else()
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/simplewaveformwidget.cpp
Expand Down
76 changes: 72 additions & 4 deletions src/preferences/upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "util/db/dbconnectionpooler.h"
#include "util/math.h"
#include "util/versionstore.h"
#include "waveform/widgets/waveformwidgettype.h"

Upgrade::Upgrade()
: m_bFirstRun(false),
Expand All @@ -29,6 +30,45 @@ Upgrade::Upgrade()
Upgrade::~Upgrade() {
}

namespace {
// mapping to proactively move users to the new all-shader waveform types
WaveformWidgetType::Type upgradeToAllShaders(WaveformWidgetType::Type waveformType) {
// TODO: convert `WaveformWidgetType::Type` to an enum class then shorten more `using enum ...`
using WWT = WaveformWidgetType;
switch (waveformType) {
case WWT::EmptyWaveform:
case WWT::SoftwareSimpleWaveform:
case WWT::SoftwareWaveform:
case WWT::GLVSyncTest:
case WWT::QtVSyncTest:
case WWT::AllShaderRGBWaveform:
case WWT::AllShaderLRRGBWaveform:
case WWT::AllShaderFilteredWaveform:
case WWT::AllShaderSimpleWaveform:
case WWT::AllShaderHSVWaveform:
case WWT::Count_WaveformwidgetType:
return waveformType;
case WWT::QtSimpleWaveform:
case WWT::GLSimpleWaveform:
return WaveformWidgetType::AllShaderSimpleWaveform;
case WWT::GLFilteredWaveform:
case WWT::GLSLFilteredWaveform:
return WaveformWidgetType::AllShaderFilteredWaveform;
case WWT::QtWaveform:
case WWT::RGBWaveform:
case WWT::GLRGBWaveform:
case WWT::GLSLRGBWaveform:
case WWT::QtRGBWaveform:
case WWT::GLSLRGBStackedWaveform:
return WWT::AllShaderRGBWaveform;
case WWT::HSVWaveform:
case WWT::QtHSVWaveform:
return WWT::AllShaderHSVWaveform;
}
return WWT::AllShaderRGBWaveform;
}
} // namespace

// We return the UserSettings here because we have to make changes to the
// configuration and the location of the file may change between releases.
UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) {
Expand Down Expand Up @@ -426,8 +466,9 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) {
// if everything until here worked fine we can mark the configuration as
// updated
if (successful) {
configVersion = VersionStore::version();
config->set(ConfigKey("[Config]", "Version"), ConfigValue(VersionStore::version()));
configVersion = "1.12.0";
config->set(ConfigKey("[Config]", "Version"),
ConfigValue(configVersion));
}
else {
qDebug() << "Upgrade failed!\n";
Expand All @@ -436,9 +477,36 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) {

const auto configFileVersion = QVersionNumber::fromString(configVersion);

// When upgrading from 2.3.x or older to 2.4, or when upgrading
// from 2.4.0-beta once we are out of beta
if (QVersionNumber::fromString(configVersion) < QVersionNumber(2, 4, 0) ||
(VersionStore::version() != "2.4.0-beta" &&
configVersion.startsWith("2.4.0-"))) {
// 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<WaveformWidgetType::Type>(
waveformType))));
}
config->set(ConfigKey("[Waveform]", "FrameRate"), ConfigValue(60));

// mark the configuration as updated
configVersion = "2.4.0";
config->set(ConfigKey("[Config]", "Version"),
ConfigValue(configVersion));
}

// This variable indicates the first known version that requires no changes.
const QVersionNumber cleanVersion(1, 12, 0);
if (configFileVersion >= cleanVersion) {
// 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);
if (QVersionNumber::fromString(configVersion) >= cleanVersion) {
// No special upgrade required, just update the value.
configVersion = VersionStore::version();
config->set(ConfigKey("[Config]", "Version"), ConfigValue(VersionStore::version()));
Expand Down
3 changes: 0 additions & 3 deletions src/waveform/renderers/allshader/waveformrenderbackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ WaveformRenderBackground::WaveformRenderBackground(
m_backgroundColor(0, 0, 0) {
}

WaveformRenderBackground::~WaveformRenderBackground() {
}

void WaveformRenderBackground::setup(const QDomNode& node,
const SkinContext& context) {
m_backgroundColor = m_waveformRenderer->getWaveformSignalColors()->getBgColor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class WaveformRenderBackground;
class allshader::WaveformRenderBackground final : public allshader::WaveformRenderer {
public:
explicit WaveformRenderBackground(WaveformWidgetRenderer* waveformWidgetRenderer);
~WaveformRenderBackground() override;

void setup(const QDomNode& node, const SkinContext& context) override;
void paintGL() override;
Expand Down
3 changes: 0 additions & 3 deletions src/waveform/renderers/allshader/waveformrenderbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ WaveformRenderBeat::WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget)
: WaveformRenderer(waveformWidget) {
}

WaveformRenderBeat::~WaveformRenderBeat() {
}

void WaveformRenderBeat::initializeGL() {
WaveformRenderer::initializeGL();
m_shader.init();
Expand Down
1 change: 0 additions & 1 deletion src/waveform/renderers/allshader/waveformrenderbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class WaveformRenderBeat;
class allshader::WaveformRenderBeat final : public allshader::WaveformRenderer {
public:
explicit WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget);
~WaveformRenderBeat() override;

void setup(const QDomNode& node, const SkinContext& context) override;
void paintGL() override;
Expand Down
2 changes: 0 additions & 2 deletions src/waveform/renderers/allshader/waveformrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ WaveformRenderer::WaveformRenderer(WaveformWidgetRenderer* widget)
: ::WaveformRendererAbstract(widget) {
}

WaveformRenderer::~WaveformRenderer() = default;

void WaveformRenderer::draw(QPainter* painter, QPaintEvent* event) {
Q_UNUSED(painter);
Q_UNUSED(event);
Expand Down
1 change: 0 additions & 1 deletion src/waveform/renderers/allshader/waveformrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class allshader::WaveformRenderer : public ::WaveformRendererAbstract,
public allshader::WaveformRendererAbstract {
public:
explicit WaveformRenderer(WaveformWidgetRenderer* widget);
~WaveformRenderer();

// Pure virtual from allshader::WaveformRendererAbstract.
// Renderers that use QPainter functionality implement this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ WaveformRendererEndOfTrack::WaveformRendererEndOfTrack(
m_pTimeRemainingControl(nullptr) {
}

WaveformRendererEndOfTrack::~WaveformRendererEndOfTrack() {
}

bool WaveformRendererEndOfTrack::init() {
m_timer.restart();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class allshader::WaveformRendererEndOfTrack final : public allshader::WaveformRe
public:
explicit WaveformRendererEndOfTrack(
WaveformWidgetRenderer* waveformWidget);
~WaveformRendererEndOfTrack() override;

void setup(const QDomNode& node, const SkinContext& context) override;

Expand Down
3 changes: 0 additions & 3 deletions src/waveform/renderers/allshader/waveformrendererfiltered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ WaveformRendererFiltered::WaveformRendererFiltered(
: WaveformRendererSignalBase(waveformWidget) {
}

WaveformRendererFiltered::~WaveformRendererFiltered() {
}

void WaveformRendererFiltered::onSetup(const QDomNode& node) {
Q_UNUSED(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class WaveformRendererFiltered;
class allshader::WaveformRendererFiltered final : public allshader::WaveformRendererSignalBase {
public:
explicit WaveformRendererFiltered(WaveformWidgetRenderer* waveformWidget);
~WaveformRendererFiltered() override;

// override ::WaveformRendererSignalBase
void onSetup(const QDomNode& node) override;
Expand Down
Loading

0 comments on commit df702f7

Please sign in to comment.