os/graphics/fbs/fontandbitmapserver/inc/FBSMBMC.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/inc/FBSMBMC.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,89 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This file holds the class declarations for the CFbTopMBMCache 
    1.18 +// The cache is used to store the stream ids of bitmaps in a MBM file
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#ifndef __FBSMBMC_H__
    1.23 +#define __FBSMBMC_H__
    1.24 +
    1.25 +#include <e32std.h>
    1.26 +#include <e32base.h>
    1.27 +#include <s32std.h>
    1.28 +#include "ShiftedFileStore.h"
    1.29 +
    1.30 +
    1.31 +//This class holds the TStreamIds of the bitmaps stored in an MBM file
    1.32 +//and the filestore of the last loaded bitmap file. The idea of the cache
    1.33 +//is to speed up loading of bitmaps from a mbm file by skipping the file
    1.34 +//opening process and mapping the MBM id directly to the Stream ids stored
    1.35 +//in the cache
    1.36 +//
    1.37 +NONSHARABLE_CLASS(CFbTopStreamIdCache): public CBase
    1.38 +	{
    1.39 +public:
    1.40 +	CFbTopStreamIdCache(TInt aForwardSize, TInt aBackwardSize, TInt aMaxFilestores);
    1.41 +	~CFbTopStreamIdCache();
    1.42 +	TStreamId GetStreamIdL(RFile& aFile,const TDesC& aFilename,TInt32 aId,TUint aFileOffset, TInt aSessionHandle);
    1.43 +	TStreamId GetStreamIdL(RFs& aFs,const TDesC& aFilename,TInt32 aId,TUint aFileOffset, TInt aSessionHandle);
    1.44 +	CShiftedFileStore* MruFileStore();
    1.45 +	void FlushCache();
    1.46 +	void CloseFileStores(TInt aSessionHandle=0);	// If aSessionHandle is not passed, all file stores will be closed
    1.47 +
    1.48 +private:
    1.49 +	class RCacheEntry;
    1.50 +	RCacheEntry* AddCacheEntryL(const TDesC& aFilename, TUint aFileOffset);
    1.51 +	RCacheEntry* FindCacheEntry(const TDesC& aFilename, TUint aFileOffset);
    1.52 +
    1.53 +private:
    1.54 +	RPointerArray<RCacheEntry> iEntries;	// Array of pointers to the cache entries in least-recently-used order
    1.55 +	TUint8* iBuffer;						// Buffer for storage of the cache entries
    1.56 +	const TInt iForwardCacheSize;			// Max number of cached bitmap ids after the last requested bitmap id
    1.57 +	const TInt iBackwardCacheSize;			// Max number of cached bitmap ids before the last requested bitmap id
    1.58 +	const TInt iMaxCacheFilestores;			// Max number of filestores in the cache
    1.59 +
    1.60 +	friend class CTStreamIdCache;			// This is used for testing purposes
    1.61 +	};
    1.62 +
    1.63 +
    1.64 +class CFbTopStreamIdCache::RCacheEntry
    1.65 +	{
    1.66 +public:
    1.67 +	RCacheEntry(const TDesC& aFilename, TUint aFileOffset);
    1.68 +	TBool SameFile(const TDesC& aFilename, TUint aFileOffset);
    1.69 +	TStreamId GetStreamIdL(TInt32 aId, TInt aForwardSize, TInt aBackwardSize);
    1.70 +	CShiftedFileStore* FileStore();
    1.71 +	void CloseFileStore();
    1.72 +	TInt SessionHandle() const;
    1.73 +	void CreateFileStoreL(RFile& aFile, TInt aSessionHandle);
    1.74 +	void CreateFileStoreL(RFs& aFs, const TDesC& aFilename, TInt aSessionHandle);
    1.75 +public:
    1.76 +	static const TInt KBaseSize;		// Size of the class excluding array iStreamIdCache
    1.77 +
    1.78 +private:
    1.79 +	TBufC<KMaxFileName>	iFilename;		// Name of the mbm file
    1.80 +	TUint iFileOffset;					// Offset into the mbm file
    1.81 +	CShiftedFileStore *iFilestore;		// File store for the mbm file
    1.82 +	TInt iLastId;						// Last requested bitmap id from the mbm file
    1.83 +	TInt iStreamIdCount;				// Number of stream ids from the mbm file
    1.84 +	TInt iSessionHandle;				// Handle to the associated client session
    1.85 +
    1.86 +	// Keep always iStreamIdCache as the last data member
    1.87 +	// Memory for it is allocated in CFbTopStreamIdCache::AddCacheEntryL()
    1.88 +	TStreamId iStreamIdCache[1];		// Array of stream ids from the mbm file
    1.89 +
    1.90 +	friend class CTStreamIdCache;		// This is used for testing purposes
    1.91 +	};
    1.92 +#endif