fbs/fontandbitmapserver/sfbs/SERVER.CPP
changeset 116 171fae344dd4
parent 36 01a6848ebfd7
--- a/fbs/fontandbitmapserver/sfbs/SERVER.CPP	Tue Jun 22 15:21:29 2010 +0300
+++ b/fbs/fontandbitmapserver/sfbs/SERVER.CPP	Fri Jul 16 11:45:55 2010 +0300
@@ -22,7 +22,7 @@
 #include "BitwiseBitmap.inl"
 
 const TInt KFbsPriority = 0;
-
+const TInt KFbsGoomMonitorSid = 0x10207218;
 // Setup security policies
 const TInt KRanges[] = 
 	{
@@ -37,7 +37,10 @@
 	EFbsMessFetchLinkedTypeface,
 	EFbsMessUpdateLinkedTypeface,
 	EFbsMessGetFontTable,
+    EFbsMessOogmNotification,
+    EFbsMessGetGlyphCacheMetrics,
 	};
+
 const TUint KRangeCount = sizeof(KRanges)/sizeof(TInt);
 const TUint8 KElementsIndex[KRangeCount] = 
 	{
@@ -52,14 +55,19 @@
 	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
@@ -70,9 +78,7 @@
 	};
 
 CFontBitmapServer::CFontBitmapServer():
-	CPolicyServer(KFbsPriority, KFbsPolicy),
-	iConnectionId(0),
-	iTopLevelStore(NULL)
+	CPolicyServer(KFbsPriority, KFbsPolicy)
 	{
 	}
 
@@ -85,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);
@@ -127,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;
 		}
@@ -195,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;
@@ -346,6 +360,7 @@
 #ifdef _DEBUG
 	aRet=ret;
 #endif	
+
 	}
 
 /**
@@ -363,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();
@@ -385,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
@@ -426,7 +447,9 @@
 		{
 		iHandle = reinterpret_cast<TInt>(this);
 		while (iFbTop->iBitmapObjectIndex.FindInOrder(this, Compare) != KErrNotFound)
+			{
 			++iHandle;
+			}
 		User::LeaveIfError(iFbTop->iBitmapObjectIndex.InsertInOrder(this, Compare));
 		}
 	}
@@ -471,9 +494,13 @@
 			if (index != KErrNotFound)
 				{
 				if (iCleanBitmap)
+					{
 					iFbTop->iBitmapObjectIndex[index] = iCleanBitmap;
+					}
 				else
+					{
 					iFbTop->iBitmapObjectIndex.Remove(index);
+					}
 				}
 			}
 		if (iCleanBitmap != NULL)
@@ -502,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());
@@ -525,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());	
 	}