Skip to content

Commit

Permalink
use rendergraph in allshader/waveformwidget, derive allshader wavefor…
Browse files Browse the repository at this point in the history
…mrenderer classes from rendergraph::openglnode
  • Loading branch information
m0dB authored and m0dB committed Dec 9, 2024
1 parent df4902f commit 17883f9
Show file tree
Hide file tree
Showing 34 changed files with 173 additions and 159 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4575,6 +4575,8 @@ endif()

# rendergraph
add_subdirectory(src/rendergraph/opengl)
target_link_libraries(mixxx-lib PUBLIC rendergraph_gl)
target_compile_definitions(mixxx-lib PRIVATE rendergraph=rendergraph_gl)

# WavPack audio file support
find_package(wavpack)
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/renderers/allshader/waveformrenderbackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ WaveformRenderBackground::WaveformRenderBackground(
}

void WaveformRenderBackground::setup(const QDomNode& node,
const SkinContext& context) {
const SkinContext& skinContext) {
m_backgroundColor = m_waveformRenderer->getWaveformSignalColors()->getBgColor();

QString backgroundPixmapPath = context.selectString(node, "BgPixmap");
QString backgroundPixmapPath = skinContext.selectString(node, "BgPixmap");
if (!backgroundPixmapPath.isEmpty()) {
qWarning() << "WaveformView BgPixmap is not supported by "
"allshader::WaveformRenderBackground";
Expand Down
7 changes: 5 additions & 2 deletions src/waveform/renderers/allshader/waveformrenderbackground.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

#include <QColor>

#include "rendergraph/openglnode.h"
#include "util/class.h"
#include "waveform/renderers/allshader/waveformrenderer.h"

namespace allshader {
class WaveformRenderBackground;
}

class allshader::WaveformRenderBackground final : public allshader::WaveformRenderer {
class allshader::WaveformRenderBackground final
: public allshader::WaveformRenderer,
public rendergraph::OpenGLNode {
public:
explicit WaveformRenderBackground(WaveformWidgetRenderer* waveformWidgetRenderer);

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

private:
Expand Down
1 change: 0 additions & 1 deletion src/waveform/renderers/allshader/waveformrenderbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ WaveformRenderBeat::WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget,
}

void WaveformRenderBeat::initializeGL() {
WaveformRenderer::initializeGL();
m_shader.init();
}

Expand Down
7 changes: 5 additions & 2 deletions src/waveform/renderers/allshader/waveformrenderbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <QColor>

#include "rendergraph/openglnode.h"
#include "shaders/unicolorshader.h"
#include "util/class.h"
#include "waveform/renderers/allshader/vertexdata.h"
Expand All @@ -14,13 +15,15 @@ namespace allshader {
class WaveformRenderBeat;
}

class allshader::WaveformRenderBeat final : public allshader::WaveformRenderer {
class allshader::WaveformRenderBeat final
: public allshader::WaveformRenderer,
public rendergraph::OpenGLNode {
public:
explicit WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::PositionSource type =
::WaveformRendererAbstract::Play);

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

Expand Down
16 changes: 1 addition & 15 deletions src/waveform/renderers/allshader/waveformrenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "waveform/renderers/allshader/waveformrendererabstract.h"
#include "waveform/renderers/waveformrendererabstract.h"

class WaveformWidgetRenderer;
Expand All @@ -9,8 +8,7 @@ namespace allshader {
class WaveformRenderer;
}

class allshader::WaveformRenderer : public ::WaveformRendererAbstract,
public allshader::WaveformRendererAbstract {
class allshader::WaveformRenderer : public ::WaveformRendererAbstract {
public:
explicit WaveformRenderer(WaveformWidgetRenderer* widget);

Expand All @@ -21,16 +19,4 @@ class allshader::WaveformRenderer : public ::WaveformRendererAbstract,
// QOpenGLWindow has bad performance), we leave this empty.
// Should never be called.
void draw(QPainter* painter, QPaintEvent* event) override final;

allshader::WaveformRendererAbstract* allshaderWaveformRenderer() override final {
// This class is indirectly derived from
// WaveformWidgetRenderer, which has a member
// QList<allshader::WaveformRendererAbstract*> m_rendererStack;
// In the case of allshader::WaveformRenderer widgets,
// all the items on this stack are derived from
// allshader::WaveformRendererAbstract and we use this method to
// access them as such. (We could also have used a
// dynamic cast (or even static cast instead)
return this;
}
};
26 changes: 0 additions & 26 deletions src/waveform/renderers/allshader/waveformrendererabstract.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void WaveformRendererEndOfTrack::setup(const QDomNode& node, const SkinContext&
}

void WaveformRendererEndOfTrack::initializeGL() {
WaveformRenderer::initializeGL();
m_shader.init();
}

Expand Down
7 changes: 5 additions & 2 deletions src/waveform/renderers/allshader/waveformrendererendoftrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QColor>
#include <memory>

#include "rendergraph/openglnode.h"
#include "shaders/endoftrackshader.h"
#include "util/class.h"
#include "util/performancetimer.h"
Expand All @@ -16,12 +17,14 @@ namespace allshader {
class WaveformRendererEndOfTrack;
}

class allshader::WaveformRendererEndOfTrack final : public allshader::WaveformRenderer {
class allshader::WaveformRendererEndOfTrack final
: public allshader::WaveformRenderer,
public rendergraph::OpenGLNode {
public:
explicit WaveformRendererEndOfTrack(
WaveformWidgetRenderer* waveformWidget);

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

bool init() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void WaveformRendererFiltered::onSetup(const QDomNode& node) {
}

void WaveformRendererFiltered::initializeGL() {
WaveformRendererSignalBase::initializeGL();
m_shader.init();
}

Expand Down
5 changes: 4 additions & 1 deletion src/waveform/renderers/allshader/waveformrendererfiltered.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "rendergraph/openglnode.h"
#include "shaders/unicolorshader.h"
#include "util/class.h"
#include "waveform/renderers/allshader/vertexdata.h"
Expand All @@ -9,7 +10,9 @@ namespace allshader {
class WaveformRendererFiltered;
}

class allshader::WaveformRendererFiltered final : public allshader::WaveformRendererSignalBase {
class allshader::WaveformRendererFiltered final
: public allshader::WaveformRendererSignalBase,
public rendergraph::OpenGLNode {
public:
explicit WaveformRendererFiltered(WaveformWidgetRenderer* waveformWidget, bool rgbStacked);

Expand Down
1 change: 0 additions & 1 deletion src/waveform/renderers/allshader/waveformrendererhsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void WaveformRendererHSV::onSetup(const QDomNode& node) {
}

void WaveformRendererHSV::initializeGL() {
WaveformRendererSignalBase::initializeGL();
m_shader.init();
}

Expand Down
5 changes: 4 additions & 1 deletion src/waveform/renderers/allshader/waveformrendererhsv.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "rendergraph/openglnode.h"
#include "shaders/rgbshader.h"
#include "util/class.h"
#include "waveform/renderers/allshader/rgbdata.h"
Expand All @@ -10,7 +11,9 @@ namespace allshader {
class WaveformRendererHSV;
}

class allshader::WaveformRendererHSV final : public allshader::WaveformRendererSignalBase {
class allshader::WaveformRendererHSV final
: public allshader::WaveformRendererSignalBase,
public rendergraph::OpenGLNode {
public:
explicit WaveformRendererHSV(WaveformWidgetRenderer* waveformWidget);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void WaveformRendererPreroll::setup(
}

void WaveformRendererPreroll::initializeGL() {
WaveformRenderer::initializeGL();
m_shader.init();
}

Expand Down
10 changes: 6 additions & 4 deletions src/waveform/renderers/allshader/waveformrendererpreroll.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QImage>
#include <memory>

#include "rendergraph/openglnode.h"
#include "shaders/patternshader.h"
#include "util/class.h"
#include "util/opengltexture2d.h"
Expand All @@ -16,18 +17,19 @@ class QOpenGLTexture;

namespace allshader {
class WaveformRendererPreroll;
class WaveformRendererSlipPreroll;
}

class allshader::WaveformRendererPreroll : public allshader::WaveformRenderer {
class allshader::WaveformRendererPreroll final
: public allshader::WaveformRenderer,
public rendergraph::OpenGLNode {
public:
explicit WaveformRendererPreroll(
WaveformWidgetRenderer* waveformWidgetRenderer,
WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::PositionSource type =
::WaveformRendererAbstract::Play);
~WaveformRendererPreroll() override;

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

Expand Down
1 change: 0 additions & 1 deletion src/waveform/renderers/allshader/waveformrendererrgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ void WaveformRendererRGB::onSetup(const QDomNode& node) {
}

void WaveformRendererRGB::initializeGL() {
WaveformRendererSignalBase::initializeGL();
m_shader.init();
}

Expand Down
5 changes: 4 additions & 1 deletion src/waveform/renderers/allshader/waveformrendererrgb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "rendergraph/openglnode.h"
#include "shaders/rgbshader.h"
#include "util/class.h"
#include "waveform/renderers/allshader/rgbdata.h"
Expand All @@ -10,7 +11,9 @@ namespace allshader {
class WaveformRendererRGB;
}

class allshader::WaveformRendererRGB final : public allshader::WaveformRendererSignalBase {
class allshader::WaveformRendererRGB final
: public allshader::WaveformRendererSignalBase,
public rendergraph::OpenGLNode {
public:
explicit WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::PositionSource type =
Expand Down
12 changes: 10 additions & 2 deletions src/waveform/renderers/allshader/waveformrenderersignalbase.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#include "waveform/renderers/allshader/waveformrenderersignalbase.h"

using namespace allshader;
namespace allshader {

allshader::WaveformRendererSignalBase::WaveformRendererSignalBase(
WaveformRendererSignalBase::WaveformRendererSignalBase(
WaveformWidgetRenderer* waveformWidget)
: ::WaveformRendererSignalBase(waveformWidget) {
}

void WaveformRendererSignalBase::draw(QPainter* painter, QPaintEvent* event) {
Q_UNUSED(painter);
Q_UNUSED(event);
DEBUG_ASSERT(false);
}

} // namespace allshader
15 changes: 3 additions & 12 deletions src/waveform/renderers/allshader/waveformrenderersignalbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <limits>

#include "util/class.h"
#include "waveform/renderers/allshader/waveformrendererabstract.h"
#include "waveform/renderers/waveformrenderersignalbase.h"

class WaveformWidgetRenderer;
Expand All @@ -13,8 +12,7 @@ namespace allshader {
class WaveformRendererSignalBase;
}

class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBase,
public allshader::WaveformRendererAbstract {
class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBase {
public:
enum class Option {
None = 0b0,
Expand All @@ -24,6 +22,8 @@ class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBas
};
Q_DECLARE_FLAGS(Options, Option)

void draw(QPainter* painter, QPaintEvent* event) override final;

static constexpr float m_maxValue{static_cast<float>(std::numeric_limits<uint8_t>::max())};

explicit WaveformRendererSignalBase(WaveformWidgetRenderer* waveformWidget);
Expand All @@ -32,14 +32,5 @@ class allshader::WaveformRendererSignalBase : public ::WaveformRendererSignalBas
return false;
}

void draw(QPainter* painter, QPaintEvent* event) override {
Q_UNUSED(painter);
Q_UNUSED(event);
}

allshader::WaveformRendererAbstract* allshaderWaveformRenderer() override {
return this;
}

DISALLOW_COPY_AND_ASSIGN(WaveformRendererSignalBase);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ void WaveformRendererSimple::onSetup(const QDomNode& node) {
}

void WaveformRendererSimple::initializeGL() {
WaveformRendererSignalBase::initializeGL();
m_shader.init();
}

Expand Down
5 changes: 4 additions & 1 deletion src/waveform/renderers/allshader/waveformrenderersimple.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "rendergraph/openglnode.h"
#include "shaders/unicolorshader.h"
#include "util/class.h"
#include "waveform/renderers/allshader/vertexdata.h"
Expand All @@ -9,7 +10,9 @@ namespace allshader {
class WaveformRendererSimple;
}

class allshader::WaveformRendererSimple final : public allshader::WaveformRendererSignalBase {
class allshader::WaveformRendererSimple final
: public allshader::WaveformRendererSignalBase,
public rendergraph::OpenGLNode {
public:
explicit WaveformRendererSimple(WaveformWidgetRenderer* waveformWidget);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void WaveformRendererSlipMode::setup(const QDomNode& node, const SkinContext& co
}

void WaveformRendererSlipMode::initializeGL() {
WaveformRenderer::initializeGL();
m_shader.init();
}

Expand Down
Loading

0 comments on commit 17883f9

Please sign in to comment.