fbs/fontandbitmapserver/sfbs/SERVER.CPP
branchRCL_3
changeset 163 bbf46f59e123
parent 0 5d03bc08d59c
child 164 25ffed67c7ef
--- a/fbs/fontandbitmapserver/sfbs/SERVER.CPP	Thu Aug 19 11:11:18 2010 +0300
+++ b/fbs/fontandbitmapserver/sfbs/SERVER.CPP	Tue Aug 31 16:31:06 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -22,7 +22,7 @@
 #include "BitwiseBitmap.inl"
 
 const TInt KFbsPriority = 0;
-
+const TInt KFbsGoomMonitorSid = 0x10207218;
 // Setup security policies
 const TInt KRanges[] = 
 	{
@@ -36,7 +36,11 @@
 	EFbsMessRegisterLinkedTypeface,
 	EFbsMessFetchLinkedTypeface,
 	EFbsMessUpdateLinkedTypeface,
+	EFbsMessGetFontTable,
+    EFbsMessOogmNotification,
+    EFbsMessGetGlyphCacheMetrics,
 	};
+
 const TUint KRangeCount = sizeof(KRanges)/sizeof(TInt);
 const TUint8 KElementsIndex[KRangeCount] = 
 	{
@@ -50,14 +54,20 @@
 	1, // ECapabilityWriteDeviceData for EFbsMessRegisterLinkedTypeface
 	2, // ECapabilityReadDeviceData for EFbsMessFetchLinkedTypeface
 	1, // ECapabilityWriteDeviceData for EFbsMessUpdateLinkedTypeface
+	0, // ECapability_None for EFbsMessGetFontTable and beyond
+    4, // SID for EFbsMessOogmNotification.
+    0, // For EFbsMessGetGlyphCacheMetrics and on.
 	};
+
 const CPolicyServer::TPolicyElement KElements[] = 
 	{
 	{_INIT_SECURITY_POLICY_C1(ECapability_None), CPolicyServer::EFailClient},
 	{_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient},
 	{_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData), CPolicyServer::EFailClient},
-	{_INIT_SECURITY_POLICY_C1(ECapabilityPowerMgmt), CPolicyServer::EFailClient},	
+	{_INIT_SECURITY_POLICY_C1(ECapabilityPowerMgmt), CPolicyServer::EFailClient},
+	{_INIT_SECURITY_POLICY_S0(KFbsGoomMonitorSid), CPolicyServer::EFailClient}
  	};
+
 const CPolicyServer::TPolicy KFbsPolicy =
 	{
 	CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
@@ -68,9 +78,7 @@
 	};
 
 CFontBitmapServer::CFontBitmapServer():
-	CPolicyServer(KFbsPriority, KFbsPolicy),
-	iConnectionId(0),
-	iTopLevelStore(NULL)
+	CPolicyServer(KFbsPriority, KFbsPolicy)
 	{
 	}
 
@@ -83,25 +91,33 @@
 
 CFontBitmapServer* CFontBitmapServer::NewL()
 	{
-	CFontBitmapServer* fbs=new(ELeave) CFontBitmapServer;
-	CleanupStack::PushL(fbs);
-	fbs->iTopLevelStore=CFbTop::NewL();
+	CFontBitmapServer* self = new(ELeave) CFontBitmapServer;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(); //self
+	return self;
+	}
+
+/**
+Two-phase constructor.
+*/
+void CFontBitmapServer::ConstructL()
+	{
+	iTopLevelStore=CFbTop::NewL();
 	
 	// If fbserv data paging is configured as unpaged, automatically pin client descriptors 
 	if(!RProcess().DefaultDataPaged())
 		{
-		fbs->SetPinClientDescriptors(ETrue);
+		SetPinClientDescriptors(ETrue);
 		}
-
-	fbs->StartL(KFBSERVGlobalThreadName);
-	CleanupStack::Pop();
-	return(fbs);
+	StartL(KFBSERVGlobalThreadName);
 	}
 
 CFbTop* CFontBitmapServer::TopLevelStore()
 	{
 	return(iTopLevelStore);
 	}
+
 CSession2* CFontBitmapServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/ ) const
 	{
 	TVersion v(KFbsMajorVersionNumber,KFbsMinorVersionNumber,KFbsBuildVersionNumber);
@@ -125,7 +141,7 @@
 	TPckgBuf<TSize> pixelSize;
 	TInt index=aMessage.Int0();
 	TInt limit=iTopLevelStore->FontStore()->NumTypefaces();
-	if(index<0 || index>limit)
+	if(index < 0 || index > limit)
 		{
 		return KErrArgument;
 		}
@@ -193,7 +209,7 @@
 void CFontBitmapServer::ProcMessage(const RMessage2& aMessage, TInt aSession)
 #endif
 	{
-	TInt ret=KErrNone;
+    TInt ret=KErrNone;
 	TBool clientPanicRequired = EFalse;
 #ifdef _DEBUG
 	TInt num=0;
@@ -344,6 +360,7 @@
 #ifdef _DEBUG
 	aRet=ret;
 #endif	
+
 	}
 
 /**
@@ -361,9 +378,9 @@
 void CFontBitmapServer::GetHeapSizesL(const RMessage2& aMessage)
 	{
 	TPckgBuf<THeapSizes> data;
-	TInt defaultHeapSize;
-	TInt smallBmpHeapSize;		
-	TInt bigBmpHeapSize;		
+	TInt defaultHeapSize = 0;
+	TInt smallBmpHeapSize = 0;		
+	TInt bigBmpHeapSize = 0;		
 	
 	User::Heap().AllocSize(defaultHeapSize);
 	bigBmpHeapSize = iTopLevelStore->iLargeBitmapChunk.Size();
@@ -383,18 +400,24 @@
 #endif
 
 
-CFontObject::CFontObject(CFontStore* aFontStore):
+CFontObject::CFontObject(CFontStore* aFontStore, CGlyphAtlas* aGlyphAtlas):
 	CObject(),
-	iAddressPointer(NULL),
-	iFontStore(aFontStore)
+	iFontStore(aFontStore),
+	iGlyphAtlas(aGlyphAtlas)
 	{
 	}
 
 CFontObject::~CFontObject()
 	{
 	if (AccessCount()==1)
+		{
 		Dec();
+		}
 	iFontStore->ReleaseFont(iAddressPointer);
+	if (iGlyphAtlas)
+		{
+		iGlyphAtlas->FontReleased(*iAddressPointer);
+		}
 	}
 
 // CBitmapObject constructor - takes ownership of aBmp
@@ -424,7 +447,9 @@
 		{
 		iHandle = reinterpret_cast<TInt>(this);
 		while (iFbTop->iBitmapObjectIndex.FindInOrder(this, Compare) != KErrNotFound)
+			{
 			++iHandle;
+			}
 		User::LeaveIfError(iFbTop->iBitmapObjectIndex.InsertInOrder(this, Compare));
 		}
 	}
@@ -469,9 +494,13 @@
 			if (index != KErrNotFound)
 				{
 				if (iCleanBitmap)
+					{
 					iFbTop->iBitmapObjectIndex[index] = iCleanBitmap;
+					}
 				else
+					{
 					iFbTop->iBitmapObjectIndex.Remove(index);
+					}
 				}
 			}
 		if (iCleanBitmap != NULL)
@@ -500,7 +529,7 @@
 
 void CBitmapObject::Close()
 	{
-	if (iCleanBitmap != NULL && Owner() != NULL && AccessCount() == 2)
+	if ((iCleanBitmap != NULL) && (Owner() != NULL) && (AccessCount() == 2))
 		{
 		static_cast<CBitmapObject*>(Owner())->iCleanBitmap = iCleanBitmap;
 		iCleanBitmap->SetOwner(Owner());
@@ -523,8 +552,7 @@
 // CSharedBitmapObject constructor - takes ownership of aBmp and aKey
 CSharedBitmapObject::CSharedBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey):
 	CBitmapObject(aFbTop, aBmp),
-	iKey(aKey),
-	iNext(NULL)
+	iKey(aKey)
 	{
 	__ASSERT_DEBUG(iKey, User::Invariant());	
 	}