Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

glwaveformrenderbackground #11523

Merged
merged 3 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/waveform/guitick.cpp
src/waveform/renderers/glslwaveformrenderersignal.cpp
src/waveform/renderers/glvsynctestrenderer.cpp
src/waveform/renderers/glwaveformrenderbackground.cpp
src/waveform/renderers/glwaveformrendererfilteredsignal.cpp
src/waveform/renderers/glwaveformrendererrgb.cpp
src/waveform/renderers/glwaveformrenderersimplesignal.cpp
Expand Down
25 changes: 25 additions & 0 deletions src/waveform/renderers/glwaveformrenderbackground.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "waveform/renderers/glwaveformrenderbackground.h"

GLWaveformRenderBackground::GLWaveformRenderBackground(
WaveformWidgetRenderer* waveformWidgetRenderer)
: WaveformRenderBackground(waveformWidgetRenderer) {
}

GLWaveformRenderBackground::~GLWaveformRenderBackground() {
}
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved

#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
void GLWaveformRenderBackground::draw(QPainter* painter, QPaintEvent* /*event*/) {
maybeInitializeGL();

painter->beginNativePainting();
glClearColor(static_cast<float>(m_backgroundColor.redF()),
static_cast<float>(m_backgroundColor.greenF()),
static_cast<float>(m_backgroundColor.blueF()),
1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
painter->endNativePainting();

drawImage(painter);
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
}
#endif
25 changes: 25 additions & 0 deletions src/waveform/renderers/glwaveformrenderbackground.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "waveform/renderers/waveformrenderbackground.h"
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
#include "waveform/renderers/glwaveformrenderer.h"
#endif

class GLWaveformRenderBackground : public WaveformRenderBackground
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
,
public GLWaveformRenderer
#endif
{
public:
explicit GLWaveformRenderBackground(
WaveformWidgetRenderer* waveformWidgetRenderer);
virtual ~GLWaveformRenderBackground();

#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
virtual void draw(QPainter* painter, QPaintEvent* event);
#endif

private:
DISALLOW_COPY_AND_ASSIGN(GLWaveformRenderBackground);
};
20 changes: 15 additions & 5 deletions src/waveform/renderers/waveformrenderbackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ void WaveformRenderBackground::setup(const QDomNode& node,
setDirty(true);
}

void WaveformRenderBackground::draw(QPainter* painter,
QPaintEvent* /*event*/) {
bool WaveformRenderBackground::drawImage(QPainter* painter) {
if (isDirty()) {
generateImage();
}

// If there is no background image, just fill the painter with the
// background color.
if (m_backgroundImage.isNull()) {
painter->fillRect(0, 0, m_waveformRenderer->getWidth(),
m_waveformRenderer->getHeight(), m_backgroundColor);
return;
return false;
}

// since we use opaque widget we need to draw the background !
Expand All @@ -44,6 +41,19 @@ void WaveformRenderBackground::draw(QPainter* painter,
// This produces a white back ground with Linux QT 4.6 QGlWidget and
// Intel i915 driver and has peroformance issues on other setups. See lp:981210
//painter->drawPixmap(QPoint(0, 0), m_backgroundPixmap);

return true;
}

void WaveformRenderBackground::draw(QPainter* painter,
QPaintEvent* /*event*/) {
if (!drawImage(painter)) {
painter->fillRect(0,
0,
m_waveformRenderer->getWidth(),
m_waveformRenderer->getHeight(),
m_backgroundColor);
}
}

void WaveformRenderBackground::generateImage() {
Expand Down
6 changes: 5 additions & 1 deletion src/waveform/renderers/waveformrenderbackground.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ class WaveformRenderBackground : public WaveformRendererAbstract {
virtual void setup(const QDomNode& node, const SkinContext& context);
virtual void draw(QPainter* painter, QPaintEvent* event);

protected:
bool drawImage(QPainter* painter);

QColor m_backgroundColor;

private:
void generateImage();

QString m_backgroundPixmapPath;
QColor m_backgroundColor;
QImage m_backgroundImage;

DISALLOW_COPY_AND_ASSIGN(WaveformRenderBackground);
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/glrgbwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "moc_glrgbwaveformwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/glwaveformrendererrgb.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -18,7 +18,7 @@ GLRGBWaveformWidget::GLRGBWaveformWidget(const QString& group, QWidget* parent)
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/glsimplewaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "moc_glsimplewaveformwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderersimplesignal.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -21,7 +21,7 @@ GLSimpleWaveformWidget::GLSimpleWaveformWidget(const QString& group, QWidget* pa
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/glslwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "moc_glslwaveformwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glslwaveformrenderersignal.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand Down Expand Up @@ -39,7 +39,7 @@ GLSLWaveformWidget::GLSLWaveformWidget(
makeCurrent();
}

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
10 changes: 5 additions & 5 deletions src/waveform/widgets/glvsynctestwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "moc_glvsynctestwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glvsynctestrenderer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderersimplesignal.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -21,10 +21,10 @@ GLVSyncTestWidget::GLVSyncTestWidget(const QString& group, QWidget* parent)
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>(); // 172 µs
// addRenderer<WaveformRendererEndOfTrack>(); // 677 µs 1145 µs (active)
// addRenderer<WaveformRendererPreroll>(); // 652 µs 2034 µs (active)
// addRenderer<WaveformRenderMarkRange>(); // 793 µs
addRenderer<GLWaveformRenderBackground>(); // 172 µs
// addRenderer<WaveformRendererEndOfTrack>(); // 677 µs 1145 µs (active)
// addRenderer<WaveformRendererPreroll>(); // 652 µs 2034 µs (active)
// addRenderer<WaveformRenderMarkRange>(); // 793 µs

#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
addRenderer<GLVSyncTestRenderer>(); // 841 µs // 2271 µs
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/glwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include "moc_glwaveformwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/glwaveformrendererfilteredsignal.h"
#include "waveform/renderers/qtwaveformrendererfilteredsignal.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -23,7 +23,7 @@ GLWaveformWidget::GLWaveformWidget(const QString& group, QWidget* parent)
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/qthsvwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QtDebug>

#include "moc_qthsvwaveformwidget.cpp"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererhsv.h"
Expand All @@ -20,7 +20,7 @@ QtHSVWaveformWidget::QtHSVWaveformWidget(const QString& group, QWidget* parent)
if (QGLContext::currentContext() != context()) {
makeCurrent();
}
addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/qtrgbwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QtDebug>

#include "moc_qtrgbwaveformwidget.cpp"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -22,7 +22,7 @@ QtRGBWaveformWidget::QtRGBWaveformWidget(const QString& group, QWidget* parent)
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/qtsimplewaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "moc_qtsimplewaveformwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/qtwaveformrenderersimplesignal.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -24,7 +24,7 @@ QtSimpleWaveformWidget::QtSimpleWaveformWidget(
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/qtvsynctestwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "moc_qtvsynctestwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/qtvsynctestrenderer.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/qtwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "moc_qtwaveformwidget.cpp"
#include "util/performancetimer.h"
#include "waveform/renderers/glwaveformrenderbackground.h"
#include "waveform/renderers/qtwaveformrendererfilteredsignal.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrendererpreroll.h"
Expand All @@ -23,7 +23,7 @@ QtWaveformWidget::QtWaveformWidget(const QString& group, QWidget* parent)
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();

addRenderer<WaveformRenderBackground>();
addRenderer<GLWaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
addRenderer<WaveformRenderMarkRange>();
Expand Down