MythTV  master
mythuithemecache.h
Go to the documentation of this file.
1 #ifndef MYTHUICACHE_H
2 #define MYTHUICACHE_H
3 
4 // Qt
5 #include <QMap>
6 #include <QRecursiveMutex>
7 
8 // MythTV
10 #include "libmythui/mythimage.h"
11 
12 enum ImageCacheMode : std::uint8_t
13 {
14  kCacheNormal = 0x0,
18 };
19 
20 class MThreadPool;
21 
23 {
24  public:
27 
28  void UpdateImageCache();
29  void SetScreenSize(QSize Size);
30  void ClearThemeCacheDir();
31  QString GetThemeCacheDir();
32  MythImage* LoadCacheImage(QString File, const QString& Label,
33  MythPainter* Painter, ImageCacheMode cacheMode = kCacheNormal);
34  MythImage* CacheImage(const QString& URL, MythImage* Image, bool NoDisk = false);
35  void RemoveFromCacheByFile(const QString& File);
36  bool IsImageInCache(const QString& URL);
37  void IncludeInCacheSize(MythImage* Image);
38  void ExcludeFromCacheSize(MythImage* Image);
39  MThreadPool* GetImageThreadPool();
40 
41  private:
42  QString GetCacheDirByUrl(const QString& URL);
43  void RemoveFromCacheByURL(const QString& URL);
44  MythImage* GetImageFromCache(const QString& URL);
45  void ClearOldImageCache();
46  void RemoveCacheDir(const QString& Dir);
47  static void PruneCacheDir(const QString& Dir);
48 
49  QMap<QString, MythImage *> m_imageCache;
50  QMap<QString, SystemTime> m_cacheTrack;
51  QRecursiveMutex m_cacheLock;
52  QAtomicInteger<qint64> m_cacheSize { 0 };
53  QAtomicInteger<qint64> m_maxCacheSize { 30LL * 1024 * 1024 };
54  QString m_themecachedir;
56  MThreadPool* m_imageThreadPool { nullptr };
57 };
58 
59 #endif
ImageCacheMode
ImageCacheMode
Definition: mythuithemecache.h:12
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythUIThemeCache::m_cacheScreenSize
QSize m_cacheScreenSize
Definition: mythuithemecache.h:55
MythUIThemeCache::m_imageCache
QMap< QString, MythImage * > m_imageCache
Definition: mythuithemecache.h:49
MythUIThemeCache
Definition: mythuithemecache.h:22
kCacheForceStat
@ kCacheForceStat
Definition: mythuithemecache.h:17
kCacheNormal
@ kCacheNormal
Definition: mythuithemecache.h:14
MythUIThemeCache::m_themecachedir
QString m_themecachedir
Definition: mythuithemecache.h:54
MythUIThemeCache::m_cacheLock
QRecursiveMutex m_cacheLock
Definition: mythuithemecache.h:51
kCacheCheckMemoryOnly
@ kCacheCheckMemoryOnly
Definition: mythuithemecache.h:16
MThreadPool
Definition: mthreadpool.h:18
mythimage.h
MythPainter
Definition: mythpainter.h:34
MythImage
Definition: mythimage.h:36
mythchrono.h
MythUIThemeCache::m_cacheTrack
QMap< QString, SystemTime > m_cacheTrack
Definition: mythuithemecache.h:50
kCacheIgnoreDisk
@ kCacheIgnoreDisk
Definition: mythuithemecache.h:15