40 #define Q_TEST_QPIXMAPCACHE
94 static const int cache_limit_default = 10240;
101 const qint64 costMax = std::numeric_limits<qsizetype>::max();
103 return static_cast<qsizetype>(qBound(1LL, costKb, costMax));
106 static inline bool qt_pixmapcache_thread_test()
149 if (
d && --(
d->ref) == 0)
194 return d &&
d->isValid;
205 if (
d && --(
d->ref) == 0)
226 void resizeKeyArray(
int size);
239 bool flushDetachedPixmaps(
bool nt);
242 enum { soon_time = 10000, flush_time = 30000 };
253 #include "qpixmapcache.moc"
259 return qHash(keyData ? keyData->key : 0, seed);
265 keyArray(
nullptr), theid(0),
ps(0), keyArraySize(0), freeKey(0),
t(
false)
293 setMaxCost(nt ? currentTotal * 3 / 4 : currentTotal - 1);
299 while (
it != cacheKeys.
end()) {
319 }
else if (nt !=
t) {
321 theid =
startTimer(nt ? soon_time : flush_time);
330 if (!cacheKey.d || !cacheKey.d->
isValid) {
411 if (cacheKey == cacheKeys.
constEnd())
414 cacheKeys.
erase(cacheKey);
425 if (
size <= keyArraySize ||
size == 0)
427 keyArray = q_check_ptr(
static_cast<int *
>(realloc(keyArray,
428 size *
sizeof(
int))));
429 for (
int i = keyArraySize;
i !=
size; ++
i)
436 if (freeKey == keyArraySize)
439 freeKey = keyArray[
id];
449 if (!keyData || keyData->
key > keyArraySize || keyData->
key <= 0)
452 keyArray[keyData->
key] = freeKey;
453 freeKey = keyData->
key;
468 key.d->isValid =
false;
489 return pm_cache()->size();
494 pm_cache()->releaseKey(
key);
510 if (!qt_pixmapcache_thread_test())
515 return ptr !=
nullptr;
529 if (!qt_pixmapcache_thread_test())
532 if (!
key.d || !
key.d->isValid)
537 return ptr !=
nullptr;
562 if (!qt_pixmapcache_thread_test())
584 if (!qt_pixmapcache_thread_test())
600 if (!qt_pixmapcache_thread_test())
603 if (!
key.d || !
key.d->isValid)
618 if (!qt_pixmapcache_thread_test())
620 return pm_cache()->maxCost();
633 if (!qt_pixmapcache_thread_test())
635 pm_cache()->setMaxCost(
n);
643 if (!qt_pixmapcache_thread_test())
645 pm_cache()->remove(
key);
656 if (!qt_pixmapcache_thread_test())
659 if (!
key.d || !
key.d->isValid)
661 pm_cache()->remove(
key);
673 if (pm_cache.exists())
675 } QT_CATCH(
const std::bad_alloc &) {
681 void QPixmapCache::flushDetachedPixmaps()
683 if (!qt_pixmapcache_thread_test())
685 pm_cache()->flushDetachedPixmaps(
true);
688 int QPixmapCache::totalUsed()
690 if (!qt_pixmapcache_thread_test())
692 return (pm_cache()->totalCost()+1023) / 1024;
small capitals from c petite p scientific i
[1]
bool remove(const Key &key) noexcept(std::is_nothrow_destructible_v< Node >)
void setMaxCost(qsizetype m) noexcept(std::is_nothrow_destructible_v< Node >)
bool contains(const QPixmapCache::Key &key) const noexcept
qsizetype maxCost() const noexcept
qsizetype totalCost() const noexcept
T * object(const Key &key) const noexcept
qsizetype size() const noexcept
void clear() noexcept(std::is_nothrow_destructible_v< Node >)
bool insert(const Key &key, T *object, qsizetype cost=1)
QList< QPixmapCache::Key > keys() const
static QCoreApplication * instance()
static bool closingDown()
bool remove(const Key &key)
const_iterator constFind(const Key &key) const noexcept
const_iterator constEnd() const noexcept
iterator erase(const_iterator it)
T value(const Key &key) const noexcept
The QObject class is the base class of all Qt objects.
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
bool remove(const QString &key)
bool insert(const QString &key, const QPixmap &pixmap, int cost)
void releaseKey(const QPixmapCache::Key &key)
static QPixmapCache::KeyData * getKeyData(QPixmapCache::Key *key)
bool flushDetachedPixmaps(bool nt)
static QPixmapCache::KeyData * get(const QPixmapCache::Key &key)
QPixmap * object(const QString &key) const
void resizeKeyArray(int size)
QPixmapCache::Key createKey()
bool replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost)
void timerEvent(QTimerEvent *) override
The QPixmapCache::Key class can be used for efficient access to the QPixmapCache. \inmodule QtGui.
Key & operator=(Key &&other) noexcept
bool isValid() const noexcept
bool operator==(const Key &key) const
The QPixmapCache class provides an application-wide cache for pixmaps.
static bool find(const QString &key, QPixmap *pixmap)
static void remove(const QString &key)
static bool insert(const QString &key, const QPixmap &pixmap)
static void setCacheLimit(int)
static bool replace(const Key &key, const QPixmap &pixmap)
The QPixmap class is an off-screen image representation that can be used as a paint device.
The QString class provides a Unicode character string.
static QThread * currentThread()
The QTimerEvent class contains parameters that describe a timer event.
QRhiGraphicsPipeline * ps
auto it unsigned count const
EGLOutputLayerEXT EGLint EGLAttrib value
#define QT_BEGIN_INCLUDE_NAMESPACE
#define Q_AUTOTEST_EXPORT
#define QT_END_INCLUDE_NAMESPACE
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLenum GLuint GLintptr GLsizeiptr size
[1]
int Q_AUTOTEST_EXPORT q_QPixmapCache_keyHashSize()
QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE size_t qHash(const QPixmapCache::Key &k, size_t seed)