18#ifndef QGSIMAGECACHE_H
19#define QGSIMAGECACHE_H
25#include <QElapsedTimer>
47 QgsImageSizeCacheEntry(
const QString &path );
53 void dump()
const override;
54 bool isEqual(
const QgsAbstractContentCacheEntry *other )
const override;
75 ~QgsImageSizeCache()
override;
76 long maximumSize()
const {
return mMaxCacheSize; }
77 QSize originalSize(
const QString &path,
bool blocking =
false );
100 QgsImageCacheEntry(
const QString &path, QSize size,
bool keepAspectRatio,
double opacity,
double targetDpi,
int frameNumber );
106 bool keepAspectRatio =
true;
109 double opacity = 1.0;
119 bool isMissingImage =
false;
126 double targetDpi = 96;
133 int frameNumber = -1;
140 int totalFrameCount = -1;
147 int nextFrameDelay = -1;
150 void dump()
const override;
151 bool isEqual(
const QgsAbstractContentCacheEntry *other )
const override;
224 const bool keepAspectRatio,
225 const double opacity,
227 bool blocking =
false,
228 double targetDpi = 96,
229 int frameNumber = -1,
248 QSize originalSize(
const QString &path,
bool blocking =
false )
const;
267 int totalFrameCount(
const QString &path,
bool blocking =
false );
287 int nextFrameDelay(
const QString &path,
int currentFrame = 0,
bool blocking =
false );
294 void prepareAnimation(
const QString &path );
304 QImage pathAsImagePrivate(
305 const QString &path,
const QSize size,
const bool keepAspectRatio,
const double opacity,
bool &fitsInCache,
bool blocking,
double targetDpi,
int frameNumber,
bool *isMissing,
int &
totalFrameCount,
int &nextFrameDelayMs
309 const QString &path, QSize size,
const bool keepAspectRatio,
const double opacity,
double targetDpi,
int frameNumber,
bool &isBroken,
int &
totalFrameCount,
int &nextFrameDelayMs,
bool blocking =
false
312 static QImage getFrameFromReader( QImageReader &reader,
int frameNumber );
314 QSize originalSizePrivate(
const QString &path,
bool blocking =
false )
const;
317 QByteArray mMissingSvg;
319 QByteArray mFetchingSvg;
321 QMap< QString, QString > mExtractedAnimationPaths;
322 std::unique_ptr< QTemporaryDir > mTemporaryDir;
323 QMap< QString, int > mTotalFrameCounts;
324 QMap< QString, QVector< int > > mImageDelays;
A QObject derived base class for QgsAbstractContentCache.
Base class for entries in a QgsAbstractContentCache.
virtual int dataSize() const =0
Returns the memory usage in bytes for the entry.
virtual void dump() const =0
Dumps debugging strings containing the item's properties.
virtual bool isEqual(const QgsAbstractContentCacheEntry *other) const =0
Tests whether this entry matches another entry.
Abstract base class for file content caches, such as SVG or raster image caches.
QgsAbstractContentCache(QObject *parent=nullptr, const QString &typeString=QString(), long maxCacheSize=20000000, int fileModifiedCheckTimeout=30000)
A cache for images derived from raster files.
friend class TestQgsImageCache
friend class QgsImageSizeCache
QgsImageCache(QObject *parent=nullptr)
Constructor for QgsImageCache, with the specified parent object.
int totalFrameCount(const QString &path, bool blocking=false)
Returns the total frame count of the image at the specified path.
~QgsImageCache() override
void remoteImageFetched(const QString &url)
Emitted when the cache has finished retrieving an image file from a remote url.
long maximumSize() const
Returns the maximum size of the cache, in bytes.