src/hbservers/hbthemeserver/hbicondatacache_p.h
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbServers module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #ifndef HBICONDATACACHE_P_H
       
    27 #define HBICONDATACACHE_P_H
       
    28 
       
    29 #include <QHash>
       
    30 #include "hbthemeserverutils_p.h"
       
    31 #include "hbiconcacheitemcreator_p.h"
       
    32 
       
    33 class HbIconDataCache
       
    34 {
       
    35 
       
    36 public:
       
    37     HbIconDataCache();
       
    38     ~HbIconDataCache();
       
    39     void clear();
       
    40     HbIconCacheItem* getCacheItem(const HbIconKey &key ,
       
    41                                   bool isMultiIconPiece = false);
       
    42     bool insert(const HbIconKey &key,  HbIconCacheItem* item);
       
    43     bool remove(const HbIconKey&  key);
       
    44     void setMaxGpuCacheSize(int size);
       
    45     void setMaxCpuCacheSize(int size);
       
    46     bool contains(const HbIconKey &key) const;
       
    47     HbIconCacheItem* value(const HbIconKey &key) const;
       
    48     bool isItemCachableInGpu(const HbIconCacheItem* item)const;
       
    49     bool isItemCachableInCpu(const HbIconCacheItem* item)const;
       
    50     void memoryGood();
       
    51     void freeGpuRam(int bytes);
       
    52 
       
    53 //Debug Code for Test Purpose
       
    54 #ifdef HB_ICON_CACHE_DEBUG
       
    55     void cleanVectorLRUList();
       
    56     void cleanRasterLRUList();
       
    57     int count() const;
       
    58     int freeVectorMemory();
       
    59     int freeRasterMemory();
       
    60     int lastAddedRefCount();
       
    61     int lastAddedItemMem();
       
    62     int lastRemovedItemMem();
       
    63     int lastRemovedItemRfCount();
       
    64     bool enableCache(bool cacheIt);
       
    65     int cacheHitCount();
       
    66     int cacheMissCount();
       
    67     int rasterLruCount();
       
    68     int vectorLruCount();
       
    69     int gpuLRUSize() const;
       
    70 #endif
       
    71 
       
    72 private:
       
    73 
       
    74     void createGpuCacheSpace(int itemCost);
       
    75     void createCpuCacheSpace(int itemCost);
       
    76     void updateGpuLruSize(int iconDataCost);
       
    77     void updateCpuLruSize(int iconDataCost);
       
    78     //Debug Code for Test Purpose
       
    79 #ifdef HB_ICON_CACHE_DEBUG
       
    80     void removeFromCache(const HbIconKey &key, const HbIconCacheItem* releaseItem);
       
    81     void releaseVectorItem(HbIconCacheItem* releaseItem);
       
    82     void releaseRasterItem(HbIconCacheItem* releaseItem);
       
    83 #endif
       
    84 
       
    85 private:
       
    86     QHash<HbIconKey, HbIconCacheItem*> *cache;
       
    87     HbDLinkList<HbIconCacheItem> gpuLruList;
       
    88     HbDLinkList<HbIconCacheItem> cpuLruList;
       
    89     int currentGpuCacheSize;
       
    90     int currentCpuCacheSize;
       
    91     int gpuLruListSize;
       
    92     int cpuLruListSize;
       
    93     int maxGpuCacheLimit;
       
    94     int maxCpuCacheLimit;
       
    95     bool goodMemory;
       
    96 
       
    97     //Debug Code for Test Purpose
       
    98 #ifdef HB_ICON_CACHE_DEBUG
       
    99     int addedItemRefCount;
       
   100     int addedItemMem;
       
   101     int removedItemMem;
       
   102     int remRfCount;
       
   103     bool enableCaching;
       
   104     int cacheHit;
       
   105     int cacheMiss;
       
   106     int vectorLruListCount;
       
   107     int rasterLruListCount;
       
   108 #endif
       
   109 };
       
   110 #endif // HBICONCACHE_P_H
       
   111