epoc32/include/fbs.h
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     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
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    14 //
    14 //
    15 
    15 
    16 #ifndef __FBS_H__
    16 #ifndef __FBS_H__
    17 #define __FBS_H__
    17 #define __FBS_H__
    18 
    18 
       
    19 /**
       
    20 @file
       
    21 @publishedAll
       
    22 @released
       
    23  */
    19 #include <e32std.h>
    24 #include <e32std.h>
    20 #include <gdi.h>
    25 #include <gdi.h>
    21 #include <fntstore.h>
    26 #include <fntstore.h>
    22 #include <bitmap.h>
    27 #include <bitmap.h>
    23 #include <fbsmessage.h>
    28 #include <graphics/fbsdefs.h>
       
    29 
       
    30 /**
       
    31 @publishedAll
       
    32 @released
       
    33  */
       
    34 const TUid KCFbsFontUid = { 268435518 };
    24 
    35 
    25 /**
    36 /**
    26 Indicates version of the font and bitmap server without heap locking.
    37 Indicates version of the font and bitmap server without heap locking.
    27 @publishedAll
    38 @publishedAll
    28 @released
    39 @released
    29 */
    40 */
    30 #define SYMBIAN_FBSERV_V2
    41 #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 
    42 
    62 /** 
    43 /** 
    63 Character width and adjustment information. 
    44 Character width and adjustment information. 
    64 @publishedAll
    45 @publishedAll
    65 @released
    46 @released
    77 	TInt iWidth;
    58 	TInt iWidth;
    78 	};
    59 	};
    79 
    60 
    80 class CFbsRalCache;
    61 class CFbsRalCache;
    81 class CFbsSessionHelper;
    62 class CFbsSessionHelper;
       
    63 class CFbsRasterizer;
    82 
    64 
    83 /** 
    65 /** 
    84 A session with the font and bitmap server. 
    66 A session with the font and bitmap server. 
    85 @publishedAll 
    67 @publishedAll 
    86 @released
    68 @released
   116 	TInt AllocScanLineBuffer(TInt aSize);
    98 	TInt AllocScanLineBuffer(TInt aSize);
   117 	HBufC8* GetScanLineBuffer();
    99 	HBufC8* GetScanLineBuffer();
   118 	void SetCallBackPtr(TInt* aBitmapHandle)const;
   100 	void SetCallBackPtr(TInt* aBitmapHandle)const;
   119 	HBufC8* GetDecompressionBuffer(TInt aSize);
   101 	HBufC8* GetDecompressionBuffer(TInt aSize);
   120 	HBufC8* GetExtraBuffer(TInt aSize);
   102 	HBufC8* GetExtraBuffer(TInt aSize);
   121 public:
   103     TInt ServerSessionHandle() const;
   122 	/**
   104 public:
   123 	Used for testing server side out of memory failures
   105 	/** WARNING: For internal use ONLY.  Compatibility is not guaranteed in future releases.	 
   124 	
   106 	Used for testing server side out of memory failures.	
   125 	@internalTechnology
   107 	@test
   126 	@prototype
       
   127 	*/
   108 	*/
   128 	enum THeapFailType
   109 	enum THeapFailType
   129 		{
   110 		{
   130 		EHeapFailTypeServerMemory,
   111 		EHeapFailTypeServerMemory,
   131 		EHeapFailTypeHeapMemory,
   112 		EHeapFailTypeHeapMemory,
   194 	IMPORT_C TCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
   175 	IMPORT_C TCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
   195 	IMPORT_C TInt RawTextWidthInPixels(const TDesC& aText) const;
   176 	IMPORT_C TInt RawTextWidthInPixels(const TDesC& aText) const;
   196 	IMPORT_C TBool GetFaceAttrib(TOpenFontFaceAttrib& aAttrib) const;
   177 	IMPORT_C TBool GetFaceAttrib(TOpenFontFaceAttrib& aAttrib) const;
   197 	IMPORT_C TBool IsOpenFont() const;
   178 	IMPORT_C TBool IsOpenFont() const;
   198 	IMPORT_C TBool HasCharacter(TInt aCode) const;
   179 	IMPORT_C TBool HasCharacter(TInt aCode) const;
       
   180 	IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const;
       
   181 	IMPORT_C void TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam,SCharWidth& aCharWidth) const;
       
   182 
   199 
   183 
   200 protected:
   184 protected:
   201 	IMPORT_C CFbsFont();
   185 	IMPORT_C CFbsFont();
   202 	IMPORT_C ~CFbsFont();
   186 	IMPORT_C ~CFbsFont();
   203 	IMPORT_C CFbsFont(const CFbsFont& aFont);
   187 	IMPORT_C CFbsFont(const CFbsFont& aFont);
   204 	IMPORT_C CBitmapFont* Address() const;
   188 	IMPORT_C CBitmapFont* Address() const;
   205 	IMPORT_C TInt Duplicate(TInt aHandle);
   189 	IMPORT_C TInt Duplicate(TInt aHandle);
   206 	IMPORT_C void Reset();
   190 	IMPORT_C void Reset();
   207 	
   191 	
   208 private:
   192 private:
   209 	void InsertCharacterInCache(TInt aCode, CLinkedFontInformation* &aInfo, CBitmapFont* &aBitmapFont) const;
       
   210 
       
   211 private:
       
   212 	TInt DoFontGetShaping(TFontShapeFunctionParameters* aParam) const;
   193 	TInt DoFontGetShaping(TFontShapeFunctionParameters* aParam) const;
   213 	TInt DoFontDeleteShaping(TFontShapeDeleteFunctionParameters* aParam) const;
   194 	TInt DoFontDeleteShaping(TFontShapeDeleteFunctionParameters* aParam) const;
       
   195 	TInt DoTextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const;
   214 
   196 
   215 protected:
   197 protected:
   216 	RFbsSession* iFbs;
   198 	RFbsSession* iFbs;
   217 	CBitmapFont* iAddressPointer;
   199 	CBitmapFont* iAddressPointer;
   218 	TInt iHandle;
   200 	TInt iHandle;
   219 	TInt iServerHandle;
   201 	TInt iServerHandle;
       
   202 	};
       
   203 
       
   204 /**
       
   205 An interface for initialization of extended bitmaps. By implementing this interface, 
       
   206 creators of extended bitmaps can set the contents of an extended bitmap without 
       
   207 allocating a temporary buffer and avoid unnecessary memory copying during calls to 
       
   208 CFbsBitmap::CreateExtendedBitmap().
       
   209 
       
   210 WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
       
   211 
       
   212 @publishedAll
       
   213 @see CFbsBitmap::CreateExtendedBitmap()
       
   214 */
       
   215 class MFbsExtendedBitmapInitializer
       
   216 	{
       
   217 public:
       
   218 	/**
       
   219 	Initializes the raw data of an extended bitmap.
       
   220 	@param aData A pointer to the raw data to be initialized.
       
   221 	@param aDataSize The size in bytes of the raw data to be initialized.
       
   222 	@return KErrNone if successful, otherwise another of the system-wide error codes.
       
   223 	*/
       
   224 	virtual TInt InitExtendedBitmap(TAny* aData, TInt aDataSize) = 0;
   220 	};
   225 	};
   221 
   226 
   222 class CDirectFileStore;
   227 class CDirectFileStore;
   223 
   228 
   224 /** 
   229 /** 
   305 	IMPORT_C void EndDataAccess(TBool aReadOnly=EFalse) const;
   310 	IMPORT_C void EndDataAccess(TBool aReadOnly=EFalse) const;
   306 	IMPORT_C void LockHeap(TBool aAlways=EFalse) const;
   311 	IMPORT_C void LockHeap(TBool aAlways=EFalse) const;
   307 	IMPORT_C void UnlockHeap(TBool aAlways=EFalse) const;
   312 	IMPORT_C void UnlockHeap(TBool aAlways=EFalse) const;
   308 	IMPORT_C void LockHeapLC(TBool aAlways=EFalse) const;
   313 	IMPORT_C void LockHeapLC(TBool aAlways=EFalse) const;
   309 	IMPORT_C static void UnlockHeap(TAny* aFbsBitmap);
   314 	IMPORT_C static void UnlockHeap(TAny* aFbsBitmap);
       
   315 	IMPORT_C TBool IsVolatile() const;
       
   316 	IMPORT_C TInt TouchCount() const;
       
   317 	IMPORT_C TInt64 SerialNumber() const;
   310 	IMPORT_C TBool IsCompressedInRAM() const;
   318 	IMPORT_C TBool IsCompressedInRAM() const;
   311 	IMPORT_C TInt SwapWidthAndHeight();
   319 	IMPORT_C TInt SwapWidthAndHeight();
       
   320 	IMPORT_C TInt CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, const TAny* aData, TInt aDataSize);
       
   321 	IMPORT_C TInt CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, TInt aDataSize, MFbsExtendedBitmapInitializer& aInitializer);
       
   322 	IMPORT_C TUid ExtendedBitmapType() const;
       
   323 	IMPORT_C TInt DataSize() const;
   312 	IMPORT_C static HBufC8* GetDecompressionBuffer(TInt aSize);
   324 	IMPORT_C static HBufC8* GetDecompressionBuffer(TInt aSize);
       
   325 	IMPORT_C static CFbsRasterizer* Rasterizer();
   313 	IMPORT_C TInt GetAllBitmapHandles(RArray<TInt>& aBitmapIdArray) const;
   326 	IMPORT_C TInt GetAllBitmapHandles(RArray<TInt>& aBitmapIdArray) const;
   314 	IMPORT_C static HBufC8* GetExtraBuffer(TInt aSize);
   327 	IMPORT_C static HBufC8* GetExtraBuffer(TInt aSize);
   315 protected:
   328 protected:
   316     IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,const TPoint& aDitherOffset,TDisplayMode aDispMode) const;
   329     IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,const TPoint& aDitherOffset,TDisplayMode aDispMode) const;
   317 	CBitwiseBitmap* Address() const;
   330 	CBitwiseBitmap* Address() const;
   318 	IMPORT_C CBitwiseBitmap* CleanAddress() const;
   331 	IMPORT_C CBitwiseBitmap* CleanAddress() const;
   319 	inline CBitwiseBitmap* CleanAddress(TUint32*& aDataAddress) const;
   332 	inline CBitwiseBitmap* BeginDataAccessAndGetCleanAddress(TUint32*& aDataAddress) const;
   320 	void DoSaveL(RFile& aFile);
   333 	void DoSaveL(RFile& aFile);
   321 	TInt DoCreate(const TSize& aSizeInPixels,TDisplayMode aDispMode,TUid aCreatorUid);
   334 	TInt DoCreate(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aUid, TInt aDataSize = 0);
   322 private:
   335 private:
   323 	TInt DoLoad(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
   336 	TInt DoLoad(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
   324 	TInt DoLoad(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
   337 	TInt DoLoad(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset);
   325 	TInt DoLoadFromRom(TUint32* aRomPointer, TInt32 aId, TUint aFileOffset, TBool& aRomPointerValid);
   338 	TInt DoLoadFromRom(TUint32* aRomPointer, TInt32 aId, TUint aFileOffset, TBool& aRomPointerValid);
   326 	TBool LoadShiftedRomBmpL(const TDesC& aFileName,TInt32 aId,TUint aFileOffset);
   339 	TBool LoadShiftedRomBmpL(const TDesC& aFileName,TInt32 aId,TUint aFileOffset);
   327 	static void DoStoreL(CDirectFileStore* aFileStore,CFbsBitmap* aBitmap,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]);
   340 	static void DoStoreL(CDirectFileStore* aFileStore,CFbsBitmap* aBitmap,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]);
   328 protected:
   341 protected:
   329 /**
   342 	/** WARNING: For internal use ONLY.  Compatibility is not guaranteed in future releases.
   330 @internalComponent
   343 	 */
   331 */
       
   332 	enum // Flags
   344 	enum // Flags
   333 		{
   345 		{
   334 		EIsRomBitmap = 0x0001
   346 		EIsRomBitmap = 0x0001,
       
   347 		EIsExtendedBitmap = 0x0002,
       
   348 		EIsReadOnlyBitmapMask = EIsRomBitmap | EIsExtendedBitmap
   335 		};
   349 		};
   336 protected:
   350 protected:		
   337 /**
   351 	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. */	
   338 @internalComponent
   352 	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. */	
   339 */
   353 	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. */
   340 	RFbsSession* iFbs;
   354 	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. */
   341 /**
   355 	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. */
   342 @internalComponent
   356 	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. */
   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 	};
   357 	};
   398 
   358 
   399 
   359 
   400 /** 
   360 /** 
   401 Provides fast read/write access to the pixel data of a bitmap. 
   361 Provides fast read/write access to the pixel data of a bitmap. 
   480 	IMPORT_C static void RemoveFontFileLocksL(const TDesC& aDrive, TBool aAllFonts);
   440 	IMPORT_C static void RemoveFontFileLocksL(const TDesC& aDrive, TBool aAllFonts);
   481 	IMPORT_C static void RemoveFontFileLocksL(const TDesC& aFileName);
   441 	IMPORT_C static void RemoveFontFileLocksL(const TDesC& aFileName);
   482 	IMPORT_C void ReleaseTwipsCache();
   442 	IMPORT_C void ReleaseTwipsCache();
   483 	IMPORT_C void SetSystemDefaultTypefaceNameL(const TDesC& aFontTypefaceName);
   443 	IMPORT_C void SetSystemDefaultTypefaceNameL(const TDesC& aFontTypefaceName);
   484 	IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId);
   444 	IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId);
       
   445 	IMPORT_C void GetLinkedTypefaceL(CLinkedTypefaceSpecification& aLinkedTypefaceSpec);
       
   446 	IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec);
       
   447 	IMPORT_C TInt UpdateLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec);
   485 private:
   448 private:
   486 	CFbsTypefaceStore(CGraphicsDevice* aDevice);
   449 	CFbsTypefaceStore(CGraphicsDevice* aDevice);
   487 	void ConstructL();
   450 	void ConstructL();
   488 	TInt CreateFont(CFont*& aFont,const TFontInfo& aFontInfo);
   451 	TInt CreateFont(CFont*& aFont,const TFontInfo& aFontInfo);
   489 	TBool IsFontLoaded(CFont*& aFont, const TFontInfo& aFontInfo) const;
   452 	TBool IsFontLoaded(CFont*& aFont, const TFontInfo& aFontInfo) const;
   490 	TInt FontHeight(TInt aTypefaceIndex,TInt aHeightIndex,TInt aMessage) const;
   453 	TInt FontHeight(TInt aTypefaceIndex,TInt aHeightIndex,TInt aMessage) const;
   491 	TInt GetNearestFontInTwipsAndCreateFont(CFont*& aFont, TFbsMessage aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
   454 	TInt GetNearestFontInTwipsAndCreateFont(CFont*& aFont, TInt aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
   492 	TInt SendGetNearestFontCommandNCreateFont(
   455 	TInt SendGetNearestFontCommandNCreateFont(
   493 		CFont*& aFont, TFbsMessage aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
   456 		CFont*& aFont, TInt aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
   494 	void GetPixelSizeInTwips(TSize& aSize) const;
   457 	void GetPixelSizeInTwips(TSize& aSize) const;
   495 
   458 
   496 private:
   459 private:
   497 	RFbsSession* iFbs;
   460 	RFbsSession* iFbs;
   498 	CGraphicsDevice* iDevice;
   461 	CGraphicsDevice* iDevice;