Kstars

pixcache.cpp
1 /*
2  SPDX-FileCopyrightText: 2015-2017 Pavel Mraz
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "pixcache.h"
8 
9 static int qHash(const pixCacheKey_t &key, uint seed)
10 {
11  return qHash(QString("%1_%2_%3").arg(key.level).arg(key.pix).arg(key.uid), seed);
12 }
13 
14 inline bool operator<(const pixCacheKey_t &k1, const pixCacheKey_t &k2)
15 {
16  if (k1.uid != k2.uid)
17  {
18  return k1.uid < k2.uid;
19  }
20 
21  if (k1.level != k2.level)
22  {
23  return k1.level < k2.level;
24  }
25 
26  return k1.pix < k2.pix;
27 }
28 
29 inline bool operator==(const pixCacheKey_t &k1, const pixCacheKey_t &k2)
30 {
31  return (k1.uid == k2.uid) && (k1.level == k2.level) && (k1.pix == k2.pix);
32 }
33 
34 void PixCache::add(pixCacheKey_t &key, pixCacheItem_t *item, int cost)
35 {
36  Q_ASSERT(cost < m_cache.maxCost());
37 
38  m_cache.insert(key, item, cost);
39 }
40 
41 pixCacheItem_t *PixCache::get(pixCacheKey_t &key)
42 {
43  return m_cache.object(key);
44 }
45 
46 void PixCache::setMaxCost(int maxCost)
47 {
48  m_cache.setMaxCost(maxCost);
49 }
50 
51 void PixCache::printCache()
52 {
53  qDebug() << Q_FUNC_INFO << " -- cache ---------------";
54  qDebug() << Q_FUNC_INFO << m_cache.size() << m_cache.totalCost() << m_cache.maxCost();
55 }
56 
57 int PixCache::used()
58 {
59  return m_cache.totalCost();
60 }
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
virtual QVariant get(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 04:04:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.