fbs/fontandbitmapserver/trasterizer/src/examplerasterizer.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @prototype
       
    20 */
       
    21 
       
    22 #ifndef EXAMPLERASTERIZER_H
       
    23 #define EXAMPLERASTERIZER_H
       
    24 
       
    25 
       
    26 #include <graphics/fbsrasterizer.h>
       
    27 #include <graphics/fbsrasterizerclearcache.h>
       
    28 
       
    29 
       
    30 class RMemReadStream;
       
    31 
       
    32 
       
    33 const TUid KUidExampleExtendedBitmap = {0x10285A78};
       
    34 const TInt KMaxRecentBmpCacheSize = 0x40000; // 256 KB
       
    35 
       
    36 
       
    37 /** Example implementation of a rasterizer that is used to generate pixel
       
    38 data for extended bitmaps of type KUidExampleExtendedBitmap.
       
    39  */
       
    40 class CExampleRasterizer : public CFbsRasterizer, public MFbsRasterizerClearCache
       
    41 	{
       
    42 public:
       
    43 	CExampleRasterizer();
       
    44 	~CExampleRasterizer();
       
    45 
       
    46 	// From CFbsRasterizer
       
    47 	void BeginBitmap(TInt64 aBitmapId, const TBitmapDesc& aBitmapDesc, const TRegion* aRegionOfInterest);
       
    48 	void EndBitmap(TInt64 aBitmapId);
       
    49 	const TUint32* ScanLine(TInt64 aBitmapId, const TPoint& aPixel, TInt aLength);	
       
    50 	TInt GetInterface(TUid aInterfaceId, TAny*& aInterface);
       
    51 	
       
    52 	// From MFbsRasterizerClearCache
       
    53 	void ClearCache();
       
    54 
       
    55 private:
       
    56 	/** Class for holding information about an extended bitmap registered with this rasterizer.
       
    57 	The buffer to store the pre-rendered pixels is allocated in the same heap cell, after the
       
    58 	instance variables, by using the overload of operator new with an extra size parameter.
       
    59 	 */
       
    60 	class CRegisteredBitmap : public CBase
       
    61 		{
       
    62 	public:
       
    63 		CRegisteredBitmap(TInt64 aBitmapId, const TBitmapDesc& aBitmapDesc, TInt aBufLength);
       
    64 		~CRegisteredBitmap();
       
    65 		TInt Draw(RMemReadStream& aReadStream, const TRegion* aRegionOfInterest);
       
    66 		TUint8* Buffer();
       
    67 		
       
    68 	public:
       
    69 		const TInt64 iBitmapId;
       
    70 		const TSize iSizeInPixels;
       
    71 		const TDisplayMode iDispMode;
       
    72 		const TUid iDataType;
       
    73 		const TInt iBufLength;
       
    74 		TDblQueLink iLink;
       
    75 		/** The number of times the bitmap with the ID aBitmapId is currently registered with this
       
    76 		rasterizer or zero for recently used bitmaps.
       
    77 		 */
       
    78 		TInt iRefCount;
       
    79 		/** Whether the whole bitmap has been rasterized into the buffer.
       
    80 		 */
       
    81 		TBool iWhole;
       
    82 		};
       
    83 	
       
    84 private:
       
    85 	CRegisteredBitmap* RegisteredBitmap(TInt64 aBitmapId);
       
    86 	CRegisteredBitmap* RecentBitmap(TInt64 aBitmapId);
       
    87 	static TInt IdleFunction(TAny* aPtr);
       
    88 
       
    89 private:
       
    90 	/** List of currently registered extended bitmaps, the key is the bitmap id.
       
    91 	 */
       
    92 	TDblQue<CRegisteredBitmap> iRegisteredBmps;
       
    93 	/** List of recently used extended bitmaps, the key is the bitmap id.
       
    94 	 */
       
    95 	TDblQue<CRegisteredBitmap> iRecentBmps;
       
    96 	/** Total size in bytes of the pre-rendered buffers for all the recently used extended bitmaps.
       
    97 	 */
       
    98 	TInt iTotalRecentBmpSize;
       
    99 	/** An idle-time active object to clean up the recently used extended bitmaps.
       
   100 	 */
       
   101 	CIdle* iIdle;
       
   102 	};
       
   103 
       
   104 #endif // EXAMPLERASTERIZER_H