sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef VGIMAGECACHE_H_ sl@0: #define VGIMAGECACHE_H_ sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent Reference implementation of Open VG hardware accelerated DirectGDI adaptation. sl@0: */ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: /** sl@0: A class for managing a cache of VGImages. sl@0: Each VGImage has a CFbsBitmap associated with it. sl@0: The CFbsBitmap's serial number is used to retrieve VGImages from the cache sl@0: as these are unique to the bitmap for the lifetime of the system. sl@0: */ sl@0: NONSHARABLE_CLASS(CVgImageCache): public CBase, public MVgImageCache sl@0: { sl@0: public: sl@0: CVgImageCache(TInt aMaxCacheSize); sl@0: ~CVgImageCache(); sl@0: TBool AddImage(const CFbsBitmap& aBitmap, VGImage& aImage, const TPoint& aOrigin); sl@0: VGImage GetVgImageFromBitmap(const CFbsBitmap& aBitmap, const TPoint& aOrigin); sl@0: sl@0: //MVgImageCache commands sl@0: TBool IsInCache(TInt64 aSerialNumber); /**< @internalTechnology*/ sl@0: TInt TouchCount(TInt64 aSerialNumber); /**< @internalTechnology*/ sl@0: TInt NumEntries() const; /**< @internalTechnology*/ sl@0: void GetOrderedCacheEntries(TInt64& aSerialNumberList, TInt aListSize); /**< @internalTechnology*/ sl@0: TInt CacheSizeInBytes() const; /**< @internalTechnology*/ sl@0: TInt MaxCacheSize() const; /**< @internalTechnology*/ sl@0: void ResetCache(); /**< @internalTechnology*/ sl@0: TInt SetMaxCacheSize(TInt aMaxCacheSize); /**< @internalTechnology*/ sl@0: sl@0: private: sl@0: NONSHARABLE_CLASS(CVgImageCacheItem): public CBase sl@0: { sl@0: public: sl@0: CVgImageCacheItem(); sl@0: ~CVgImageCacheItem(); sl@0: sl@0: TDblQueLink iLink; sl@0: VGImage iImage; /**< VGImage created from CFbsBitmap.*/ sl@0: TInt64 iSerialNumber; /**< Bitmap ID used to select VGImage.*/ sl@0: TInt iImageSizeInBytes; sl@0: TInt iTouchCount; /**< Touch count of CFbsBitmap when VGImage was stored.*/ sl@0: TPoint iOrigin; /**< Origin used to tile image when created.*/ sl@0: }; sl@0: void DeleteItem(CVgImageCacheItem* aItem); sl@0: static TUint32 Hash(const TInt64& aKey); sl@0: sl@0: private: sl@0: RHashMap iCacheItemMap; /**< Maps bitmap's unique identifier to a cache item.*/ sl@0: TDblQue iVgImageCache; /**< Least-recently used ordered queue (most-recently used at head).*/ sl@0: TInt iCacheSizeInBytes; sl@0: TInt iMaxCacheSizeInBytes; sl@0: TInt iNumMatchMisses; /**< Number of unsuccessful matches when retrieving VGImage from cache.*/ sl@0: TInt iNumMatchTries; /**< Number of attempts to retrieve VGImage from cache.*/ sl@0: }; sl@0: sl@0: #endif /*VGIMAGECACHE_H_*/