epoc32/include/fbs.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 fbs.h
     1 // Copyright (c) 1995-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __FBS_H__
       
    17 #define __FBS_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <gdi.h>
       
    21 #include <fntstore.h>
       
    22 #include <bitmap.h>
       
    23 #include <fbsmessage.h>
       
    24 
       
    25 /**
       
    26 Indicates version of the font and bitmap server without heap locking.
       
    27 @publishedAll
       
    28 @released
       
    29 */
       
    30 #define SYMBIAN_FBSERV_V2
       
    31 
       
    32 /**
       
    33 @internalTechnology
       
    34 */
       
    35 const TUid KCFbsFontUid = { 268435518 };
       
    36 /**
       
    37 @internalComponent
       
    38 */
       
    39 const TUid KMultiBitmapRomImageUid = { 268435521 };
       
    40 /**
       
    41 @internalComponent
       
    42 */
       
    43 const TUint32 KFontBitmapServerUidValue = 0x10003a16;
       
    44 /**
       
    45 @internalComponent
       
    46 */
       
    47 const TUid KFontBitmapServerUid = { KFontBitmapServerUidValue };
       
    48 /**
       
    49 @internalAll
       
    50 */
       
    51 IMPORT_C TInt FbsStartup();
       
    52 
       
    53 /** 
       
    54 Required to ensure BC between NGage and 7.0S platforms.  
       
    55 Function is exported at ordinal corresponding to where NGage platform
       
    56 has extended this library and must not be moved.
       
    57 @internalAll
       
    58 */
       
    59 IMPORT_C void DummyReserved1();
       
    60 
       
    61 
       
    62 /** 
       
    63 Character width and adjustment information. 
       
    64 @publishedAll
       
    65 @released
       
    66 */
       
    67 class SCharWidth
       
    68 	{
       
    69 public:
       
    70 	/** The left adjust of the character. */
       
    71 	TInt iLeftAdjust;
       
    72 	/** The right adjust of the character. */
       
    73 	TInt iRightAdjust;
       
    74 	/** The total width of the character, defined as iLeftAdjust + iWidth + iRightAdjust. */
       
    75 	TInt iMove;
       
    76 	/** The width of the character. */
       
    77 	TInt iWidth;
       
    78 	};
       
    79 
       
    80 class CFbsRalCache;
       
    81 class CFbsSessionHelper;
       
    82 
       
    83 /** 
       
    84 A session with the font and bitmap server. 
       
    85 @publishedAll 
       
    86 @released
       
    87 */
       
    88 class RFbsSession : protected RSessionBase
       
    89 	{
       
    90 	// Allow access to internals for test
       
    91 	friend class RClean;
       
    92 	friend class TestFbs;
       
    93 	friend class CTBitmap;
       
    94 	friend class CTClean;
       
    95 	friend class CTFbs;
       
    96 	
       
    97 	friend class CFbsBitmap;
       
    98 	friend class CFbsBitmapAsyncStreamer;
       
    99 public:
       
   100 	IMPORT_C RFbsSession();
       
   101 	IMPORT_C static TInt Connect();
       
   102 	IMPORT_C static TInt Connect(RFs& aFileServer);
       
   103 	IMPORT_C static void Disconnect();
       
   104 	IMPORT_C static RFbsSession* GetSession();
       
   105 	IMPORT_C void CallBack();
       
   106 	IMPORT_C void SetCallBack(TCallBack aCallBack);
       
   107 	IMPORT_C void ResetCallBack();
       
   108 	IMPORT_C TInt ResourceCount();
       
   109 	IMPORT_C TInt SendCommand(TInt aMessage,TInt aInt0=0,TInt aInt1=0,TInt aInt2=0,TInt aInt3=0) const;
       
   110 	TInt SendCommand(TInt aMessage, const TIpcArgs& aArgs) const;
       
   111 	void SendCommand(TInt aMessage, const TIpcArgs& aArgs, TRequestStatus &aStatus) const;
       
   112 	IMPORT_C TVersion Version();
       
   113 	IMPORT_C TUint8* HeapBase() const;
       
   114 	IMPORT_C TInt GetHeapSizes(TInt& aDefaultHeap, TInt& aSmallBmpHeap, TInt& aBigBmpChunk);
       
   115 	TInt SessionHandle() const { return Handle(); }
       
   116 	TInt AllocScanLineBuffer(TInt aSize);
       
   117 	HBufC8* GetScanLineBuffer();
       
   118 	void SetCallBackPtr(TInt* aBitmapHandle)const;
       
   119 	HBufC8* GetDecompressionBuffer(TInt aSize);
       
   120 	HBufC8* GetExtraBuffer(TInt aSize);
       
   121 public:
       
   122 	/**
       
   123 	Used for testing server side out of memory failures
       
   124 	
       
   125 	@internalTechnology
       
   126 	@prototype
       
   127 	*/
       
   128 	enum THeapFailType
       
   129 		{
       
   130 		EHeapFailTypeServerMemory,
       
   131 		EHeapFailTypeHeapMemory,
       
   132 		};
       
   133 private:
       
   134 	TBool LookupBitmapInROM(const TDesC& aFilename, TAny*& aAddr);
       
   135 	RFs& FileServer() { return *((RFs*)iSpare); }
       
   136 	static TInt DoAlloc(RFbsSession*& aNewSession);
       
   137 	TInt DoConnect(RFs& aFileServer);
       
   138 private:
       
   139 	TInt iConnections;
       
   140 	mutable TCallBack iCallBack;
       
   141 	RChunk iSharedChunk;
       
   142 	CFbsSessionHelper* iHelper;
       
   143 	RChunk iLargeBitmapChunk;
       
   144 	RFs iFileServer;
       
   145 	CFbsRalCache* iRomFileAddrCache;
       
   146 	HBufC8* iDecompressionBuffer;
       
   147 	HBufC8* iScanLineBuffer;	
       
   148 	TUint32* iSpare;
       
   149 	};
       
   150 
       
   151 /** 
       
   152 Font managed by the font and bitmap server.
       
   153 CFbsFont objects are used for screen and off-screen bitmap fonts. They are 
       
   154 usually obtained by calls to the CBitmapDevice::GetNearestFontInPixels() and 
       
   155 MGraphicsDeviceMap::GetNearestFontInTwips() functions.
       
   156 The class implements a number of functions inherited from CFont.
       
   157 @see CBitmapDevice::GetNearestFontInPixels()
       
   158 @see MGraphicsDeviceMap::GetNearestFontInTwips() 
       
   159 @publishedAll 
       
   160 @released
       
   161 */
       
   162 class CFbsFont: public CFont
       
   163 	{
       
   164 	friend class CFbsTypefaceStore;
       
   165 
       
   166 private:
       
   167 	// From CFont
       
   168 	/** Gets the font's UID. 
       
   169 	All CFbsFont objects have the constant UID KCFbsFontUid. It is safe to cast 
       
   170 	from CFont* to CFbsFont* if CFont::TypeUid() returns KCFbsFontUid.
       
   171 	@return The font's UID. This should be KCFbsFontUid. 
       
   172 	@see CFont::TypeUid() */
       
   173 	virtual TUid DoTypeUid() const { return KCFbsFontUid; }
       
   174 	IMPORT_C virtual TInt DoHeightInPixels() const;
       
   175 	IMPORT_C virtual TInt DoAscentInPixels() const;
       
   176 	IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const;
       
   177 	IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC& aText) const;
       
   178 	IMPORT_C virtual TInt DoBaselineOffsetInPixels() const;
       
   179 	IMPORT_C virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const;
       
   180 	IMPORT_C virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
       
   181 	IMPORT_C virtual TInt DoMaxCharWidthInPixels() const;
       
   182 	IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const;
       
   183 	IMPORT_C virtual TFontSpec DoFontSpecInTwips() const;
       
   184 	IMPORT_C virtual CFont::TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,
       
   185 		const TUint8*& aBitmap, TSize& aBitmapSize) const;
       
   186 	IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
       
   187 
       
   188 public:
       
   189 	// New functions
       
   190 	IMPORT_C TBool GetFontMetrics(TOpenFontMetrics& aMetrics) const;
       
   191 	IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const;
       
   192 	IMPORT_C void TextWidthInPixels(const TDesC& aText,SCharWidth& aCharWidth) const;
       
   193 	IMPORT_C TInt Handle() const;
       
   194 	IMPORT_C TCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
       
   195 	IMPORT_C TInt RawTextWidthInPixels(const TDesC& aText) const;
       
   196 	IMPORT_C TBool GetFaceAttrib(TOpenFontFaceAttrib& aAttrib) const;
       
   197 	IMPORT_C TBool IsOpenFont() const;
       
   198 	IMPORT_C TBool HasCharacter(TInt aCode) const;
       
   199 
       
   200 protected:
       
   201 	IMPORT_C CFbsFont();
       
   202 	IMPORT_C ~CFbsFont();
       
   203 	IMPORT_C CFbsFont(const CFbsFont& aFont);
       
   204 	IMPORT_C CBitmapFont* Address() const;
       
   205 	IMPORT_C TInt Duplicate(TInt aHandle);
       
   206 	IMPORT_C void Reset();
       
   207 	
       
   208 private:
       
   209 	void InsertCharacterInCache(TInt aCode, CLinkedFontInformation* &aInfo, CBitmapFont* &aBitmapFont) const;
       
   210 
       
   211 private:
       
   212 	TInt DoFontGetShaping(TFontShapeFunctionParameters* aParam) const;
       
   213 	TInt DoFontDeleteShaping(TFontShapeDeleteFunctionParameters* aParam) const;
       
   214 
       
   215 protected:
       
   216 	RFbsSession* iFbs;
       
   217 	CBitmapFont* iAddressPointer;
       
   218 	TInt iHandle;
       
   219 	TInt iServerHandle;
       
   220 	};
       
   221 
       
   222 class CDirectFileStore;
       
   223 
       
   224 /** 
       
   225 Note that this class is not intended for user derivation.
       
   226 A bitmap managed by the font and bitmap server.
       
   227 The class also defines some palette functionality which is not yet 
       
   228 implemented, since none of the modes currently supported by screen 
       
   229 or bitmaps require variable palettes.
       
   230 Note that the CFbsBitmap format is internal to Symbian, but the 
       
   231 Image Converter API can be used to convert such bitmaps to standard formats. 
       
   232 CFbsBitmap instances cannot be shared between different threads. They use some shared
       
   233 thread local storage data. If you want to share a bitmap between threads, use Duplicate().
       
   234 @publishedAll 
       
   235 @released
       
   236 @see CFbsBitmap::Duplicate()
       
   237 */
       
   238 class CFbsBitmap : public CBase
       
   239 	{
       
   240 	friend class TBitmapUtil;
       
   241 	friend class CBitwiseBitmap;
       
   242 	friend class CFbsBitmapAsyncStreamer;
       
   243 	friend class CFbsSessionHelper;
       
   244 public:
       
   245 	IMPORT_C CFbsBitmap();
       
   246 	IMPORT_C ~CFbsBitmap();
       
   247 	IMPORT_C void Reset();
       
   248 	IMPORT_C static TInt ScanLineLength(TInt aLength,TDisplayMode aDispMode);
       
   249 	IMPORT_C TDisplayMode DisplayMode() const;
       
   250 	IMPORT_C TDisplayMode InitialDisplayMode() const;
       
   251 	IMPORT_C TInt SetDisplayMode(TDisplayMode aDisplayMode);
       
   252 	IMPORT_C TInt Create(const TSize& aSizeInPixels,TDisplayMode aDispMode);
       
   253 	IMPORT_C TInt Duplicate(TInt aHandle);
       
   254 	IMPORT_C TBool IsRomBitmap() const;
       
   255 	IMPORT_C void SetRomBitmapL(CBitwiseBitmap* aRomBitmapPointer,TInt& aBitmapSizeInBytes);
       
   256 	IMPORT_C TInt Load(const TDesC& aFileName,TInt32 aId=0,TBool aShareIfLoaded=ETrue);
       
   257 	IMPORT_C TInt Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
       
   258 	IMPORT_C TInt LoadAndCompress(const TDesC& aFileName,TInt32 aId=0,TBool aShareIfLoaded=ETrue);
       
   259 	IMPORT_C TInt LoadAndCompress(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
       
   260 	IMPORT_C TInt Load(RFile& aFile,TInt32 aId=0,TBool aShareIfLoaded=ETrue);
       
   261 	IMPORT_C TInt Load(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);		
       
   262 	IMPORT_C TInt LoadAndCompress(RFile& aFile,TInt32 aId=0,TBool aShareIfLoaded=ETrue);	
       
   263 	IMPORT_C TInt LoadAndCompress(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);	
       
   264 	IMPORT_C TInt Save(const TDesC& aFilename);
       
   265 	IMPORT_C TInt Save(RFile& aFile);
       
   266 	IMPORT_C static void StoreL(const TDesC& aFilename,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]);
       
   267 	IMPORT_C static void StoreL(RFile& aFile,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]);
       
   268     IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode) const;
       
   269     IMPORT_C void SetScanLine(TDes8& aBuf,TInt aY) const;
       
   270 	IMPORT_C void GetVerticalScanLine(TDes8& aBuf,TInt aX,TDisplayMode aDispMode) const;
       
   271 	IMPORT_C void GetVerticalScanLine(TDes8& aBuf,TInt aX,const TPoint& aDitherOffset,TDisplayMode aDispMode) const;
       
   272 	IMPORT_C TInt Handle() const;
       
   273 	IMPORT_C SEpocBitmapHeader Header() const;
       
   274 	IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
       
   275 	IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
       
   276 	IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
       
   277 	IMPORT_C TInt Resize(const TSize& aSizeInPixels);
       
   278 	IMPORT_C TSize SizeInPixels() const;
       
   279 	IMPORT_C TSize SizeInTwips() const;
       
   280 	IMPORT_C void SetSizeInTwips(const MGraphicsDeviceMap* aMap);
       
   281 	IMPORT_C void SetSizeInTwips(const TSize& aSizeInTwips);
       
   282 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   283 	IMPORT_C void ExternalizeRectangleL(RWriteStream& aStream,const TRect& aRect) const;
       
   284 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   285 	IMPORT_C TInt Compress();
       
   286 	IMPORT_C TInt Compress(TBitmapfileCompressionScheme aScheme);
       
   287 	IMPORT_C void CompressInBackground(TRequestStatus& aRequestStatus);
       
   288 	IMPORT_C TInt CompressInBackground();
       
   289 	IMPORT_C void CompressInBackground(TRequestStatus& aRequestStatus, TBitmapfileCompressionScheme aScheme);
       
   290 	IMPORT_C TInt CompressInBackground(TBitmapfileCompressionScheme aScheme);
       
   291 	IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
       
   292 	IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
       
   293 	IMPORT_C static TBool IsFileInRom(const TDesC& aFilename,TUint32*& aWord);
       
   294 	IMPORT_C static TBool IsFileInRom(RFile& aFile,TUint32*& aWord);
       
   295 	IMPORT_C TBool IsMonochrome() const;
       
   296 	IMPORT_C TBool IsLargeBitmap() const;
       
   297 	IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
       
   298 	IMPORT_C void SetPalette(CPalette* aPalette);
       
   299 	IMPORT_C TInt GetPalette(CPalette*& aPalette) const;
       
   300 	IMPORT_C TUint32* DataAddress() const;
       
   301 	IMPORT_C TInt DataStride() const;
       
   302 	IMPORT_C TInt CreateHardwareBitmap(const TSize& aSizeInPixels,TDisplayMode aDispMode,TUid aCreatorUid);
       
   303 	IMPORT_C TInt HardwareBitmapHandle() const;
       
   304 	IMPORT_C void BeginDataAccess() const;
       
   305 	IMPORT_C void EndDataAccess(TBool aReadOnly=EFalse) const;
       
   306 	IMPORT_C void LockHeap(TBool aAlways=EFalse) const;
       
   307 	IMPORT_C void UnlockHeap(TBool aAlways=EFalse) const;
       
   308 	IMPORT_C void LockHeapLC(TBool aAlways=EFalse) const;
       
   309 	IMPORT_C static void UnlockHeap(TAny* aFbsBitmap);
       
   310 	IMPORT_C TBool IsCompressedInRAM() const;
       
   311 	IMPORT_C TInt SwapWidthAndHeight();
       
   312 	IMPORT_C static HBufC8* GetDecompressionBuffer(TInt aSize);
       
   313 	IMPORT_C TInt GetAllBitmapHandles(RArray<TInt>& aBitmapIdArray) const;
       
   314 	IMPORT_C static HBufC8* GetExtraBuffer(TInt aSize);
       
   315 protected:
       
   316     IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,const TPoint& aDitherOffset,TDisplayMode aDispMode) const;
       
   317 	CBitwiseBitmap* Address() const;
       
   318 	IMPORT_C CBitwiseBitmap* CleanAddress() const;
       
   319 	inline CBitwiseBitmap* CleanAddress(TUint32*& aDataAddress) const;
       
   320 	void DoSaveL(RFile& aFile);
       
   321 	TInt DoCreate(const TSize& aSizeInPixels,TDisplayMode aDispMode,TUid aCreatorUid);
       
   322 private:
       
   323 	TInt DoLoad(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
       
   324 	TInt DoLoad(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
       
   325 	TInt DoLoadFromRom(TUint32* aRomPointer, TInt32 aId, TUint aFileOffset, TBool& aRomPointerValid);
       
   326 	TBool LoadShiftedRomBmpL(const TDesC& aFileName,TInt32 aId,TUint aFileOffset);
       
   327 	static void DoStoreL(CDirectFileStore* aFileStore,CFbsBitmap* aBitmap,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]);
       
   328 protected:
       
   329 /**
       
   330 @internalComponent
       
   331 */
       
   332 	enum // Flags
       
   333 		{
       
   334 		EIsRomBitmap = 0x0001
       
   335 		};
       
   336 protected:
       
   337 /**
       
   338 @internalComponent
       
   339 */
       
   340 	RFbsSession* iFbs;
       
   341 /**
       
   342 @internalComponent
       
   343 */
       
   344 	CBitwiseBitmap* iAddressPointer;
       
   345 /**
       
   346 @internalComponent
       
   347 */
       
   348 	TUint16 iFlags;
       
   349 /**
       
   350 @internalComponent
       
   351 */
       
   352 	TInt16 iUseCount;
       
   353 /**
       
   354 @internalComponent
       
   355 */
       
   356 	TInt iHandle;
       
   357 /**
       
   358 @internalComponent
       
   359 */
       
   360 	TInt iServerHandle;
       
   361 	};
       
   362 
       
   363 class CDirectFileStore;
       
   364 
       
   365 /**
       
   366 @deprecated
       
   367 @internalComponent
       
   368 */
       
   369 class CFbsBitmapAsyncStreamer : public CBase
       
   370 	{
       
   371 public:
       
   372 	enum TMode {ELoad, ESave};
       
   373 public:
       
   374 	IMPORT_C ~CFbsBitmapAsyncStreamer();
       
   375 	IMPORT_C static CFbsBitmapAsyncStreamer* NewL(TMode aMode);
       
   376 	IMPORT_C TInt Load(const TDesC& aFilename,TInt32 aId,TInt& aScanLines);
       
   377 	IMPORT_C TBool LoadScanLinesL(TInt aNumberOfScanLines,CFbsBitmap*& aBitmap);
       
   378 	IMPORT_C TInt Save(const TDesC& aFilename,CFbsBitmap* aBitmap,TInt32& aId,TInt& aScanLines);
       
   379 	IMPORT_C TBool SaveScanLinesL(TInt aNumberOfScanLines);
       
   380 private:
       
   381 	CFbsBitmapAsyncStreamer(TMode aMode);
       
   382 	void ConstructL();
       
   383 	void DoLoadL(const TDesC& aFilename,TInt32 aId);
       
   384 	void DoSaveL(RFile& aFile);
       
   385 private:
       
   386 	RFbsSession* iFbs;
       
   387 	RStoreReadStream iReadStream;
       
   388 	RStoreWriteStream iWriteStream;
       
   389 	TStreamId iId;
       
   390 	CDirectFileStore* iStore;
       
   391 	TInt iCurrentScanLine;
       
   392 	TUint32* iScanLineBase;
       
   393 	CFbsBitmap* iBitmap;
       
   394 	SEpocBitmapHeader iHeader;
       
   395 	TDisplayMode iDispMode;
       
   396 	TMode iMode;
       
   397 	};
       
   398 
       
   399 
       
   400 /** 
       
   401 Provides fast read/write access to the pixel data of a bitmap. 
       
   402 
       
   403 Functionality includes getting and setting the individual pixels of a bitmap. 
       
   404 Common to this is the concept of the current pixel position. This is held 
       
   405 as member data and is changed by using various efficient functions. For example, 
       
   406 incrementing the position's x- or y co-ordinate is much quicker than setting 
       
   407 a completely new position. This efficiency issue is important as these functions 
       
   408 are used as part of the frequently used blitting DDA used for creating 
       
   409 stretched or compressed versions of bitmaps.
       
   410 
       
   411 Calls to Begin() and End() must surround any calls to the other member functions.
       
   412 Note that you should always ensure each Begin() is matched by an End() call 
       
   413 when using this class.
       
   414 
       
   415 Note also that all display modes including EColor16M are supported, but the 
       
   416 TDisplayMode values ERgb and ENone are not considered to be display modes. 
       
   417 @publishedAll 
       
   418 @released
       
   419 */
       
   420 class TBitmapUtil
       
   421 	{
       
   422 public:
       
   423 	IMPORT_C void Begin(const TPoint& aPosition);
       
   424 	IMPORT_C void Begin(const TPoint& aPosition,const TBitmapUtil& aUtil);
       
   425 	IMPORT_C void End();
       
   426 	IMPORT_C TBitmapUtil(CFbsBitmap* aBitmap);
       
   427 	IMPORT_C TUint32 GetPixel() const;
       
   428 	IMPORT_C void SetPixel(TUint32 aValue);
       
   429 	IMPORT_C void SetPixel(const TBitmapUtil& aSource);
       
   430 	IMPORT_C void SetPos(const TPoint& aPosition);
       
   431 	IMPORT_C void DecXPos();
       
   432 	IMPORT_C void DecYPos();
       
   433 	IMPORT_C void IncXPos();
       
   434 	IMPORT_C void IncYPos();
       
   435 private:
       
   436 	CFbsBitmap* iFbsBitmap;
       
   437 	TUint32* iWordPos;
       
   438 	TUint32* iMinWordPos;
       
   439 	TUint32* iMaxWordPos;
       
   440 	TInt iBpp;
       
   441 	TInt iPixelShift;
       
   442 	TInt iBitShift;
       
   443 	TUint32 iMask;
       
   444 	TInt iScanlineWordLength;
       
   445 	TBool iWritten;
       
   446 	};
       
   447 
       
   448 class TFontInfo;
       
   449 
       
   450 /** 
       
   451 Font and bitmap server typeface store. 
       
   452 @publishedAll 
       
   453 @released
       
   454 */
       
   455 class CFbsTypefaceStore : public CTypefaceStore
       
   456 	{
       
   457 	friend class CWsScreenDevice;
       
   458 public:
       
   459 	IMPORT_C static CFbsTypefaceStore* NewL(CGraphicsDevice* aDevice);
       
   460 	IMPORT_C ~CFbsTypefaceStore();
       
   461 	IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId);
       
   462 	IMPORT_C TInt InstallFile(const TDesC& aName,TInt& aId);
       
   463 	IMPORT_C void RemoveFile(TInt aId=0);
       
   464 	IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
       
   465 	IMPORT_C TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
       
   466 	IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
       
   467 	IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
       
   468 	IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
       
   469 	IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
       
   470 	IMPORT_C TInt GetFontById(CFont *&aFont,TUid aUid,const TAlgStyle& aAlgStyle);
       
   471 	IMPORT_C virtual TInt NumTypefaces() const;
       
   472 	IMPORT_C virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const;
       
   473 	IMPORT_C virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
       
   474 	IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
       
   475 	IMPORT_C TGlyphBitmapType DefaultBitmapType() const;
       
   476 	IMPORT_C void SetDefaultBitmapType(TGlyphBitmapType aType) const;
       
   477 	IMPORT_C void SetFontNameAliasL(const TDesC& aFontAlias,const TDesC& aFontName) const;
       
   478 	IMPORT_C void SetDefaultLanguageForMetrics(TLanguage aLanguage) const;
       
   479 	IMPORT_C static void RemoveFontFileLocksL();
       
   480 	IMPORT_C static void RemoveFontFileLocksL(const TDesC& aDrive, TBool aAllFonts);
       
   481 	IMPORT_C static void RemoveFontFileLocksL(const TDesC& aFileName);
       
   482 	IMPORT_C void ReleaseTwipsCache();
       
   483 	IMPORT_C void SetSystemDefaultTypefaceNameL(const TDesC& aFontTypefaceName);
       
   484 	IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId);
       
   485 private:
       
   486 	CFbsTypefaceStore(CGraphicsDevice* aDevice);
       
   487 	void ConstructL();
       
   488 	TInt CreateFont(CFont*& aFont,const TFontInfo& aFontInfo);
       
   489 	TBool IsFontLoaded(CFont*& aFont, const TFontInfo& aFontInfo) const;
       
   490 	TInt FontHeight(TInt aTypefaceIndex,TInt aHeightIndex,TInt aMessage) const;
       
   491 	TInt GetNearestFontInTwipsAndCreateFont(CFont*& aFont, TFbsMessage aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
       
   492 	TInt SendGetNearestFontCommandNCreateFont(
       
   493 		CFont*& aFont, TFbsMessage aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
       
   494 	void GetPixelSizeInTwips(TSize& aSize) const;
       
   495 
       
   496 private:
       
   497 	RFbsSession* iFbs;
       
   498 	CGraphicsDevice* iDevice;
       
   499 	CFontCache* iTwipsCache;
       
   500 	};
       
   501 
       
   502 class CDitherColor256;
       
   503 
       
   504 /** 
       
   505 Copies a bitmap in any display mode of at least 256 colours into a 256 
       
   506 colour bitmap, optionally using a user-defined palette. 
       
   507 @publishedAll 
       
   508 @released
       
   509 */
       
   510 class CFbsColor256BitmapUtil : public CBase
       
   511 	{
       
   512 public:
       
   513 	/** Indicates whether or not to use dithering. */
       
   514 	enum TDither
       
   515 		{
       
   516 		/** No dithering. */
       
   517 		ENoDither,
       
   518 		/** Use the Floyd-Steinberg dithering algorithm. */
       
   519 		EFloydSteinberg
       
   520 		};
       
   521 public:
       
   522 
       
   523 	IMPORT_C static CFbsColor256BitmapUtil* NewL(const CPalette* aPalette);
       
   524 
       
   525 	IMPORT_C TInt CopyBitmap(CFbsBitmap* aColor256Destination,CFbsBitmap* aSource,TDither aDither=ENoDither);
       
   526 
       
   527 	~CFbsColor256BitmapUtil();
       
   528 private:
       
   529 	CFbsColor256BitmapUtil();
       
   530 private:
       
   531 	TColor256Util* iColor256Util;
       
   532 	CDitherColor256* iDither;
       
   533 	};
       
   534 
       
   535 #endif