sl@0: // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __FBS_H__ sl@0: #define __FBS_H__ sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TUid KCFbsFontUid = { 268435518 }; sl@0: sl@0: /** sl@0: Indicates version of the font and bitmap server without heap locking. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define SYMBIAN_FBSERV_V2 sl@0: sl@0: /** sl@0: Indicates version of FBS that provides the CFbsFont extension sl@0: interfaces RFbsGlyphDataIterator for using hardware glyphs, and sl@0: RFbsGlyphMetricsArray. sl@0: @publishedAll sl@0: @prototype sl@0: */ sl@0: //#define SYMBIAN_FBSERV_GLYPHDATA sl@0: sl@0: /** sl@0: Character width and adjustment information. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class SCharWidth sl@0: { sl@0: public: sl@0: /** The left adjust of the character. */ sl@0: TInt iLeftAdjust; sl@0: /** The right adjust of the character. */ sl@0: TInt iRightAdjust; sl@0: /** The total width of the character, defined as iLeftAdjust + iWidth + iRightAdjust. */ sl@0: TInt iMove; sl@0: /** The width of the character. */ sl@0: TInt iWidth; sl@0: }; sl@0: sl@0: class CFbsRalCache; sl@0: class CFbsSessionHelper; sl@0: class CFbsRasterizer; sl@0: class TGlyphCacheMetrics; sl@0: class TFbsOogmMessage; sl@0: sl@0: /** sl@0: A session with the font and bitmap server. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class RFbsSession : protected RSessionBase sl@0: { sl@0: // Allow access to internals for test sl@0: friend class RClean; sl@0: friend class TestFbs; sl@0: friend class CTBitmap; sl@0: friend class CTClean; sl@0: friend class CTFbs; sl@0: sl@0: friend class CFbsBitmap; sl@0: friend class CFbsBitmapAsyncStreamer; sl@0: public: sl@0: IMPORT_C RFbsSession(); sl@0: IMPORT_C static TInt Connect(); sl@0: IMPORT_C static TInt Connect(RFs& aFileServer); sl@0: IMPORT_C static void Disconnect(); sl@0: IMPORT_C static RFbsSession* GetSession(); sl@0: IMPORT_C void CallBack(); sl@0: IMPORT_C void SetCallBack(TCallBack aCallBack); sl@0: IMPORT_C void ResetCallBack(); sl@0: IMPORT_C TInt ResourceCount(); sl@0: IMPORT_C TInt SendCommand(TInt aMessage,TInt aInt0=0,TInt aInt1=0,TInt aInt2=0,TInt aInt3=0) const; sl@0: TInt SendCommand(TInt aMessage, const TIpcArgs& aArgs) const; sl@0: void SendCommand(TInt aMessage, const TIpcArgs& aArgs, TRequestStatus &aStatus) const; sl@0: IMPORT_C TVersion Version(); sl@0: IMPORT_C TUint8* HeapBase() const; sl@0: IMPORT_C TInt GetHeapSizes(TInt& aDefaultHeap, TInt& aSmallBmpHeap, TInt& aBigBmpChunk); sl@0: TInt SessionHandle() const { return Handle(); } sl@0: TInt AllocScanLineBuffer(TInt aSize); sl@0: HBufC8* GetScanLineBuffer(); sl@0: void SetCallBackPtr(TInt* aBitmapHandle)const; sl@0: HBufC8* GetDecompressionBuffer(TInt aSize); sl@0: HBufC8* GetExtraBuffer(TInt aSize); sl@0: TInt ServerSessionHandle() const; sl@0: IMPORT_C TInt GetGlyphCacheMetrics(TGlyphCacheMetrics& aGlyphCacheMetrics); sl@0: IMPORT_C TInt ConveyOogmMessage( TFbsOogmMessage& aOogmMessage ); sl@0: sl@0: public: sl@0: /** WARNING: For internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: Used for testing server side out of memory failures. sl@0: @test sl@0: */ sl@0: enum THeapFailType sl@0: { sl@0: EHeapFailTypeServerMemory, sl@0: EHeapFailTypeHeapMemory, sl@0: }; sl@0: private: sl@0: TBool LookupBitmapInROM(const TDesC& aFilename, TAny*& aAddr); sl@0: RFs& FileServer() { return *((RFs*)iSpare); } sl@0: static TInt DoAlloc(RFbsSession*& aNewSession); sl@0: TInt DoConnect(RFs& aFileServer); sl@0: private: sl@0: TInt iConnections; sl@0: mutable TCallBack iCallBack; sl@0: RChunk iSharedChunk; sl@0: CFbsSessionHelper* iHelper; sl@0: RChunk iLargeBitmapChunk; sl@0: RFs iFileServer; sl@0: CFbsRalCache* iRomFileAddrCache; sl@0: HBufC8* iDecompressionBuffer; sl@0: HBufC8* iScanLineBuffer; sl@0: TUint32* iSpare; sl@0: }; sl@0: sl@0: /** forward declaration of some private classes. */ sl@0: class TGetFontTableParam; sl@0: class TReleaseGlyphOutlineParam; sl@0: class TGetGlyphOutlineParam; sl@0: sl@0: sl@0: /** sl@0: Font managed by the font and bitmap server. sl@0: CFbsFont objects are used for screen and off-screen bitmap fonts. They are sl@0: usually obtained by calls to the CBitmapDevice::GetNearestFontInPixels() and sl@0: MGraphicsDeviceMap::GetNearestFontInTwips() functions. sl@0: The class implements a number of functions inherited from CFont. sl@0: @see CBitmapDevice::GetNearestFontInPixels() sl@0: @see MGraphicsDeviceMap::GetNearestFontInTwips() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFbsFont: public CFont sl@0: { sl@0: friend class CFbsTypefaceStore; sl@0: friend class RFbsGlyphDataIterator; sl@0: friend class RFbsGlyphMetricsArray; sl@0: sl@0: private: sl@0: // From CFont sl@0: /** Gets the font's UID. sl@0: All CFbsFont objects have the constant UID KCFbsFontUid. It is safe to cast sl@0: from CFont* to CFbsFont* if CFont::TypeUid() returns KCFbsFontUid. sl@0: @return The font's UID. This should be KCFbsFontUid. sl@0: @see CFont::TypeUid() */ sl@0: virtual TUid DoTypeUid() const { return KCFbsFontUid; } sl@0: IMPORT_C virtual TInt DoHeightInPixels() const; sl@0: IMPORT_C virtual TInt DoAscentInPixels() const; sl@0: IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const; sl@0: IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC& aText) const; sl@0: IMPORT_C virtual TInt DoBaselineOffsetInPixels() const; sl@0: IMPORT_C virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const; sl@0: IMPORT_C virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const; sl@0: IMPORT_C virtual TInt DoMaxCharWidthInPixels() const; sl@0: IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const; sl@0: IMPORT_C virtual TFontSpec DoFontSpecInTwips() const; sl@0: IMPORT_C virtual CFont::TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics, sl@0: const TUint8*& aBitmap, TSize& aBitmapSize) const; sl@0: IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const; sl@0: sl@0: public: sl@0: // New functions sl@0: IMPORT_C TBool GetFontMetrics(TOpenFontMetrics& aMetrics) const; sl@0: IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const; sl@0: IMPORT_C void TextWidthInPixels(const TDesC& aText,SCharWidth& aCharWidth) const; sl@0: IMPORT_C TInt Handle() const; sl@0: IMPORT_C TCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const; sl@0: IMPORT_C TInt RawTextWidthInPixels(const TDesC& aText) const; sl@0: IMPORT_C TBool GetFaceAttrib(TOpenFontFaceAttrib& aAttrib) const; sl@0: IMPORT_C TBool IsOpenFont() const; sl@0: IMPORT_C TBool HasCharacter(TInt aCode) const; sl@0: IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const; sl@0: IMPORT_C void TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam,SCharWidth& aCharWidth) const; sl@0: sl@0: sl@0: protected: sl@0: IMPORT_C CFbsFont(); sl@0: IMPORT_C ~CFbsFont(); sl@0: IMPORT_C CFbsFont(const CFbsFont& aFont); sl@0: IMPORT_C CBitmapFont* Address() const; sl@0: IMPORT_C TInt Duplicate(TInt aHandle); sl@0: IMPORT_C void Reset(); sl@0: sl@0: private: sl@0: TInt DoFontGetShaping(TFontShapeFunctionParameters* aParam) const; sl@0: TInt DoFontDeleteShaping(TFontShapeDeleteFunctionParameters* aParam) const; sl@0: TInt DoTextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const; sl@0: TInt DoGetFontTable(TGetFontTableParam * aParam) const; sl@0: TInt DoGetGlyphOutline(TGetGlyphOutlineParam *aParam) const; sl@0: TInt DoReleaseGlyphOutline(TReleaseGlyphOutlineParam *aParam) const; sl@0: TInt DoReleaseFontTable(TUint32 *aParam) const; sl@0: sl@0: protected: sl@0: RFbsSession* iFbs; sl@0: CBitmapFont* iAddressPointer; sl@0: TInt iHandle; sl@0: TInt iServerHandle; sl@0: }; sl@0: sl@0: /** sl@0: An interface for initialization of extended bitmaps. By implementing this interface, sl@0: creators of extended bitmaps can set the contents of an extended bitmap without sl@0: allocating a temporary buffer and avoid unnecessary memory copying during calls to sl@0: CFbsBitmap::CreateExtendedBitmap(). sl@0: sl@0: WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases. sl@0: sl@0: @publishedAll sl@0: @see CFbsBitmap::CreateExtendedBitmap() sl@0: */ sl@0: class MFbsExtendedBitmapInitializer sl@0: { sl@0: public: sl@0: /** sl@0: Initializes the raw data of an extended bitmap. sl@0: @param aData A pointer to the raw data to be initialized. sl@0: @param aDataSize The size in bytes of the raw data to be initialized. sl@0: @return KErrNone if successful, otherwise another of the system-wide error codes. sl@0: */ sl@0: virtual TInt InitExtendedBitmap(TAny* aData, TInt aDataSize) = 0; sl@0: }; sl@0: sl@0: class CDirectFileStore; sl@0: sl@0: /** sl@0: Note that this class is not intended for user derivation. sl@0: A bitmap managed by the font and bitmap server. sl@0: The class also defines some palette functionality which is not yet sl@0: implemented, since none of the modes currently supported by screen sl@0: or bitmaps require variable palettes. sl@0: Note that the CFbsBitmap format is internal to Symbian, but the sl@0: Image Converter API can be used to convert such bitmaps to standard formats. sl@0: CFbsBitmap instances cannot be shared between different threads. They use some shared sl@0: thread local storage data. If you want to share a bitmap between threads, use Duplicate(). sl@0: @publishedAll sl@0: @released sl@0: @see CFbsBitmap::Duplicate() sl@0: */ sl@0: class CFbsBitmap : public CBase sl@0: { sl@0: friend class TBitmapUtil; sl@0: friend class CBitwiseBitmap; sl@0: friend class CFbsBitmapAsyncStreamer; sl@0: friend class CFbsSessionHelper; sl@0: public: sl@0: IMPORT_C CFbsBitmap(); sl@0: IMPORT_C ~CFbsBitmap(); sl@0: IMPORT_C void Reset(); sl@0: IMPORT_C static TInt ScanLineLength(TInt aLength,TDisplayMode aDispMode); sl@0: IMPORT_C TDisplayMode DisplayMode() const; sl@0: IMPORT_C TDisplayMode InitialDisplayMode() const; sl@0: IMPORT_C TInt SetDisplayMode(TDisplayMode aDisplayMode); sl@0: IMPORT_C TInt Create(const TSize& aSizeInPixels,TDisplayMode aDispMode); sl@0: IMPORT_C TInt Duplicate(TInt aHandle); sl@0: IMPORT_C TBool IsRomBitmap() const; sl@0: IMPORT_C void SetRomBitmapL(CBitwiseBitmap* aRomBitmapPointer,TInt& aBitmapSizeInBytes); sl@0: IMPORT_C TInt Load(const TDesC& aFileName,TInt32 aId=0,TBool aShareIfLoaded=ETrue); sl@0: IMPORT_C TInt Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset); sl@0: IMPORT_C TInt LoadAndCompress(const TDesC& aFileName,TInt32 aId=0,TBool aShareIfLoaded=ETrue); sl@0: IMPORT_C TInt LoadAndCompress(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset); sl@0: IMPORT_C TInt Load(RFile& aFile,TInt32 aId=0,TBool aShareIfLoaded=ETrue); sl@0: IMPORT_C TInt Load(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset); sl@0: IMPORT_C TInt LoadAndCompress(RFile& aFile,TInt32 aId=0,TBool aShareIfLoaded=ETrue); sl@0: IMPORT_C TInt LoadAndCompress(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset); sl@0: IMPORT_C TInt Save(const TDesC& aFilename); sl@0: IMPORT_C TInt Save(RFile& aFile); sl@0: IMPORT_C static void StoreL(const TDesC& aFilename,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]); sl@0: IMPORT_C static void StoreL(RFile& aFile,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]); sl@0: IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode) const; sl@0: IMPORT_C void SetScanLine(TDes8& aBuf,TInt aY) const; sl@0: IMPORT_C void GetVerticalScanLine(TDes8& aBuf,TInt aX,TDisplayMode aDispMode) const; sl@0: IMPORT_C void GetVerticalScanLine(TDes8& aBuf,TInt aX,const TPoint& aDitherOffset,TDisplayMode aDispMode) const; sl@0: IMPORT_C TInt Handle() const; sl@0: IMPORT_C SEpocBitmapHeader Header() const; sl@0: IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const; sl@0: IMPORT_C TInt Resize(const TSize& aSizeInPixels); sl@0: IMPORT_C TSize SizeInPixels() const; sl@0: IMPORT_C TSize SizeInTwips() const; sl@0: IMPORT_C void SetSizeInTwips(const MGraphicsDeviceMap* aMap); sl@0: IMPORT_C void SetSizeInTwips(const TSize& aSizeInTwips); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C void ExternalizeRectangleL(RWriteStream& aStream,const TRect& aRect) const; sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C TInt Compress(); sl@0: IMPORT_C TInt Compress(TBitmapfileCompressionScheme aScheme); sl@0: IMPORT_C void CompressInBackground(TRequestStatus& aRequestStatus); sl@0: IMPORT_C TInt CompressInBackground(); sl@0: IMPORT_C void CompressInBackground(TRequestStatus& aRequestStatus, TBitmapfileCompressionScheme aScheme); sl@0: IMPORT_C TInt CompressInBackground(TBitmapfileCompressionScheme aScheme); sl@0: IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C static TBool IsFileInRom(const TDesC& aFilename,TUint32*& aWord); sl@0: IMPORT_C static TBool IsFileInRom(RFile& aFile,TUint32*& aWord); sl@0: IMPORT_C TBool IsMonochrome() const; sl@0: IMPORT_C TBool IsLargeBitmap() const; sl@0: IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const; sl@0: IMPORT_C void SetPalette(CPalette* aPalette); sl@0: IMPORT_C TInt GetPalette(CPalette*& aPalette) const; sl@0: IMPORT_C TUint32* DataAddress() const; sl@0: IMPORT_C TInt DataStride() const; sl@0: IMPORT_C TInt CreateHardwareBitmap(const TSize& aSizeInPixels,TDisplayMode aDispMode,TUid aCreatorUid); sl@0: IMPORT_C TInt HardwareBitmapHandle() const; sl@0: IMPORT_C void BeginDataAccess() const; sl@0: IMPORT_C void EndDataAccess(TBool aReadOnly=EFalse) const; sl@0: IMPORT_C void LockHeap(TBool aAlways=EFalse) const; sl@0: IMPORT_C void UnlockHeap(TBool aAlways=EFalse) const; sl@0: IMPORT_C void LockHeapLC(TBool aAlways=EFalse) const; sl@0: IMPORT_C static void UnlockHeap(TAny* aFbsBitmap); sl@0: IMPORT_C TBool IsVolatile() const; sl@0: IMPORT_C TInt TouchCount() const; sl@0: IMPORT_C TInt64 SerialNumber() const; sl@0: IMPORT_C TBool IsCompressedInRAM() const; sl@0: IMPORT_C TInt SwapWidthAndHeight(); sl@0: IMPORT_C TInt CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, const TAny* aData, TInt aDataSize); sl@0: IMPORT_C TInt CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, TInt aDataSize, MFbsExtendedBitmapInitializer& aInitializer); sl@0: IMPORT_C TUid ExtendedBitmapType() const; sl@0: IMPORT_C TInt DataSize() const; sl@0: IMPORT_C static HBufC8* GetDecompressionBuffer(TInt aSize); sl@0: IMPORT_C static CFbsRasterizer* Rasterizer(); sl@0: IMPORT_C TInt GetAllBitmapHandles(RArray& aBitmapIdArray) const; sl@0: IMPORT_C static HBufC8* GetExtraBuffer(TInt aSize); sl@0: protected: sl@0: IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,const TPoint& aDitherOffset,TDisplayMode aDispMode) const; sl@0: CBitwiseBitmap* Address() const; sl@0: IMPORT_C CBitwiseBitmap* CleanAddress() const; sl@0: inline CBitwiseBitmap* BeginDataAccessAndGetCleanAddress(TUint32*& aDataAddress) const; sl@0: void DoSaveL(RFile& aFile); sl@0: TInt DoCreate(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aUid, TInt aDataSize = 0); sl@0: private: sl@0: TInt DoLoad(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset); sl@0: TInt DoLoad(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset); sl@0: TInt DoLoadFromRom(TUint32* aRomPointer, TInt32 aId, TUint aFileOffset, TBool& aRomPointerValid); sl@0: TBool LoadShiftedRomBmpL(const TDesC& aFileName,TInt32 aId,TUint aFileOffset); sl@0: static void DoStoreL(CDirectFileStore* aFileStore,CFbsBitmap* aBitmap,TInt aNumSources,const TDesC* aSources[],TInt32 aSourceIds[]); sl@0: TInt DuplicateInRom(TInt aBitmapHandle); sl@0: TInt DuplicateInRam(TInt aBitmapHandle); sl@0: protected: sl@0: /** WARNING: For internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: */ sl@0: enum // Flags sl@0: { sl@0: EIsRomBitmap = 0x0001, sl@0: EIsExtendedBitmap = 0x0002, sl@0: EIsReadOnlyBitmapMask = EIsRomBitmap | EIsExtendedBitmap sl@0: }; sl@0: protected: sl@0: 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. */ sl@0: 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. */ sl@0: 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. */ sl@0: 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. */ sl@0: 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. */ sl@0: 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. */ sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Provides fast read/write access to the pixel data of a bitmap. sl@0: sl@0: Functionality includes getting and setting the individual pixels of a bitmap. sl@0: Common to this is the concept of the current pixel position. This is held sl@0: as member data and is changed by using various efficient functions. For example, sl@0: incrementing the position's x- or y co-ordinate is much quicker than setting sl@0: a completely new position. This efficiency issue is important as these functions sl@0: are used as part of the frequently used blitting DDA used for creating sl@0: stretched or compressed versions of bitmaps. sl@0: sl@0: Calls to Begin() and End() must surround any calls to the other member functions. sl@0: Note that you should always ensure each Begin() is matched by an End() call sl@0: when using this class. sl@0: sl@0: Note also that all display modes including EColor16M are supported, but the sl@0: TDisplayMode values ERgb and ENone are not considered to be display modes. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TBitmapUtil sl@0: { sl@0: public: sl@0: IMPORT_C void Begin(const TPoint& aPosition); sl@0: IMPORT_C void Begin(const TPoint& aPosition,const TBitmapUtil& aUtil); sl@0: IMPORT_C void End(); sl@0: IMPORT_C TBitmapUtil(CFbsBitmap* aBitmap); sl@0: IMPORT_C TUint32 GetPixel() const; sl@0: IMPORT_C void SetPixel(TUint32 aValue); sl@0: IMPORT_C void SetPixel(const TBitmapUtil& aSource); sl@0: IMPORT_C void SetPos(const TPoint& aPosition); sl@0: IMPORT_C void DecXPos(); sl@0: IMPORT_C void DecYPos(); sl@0: IMPORT_C void IncXPos(); sl@0: IMPORT_C void IncYPos(); sl@0: private: sl@0: CFbsBitmap* iFbsBitmap; sl@0: TUint32* iWordPos; sl@0: TUint32* iMinWordPos; sl@0: TUint32* iMaxWordPos; sl@0: TInt iBpp; sl@0: TInt iPixelShift; sl@0: TInt iBitShift; sl@0: TUint32 iMask; sl@0: TInt iScanlineWordLength; sl@0: TBool iWritten; sl@0: }; sl@0: sl@0: class TFontInfo; sl@0: sl@0: /** sl@0: Font and bitmap server typeface store. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFbsTypefaceStore : public CTypefaceStore sl@0: { sl@0: friend class CWsScreenDevice; sl@0: public: sl@0: IMPORT_C static CFbsTypefaceStore* NewL(CGraphicsDevice* aDevice); sl@0: IMPORT_C ~CFbsTypefaceStore(); sl@0: IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId); sl@0: IMPORT_C TInt InstallFile(const TDesC& aName,TInt& aId); sl@0: IMPORT_C void RemoveFile(TInt aId=0); sl@0: IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: IMPORT_C TInt GetFontById(CFont *&aFont,TUid aUid,const TAlgStyle& aAlgStyle); sl@0: IMPORT_C virtual TInt NumTypefaces() const; sl@0: IMPORT_C virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const; sl@0: IMPORT_C virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const; sl@0: IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const; sl@0: IMPORT_C TGlyphBitmapType DefaultBitmapType() const; sl@0: IMPORT_C void SetDefaultBitmapType(TGlyphBitmapType aType) const; sl@0: IMPORT_C void SetFontNameAliasL(const TDesC& aFontAlias,const TDesC& aFontName) const; sl@0: IMPORT_C void SetDefaultLanguageForMetrics(TLanguage aLanguage) const; sl@0: IMPORT_C static void RemoveFontFileLocksL(); sl@0: IMPORT_C static void RemoveFontFileLocksL(const TDesC& aDrive, TBool aAllFonts); sl@0: IMPORT_C static void RemoveFontFileLocksL(const TDesC& aFileName); sl@0: IMPORT_C void ReleaseTwipsCache(); sl@0: IMPORT_C void SetSystemDefaultTypefaceNameL(const TDesC& aFontTypefaceName); sl@0: IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId); sl@0: IMPORT_C void GetLinkedTypefaceL(CLinkedTypefaceSpecification& aLinkedTypefaceSpec); sl@0: IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec); sl@0: IMPORT_C TInt UpdateLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec); sl@0: private: sl@0: CFbsTypefaceStore(CGraphicsDevice* aDevice); sl@0: void ConstructL(); sl@0: TInt CreateFont(CFont*& aFont,const TFontInfo& aFontInfo); sl@0: TBool IsFontLoaded(CFont*& aFont, const TFontInfo& aFontInfo) const; sl@0: TInt FontHeight(TInt aTypefaceIndex,TInt aHeightIndex,TInt aMessage) const; sl@0: TInt GetNearestFontInTwipsAndCreateFont(CFont*& aFont, TInt aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0); sl@0: TInt SendGetNearestFontCommandNCreateFont( sl@0: CFont*& aFont, TInt aFbsMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0); sl@0: void GetPixelSizeInTwips(TSize& aSize) const; sl@0: sl@0: private: sl@0: RFbsSession* iFbs; sl@0: CGraphicsDevice* iDevice; sl@0: CFontCache* iTwipsCache; sl@0: }; sl@0: sl@0: class CDitherColor256; sl@0: sl@0: /** sl@0: Copies a bitmap in any display mode of at least 256 colours into a 256 sl@0: colour bitmap, optionally using a user-defined palette. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFbsColor256BitmapUtil : public CBase sl@0: { sl@0: public: sl@0: /** Indicates whether or not to use dithering. */ sl@0: enum TDither sl@0: { sl@0: /** No dithering. */ sl@0: ENoDither, sl@0: /** Use the Floyd-Steinberg dithering algorithm. */ sl@0: EFloydSteinberg sl@0: }; sl@0: public: sl@0: sl@0: IMPORT_C static CFbsColor256BitmapUtil* NewL(const CPalette* aPalette); sl@0: sl@0: IMPORT_C TInt CopyBitmap(CFbsBitmap* aColor256Destination,CFbsBitmap* aSource,TDither aDither=ENoDither); sl@0: sl@0: ~CFbsColor256BitmapUtil(); sl@0: private: sl@0: CFbsColor256BitmapUtil(); sl@0: private: sl@0: TColor256Util* iColor256Util; sl@0: CDitherColor256* iDither; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: A class encapsulating the current state of the glyph cache. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TGlyphCacheMetrics sl@0: { sl@0: public: sl@0: TInt iMaxCacheSizeInBytes; sl@0: TInt iMaxCacheSizeHigh; sl@0: TInt iMaxCacheSizeLow; sl@0: TInt iCacheSizeInBytes; sl@0: TBool iGpuCacheSizeLimitIsMax; sl@0: }; sl@0: sl@0: #endif // __FBS_H__ sl@0: