1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/fbs/fontandbitmapserver/sfbs/SERVER.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,378 @@
1.4 +// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef SERVER_H
1.20 +#define SERVER_H
1.21 +
1.22 +#include <e32base.h>
1.23 +#include <f32file.h>
1.24 +#include <fbs.h>
1.25 +#include <sgresource/sgimage.h>
1.26 +#include "UTILS.H"
1.27 +#include "FBSMBMC.H"
1.28 +#include "FbsMessage.H"
1.29 +#include "glyphatlas.h"
1.30 +
1.31 +class CFbTop;
1.32 +class CFbsBackgroundCompression;
1.33 +class CFbsBackgroundCompressionQueueElement;
1.34 +class TOpenFontGlyphData;
1.35 +
1.36 +
1.37 +NONSHARABLE_CLASS(CFontObject): public CObject
1.38 +/**
1.39 +@internalComponent
1.40 +*/
1.41 + {
1.42 +public:
1.43 + CFontObject(CFontStore* aFontStore, CGlyphAtlas* aGlyphAtlas);
1.44 + ~CFontObject();
1.45 +public:
1.46 + CBitmapFont* iAddressPointer;
1.47 + CFontStore* iFontStore;
1.48 + TInt iHeightInTwips;
1.49 + CGlyphAtlas* iGlyphAtlas;
1.50 + };
1.51 +
1.52 +NONSHARABLE_CLASS(CBitmapObject): public CObject
1.53 +/**
1.54 +Provides reference counting facilities for bitmaps managed by CFbTop.
1.55 +@internalComponent
1.56 +*/
1.57 + {
1.58 + friend class CFbsBackgroundCompression;
1.59 + friend class CFbsBackgroundCompressionQueueElement;
1.60 +protected:
1.61 + CBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp);
1.62 + void ConstructL(TBool aReplacement);
1.63 +public:
1.64 + static CBitmapObject* NewL(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TBool aReplacement);
1.65 + ~CBitmapObject();
1.66 + inline CBitwiseBitmap* Address() const;
1.67 + inline TInt Handle() const;
1.68 + inline CBitmapObject* CleanBitmap() const;
1.69 + inline TBool IsInCompressionQueue() const;
1.70 + void SetCleanBitmap(CBitmapObject* aNewBmpObj);
1.71 + virtual void Close();
1.72 + static TInt Compare(const CBitmapObject& aBmpObj1, const CBitmapObject& aBmpObj2);
1.73 + static TInt Compare(const TInt* aHandle, const CBitmapObject& aBmpObj);
1.74 +protected:
1.75 + CFbTop* iFbTop;
1.76 +private:
1.77 + CBitwiseBitmap* iAddressPointer;
1.78 + TInt iHandle;
1.79 + CBitmapObject* iCleanBitmap;
1.80 + CFbsBackgroundCompressionQueueElement* iCompressionQueueElement;
1.81 + };
1.82 +
1.83 +NONSHARABLE_CLASS(CSharedBitmapObject): public CBitmapObject
1.84 +/**
1.85 +Provides reference counting facilities for shared bitmaps managed by CFbTop.
1.86 +Shared bitmaps are only loaded once. They are uniquely identified by the
1.87 +combination of the filename, bitmap ID and last modified time of the file.
1.88 +@internalComponent
1.89 +*/
1.90 + {
1.91 +friend class CHashMap;
1.92 +private:
1.93 + CSharedBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey);
1.94 + void ConstructL(TUint aHash);
1.95 +public:
1.96 + static CSharedBitmapObject* NewL(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey, TUint aHash);
1.97 + ~CSharedBitmapObject();
1.98 + static HBufC* KeyLC(const TDesC& aFileName, TInt aId, const TTime& aModTime);
1.99 +private:
1.100 + TDesC* iKey;
1.101 + mutable CSharedBitmapObject* iNext; // Next object in a linked list
1.102 + };
1.103 +
1.104 +NONSHARABLE_CLASS(CFontBitmapServer): public CPolicyServer
1.105 +/**
1.106 +@internalComponent
1.107 +*/
1.108 + {
1.109 +public:
1.110 + CFontBitmapServer();
1.111 + ~CFontBitmapServer();
1.112 + static CFontBitmapServer* NewL();
1.113 + CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
1.114 + TInt Init();
1.115 +#ifdef _DEBUG
1.116 + void ProcMessage(const RMessage2& aMessage, TInt aSession, TInt& aRet);
1.117 +#else
1.118 + void ProcMessage(const RMessage2& aMessage, TInt aSession);
1.119 +#endif
1.120 + CFbTop* TopLevelStore();
1.121 +
1.122 +private:
1.123 + void ConstructL();
1.124 + void GetHeapSizesL(const RMessage2& aMessage);
1.125 + TInt HandleMesgTypefaceSupport(const RMessage2& aMessage, TBool& aClientPanicRequired);
1.126 + TInt HandleMesgFontHeight(const RMessage2& aMessage, TBool aInTwips);
1.127 +
1.128 +protected:
1.129 + TUint iConnectionId;
1.130 + CFbTop* iTopLevelStore;
1.131 + };
1.132 +
1.133 +class TFontFileIndex
1.134 +/**
1.135 +@internalComponent
1.136 +*/
1.137 + {
1.138 +public:
1.139 + TUid iUid;
1.140 + TInt iAccessCount;
1.141 + };
1.142 +
1.143 +
1.144 +class CFbClient;
1.145 +
1.146 +NONSHARABLE_CLASS(TFbClientHelper): public TDblQueLink
1.147 +/**
1.148 +@internalComponent
1.149 +*/
1.150 + {
1.151 +public:
1.152 + inline TFbClientHelper(CFbClient& aClient);
1.153 +
1.154 +public:
1.155 + CFbClient& iClient;
1.156 + RMessagePtr2 iMessage;
1.157 + TBool iDirty;
1.158 + };
1.159 +
1.160 +NONSHARABLE_CLASS(CFbClient): public CSession2
1.161 +/**
1.162 +@internalComponent
1.163 +*/
1.164 + {
1.165 +public:
1.166 + static CFbClient* NewL(RHeap* aHeap);
1.167 + ~CFbClient();
1.168 + void Init(TUint aConnectionHandle);
1.169 + void CreateL();
1.170 + CFontBitmapServer* FontBitmapServer();
1.171 + CFbTop* TopLevelStore();
1.172 + void CopyFontInfo(CFontObject* aFontObjPtr,TInt aHandle,TFontInfo& aFontInfo);
1.173 + void ServiceL(const RMessage2& aMessage);
1.174 + void ProcFontMessage(const RMessage2& aMessage);
1.175 + void ProcBitmapMessage(const RMessage2& aMessage);
1.176 + void NotifyDirtyBitmap(CBitmapObject& aBmpObj);
1.177 + void AddFontFileIndexL(TUid aId);
1.178 + void RemoveFontFileIndex(TUid aId);
1.179 + void Disconnect(const RMessage2 &aMessage);
1.180 +#ifdef _DEBUG
1.181 + void ProcMemMessage (const RMessage2& aMessage);
1.182 + void ProcAtlasMessage (const RMessage2& aMessage);
1.183 +#endif
1.184 +private:
1.185 + void ConstructL();
1.186 + CFbClient(RHeap* aHeap);
1.187 + TInt HandleMesgFontDuplicate(const RMessage2& aMessage, TBool& aPanicRequired);
1.188 + TInt HandleMesgGetNearestFont(const RMessage2& aMessage, TBool& aPanicRequired);
1.189 + TInt HandleMesgGetFontById(const RMessage2& aMessage, TBool& aPanicRequired);
1.190 + TInt CopyFontInfoIntoReturnMessage(const RMessage2& aMessage, TBool& aPanicRequired, CFontObject* aFontObj, TInt iWritePosition);
1.191 + TInt HandleMesgAddOrInstallFontFile(const RMessage2& aMessage, TBool& aPanicRequired);
1.192 + TInt HandleMesgRemoveFontFile(const RMessage2& aMessage);
1.193 + TInt HandleMesgRasterize(const RMessage2& aMessage, TBool& aPanicRequired);
1.194 + TInt HandleMesgFaceAttrib(const RMessage2& aMessage, TBool& aPanicRequired);
1.195 + TInt HandleMesgHasCharacter(const RMessage2& aMessage, TBool& aPanicRequired);
1.196 + TInt HandleMesgShapeText(const RMessage2& aMessage, TBool& aPanicRequired);
1.197 + TInt HandleMesgShapeDelete(const RMessage2& aMessage, TBool& aPanicRequired);
1.198 + TInt HandleMesgGetFontTable(const RMessage2& aMessage, TBool& aPanicRequired);
1.199 + TInt HandleMesgGetGlyphOutline(const RMessage2& aMessage, TBool& aPanicRequired);
1.200 + TInt HandleMesgReleaseGlyphOutline(const RMessage2& aMessage, TBool& aPanicRequired);
1.201 + TInt HandleMesgReleaseFontTable(const RMessage2& aMessage, TBool& aPanicRequired);
1.202 + TInt HandleMesgGetGlyphs(const RMessage2& aMessage, TBool& aPanicRequired);
1.203 + TInt HandleMesgGetGlyphMetrics(const RMessage2& aMessage, TBool& aPanicRequired);
1.204 + TInt HandleMesgOogmStatus(const RMessage2& aMessage);
1.205 + void HandleMesgGlyphCacheMetrics(const RMessage2& aMessage);
1.206 +
1.207 +protected:
1.208 + TUint iConnectionHandle;
1.209 + CObjectIx* iIx;
1.210 + TInt iResourceCount;
1.211 + CArrayFixFlat<TFontFileIndex>* iFontFileIndex;
1.212 + RHeap* iHeap; // the heap containing iOpenFontGlyphData
1.213 + TOpenFontGlyphData* iOpenFontGlyphData; // the metrics and bitmap, in shared memory, of the last character rasterized
1.214 + TInt iSessionHandle; // used to identify client-specific glyph caches for the new font system
1.215 + TFbClientHelper* iHelper; // used to notify client of any bitmap becoming dirty
1.216 +
1.217 +private:
1.218 + RBuf16 iTextToShape; // buffer used to hold incoming text that needs shaping
1.219 + RArray<RSgImage> iGlyphImagesInTransit; // last glyph images retrieved from glyph atlas
1.220 +#ifdef _DEBUG
1.221 + TBool iOwnHeapCheck; //for the process heap - current state
1.222 + TBool iHeapCheck; //for iHeap - current state
1.223 + TBool iOwnHeapCheckFlip; //for the process heap - to switch the current state
1.224 + TBool iHeapCheckFlip; //for iHeap - used to switch the current state
1.225 + TInt iOwnHeapFailNumber; //the number for the memory fail to be set to. -1: don't set.
1.226 + TInt iSharedHeapFailNumber; //the number for the memory fail to be set to. -1 don't set
1.227 + TInt iRet;
1.228 + TInt iFontDuplicateToFail; //when this is set calls to HandleMesgFontDuplicate() fail for the class.
1.229 +#endif
1.230 + };
1.231 +
1.232 +NONSHARABLE_CLASS(CFbActiveScheduler): public CActiveScheduler
1.233 +/**
1.234 +@internalComponent
1.235 +*/
1.236 + {
1.237 +public:
1.238 + CFbActiveScheduler();
1.239 + virtual void Error(TInt anError) const;
1.240 + };
1.241 +
1.242 +class CFontStore;
1.243 +
1.244 +NONSHARABLE_CLASS(CHashMap): public CBase
1.245 +/**
1.246 +A HashMap data structure for storing pointers to CSharedBitmapObjects.
1.247 +Provides fast insert/lookup/removal based on a key.
1.248 +@internalComponent
1.249 +*/
1.250 + {
1.251 +public:
1.252 + CHashMap();
1.253 + ~CHashMap();
1.254 +
1.255 + void Insert(CSharedBitmapObject& aBmpObj, TUint aHash);
1.256 + CSharedBitmapObject* Lookup(const TDesC& aKey, TUint aHash) const;
1.257 + TInt Remove(const CSharedBitmapObject& aBmpObj);
1.258 + static TUint Hash(const TDesC16& aKey);
1.259 +
1.260 +private:
1.261 + CSharedBitmapObject* iHashTable[1<<KFBSERVSharedBitmapHashTableSizeInBits]; // Array of pointers to singularly linked lists. Linked list elements are CSharedBitmapObjects.
1.262 + TInt iTableSize;
1.263 + TInt iMask;
1.264 + };
1.265 +
1.266 +
1.267 +IMPORT_C extern const TInt KFbServSharedHeapMaxSize;
1.268 +IMPORT_C extern const TInt KFbServGlyphAtlasCacheLimit;
1.269 +
1.270 +
1.271 +NONSHARABLE_CLASS(CFbTop): public CBase
1.272 +/**
1.273 +@internalComponent
1.274 +*/
1.275 + {
1.276 + friend class CFontBitmapServer;
1.277 + friend class CBitmapObject;
1.278 + friend class CSharedBitmapObject;
1.279 +public:
1.280 + ~CFbTop();
1.281 + static CFbTop* NewL();
1.282 + TInt GetNearestFont(CFontObject*& aFontObjPtr, TFbsMessage aMessage, const TFontSpec& aFontSpec, TInt aMaxHeight = 0);
1.283 + TInt GetFontById(CFontObject*& aFontObjPtr,TUid aUid,const TAlgStyle& aAlgStyle);
1.284 + CBitmapObject* CreateBitmapL(const TSize& aSize, TDisplayMode aDispMode, TUid aUid, TBool aReplacement, TInt aDataSize = 0);
1.285 + CBitmapObject* LoadBitmapL(const TDesC& aFilename, TInt32 aId, TUint aFileOffset,RFile* aFile, TInt aSessionHandle);
1.286 + CSharedBitmapObject* ShareBitmapL(TDes& aFilename, TInt32 aId, TUint aFileOffset,RFile* aFile, TInt aSessionHandle);
1.287 + TInt GetCleanBitmap(CBitmapObject*& aBmpObjPtr);
1.288 + CBitmapObject* FindBitmap(TInt aHandle);
1.289 + TBool ValidFontHandle(TInt aHandle);
1.290 + CFontStore* FontStore() const;
1.291 + RHeap* Heap() const;
1.292 + CChunkPile* Pile() const;
1.293 + TInt HeapBase() const;
1.294 + void SetFontNameAliasL(const RMessage2& aMessage);
1.295 + void SetDefaultLanguageForMetrics(const RMessage2& aMessage);
1.296 + inline CFbsBackgroundCompression* BackgroundCompression() const;
1.297 + void CloseFileStores(TInt aSessionHandle);
1.298 + void SetSystemDefaultTypefaceName(const TDesC& aFontTypefaceName);
1.299 + TInt GetAllBitmapHandles(const RMessage2& aMessage) const;
1.300 + inline RFs& FileSession();
1.301 + void AddClientHelper(TFbClientHelper& aHelper);
1.302 + void NotifyDirtyBitmap(CBitmapObject& aBmpObj, CFbClient* aClient);
1.303 + TInt BitmapConUniqueID() const;
1.304 + TInt FontConUniqueID() const;
1.305 + CGlyphAtlas* GlyphAtlas() const;
1.306 +private:
1.307 + CFbTop();
1.308 + void ConstructL();
1.309 + CBitwiseBitmap* DoLoadBitmapLC(const TDesC& aFilename, TInt32 aId, TUint aFileOffset, RFile* aFile, TInt aSessionHandle);
1.310 + void LoadOpenFontLibraries();
1.311 + void SafeInstallOfRasterizerL(TUid aInterfaceImplUid);
1.312 + TInt FindFontNameAlias(const TDesC& aAlias);
1.313 + void LoadShaperFactories();
1.314 + void SafeInstallOfShaperFactoryL(TUid aInterfaceImplUid);
1.315 + TInt GetFontObjectFromFont(CFontObject*& aFontObjPtr, CFont* aFont);
1.316 + TInt GetNearestNonAliasedFont(CFont*& aFont, TFbsMessage aMessage, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.317 +private:
1.318 + RFs iFilesys;
1.319 + CFontStore* iFontStore;
1.320 + CObjectCon* iBitmapCon;
1.321 + CObjectCon* iFontCon;
1.322 + CObjectConIx* iConIx;
1.323 + RHeap* iHeap;
1.324 + RChunk iChunk;
1.325 + RChunk iLargeBitmapChunk;
1.326 + RMutex iDebugMutex; // used only in builds with SYMBIAN_DEBUG_FBS_LOCKHEAP defined
1.327 + CChunkPile* iPile;
1.328 + RPointerArray<HBufC> iFontNameAlias;
1.329 + RPointerArray<CBitmapObject> iBitmapObjectIndex;
1.330 + CHashMap iSharedBitmapObjectHashMap;
1.331 + CFbTopStreamIdCache* iMBMCache;
1.332 + TLanguage iDefaultLanguageForMetrics;
1.333 + CFbsBackgroundCompression* iBackgroundCompression;
1.334 + TBuf<KMaxTypefaceNameLength> iSystemDefaultFontTypefaceName;
1.335 + TDblQue<TFbClientHelper> iClientHelpers;
1.336 + TInt64 iNextAvailableSerialNumber;
1.337 + CGlyphAtlas* iGlyphAtlas;
1.338 + };
1.339 +
1.340 +inline CBitwiseBitmap* CBitmapObject::Address() const
1.341 + {
1.342 + return iAddressPointer;
1.343 + }
1.344 +
1.345 +inline TInt CBitmapObject::Handle() const
1.346 + {
1.347 + return iHandle;
1.348 + }
1.349 +
1.350 +inline CBitmapObject* CBitmapObject::CleanBitmap() const
1.351 + {
1.352 + return iCleanBitmap;
1.353 + }
1.354 +
1.355 +inline TBool CBitmapObject::IsInCompressionQueue() const
1.356 + {
1.357 + return iCompressionQueueElement != NULL;
1.358 + }
1.359 +
1.360 +inline TFbClientHelper::TFbClientHelper(CFbClient& aClient)
1.361 + : iClient(aClient), iDirty(EFalse)
1.362 + {}
1.363 +
1.364 +inline CFbsBackgroundCompression* CFbTop::BackgroundCompression() const
1.365 + {
1.366 + __ASSERT_DEBUG(iBackgroundCompression != NULL, User::Invariant());
1.367 + return iBackgroundCompression;
1.368 + }
1.369 +
1.370 +/**
1.371 +It returns the file session handle.
1.372 +
1.373 +@internalComponent
1.374 +*/
1.375 +inline RFs& CFbTop::FileSession()
1.376 + {
1.377 + return iFilesys;
1.378 + }
1.379 +
1.380 +#endif // SERVER_H
1.381 +