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

Library: add overview column #13638

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Sep 8, 2024

This is based on @ninomp's initial POC commit 9932cfc
https://github.com/ninomp/mixxx/tree/overviewsinlibrary

I removed the disabled parts and added some TODOs/concerns.
(I'll split up some of the commits so it's a bit easier to review)
image

  • all overview renderers are now in src/waveform/overviews, i.e. WOverView and OverviewDelegate use the same renderer
    (I adopted the RGB simplifications made by @Nino MP, and simplified the others, too)
  • the renderer selected for the decks is also used in the library (incl. live update when changing it in the preferences)

Peforms nicely, though I bet some parts can be optimized.
For example, why pass a mixxx::DbConnectionPoolPtr to static FutureResult OverviewCache::prepareOverview to create a AnyalysisDAO for each request, and not a AnyalysisDAO pointer (probably in TrackCollection)?

@ninomp
Copy link
Contributor

ninomp commented Sep 9, 2024

For example, why pass a mixxx::DbConnectionPoolPtr to static FutureResult OverviewCache::prepareOverview to create a AnyalysisDAO for each request, and not a AnyalysisDAO pointer (probably in TrackCollection)?

IIUC Each thread needs its own database connection, we cannot share/reuse them. Actually, I'm currently experimenting with using a dedicated thread to render overviews. I'll comment back when I get it working.

@ywwg
Copy link
Member

ywwg commented Sep 9, 2024

I will def review this when you think it's ready for a look

@ronso0 ronso0 force-pushed the lib-overview-column-ro branch 2 times, most recently from 2fe92b6 to 132976a Compare September 9, 2024 08:45
@ronso0
Copy link
Member Author

ronso0 commented Sep 9, 2024

I will def review this when you think it's ready for a look

In case you refer to this PR (thanks!), I think it's better to wait for @ninomp's update.
I did this primarily to get it working for myself so I can test it in my live builds. (should probably add some VERIFY_OR_DEBUG_ASSERT here and there, just in case.. 😆 )

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this needs a bunch of work before I trust it...

Comment on lines +1227 to +1229
if (row == -1) {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed here but not in slotOverviewChanged?

column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_WAVESUMMARYHEX) ||
// column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_WAVESUMMARYHEX) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove completely, right?

Comment on lines +21 to +27
QString pixmapCacheKey(TrackId trackId, QSize size, WOverview::Type type) {
return QString("Overview_%1_%2_%3_%4")
.arg(static_cast<int>(type))
.arg(trackId.toString())
.arg(size.width())
.arg(size.height());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using a string as a cache key is not particularly efficient. a struct with a qHash implementation would be better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think most of this is adopted from CoverArtCache)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?
https://doc.qt.io/qt-6/qpixmapcache-key.html#details

Use QPixmapCache::insert() to receive an instance of Key generated by the pixmap cache. You can store the key in your own objects for a very efficient one-to-one object-to-pixmap mapping.

Does such a one-to-one map QString <--> Key map/hash make sense performance wise?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, you're right. I didn't see that this was using QPixmapCache internally. The only improvement then is

Suggested change
QString pixmapCacheKey(TrackId trackId, QSize size, WOverview::Type type) {
return QString("Overview_%1_%2_%3_%4")
.arg(static_cast<int>(type))
.arg(trackId.toString())
.arg(size.width())
.arg(size.height());
}
QString pixmapCacheKey(TrackId trackId, QSize size, WOverview::Type type) {
return QStringLiteral("Overview_%1_%2_%3_%4")
.arg(static_cast<int>(type),
trackId.toString(),
size.width(),
size.height());
}

// The transformation mode when scaling images
const Qt::TransformationMode kTransformationMode = Qt::SmoothTransformation;

inline QImage resizeImageSize(const QImage& image, QSize size) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline QImage resizeImageSize(const QImage& image, QSize size) {
QImage resizeImageSize(const QImage& image, QSize size) {

Comment on lines +11 to +14
class WaveformOverviewRenderer : public Singleton<WaveformOverviewRenderer> {
public:
QImage render(ConstWaveformPointer, WOverview::Type type);
void drawWaveformPartRGB(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't have internal state, nor does it need to be a singleton. Consider making this free functions instead and removing the static data. Pass it instead when calling the functions.

@ronso0
Copy link
Member Author

ronso0 commented Sep 9, 2024

@Swiftb0y Thanks for your review, but I'm not inclined to fixup mayself since @ninomp said they would / are about to rework this anyway.

@ninomp Please share your progress early, even if it's rough and dirty.
Thanks!

@ronso0
Copy link
Member Author

ronso0 commented Sep 9, 2024

FYI I'll keep pushing fixups to hopefully make this safer and maybe a bit faster for my own builds.

@ninomp
Copy link
Contributor

ninomp commented Sep 11, 2024

I just created a PR that contains the work I've done in the past week or so: #13644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants