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