os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/vgimagecache.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef VGIMAGECACHE_H_
    17 #define VGIMAGECACHE_H_
    18 
    19 /**
    20 @file
    21 @internalComponent Reference implementation of Open VG hardware accelerated DirectGDI adaptation.
    22 */
    23 #include <fbs.h>
    24 #include <VG/openvg.h>
    25 #include <e32hashtab.h>
    26 #include <graphics/directgdiextensioninterfaces.h>
    27 
    28 
    29 /**
    30 A class for managing a cache of VGImages.
    31 Each VGImage has a CFbsBitmap associated with it.
    32 The CFbsBitmap's serial number is used to retrieve VGImages from the cache
    33 as these are unique to the bitmap for the lifetime of the system.
    34 */
    35 NONSHARABLE_CLASS(CVgImageCache): public CBase, public MVgImageCache
    36 	{
    37 public:
    38 	CVgImageCache(TInt aMaxCacheSize);
    39 	~CVgImageCache();
    40 	TBool AddImage(const CFbsBitmap& aBitmap, VGImage& aImage, const TPoint& aOrigin);
    41 	VGImage GetVgImageFromBitmap(const CFbsBitmap& aBitmap, const TPoint& aOrigin);
    42 	
    43 	//MVgImageCache commands
    44 	TBool IsInCache(TInt64 aSerialNumber);	/**< @internalTechnology*/
    45 	TInt TouchCount(TInt64 aSerialNumber);	/**< @internalTechnology*/
    46 	TInt NumEntries() const;	/**< @internalTechnology*/
    47 	void GetOrderedCacheEntries(TInt64& aSerialNumberList, TInt aListSize);	/**< @internalTechnology*/
    48 	TInt CacheSizeInBytes() const;	/**< @internalTechnology*/
    49 	TInt MaxCacheSize() const;	/**< @internalTechnology*/
    50 	void ResetCache();	/**< @internalTechnology*/
    51 	TInt SetMaxCacheSize(TInt aMaxCacheSize); /**< @internalTechnology*/
    52 
    53 private:
    54 	NONSHARABLE_CLASS(CVgImageCacheItem): public CBase
    55 		{
    56 		public:
    57 		CVgImageCacheItem();
    58 		~CVgImageCacheItem();
    59 		
    60 		TDblQueLink iLink;
    61 		VGImage iImage;			/**< VGImage created from CFbsBitmap.*/
    62 		TInt64 iSerialNumber;			/**< Bitmap ID used to select VGImage.*/
    63 		TInt iImageSizeInBytes;
    64 		TInt iTouchCount;		/**< Touch count of CFbsBitmap when VGImage was stored.*/
    65 		TPoint iOrigin;			/**< Origin used to tile image when created.*/
    66 		};
    67 	void DeleteItem(CVgImageCacheItem* aItem);
    68 	static TUint32 Hash(const TInt64& aKey);
    69 
    70 private:
    71 	RHashMap<TInt64, CVgImageCacheItem*> iCacheItemMap;	/**< Maps bitmap's unique identifier to a cache item.*/
    72 	TDblQue<CVgImageCacheItem> iVgImageCache;	/**< Least-recently used ordered queue (most-recently used at head).*/
    73 	TInt iCacheSizeInBytes;
    74 	TInt iMaxCacheSizeInBytes;
    75 	TInt iNumMatchMisses;	/**< Number of unsuccessful matches when retrieving VGImage from cache.*/
    76 	TInt iNumMatchTries; /**< Number of attempts to retrieve VGImage from cache.*/
    77 	};
    78 
    79 #endif /*VGIMAGECACHE_H_*/