profile: cache pixmaps for dive event items

For better scalability, we might replace the dive event icons
by SVGs. Since rendering SVGs is potentially very slow, cache
the pixmaps when the scene is generated.

Note: this does not yet do any SVG rendering, only the caching
of pixmaps.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-08-30 21:11:11 +02:00 committed by Dirk Hohndel
parent 9e20cb5a49
commit f82ae2be7f
9 changed files with 163 additions and 57 deletions

View file

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef DIVEPIXMAPCACHE_H
#define DIVEPIXMAPCACHE_H
#include <QPixmap>
#include <memory>
#include <vector>
// Since (some) pixmaps are rendered from SVG, which may be very slow,
// cache them once per ProfileScene. Different ProfileScenes may have
// different pixmap sizes. Scenes are created rarely (once per print
// job or UI window), so it should be fine to render the pixmaps
// on construction.
struct DivePixmaps {
int dpr;
QPixmap warning;
QPixmap info;
QPixmap violation;
QPixmap bailout;
QPixmap onCCRLoop;
QPixmap bookmark;
QPixmap gaschangeTrimixICD;
QPixmap gaschangeTrimix;
QPixmap gaschangeAirICD;
QPixmap gaschangeAir;
QPixmap gaschangeOxygenICD;
QPixmap gaschangeOxygen;
QPixmap gaschangeEANICD;
QPixmap gaschangeEAN;
QPixmap transparent;
~DivePixmaps();
DivePixmaps(int dpr);
};
// Note: This is NOT thread safe. Must be called from UI thread!
extern std::shared_ptr<const DivePixmaps> getDivePixmaps(double dpr);
#endif