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 SERVER_H sl@0: #define SERVER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "UTILS.H" sl@0: #include "FBSMBMC.H" sl@0: #include "FbsMessage.H" sl@0: #include "glyphatlas.h" sl@0: sl@0: class CFbTop; sl@0: class CFbsBackgroundCompression; sl@0: class CFbsBackgroundCompressionQueueElement; sl@0: class TOpenFontGlyphData; sl@0: sl@0: sl@0: NONSHARABLE_CLASS(CFontObject): public CObject sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: CFontObject(CFontStore* aFontStore, CGlyphAtlas* aGlyphAtlas); sl@0: ~CFontObject(); sl@0: public: sl@0: CBitmapFont* iAddressPointer; sl@0: CFontStore* iFontStore; sl@0: TInt iHeightInTwips; sl@0: CGlyphAtlas* iGlyphAtlas; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CBitmapObject): public CObject sl@0: /** sl@0: Provides reference counting facilities for bitmaps managed by CFbTop. sl@0: @internalComponent sl@0: */ sl@0: { sl@0: friend class CFbsBackgroundCompression; sl@0: friend class CFbsBackgroundCompressionQueueElement; sl@0: protected: sl@0: CBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp); sl@0: void ConstructL(TBool aReplacement); sl@0: public: sl@0: static CBitmapObject* NewL(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TBool aReplacement); sl@0: ~CBitmapObject(); sl@0: inline CBitwiseBitmap* Address() const; sl@0: inline TInt Handle() const; sl@0: inline CBitmapObject* CleanBitmap() const; sl@0: inline TBool IsInCompressionQueue() const; sl@0: void SetCleanBitmap(CBitmapObject* aNewBmpObj); sl@0: virtual void Close(); sl@0: static TInt Compare(const CBitmapObject& aBmpObj1, const CBitmapObject& aBmpObj2); sl@0: static TInt Compare(const TInt* aHandle, const CBitmapObject& aBmpObj); sl@0: protected: sl@0: CFbTop* iFbTop; sl@0: private: sl@0: CBitwiseBitmap* iAddressPointer; sl@0: TInt iHandle; sl@0: CBitmapObject* iCleanBitmap; sl@0: CFbsBackgroundCompressionQueueElement* iCompressionQueueElement; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CSharedBitmapObject): public CBitmapObject sl@0: /** sl@0: Provides reference counting facilities for shared bitmaps managed by CFbTop. sl@0: Shared bitmaps are only loaded once. They are uniquely identified by the sl@0: combination of the filename, bitmap ID and last modified time of the file. sl@0: @internalComponent sl@0: */ sl@0: { sl@0: friend class CHashMap; sl@0: private: sl@0: CSharedBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey); sl@0: void ConstructL(TUint aHash); sl@0: public: sl@0: static CSharedBitmapObject* NewL(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey, TUint aHash); sl@0: ~CSharedBitmapObject(); sl@0: static HBufC* KeyLC(const TDesC& aFileName, TInt aId, const TTime& aModTime); sl@0: private: sl@0: TDesC* iKey; sl@0: mutable CSharedBitmapObject* iNext; // Next object in a linked list sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CFontBitmapServer): public CPolicyServer sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: CFontBitmapServer(); sl@0: ~CFontBitmapServer(); sl@0: static CFontBitmapServer* NewL(); sl@0: CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; sl@0: TInt Init(); sl@0: #ifdef _DEBUG sl@0: void ProcMessage(const RMessage2& aMessage, TInt aSession, TInt& aRet); sl@0: #else sl@0: void ProcMessage(const RMessage2& aMessage, TInt aSession); sl@0: #endif sl@0: CFbTop* TopLevelStore(); sl@0: sl@0: private: sl@0: void ConstructL(); sl@0: void GetHeapSizesL(const RMessage2& aMessage); sl@0: TInt HandleMesgTypefaceSupport(const RMessage2& aMessage, TBool& aClientPanicRequired); sl@0: TInt HandleMesgFontHeight(const RMessage2& aMessage, TBool aInTwips); sl@0: sl@0: protected: sl@0: TUint iConnectionId; sl@0: CFbTop* iTopLevelStore; sl@0: }; sl@0: sl@0: class TFontFileIndex sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: TUid iUid; sl@0: TInt iAccessCount; sl@0: }; sl@0: sl@0: sl@0: class CFbClient; sl@0: sl@0: NONSHARABLE_CLASS(TFbClientHelper): public TDblQueLink sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: inline TFbClientHelper(CFbClient& aClient); sl@0: sl@0: public: sl@0: CFbClient& iClient; sl@0: RMessagePtr2 iMessage; sl@0: TBool iDirty; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CFbClient): public CSession2 sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: static CFbClient* NewL(RHeap* aHeap); sl@0: ~CFbClient(); sl@0: void Init(TUint aConnectionHandle); sl@0: void CreateL(); sl@0: CFontBitmapServer* FontBitmapServer(); sl@0: CFbTop* TopLevelStore(); sl@0: void CopyFontInfo(CFontObject* aFontObjPtr,TInt aHandle,TFontInfo& aFontInfo); sl@0: void ServiceL(const RMessage2& aMessage); sl@0: void ProcFontMessage(const RMessage2& aMessage); sl@0: void ProcBitmapMessage(const RMessage2& aMessage); sl@0: void NotifyDirtyBitmap(CBitmapObject& aBmpObj); sl@0: void AddFontFileIndexL(TUid aId); sl@0: void RemoveFontFileIndex(TUid aId); sl@0: void Disconnect(const RMessage2 &aMessage); sl@0: #ifdef _DEBUG sl@0: void ProcMemMessage (const RMessage2& aMessage); sl@0: void ProcAtlasMessage (const RMessage2& aMessage); sl@0: #endif sl@0: private: sl@0: void ConstructL(); sl@0: CFbClient(RHeap* aHeap); sl@0: TInt HandleMesgFontDuplicate(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgGetNearestFont(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgGetFontById(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt CopyFontInfoIntoReturnMessage(const RMessage2& aMessage, TBool& aPanicRequired, CFontObject* aFontObj, TInt iWritePosition); sl@0: TInt HandleMesgAddOrInstallFontFile(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgRemoveFontFile(const RMessage2& aMessage); sl@0: TInt HandleMesgRasterize(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgFaceAttrib(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgHasCharacter(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgShapeText(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgShapeDelete(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgGetFontTable(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgGetGlyphOutline(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgReleaseGlyphOutline(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgReleaseFontTable(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgGetGlyphs(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgGetGlyphMetrics(const RMessage2& aMessage, TBool& aPanicRequired); sl@0: TInt HandleMesgOogmStatus(const RMessage2& aMessage); sl@0: void HandleMesgGlyphCacheMetrics(const RMessage2& aMessage); sl@0: sl@0: protected: sl@0: TUint iConnectionHandle; sl@0: CObjectIx* iIx; sl@0: TInt iResourceCount; sl@0: CArrayFixFlat* iFontFileIndex; sl@0: RHeap* iHeap; // the heap containing iOpenFontGlyphData sl@0: TOpenFontGlyphData* iOpenFontGlyphData; // the metrics and bitmap, in shared memory, of the last character rasterized sl@0: TInt iSessionHandle; // used to identify client-specific glyph caches for the new font system sl@0: TFbClientHelper* iHelper; // used to notify client of any bitmap becoming dirty sl@0: sl@0: private: sl@0: RBuf16 iTextToShape; // buffer used to hold incoming text that needs shaping sl@0: RArray iGlyphImagesInTransit; // last glyph images retrieved from glyph atlas sl@0: #ifdef _DEBUG sl@0: TBool iOwnHeapCheck; //for the process heap - current state sl@0: TBool iHeapCheck; //for iHeap - current state sl@0: TBool iOwnHeapCheckFlip; //for the process heap - to switch the current state sl@0: TBool iHeapCheckFlip; //for iHeap - used to switch the current state sl@0: TInt iOwnHeapFailNumber; //the number for the memory fail to be set to. -1: don't set. sl@0: TInt iSharedHeapFailNumber; //the number for the memory fail to be set to. -1 don't set sl@0: TInt iRet; sl@0: TInt iFontDuplicateToFail; //when this is set calls to HandleMesgFontDuplicate() fail for the class. sl@0: #endif sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CFbActiveScheduler): public CActiveScheduler sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: CFbActiveScheduler(); sl@0: virtual void Error(TInt anError) const; sl@0: }; sl@0: sl@0: class CFontStore; sl@0: sl@0: NONSHARABLE_CLASS(CHashMap): public CBase sl@0: /** sl@0: A HashMap data structure for storing pointers to CSharedBitmapObjects. sl@0: Provides fast insert/lookup/removal based on a key. sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: CHashMap(); sl@0: ~CHashMap(); sl@0: sl@0: void Insert(CSharedBitmapObject& aBmpObj, TUint aHash); sl@0: CSharedBitmapObject* Lookup(const TDesC& aKey, TUint aHash) const; sl@0: TInt Remove(const CSharedBitmapObject& aBmpObj); sl@0: static TUint Hash(const TDesC16& aKey); sl@0: sl@0: private: sl@0: CSharedBitmapObject* iHashTable[1< iFontNameAlias; sl@0: RPointerArray iBitmapObjectIndex; sl@0: CHashMap iSharedBitmapObjectHashMap; sl@0: CFbTopStreamIdCache* iMBMCache; sl@0: TLanguage iDefaultLanguageForMetrics; sl@0: CFbsBackgroundCompression* iBackgroundCompression; sl@0: TBuf iSystemDefaultFontTypefaceName; sl@0: TDblQue iClientHelpers; sl@0: TInt64 iNextAvailableSerialNumber; sl@0: CGlyphAtlas* iGlyphAtlas; sl@0: }; sl@0: sl@0: inline CBitwiseBitmap* CBitmapObject::Address() const sl@0: { sl@0: return iAddressPointer; sl@0: } sl@0: sl@0: inline TInt CBitmapObject::Handle() const sl@0: { sl@0: return iHandle; sl@0: } sl@0: sl@0: inline CBitmapObject* CBitmapObject::CleanBitmap() const sl@0: { sl@0: return iCleanBitmap; sl@0: } sl@0: sl@0: inline TBool CBitmapObject::IsInCompressionQueue() const sl@0: { sl@0: return iCompressionQueueElement != NULL; sl@0: } sl@0: sl@0: inline TFbClientHelper::TFbClientHelper(CFbClient& aClient) sl@0: : iClient(aClient), iDirty(EFalse) sl@0: {} sl@0: sl@0: inline CFbsBackgroundCompression* CFbTop::BackgroundCompression() const sl@0: { sl@0: __ASSERT_DEBUG(iBackgroundCompression != NULL, User::Invariant()); sl@0: return iBackgroundCompression; sl@0: } sl@0: sl@0: /** sl@0: It returns the file session handle. sl@0: sl@0: @internalComponent sl@0: */ sl@0: inline RFs& CFbTop::FileSession() sl@0: { sl@0: return iFilesys; sl@0: } sl@0: sl@0: #endif // SERVER_H sl@0: