fbs/fontandbitmapserver/sfbs/FBSCLI.CPP
changeset 36 01a6848ebfd7
parent 0 5d03bc08d59c
child 103 2717213c588a
child 110 7f25ef56562d
equal deleted inserted replaced
0:5d03bc08d59c 36:01a6848ebfd7
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    93 		{
    93 		{
    94 		font_store = fbTop->FontStore();
    94 		font_store = fbTop->FontStore();
    95 		}
    95 		}
    96 	
    96 	
    97 	if (font_store)
    97 	if (font_store)
       
    98 		{
    98 		font_store->DeleteSessionCache(iSessionHandle);
    99 		font_store->DeleteSessionCache(iSessionHandle);
    99 	
   100 		font_store->CleanupCacheOnFbsSessionTermination(iSessionHandle);
   100 	// If the font store doesn't exist, neither will the shared heap owned by FBSERV.
   101 		
   101 	if (font_store)
   102 		// If the font store doesn't exist, neither will the shared heap owned by FBSERV.
   102 		iHeap->Free(iOpenFontGlyphData);
   103 		iHeap->Free(iOpenFontGlyphData);
       
   104 		}
   103 	
   105 	
   104 	// delete fonts hold by the client
   106 	// delete fonts hold by the client
   105 	delete iIx;
   107 	delete iIx;
   106 	
   108 	
   107 	// delete font files hold by the client
   109 	// delete font files hold by the client
   108     if (iFontFileIndex)
   110 	if (iFontFileIndex)
   109         {
   111 		{
   110         TInt count = iFontFileIndex->Count();
   112 		TInt count = iFontFileIndex->Count();
   111         for (TInt index = 0;index < count; index++)
   113 		for (TInt index = 0;index < count; index++)
   112             {
   114 			{
   113             if (font_store)
   115 			if (font_store)
   114                 font_store->RemoveFile(iFontFileIndex->At(0).iUid);
   116 				font_store->RemoveFile(iFontFileIndex->At(0).iUid);
   115             iFontFileIndex->Delete(0);
   117 			iFontFileIndex->Delete(0);
   116             }
   118 			}
   117         delete iFontFileIndex;
   119 		delete iFontFileIndex;
   118         }
   120 		}
   119 
   121 
   120 	// Close the buffer used to hold the text thats needs shaping.
   122 	// Close the buffer used to hold the text thats needs shaping.
   121 	iTextToShape.Close();
   123 	iTextToShape.Close();
   122 	}
   124 	}
   123 
   125 
   266 	case EFbsMessShapeText:
   268 	case EFbsMessShapeText:
   267 	case EFbsMessShapeDelete:
   269 	case EFbsMessShapeDelete:
   268 	case EFbsMessSetTwipsHeight:
   270 	case EFbsMessSetTwipsHeight:
   269 	case EFbsMessGetTwipsHeight:
   271 	case EFbsMessGetTwipsHeight:
   270 	case EFbsSetSystemDefaultTypefaceName:
   272 	case EFbsSetSystemDefaultTypefaceName:
       
   273 	case EFbsMessGetFontTable:
       
   274 	case EFbsMessReleaseFontTable:
       
   275 	case EFbsMessGetGlyphOutline:
       
   276 	case EFbsMessReleaseGlyphOutline: 
   271 #if (_DEBUG)
   277 #if (_DEBUG)
   272 	case EFbsMessSetDuplicateFail:
   278 	case EFbsMessSetDuplicateFail:
   273 #endif
   279 #endif
   274 		ProcFontMessage(aMessage);
   280 		ProcFontMessage(aMessage);
   275 		break;
   281 		break;
   790 
   796 
   791 	bitmapFont->DeleteShape(iSessionHandle,shapeheader);
   797 	bitmapFont->DeleteShape(iSessionHandle,shapeheader);
   792 	return KErrNone;
   798 	return KErrNone;
   793 	}
   799 	}
   794 
   800 
       
   801 TInt CFbClient::HandleMesgReleaseGlyphOutline(const RMessage2& aMessage, TBool& aPanicRequired)
       
   802 	{
       
   803 	TInt ret = KErrNone;
       
   804 	CFbTop* fbtop = TopLevelStore();
       
   805 	TPckgBuf<TFBSGlyphOutlineParam> params;
       
   806 	ret = aMessage.Read(0, params);
       
   807 	if (KErrNone != ret)
       
   808 		{
       
   809 		aPanicRequired = ETrue;
       
   810 		return ret;
       
   811 		}
       
   812 	CFontObject* fontptr = static_cast<CFontObject*>(iIx->At(params().iHandle, fbtop->FontConUniqueID()));
       
   813 	if(!fontptr)
       
   814 		{
       
   815 		aPanicRequired = ETrue;
       
   816 		return KErrArgument;
       
   817 		}
       
   818 	CBitmapFont* bitmapFont = fontptr->iAddressPointer;
       
   819 
       
   820 	TInt count = params().iCount;
       
   821 	TUint *glyphCodes = (TUint *)User::Alloc(count * sizeof(TUint));
       
   822 	if (NULL == glyphCodes)
       
   823 		{
       
   824 		return KErrNoMemory;
       
   825 		}
       
   826 	// copy the glyph codes out of the IPC buffer...
       
   827 	TPtr8 ptr((TUint8 *)glyphCodes, count * sizeof(TUint), count * sizeof(TUint));
       
   828 	ret = aMessage.Read(1, ptr);  
       
   829 
       
   830 	if (KErrNone == ret)
       
   831 		{
       
   832 		bitmapFont->ReleaseGlyphOutlines(count, glyphCodes,  
       
   833 				params().iHinted, iSessionHandle);
       
   834 		}
       
   835 	else 
       
   836 		{
       
   837 		aPanicRequired = ETrue;
       
   838 		}
       
   839 
       
   840 	User::Free(glyphCodes);
       
   841 	return ret;
       
   842 	}
       
   843 
       
   844 TInt CFbClient::HandleMesgGetGlyphOutline(const RMessage2& aMessage, TBool& aPanicRequired) 
       
   845 	{
       
   846 	TInt ret = KErrNone;
       
   847 	CFbTop* fbtop = TopLevelStore();
       
   848 	TPckgBuf<TFBSGlyphOutlineParam> params;
       
   849 	ret = aMessage.Read(0, params);
       
   850 	if (KErrNone != ret)
       
   851 		{
       
   852 		aPanicRequired = ETrue;
       
   853 		return ret;
       
   854 		}
       
   855 	CFontObject* fontptr = static_cast<CFontObject*>(iIx->At(params().iHandle, fbtop->FontConUniqueID()));
       
   856 	if(!fontptr)
       
   857 		{
       
   858 		aPanicRequired = ETrue;
       
   859 		return KErrArgument;
       
   860 		}
       
   861 	CBitmapFont* bitmapFont = fontptr->iAddressPointer;
       
   862 
       
   863 	TInt count = params().iCount;
       
   864 	TUint* glyphCodes = (TUint *)User::Alloc(count * sizeof(TUint));
       
   865 	if (NULL == glyphCodes)
       
   866 		{
       
   867 		return KErrNoMemory;
       
   868 		}
       
   869 	// copy the glyph codes out of the IPC buffer...
       
   870 	TPtr8 ptr((TUint8 *)glyphCodes, count * sizeof(TUint), count * sizeof(TUint));
       
   871 	ret = aMessage.Read(1, ptr);
       
   872 	if (KErrNone != ret)
       
   873 		{
       
   874 		User::Free(glyphCodes);
       
   875 		aPanicRequired = ETrue;
       
   876 		return ret;
       
   877 		}
       
   878 
       
   879 	TOffsetLen* offsetLens = 
       
   880 		(TOffsetLen *)User::Alloc(count * sizeof(TOffsetLen));
       
   881 	if (NULL == offsetLens)
       
   882 		{
       
   883 		User::Free(glyphCodes);
       
   884 		return KErrNoMemory;
       
   885 		}
       
   886 
       
   887 	TInt len = 0;
       
   888 	TAny* outline = NULL;
       
   889 	for (TInt i = 0; i < count; ++i)
       
   890 		{
       
   891 		bitmapFont->GetGlyphOutline(glyphCodes[i],  
       
   892 			params().iHinted, outline, len, iSessionHandle);
       
   893 		
       
   894 		offsetLens[i].iLen = len;
       
   895 		offsetLens[i].iOffset = PointerToOffset((outline), fbtop->HeapBase());
       
   896 		}
       
   897 	TPtr8 pkg2((TUint8 *)offsetLens, count * sizeof(TOffsetLen), 
       
   898 			count * sizeof(TOffsetLen));
       
   899 	ret = aMessage.Write(2, pkg2);
       
   900 	if (KErrNone != ret)
       
   901 		{
       
   902 		aPanicRequired = ETrue;
       
   903 		}
       
   904 
       
   905 	User::Free(glyphCodes);
       
   906 	User::Free(offsetLens);
       
   907 	return ret;  
       
   908 	}
       
   909 
       
   910 TInt CFbClient::HandleMesgReleaseFontTable(const RMessage2& aMessage, TBool& aPanicRequired)
       
   911 	{
       
   912 	CFbTop* fbtop = TopLevelStore();
       
   913 	CFontObject* fontptr = static_cast<CFontObject*>(iIx->At(aMessage.Int0(), fbtop->FontConUniqueID()));
       
   914 	if(!fontptr)
       
   915 		{
       
   916 		aPanicRequired = ETrue;
       
   917 		return KErrArgument;
       
   918 		}
       
   919 	CBitmapFont* bitmapFont = fontptr->iAddressPointer;
       
   920 
       
   921 	TUint32 tag = aMessage.Int1();
       
   922 
       
   923 	bitmapFont->ReleaseFontTable(tag, iSessionHandle);
       
   924 
       
   925 	return KErrNone;
       
   926 	}
       
   927 
       
   928 TInt CFbClient::HandleMesgGetFontTable(const RMessage2& aMessage, TBool& aPanicRequired)
       
   929 	{
       
   930 	TInt ret = KErrNone;
       
   931 	CFbTop* fbtop = TopLevelStore();
       
   932 	CFontObject* fontptr = static_cast<CFontObject*>(iIx->At(aMessage.Int0(), fbtop->FontConUniqueID()));
       
   933 	if(!fontptr)
       
   934 		{
       
   935 		aPanicRequired = ETrue;
       
   936 		return KErrArgument;
       
   937 		}
       
   938 	CBitmapFont* bitmapFont = fontptr->iAddressPointer;
       
   939 
       
   940 	TInt len = 0;
       
   941 	TAny* tablePtr = NULL;
       
   942 	ret = bitmapFont->GetFontTable((TUint32)aMessage.Int1(), tablePtr, len, iSessionHandle);
       
   943 
       
   944 	if (KErrNone == ret) 
       
   945 		{
       
   946 		TPckgBuf<TOffsetLen> params;
       
   947 		params().iLen = len;
       
   948 		params().iOffset = PointerToOffset(tablePtr, fbtop->HeapBase());
       
   949 		ret = aMessage.Write(2, params);
       
   950 		aPanicRequired = (KErrNone != ret);
       
   951 		}
       
   952 
       
   953 	return ret;
       
   954 	}
   795 
   955 
   796 void CFbClient::ProcFontMessage(const RMessage2& aMessage)
   956 void CFbClient::ProcFontMessage(const RMessage2& aMessage)
   797 	{
   957 	{
   798 	TInt ret = KErrUnknown;
   958 	TInt ret = KErrUnknown;
   799 	TBool panicRequired = EFalse;
   959 	TBool panicRequired = EFalse;
   898 				{
  1058 				{
   899 				panicRequired = ETrue;
  1059 				panicRequired = ETrue;
   900 				ret = KErrTooBig;
  1060 				ret = KErrTooBig;
   901 				}
  1061 				}
   902 
  1062 
       
  1063 			break;
       
  1064 			}
       
  1065 		case EFbsMessGetFontTable:
       
  1066 			{
       
  1067 			ret = HandleMesgGetFontTable(aMessage, panicRequired);
       
  1068 			break;
       
  1069 			}
       
  1070 		case EFbsMessGetGlyphOutline:
       
  1071 			{
       
  1072 			ret = HandleMesgGetGlyphOutline(aMessage, panicRequired);
       
  1073 			break;
       
  1074 			}
       
  1075 		case EFbsMessReleaseGlyphOutline:
       
  1076 			{
       
  1077 			ret = HandleMesgReleaseGlyphOutline(aMessage, panicRequired);
       
  1078 			break;
       
  1079 			}
       
  1080 		case EFbsMessReleaseFontTable:
       
  1081 			{
       
  1082 			ret = HandleMesgReleaseFontTable(aMessage, panicRequired);
   903 			break;
  1083 			break;
   904 			}
  1084 			}
   905 
  1085 
   906 #ifdef _DEBUG
  1086 #ifdef _DEBUG
   907 		case EFbsMessSetDuplicateFail:
  1087 		case EFbsMessSetDuplicateFail: