Skip to content

Commit

Permalink
Plotter and waterfall performance enhancements (#1383)
Browse files Browse the repository at this point in the history
* cache meter font

* cache peak circles

* sliding window waterfall implementation

* use polygons for fills

* prevent rounding errors

* avoid duplicate fills on mac

* stop using alpha composition

* use precomputed solid colors

* static allocation

* opaque drawing without background fills

* prevent extra redraws on meter

* add to authors list

* fix fills

* fix centering on peak pixmap

* use two draws for waterfall

* fix no plotter case

* fix peak alignment
  • Loading branch information
yuzawa-san authored Oct 19, 2024
1 parent ab349b4 commit bf40e76
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 83 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ The following people and organisations have contributed to gqrx:
* Grigory Shipunov
* Gwenhael Goavec-Merou
* Herman Semenov
* James Yuzawa
* Jaroslav Škarvada
* Jeff Long
* Jiawei Chen
Expand Down
5 changes: 1 addition & 4 deletions src/applications/gqrx/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set>
</property>
<property name="unifiedTitleAndToolBarOnMac">
<bool>true</bool>
<bool>false</bool>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -349,9 +349,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
Expand Down
18 changes: 11 additions & 7 deletions src/qtgui/meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ CMeter::CMeter(QWidget *parent) : QFrame(parent)

m_dBFS = MIN_DB;
m_Sql = -150.0;
m_font = QFont("Arial");
}

CMeter::~CMeter()
Expand All @@ -71,9 +72,14 @@ QSize CMeter::sizeHint() const

void CMeter::setLevel(float dbfs)
{
const float old = m_dBFS;
float alpha = dbfs < m_dBFS ? ALPHA_DECAY : ALPHA_RISE;
m_dBFS -= alpha * (m_dBFS - dbfs);
update();
// only redraw when the label needs to change
if (qRound(m_dBFS * 10) != qRound(old * 10))
{
update();
}
}

void CMeter::setSqlLevel(float dbfs)
Expand Down Expand Up @@ -116,9 +122,8 @@ void CMeter::draw(QPainter &painter)
painter.drawLine(QLineF(x, hline, x, hline + 8));
}

QFont font("Arial");
font.setPixelSize(height() / 4);
painter.setFont(font);
m_font.setPixelSize(height() / 4);
painter.setFont(m_font);

painter.setPen(QColor(0xDA, 0xDA, 0xDA, 0xFF));
painter.drawText(marg, height() - 2, QString::number((double)m_dBFS, 'f', 1) + " dBFS" );
Expand Down Expand Up @@ -148,9 +153,8 @@ void CMeter::drawOverlay(QPainter &painter)
}

// draw scale text
QFont font("Arial");
font.setPixelSize(height() / 4);
painter.setFont(font);
m_font.setPixelSize(height() / 4);
painter.setFont(m_font);
qreal rwidth = (hstop - marg) / 5.0;
QRectF rect(marg - rwidth / 2, 0, rwidth, majstart);

Expand Down
1 change: 1 addition & 0 deletions src/qtgui/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ public slots:

float m_dBFS;
float m_Sql;
QFont m_font;
};
Loading

0 comments on commit bf40e76

Please sign in to comment.