fbs/fontandbitmapserver/sfbs/FBSBMP.CPP
branchRCL_3
changeset 209 5c40347c6f16
parent 186 1bc91eb0b8ae
equal deleted inserted replaced
186:1bc91eb0b8ae 209:5c40347c6f16
     1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1995-2009 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".
    23 #include "fbshelper.h"
    23 #include "fbshelper.h"
    24 #include "fbsrasterizer.h"
    24 #include "fbsrasterizer.h"
    25 #include "BitwiseBitmap.inl"
    25 #include "BitwiseBitmap.inl"
    26 #include "fbsmessage.h"
    26 #include "fbsmessage.h"
    27 #include "bitmapconst.h"
    27 #include "bitmapconst.h"
    28 #include "OstTraceDefinitions.h"
       
    29 #include "fbstrace.h"
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "FBSBMPTraces.h"
       
    32 #endif
       
    33 
    28 
    34 const TInt KMaxPixelSize = KMaxTInt / 4; // Maximum pixel size to avoid some overflow problems
    29 const TInt KMaxPixelSize = KMaxTInt / 4; // Maximum pixel size to avoid some overflow problems
    35 const TInt KMaxBitmapHandleBufferSize = KNumBytesPerBitmapHandle * 2000; 	// Maximum size of buffer to store all bitmap handles.
    30 const TInt KMaxBitmapHandleBufferSize = KNumBytesPerBitmapHandle * 2000; 	// Maximum size of buffer to store all bitmap handles.
    36 
    31 
    37 GLREF_C void Panic(TFbsPanic aPanic);
    32 GLREF_C void Panic(TFbsPanic aPanic);
    98 @publishedAll
    93 @publishedAll
    99 @released
    94 @released
   100 */
    95 */
   101 EXPORT_C void CFbsBitmap::Reset()
    96 EXPORT_C void CFbsBitmap::Reset()
   102 	{
    97 	{
   103     FBS_OST(TInt ssh = (iFbs ? iFbs->ServerSessionHandle() : 0);)
       
   104     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_RESET_ENTRY, "> this=0x%08x; iH=0x%08x; iSH=0x%08x; iSSH=0x%08x", (TUint)this, iHandle, iServerHandle, ssh );)
       
   105 	if (iHandle && !(iFlags & EIsRomBitmap))
    98 	if (iHandle && !(iFlags & EIsRomBitmap))
   106 		{
    99 		{
   107 		iFbs->SendCommand(EFbsMessClose, iHandle, Handle());
   100 		iFbs->SendCommand(EFbsMessClose, iHandle, Handle());
   108 		iFbs->iHelper->RemoveBitmap(*this);
   101 		iFbs->iHelper->RemoveBitmap(*this);
   109 		}
   102 		}
   119 	iAddressPointer = NULL;
   112 	iAddressPointer = NULL;
   120 	iFlags = 0;
   113 	iFlags = 0;
   121 	iUseCount = 0;
   114 	iUseCount = 0;
   122 	iHandle = 0;
   115 	iHandle = 0;
   123 	iServerHandle = 0;
   116 	iServerHandle = 0;
   124 	FBS_OST(OstTrace1( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_RESET_EXIT, "< this=0x%08x", (TUint)this );)
       
   125 	}
   117 	}
   126 	
   118 	
   127 /** Tests whether or not the bitmap is read-only.
   119 /** Tests whether or not the bitmap is read-only.
   128 @return ETrue if the bitmap is read-only, EFalse otherwise.
   120 @return ETrue if the bitmap is read-only, EFalse otherwise.
   129 @publishedAll
   121 @publishedAll
   260 @publishedAll
   252 @publishedAll
   261 @released
   253 @released
   262 */
   254 */
   263 EXPORT_C TInt CFbsBitmap::Create(const TSize& aSizeInPixels,TDisplayMode aDispMode)
   255 EXPORT_C TInt CFbsBitmap::Create(const TSize& aSizeInPixels,TDisplayMode aDispMode)
   264 	{
   256 	{
   265     FBS_OST(OstTraceExt4(GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATE_ENTRY, "> this=0x%08x; w=%d; h=%d; dm=%d", (TUint)this, aSizeInPixels.iWidth, aSizeInPixels.iHeight, aDispMode); ) 
   257 	return DoCreate(aSizeInPixels,aDispMode,KUidCFbsBitmapCreation);
   266 	TInt err = DoCreate(aSizeInPixels,aDispMode,KUidCFbsBitmapCreation);
       
   267     FBS_OST(TInt ssh = (iFbs ? iFbs->ServerSessionHandle() : 0);)
       
   268 	FBS_OST(OstTraceExt5(GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATE_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x; iSSH=0x%08x", (TUint)this, err, iHandle, iServerHandle, ssh); )
       
   269     return err;
       
   270 	}
   258 	}
   271 
   259 
   272 TInt CFbsBitmap::DoCreate(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aUid, TInt aDataSize)
   260 TInt CFbsBitmap::DoCreate(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aUid, TInt aDataSize)
   273 	{
   261 	{
   274 	if(!iFbs) return(KErrCouldNotConnect);
   262 	if(!iFbs) return(KErrCouldNotConnect);
   315 @publishedAll
   303 @publishedAll
   316 @released
   304 @released
   317 */
   305 */
   318 EXPORT_C TInt CFbsBitmap::CreateHardwareBitmap(const TSize& aSizeInPixels,TDisplayMode aDispMode,TUid aCreatorUid)
   306 EXPORT_C TInt CFbsBitmap::CreateHardwareBitmap(const TSize& aSizeInPixels,TDisplayMode aDispMode,TUid aCreatorUid)
   319 	{
   307 	{
   320     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATEHARDWAREBITMAP_ENTRY, "> this=0x%08x; w=%d; h=%d; dm=%d; uid=0x%08x", (TUint)this, aSizeInPixels.iWidth, aSizeInPixels.iHeight, aDispMode, aCreatorUid.iUid);)
   308 	return DoCreate(aSizeInPixels,aDispMode,aCreatorUid);
   321 	TInt err = DoCreate(aSizeInPixels,aDispMode,aCreatorUid);
       
   322     FBS_OST(TInt ssh = (iFbs ? iFbs->ServerSessionHandle() : 0);)
       
   323 	FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATEHARDWAREBITMAP_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x; iSSH=0x%08x", (TUint)this, err, iHandle, iServerHandle, ssh);)
       
   324 	return err;
       
   325 	}
   309 	}
   326 
   310 
   327 /** Resets the pixel-size of the bitmap.
   311 /** Resets the pixel-size of the bitmap.
   328 If the new size is bigger than the old, the original bitmap is still situated 
   312 If the new size is bigger than the old, the original bitmap is still situated 
   329 at (0,0), but pixels outside the range of the old pixel-size are set to zero.
   313 at (0,0), but pixels outside the range of the old pixel-size are set to zero.
   420 with the specified handle number.
   404 with the specified handle number.
   421 @publishedAll
   405 @publishedAll
   422 @released
   406 @released
   423 @see CFbsBitmap::Handle()
   407 @see CFbsBitmap::Handle()
   424 */
   408 */
   425 EXPORT_C TInt CFbsBitmap::Duplicate(TInt aBitmapHandle)	
   409 EXPORT_C TInt CFbsBitmap::Duplicate(TInt aBitmapHandle)
   426     {
   410 		{
   427     TInt ret = KErrNone;
       
   428     FBS_OST(OstTraceExt2( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_DUPLICATE_ENTRY, "> this=0x%08x; iH=0x%08x;", (TUint)this, aBitmapHandle);)
       
   429 	if(!iFbs) 
   411 	if(!iFbs) 
   430 		{
   412 		{
   431 		ret = KErrCouldNotConnect;
   413 		return(KErrCouldNotConnect);
   432 		FBS_OST(OstTrace1( TRACE_ERROR, CFBSBITMAP_DUPLICATE_ERROR, "! this=0x%08x; !iFbs", (TUint)this);)
   414 		}
   433 		}
   415 	if(!aBitmapHandle) 
   434 	else if(!aBitmapHandle) 
   416 		{
   435 		{
   417 		return(KErrUnknown);
   436 		ret = KErrUnknown;
   418 		}
   437 		FBS_OST(OstTrace1( TRACE_ERROR, CFBSBITMAP_DUPLICATE_ERROR2, "! this=0x%08x; !aBitmapHandle", (TUint)this);)
   419 	Reset();
   438 		}
   420 	TBool isinrom=EFalse;
   439     else
   421 	TInt ret=User::IsRomAddress(isinrom,(TAny*)aBitmapHandle);
   440         {
   422 	if(ret!=KErrNone) 
   441         TBool isinrom = EFalse;
   423 		{
   442         ret = User::IsRomAddress(isinrom, (TAny*)aBitmapHandle);
   424 		return(KErrUnknown);
   443         if (ret == KErrNone)
   425 		}
   444             {
   426 	if(isinrom)
   445             if (isinrom)
   427 		{
   446                 {
   428 		if (((CBitwiseBitmap*)aBitmapHandle)->Uid() != KCBitwiseBitmapUid)
   447                 ret = DuplicateInRom(aBitmapHandle);
   429 			return(KErrUnknown);
   448                 FBS_OST_IF(ret != KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATE_ERROR4, "! this=0x%08x; DuplicateInRom() returned %d;", (TUint)this, ret);)
   430 		iAddressPointer = (CBitwiseBitmap*)aBitmapHandle;
   449                 }
   431 		iFlags = EIsRomBitmap;
   450             else
   432 		iHandle=1;
   451                 {
   433 		return iFbs->AllocScanLineBuffer(iAddressPointer->iByteWidth + 4);
   452                 ret = DuplicateInRam(aBitmapHandle);
   434 		}
   453                 FBS_OST_IF(ret != KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATE_ERROR5, "! this=0x%08x; DuplicateInRam() returned %d;", (TUint)this, ret);)
   435 	TPckgBuf<TBmpHandles> b;
   454                 }
   436 	TIpcArgs args(aBitmapHandle,&b);
   455             }
   437 	ret=iFbs->SendCommand(EFbsMessBitmapDuplicate,args);
   456         else 
   438 	if(ret!=KErrNone) 
   457             {
   439 		{
   458             FBS_OST(OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATE_ERROR3, "! this=0x%08x; IsRomAddress() returned %d", (TUint)this, ret);)
   440 		return(ret);
   459             ret = KErrUnknown;
   441 		}
   460             }
   442 	iHandle=b().iHandle;
   461         }
   443 	iServerHandle=b().iServerHandle;
   462     FBS_OST(TInt ssh = (iFbs ? iFbs->ServerSessionHandle() : 0);)
   444 	iAddressPointer=(CBitwiseBitmap*)(iFbs->HeapBase()+b().iAddressOffset);
   463     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_DUPLICATE_EXIT, "< this=0x%08x; iH=0x%08x; iSH=0x%08x; ret=%d; iSSH=0x%08x", (TUint)this, iHandle, iServerHandle, ret, ssh);)
   445 	if (iAddressPointer->iUid.iUid != KCBitwiseBitmapUid.iUid && iAddressPointer->iUid.iUid != KCBitwiseBitmapHardwareUid.iUid)
   464 	return ret;
   446 		{
   465     }
   447 		iFlags = EIsExtendedBitmap;
   466 
   448 		}
   467 /** Duplicates a bitmap where the bitmap handle refers to a rom bitmap.
   449 	ret = iFbs->iHelper->AddBitmap(*this);
   468 @param aBitmapHandle A valid Rom bitmap handle.
   450 	if (ret != KErrNone)
   469 @return KErrNone on success.
   451 		{
   470  */
   452 		return ret;
   471 TInt CFbsBitmap::DuplicateInRom(TInt aBitmapHandle)
   453 		}
   472     {
   454 	return iFbs->AllocScanLineBuffer(iAddressPointer->iByteWidth+4);
   473     TInt ret = KErrNone;
   455 	}
   474     Reset();
       
   475     TUid uid = ((CBitwiseBitmap*)aBitmapHandle)->Uid();
       
   476     if (uid != KCBitwiseBitmapUid)
       
   477         {
       
   478         FBS_OST(OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATEINROM_ERROR, "! this=0x%08x; 0x%08x != KCBitwiseBitmapUid", (TUint)this, (TUint)uid.iUid);)
       
   479         ret = KErrUnknown;
       
   480         }
       
   481     else
       
   482         {
       
   483         iAddressPointer = (CBitwiseBitmap*)aBitmapHandle;
       
   484         iFlags = EIsRomBitmap;
       
   485         iHandle=1;
       
   486         ret = iFbs->AllocScanLineBuffer(iAddressPointer->iByteWidth + 4);
       
   487         FBS_OST_IF(ret!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATEINROM_ERROR2, "! this=0x%08x; AllocScanLineBuffer() returned %d", (TUint)this, ret);)
       
   488         }
       
   489     return ret;
       
   490     }
       
   491 
       
   492 /** Duplicates a bitmap where the bitmap handle refers to a ram bitmap
       
   493 @param aBitmapHandle A valid Ram bitmap handle.
       
   494 @return KErrNone on success.
       
   495  */
       
   496 TInt CFbsBitmap::DuplicateInRam(TInt aBitmapHandle)
       
   497     {
       
   498     TInt ret = KErrNone;
       
   499     Reset();
       
   500      
       
   501     TPckgBuf<TBmpHandles> b;
       
   502     TIpcArgs args(aBitmapHandle,&b);
       
   503     ret=iFbs->SendCommand(EFbsMessBitmapDuplicate,args);
       
   504     FBS_OST_IF(ret!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATEINRAM_ERROR, "! this=0x%08x; SendCommand(EFbsMessBitmapDuplicate) returned %d", (TUint)this, ret);)
       
   505     if(ret==KErrNone) 
       
   506         {
       
   507         iHandle=b().iHandle;
       
   508         iServerHandle=b().iServerHandle;
       
   509         iAddressPointer=(CBitwiseBitmap*)(iFbs->HeapBase()+b().iAddressOffset);
       
   510         if (iAddressPointer->iUid.iUid != KCBitwiseBitmapUid.iUid && iAddressPointer->iUid.iUid != KCBitwiseBitmapHardwareUid.iUid)
       
   511             {
       
   512             iFlags = EIsExtendedBitmap;
       
   513             }
       
   514         ret = iFbs->iHelper->AddBitmap(*this);
       
   515         FBS_OST_IF(ret!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATEINRAM_ERROR2, "! this=0x%08x; AddBitmap() returned %d", (TUint)this, ret);)
       
   516         if (ret == KErrNone)
       
   517             {
       
   518             ret = iFbs->AllocScanLineBuffer(iAddressPointer->iByteWidth+4);
       
   519             FBS_OST_IF(ret!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_DUPLICATEINRAM_ERROR3, "! this=0x%08x; AllocScanLineBuffer() returned %d", (TUint)this, ret);)
       
   520             }
       
   521         }
       
   522     return ret;
       
   523     }
       
   524 
   456 
   525 /** Loads a specific bitmap from a multi-bitmap file.
   457 /** Loads a specific bitmap from a multi-bitmap file.
   526 The bitmap may be shared by other font and bitmap server clients.
   458 The bitmap may be shared by other font and bitmap server clients.
   527 @param aFileName The filename of the multi-bitmap (.mbm) file. 
   459 @param aFileName The filename of the multi-bitmap (.mbm) file. 
   528 @param aId The bitmap identifier.
   460 @param aId The bitmap identifier.
   533 @publishedAll
   465 @publishedAll
   534 @released
   466 @released
   535 */	
   467 */	
   536 EXPORT_C TInt CFbsBitmap::Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded)
   468 EXPORT_C TInt CFbsBitmap::Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded)
   537 	{
   469 	{
   538     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD_ENTRY, "> this=0x%08x; file=%S, id=0x%08x; share=%d", (TUint)this, aFileName, aId, aShareIfLoaded);)
   470 	return Load(aFileName,aId,aShareIfLoaded,0);
   539 	TInt err = Load(aFileName,aId,aShareIfLoaded,0);
       
   540     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, err, iHandle, iServerHandle);)
       
   541 	return err; 
       
   542 	}
   471 	}
   543 
   472 
   544 /**  Loads a specific bitmap from a multi-bitmap file.
   473 /**  Loads a specific bitmap from a multi-bitmap file.
   545 The bitmap may be shared by other font and bitmap server clients.
   474 The bitmap may be shared by other font and bitmap server clients.
   546 @param aFileName The filename of the multi-bitmap (.mbm) file.
   475 @param aFileName The filename of the multi-bitmap (.mbm) file.
   552 @publishedAll
   481 @publishedAll
   553 @released
   482 @released
   554 */	
   483 */	
   555 EXPORT_C TInt CFbsBitmap::Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
   484 EXPORT_C TInt CFbsBitmap::Load(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
   556 	{
   485 	{
   557     TInt err = KErrNone;
       
   558     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD2_ENTRY, "> this=0x%08x; file=%S, id=0x%08x; share=%d; off=%d", (TUint)this, aFileName, aId, aShareIfLoaded, aFileOffset);)
       
   559 	if(!iFbs)
   486 	if(!iFbs)
   560 		{
   487 		{
   561         FBS_OST(OstTrace1( TRACE_ERROR, CFBSBITMAP_LOAD2_ERROR, "! this=0x%08x; !iFbs", (TUint)this);)
   488 		return(KErrCouldNotConnect);
   562 		err = KErrCouldNotConnect;
   489 		}
       
   490 	Reset();
       
   491 	TUint32* rompointer = NULL;
       
   492 	//access using filename has the advantage of using rom address lookup cache
       
   493 	IsFileInRom(aFileName, rompointer);
       
   494 	TBool romPointerValid;
       
   495 	TInt err = DoLoadFromRom(rompointer, aId, aFileOffset, romPointerValid);
       
   496 	if(romPointerValid)
       
   497 		{
       
   498 		return err;
       
   499 		}
       
   500 	_LIT(KResourcePath, "?:\\Resource\\*");
       
   501 	TInt match = aFileName.MatchF(KResourcePath);
       
   502 	//if the file is in the resource directory we don't need to check capabilities and the file can just be opened on the server side.
       
   503 	if (match == 0)
       
   504 		{
       
   505 		err = DoLoad(aFileName,aId,aShareIfLoaded,aFileOffset);
   563 		}
   506 		}
   564 	else
   507 	else
   565 	    {
   508 		{
   566         Reset();
   509 		RFile file;
   567         TUint32* rompointer = NULL;
   510 		err = file.Open(iFbs->FileServer(),aFileName,EFileShareReadersOnly);
   568         //access using filename has the advantage of using rom address lookup cache
   511 		if (err!=KErrNone)
   569         IsFileInRom(aFileName, rompointer);
   512 			{
   570         TBool romPointerValid;
   513 			return err;
   571         err = DoLoadFromRom(rompointer, aId, aFileOffset, romPointerValid);
   514 			}
   572         if(!romPointerValid)
   515 		err = DoLoad(file,aId,aShareIfLoaded,aFileOffset);
   573             {
   516 		file.Close();
   574             _LIT(KResourcePath, "?:\\Resource\\*");
   517 		}
   575             TInt match = aFileName.MatchF(KResourcePath);
       
   576             //if the file is in the resource directory we don't need to check capabilities and the file can just be opened on the server side.
       
   577             if (match == 0)
       
   578                 {
       
   579                 err = DoLoad(aFileName,aId,aShareIfLoaded,aFileOffset);
       
   580                 FBS_OST_IF(err!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_LOAD2_ERROR3, "! this=0x%08x; DoLoad returned %d", (TUint)this, err);)
       
   581                 }
       
   582             else
       
   583                 {
       
   584                 RFile file;
       
   585                 err = file.Open(iFbs->FileServer(),aFileName,EFileShareReadersOnly);
       
   586                 if (err==KErrNone)
       
   587                     {
       
   588                     err = DoLoad(file,aId,aShareIfLoaded,aFileOffset);
       
   589                     FBS_OST_IF(err!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_LOAD2_ERROR4, "! this=0x%08x; DoLoad returned %d", (TUint)this, err);)
       
   590                     }
       
   591                 file.Close();
       
   592                 }
       
   593             }
       
   594 	    }
       
   595     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD2_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, err, iHandle, iServerHandle);)
       
   596 	return err;
   518 	return err;
   597 	}
   519 	}
   598 
   520 
   599 /** Loads and compresses a specific bitmap from a multi-bitmap file.
   521 /** Loads and compresses a specific bitmap from a multi-bitmap file.
   600 The bitmap may be shared by other font and bitmap server clients.
   522 The bitmap may be shared by other font and bitmap server clients.
   608 @publishedAll 
   530 @publishedAll 
   609 @released
   531 @released
   610 */	
   532 */	
   611 EXPORT_C TInt CFbsBitmap::LoadAndCompress(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded)
   533 EXPORT_C TInt CFbsBitmap::LoadAndCompress(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded)
   612     {	
   534     {	
   613     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS_ENTRY, "> this=0x%08x; file=%S; id=0x%08x; share=%d", (TUint)this, aFileName, aId, aShareIfLoaded);)
   535     return LoadAndCompress(aFileName, aId, aShareIfLoaded, 0);
   614     TInt ret = LoadAndCompress(aFileName, aId, aShareIfLoaded, 0);
       
   615     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, ret, iHandle, iServerHandle);)
       
   616     return ret;
       
   617 	}
   536 	}
   618 
   537 
   619 /** Loads and compresses a specific bitmap from a multi-bitmap file.
   538 /** Loads and compresses a specific bitmap from a multi-bitmap file.
   620 The bitmap may be shared by other font and bitmap server clients. If the 
   539 The bitmap may be shared by other font and bitmap server clients. If the 
   621 bitmap is loaded from ROM then compression is not allowed.
   540 bitmap is loaded from ROM then compression is not allowed.
   628 codes. 
   547 codes. 
   629 @publishedAll 
   548 @publishedAll 
   630 @released
   549 @released
   631 */	
   550 */	
   632 EXPORT_C TInt CFbsBitmap::LoadAndCompress(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
   551 EXPORT_C TInt CFbsBitmap::LoadAndCompress(const TDesC& aFileName,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
   633     {
   552     {	
   634     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS2_ENTRY, "> this=0x%08x; file=%S, id=0x%08x; share=%d; off=%d", (TUint)this, aFileName, aId, aShareIfLoaded, aFileOffset);)
       
   635 	TInt err = Load(aFileName,aId,aShareIfLoaded,aFileOffset);
   553 	TInt err = Load(aFileName,aId,aShareIfLoaded,aFileOffset);
   636 	if (err == KErrNone)
   554 	if (err == KErrNone)
   637 		{
   555 		{
   638 		err = !(iFlags & EIsRomBitmap) ? Compress() : KErrAccessDenied;
   556 		err = !(iFlags & EIsRomBitmap) ? Compress() : KErrAccessDenied;
   639 		FBS_OST_IF(err!=KErrNone, OstTraceExt3( TRACE_ERROR, CFBSBITMAP_LOADANDCOMPRESS2_ERROR, "! this=0x%08x; iFlags=0x%08x; err=%d", (TUint)this, (TUint)iFlags, err);)
   557 		}
   640 		}
       
   641 	FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS2_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, err, iHandle, iServerHandle);)
       
   642 	return err;
   558 	return err;
   643 	}
   559 	}
   644 
   560 
   645 /** Saves the bitmap as a direct file store.
   561 /** Saves the bitmap as a direct file store.
   646 The file store overwrites any existing file with the same name.
   562 The file store overwrites any existing file with the same name.
  1233 EXPORT_C TBool CFbsBitmap::IsCompressedInRAM() const
  1149 EXPORT_C TBool CFbsBitmap::IsCompressedInRAM() const
  1234 	{
  1150 	{
  1235 	CBitwiseBitmap* bitmap = CleanAddress();
  1151 	CBitwiseBitmap* bitmap = CleanAddress();
  1236 	if (bitmap==NULL)
  1152 	if (bitmap==NULL)
  1237 		{
  1153 		{
  1238 		return EFalse;
  1154 			return EFalse;
  1239 		}	
  1155 		}	
  1240 	return bitmap->IsCompressedInRAM();
  1156 	return bitmap->IsCompressedInRAM();
  1241 	}
  1157 	}
  1242 
  1158 
  1243 /** Gets the twip-size of the bitmap.
  1159 /** Gets the twip-size of the bitmap.
  1332 @see CFbsBitmap::DataAddress()
  1248 @see CFbsBitmap::DataAddress()
  1333 @see CFbsBitmap::EndDataAccess()
  1249 @see CFbsBitmap::EndDataAccess()
  1334 */
  1250 */
  1335 EXPORT_C void CFbsBitmap::BeginDataAccess() const
  1251 EXPORT_C void CFbsBitmap::BeginDataAccess() const
  1336 	{
  1252 	{
  1337     FBS_OST_VERBOSE(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_BEGINDATAACCESS_ENTRY, "> this=0x%08x;", (TUint)this););
  1253 	if (!iHandle)
  1338 	FBS_OST_IF(!iHandle, OstTrace1(TRACE_ERROR, CFBSBITMAP_BEGINDATAACCESS_ERROR, "! this=0x%08x; !iHandle", (TUint)this););
  1254 		return;
  1339 	
  1255 	(void)CleanAddress();	//called for side-effect to make sure bitmap reference is current. Should be low overhead.
  1340 	if (iHandle)
  1256 	const_cast<CFbsBitmap*>(this)->iUseCount++;
  1341 	    {
       
  1342         (void)CleanAddress();	//called for side-effect to make sure bitmap reference is current. Should be low overhead.
       
  1343         const_cast<CFbsBitmap*>(this)->iUseCount++;
       
  1344 	    }
       
  1345     
       
  1346 	FBS_OST_VERBOSE(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_BEGINDATAACCESS_EXIT, "< this=0x%08x; iUseCount=%d;", (TUint)this, const_cast<CFbsBitmap*>(this)->iUseCount);)
       
  1347 	}
  1257 	}
  1348 
  1258 
  1349 /** Marks the end of direct access to the bitmap data.
  1259 /** Marks the end of direct access to the bitmap data.
  1350 Use this function after ending direct access to the bitmap data.
  1260 Use this function after ending direct access to the bitmap data.
  1351 Calls to EndDataAccess() must correspond to prior calls to BeginDataAccess().
  1261 Calls to EndDataAccess() must correspond to prior calls to BeginDataAccess().
  1359 @param aReadOnly True if the bitmap data had only been read.  False if the data has been modified.
  1269 @param aReadOnly True if the bitmap data had only been read.  False if the data has been modified.
  1360 @see CFbsBitmap::BeginDataAccess()
  1270 @see CFbsBitmap::BeginDataAccess()
  1361 */
  1271 */
  1362 EXPORT_C void CFbsBitmap::EndDataAccess(TBool aReadOnly) const
  1272 EXPORT_C void CFbsBitmap::EndDataAccess(TBool aReadOnly) const
  1363 	{
  1273 	{
  1364     FBS_OST_VERBOSE(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_ENDDATAACCESS_ENTRY, "> this=0x%08x; aReadOnly=%d;", (TUint)this, (TUint)aReadOnly);)
  1274 	if (!iHandle)
  1365     FBS_OST_IF(!iHandle, OstTrace1(TRACE_ERROR, CFBSBITMAP_ENDDATAACCESS_ERROR, "! this=0x%08x; !iHandle", (TUint)this););
  1275 		return;
  1366     if (iHandle)
  1276 	const_cast<CFbsBitmap*>(this)->iUseCount--;
  1367         {
  1277 	if (!aReadOnly && !(iFlags & EIsReadOnlyBitmapMask))
  1368         const_cast<CFbsBitmap*>(this)->iUseCount--;
  1278 		User::LockedInc(iAddressPointer->Extra()->iTouchCount);
  1369         if (!aReadOnly && !(iFlags & EIsReadOnlyBitmapMask))
       
  1370             {
       
  1371             User::LockedInc(iAddressPointer->Extra()->iTouchCount);
       
  1372             }
       
  1373         }
       
  1374     FBS_OST_VERBOSE(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_ENDDATAACCESS_EXIT, "< this=0x%08x; iUseCount=%d;", (TUint)this, const_cast<CFbsBitmap*>(this)->iUseCount);)
       
  1375 	}
  1279 	}
  1376 
  1280 
  1377 /** Locks the global bitmap heap.
  1281 /** Locks the global bitmap heap.
  1378 This function is deprecated, since it is no longer necessary to lock the global
  1282 This function is deprecated, since it is no longer necessary to lock the global
  1379 bitmap heap to prevent the pixel data from being moved in memory asynchronously,
  1283 bitmap heap to prevent the pixel data from being moved in memory asynchronously,
  1393 @see CFbsBitmap::UnlockHeap()
  1297 @see CFbsBitmap::UnlockHeap()
  1394 @see CFbsBitmap::BeginDataAccess()
  1298 @see CFbsBitmap::BeginDataAccess()
  1395 */
  1299 */
  1396 EXPORT_C void CFbsBitmap::LockHeap(TBool /*aAlways*/) const
  1300 EXPORT_C void CFbsBitmap::LockHeap(TBool /*aAlways*/) const
  1397 	{
  1301 	{
  1398     FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_LOCKHEAP_ENTRY, "> this=0x%08x;", (TUint)this);)
       
  1399 	BeginDataAccess();
  1302 	BeginDataAccess();
  1400 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
  1303 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
  1401 	//These debug checks now refer to the cleaned data address
  1304 	//These debug checks now refer to the cleaned data address
  1402     FBS_OST_IF(!iHandle, OstTrace1(TRACE_ERROR, CFBSBITMAP_LOCKHEAP_ERROR, "! this=0x%08x; !iHandle", (TUint)this););
  1305 	if (!iHandle)
  1403 	if (iHandle && !(iFlags & EIsRomBitmap)) // can't do anything with ROM bitmaps
  1306 		return;
       
  1307 	if (!(iFlags & EIsRomBitmap)) // can't do anything with ROM bitmaps
  1404 		{
  1308 		{
  1405 		TThreadId threadId = RThread().Id();
  1309 		TThreadId threadId = RThread().Id();
  1406 		iFbs->iHelper->iDebugMutex.Wait();
  1310 		iFbs->iHelper->iDebugMutex.Wait();
  1407 		if (iAddressPointer->Extra()->iLockCount++ == 0)
  1311 		if (iAddressPointer->Extra()->iLockCount++ == 0)
  1408 			{
  1312 			{
  1412 		else
  1316 		else
  1413 			__ASSERT_ALWAYS(iAddressPointer->Extra()->iThreadId == threadId, Panic(EFbsPanicBadHeapLock));
  1317 			__ASSERT_ALWAYS(iAddressPointer->Extra()->iThreadId == threadId, Panic(EFbsPanicBadHeapLock));
  1414 		iFbs->iHelper->iDebugMutex.Signal();
  1318 		iFbs->iHelper->iDebugMutex.Signal();
  1415 		}
  1319 		}
  1416 #endif
  1320 #endif
  1417 	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_LOCKHEAP_EXIT, "< this=0x%08x;", (TUint)this);)
       
  1418 	}
  1321 	}
  1419 
  1322 
  1420 /** Unlocks the global heap. 
  1323 /** Unlocks the global heap. 
  1421 This function is deprecated. See LockHeap() for more details.
  1324 This function is deprecated. See LockHeap() for more details.
  1422 Calls to UnlockHeap() should be replaced by calls to EndDataAccess().
  1325 Calls to UnlockHeap() should be replaced by calls to EndDataAccess().
  1427 @see CFbsBitmap::LockHeap()
  1330 @see CFbsBitmap::LockHeap()
  1428 @see CFbsBitmap::EndDataAccess()
  1331 @see CFbsBitmap::EndDataAccess()
  1429 */
  1332 */
  1430 EXPORT_C void CFbsBitmap::UnlockHeap(TBool /*aAlways*/) const
  1333 EXPORT_C void CFbsBitmap::UnlockHeap(TBool /*aAlways*/) const
  1431 	{
  1334 	{
  1432     FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_UNLOCKHEAP_ENTRY, "> this=0x%08x;", (TUint)this);)
       
  1433     FBS_OST_IF(!iHandle, OstTrace1(TRACE_ERROR, CFBSBITMAP_UNLOCKHEAP_ERROR, "! this=0x%08x; !iHandle", (TUint)this););
       
  1434 	if (iHandle)
       
  1435 	    {
       
  1436 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
  1335 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
  1437 	    if (!(iFlags & EIsRomBitmap)) // can't do anything with ROM bitmaps
  1336 	if (!iHandle)
  1438             {
  1337 		return;
  1439             TThreadId threadId = RThread().Id();
  1338 	if (!(iFlags & EIsRomBitmap)) // can't do anything with ROM bitmaps
  1440             iFbs->iHelper->iDebugMutex.Wait();
  1339 		{
  1441             __ASSERT_ALWAYS(iAddressPointer->Extra()->iLockCount > 0, Panic(EFbsPanicBadHeapLock));
  1340 		TThreadId threadId = RThread().Id();
  1442             __ASSERT_ALWAYS(iAddressPointer->Extra()->iThreadId == threadId, Panic(EFbsPanicBadHeapLock));
  1341 		iFbs->iHelper->iDebugMutex.Wait();
  1443             if (--iAddressPointer->Extra()->iLockCount == 0)
  1342 		__ASSERT_ALWAYS(iAddressPointer->Extra()->iLockCount > 0, Panic(EFbsPanicBadHeapLock));
  1444                 iAddressPointer->Extra()->iThreadId = TThreadId(KNullThreadId);
  1343 		__ASSERT_ALWAYS(iAddressPointer->Extra()->iThreadId == threadId, Panic(EFbsPanicBadHeapLock));
  1445             iFbs->iHelper->iDebugMutex.Signal();
  1344 		if (--iAddressPointer->Extra()->iLockCount == 0)
  1446             }
  1345 			iAddressPointer->Extra()->iThreadId = TThreadId(KNullThreadId);
       
  1346 		iFbs->iHelper->iDebugMutex.Signal();
       
  1347 		}
  1447 #endif
  1348 #endif
  1448 	    EndDataAccess();
  1349 	EndDataAccess();
  1449 	    }
       
  1450 	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_UNLOCKHEAP_EXIT, "< this=0x%08x;", (TUint)this);)
       
  1451 	}
  1350 	}
  1452 
  1351 
  1453 /** Locks the global bitmap heap, leaving on the clean-up stack a pointer
  1352 /** Locks the global bitmap heap, leaving on the clean-up stack a pointer
  1454 to a TCleanupItem that unlocks the heap on deletion.
  1353 to a TCleanupItem that unlocks the heap on deletion.
  1455 Use this function instead of LockHeap() if code may leave between the
  1354 Use this function instead of LockHeap() if code may leave between the
  1461 @deprecated
  1360 @deprecated
  1462 @see CFbsBitmap::LockHeap()
  1361 @see CFbsBitmap::LockHeap()
  1463 */
  1362 */
  1464 EXPORT_C void CFbsBitmap::LockHeapLC(TBool /*aAlways*/) const
  1363 EXPORT_C void CFbsBitmap::LockHeapLC(TBool /*aAlways*/) const
  1465 	{
  1364 	{
  1466     FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_LOCKHEAPLC_ENTRY, "> this=0x%08x;", (TUint)this);)
  1365 	LockHeap();
  1467     LockHeap();
       
  1468 	TCleanupItem cleanitem(CFbsBitmap::UnlockHeap, (TAny*)this);
  1366 	TCleanupItem cleanitem(CFbsBitmap::UnlockHeap, (TAny*)this);
  1469 	CleanupStack::PushL(cleanitem);
  1367 	CleanupStack::PushL(cleanitem);
  1470 	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_LOCKHEAPLC_EXIT, "< this=0x%08x;", (TUint)this);)
       
  1471 	}
  1368 	}
  1472 
  1369 
  1473 EXPORT_C void CFbsBitmap::UnlockHeap(TAny* aFbsBitmap)
  1370 EXPORT_C void CFbsBitmap::UnlockHeap(TAny* aFbsBitmap)
  1474 	{
  1371 	{
  1475     FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_UNLOCKHEAP2_ENTRY, "> bitmap=0x%08x;", (TUint)aFbsBitmap);)
  1372 	((CFbsBitmap*)aFbsBitmap)->UnlockHeap();
  1476     ((CFbsBitmap*)aFbsBitmap)->UnlockHeap();
       
  1477     FBS_OST(OstTrace0(GRAPHICS_CONTROL_FUNCTIONS, CFBSBITMAP_UNLOCKHEAP2_EXIT, "<");)
       
  1478 	}
  1373 	}
  1479 
  1374 
  1480 /** Tests whether the bitmap is volatile.
  1375 /** Tests whether the bitmap is volatile.
  1481 A bitmap becomes volatile if CFbsBitmap::DataAdress() is called without
  1376 A bitmap becomes volatile if CFbsBitmap::DataAdress() is called without
  1482 CFbsBitmap::BeginDataAccess() having been called before and it can become non-volatile
  1377 CFbsBitmap::BeginDataAccess() having been called before and it can become non-volatile
  1501 @return The number of times the bitmap has been touched.
  1396 @return The number of times the bitmap has been touched.
  1502 */
  1397 */
  1503 EXPORT_C TInt CFbsBitmap::TouchCount() const
  1398 EXPORT_C TInt CFbsBitmap::TouchCount() const
  1504 	{
  1399 	{
  1505 	if (!iHandle || (iFlags & EIsReadOnlyBitmapMask))
  1400 	if (!iHandle || (iFlags & EIsReadOnlyBitmapMask))
  1506 		return 0; // A read-only bitmap can never be touched.
  1401 			return 0; // A read-only bitmap can never be touched.
  1507 	return CleanAddress()->Extra()->iTouchCount;
  1402 	return CleanAddress()->Extra()->iTouchCount;
  1508 	}
  1403 	}
  1509 
  1404 
  1510 /** Returns the serial number of the bitmap
  1405 /** Returns the serial number of the bitmap
  1511 The serial number is unique to this bitmap.
  1406 The serial number is unique to this bitmap.
  1826 @publishedAll
  1721 @publishedAll
  1827 @released
  1722 @released
  1828 */	
  1723 */	
  1829 EXPORT_C TInt CFbsBitmap::Load(RFile& aFile,TInt32 aId/*=0*/,TBool aShareIfLoaded/*=ETrue*/)
  1724 EXPORT_C TInt CFbsBitmap::Load(RFile& aFile,TInt32 aId/*=0*/,TBool aShareIfLoaded/*=ETrue*/)
  1830 	{
  1725 	{
  1831     FBS_OST(TFullName fileName;)
  1726 	return Load(aFile,aId,aShareIfLoaded,0);
  1832     FBS_OST(aFile.FullName(fileName);)
       
  1833     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD3_ENTRY, "> this=0x%08x; file=%S; id=0x%08x; share=%d", (TUint)this, fileName, aId, aShareIfLoaded);)
       
  1834 	TInt ret = Load(aFile,aId,aShareIfLoaded,0);
       
  1835     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD3_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, ret, iHandle, iServerHandle);) 
       
  1836 	return ret;
       
  1837 	}
  1727 	}
  1838 
  1728 
  1839 /** Loads a specific bitmap from an opened multi-bitmap file handle.
  1729 /** Loads a specific bitmap from an opened multi-bitmap file handle.
  1840 The bitmap may be shared by other font and bitmap server clients.
  1730 The bitmap may be shared by other font and bitmap server clients.
  1841 @param aFile The handle of the multi-bitmap (.mbm) file. 
  1731 @param aFile The handle of the multi-bitmap (.mbm) file. 
  1847 @publishedAll
  1737 @publishedAll
  1848 @released
  1738 @released
  1849 */	
  1739 */	
  1850 EXPORT_C TInt CFbsBitmap::Load(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
  1740 EXPORT_C TInt CFbsBitmap::Load(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
  1851 	{
  1741 	{
  1852     TInt err = KErrNone;
       
  1853     FBS_OST(TFullName fileName;)
       
  1854     FBS_OST(aFile.FullName(fileName);)
       
  1855     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD4_ENTRY, "> this=0x%08x; file=%S; id=0x%08x; share=%d; off=%d", (TUint)this, fileName, aId, aShareIfLoaded, aFileOffset);)
       
  1856 	if (!iFbs)
  1742 	if (!iFbs)
  1857 		{
  1743 		{
  1858         FBS_OST(OstTrace1( TRACE_ERROR, CFBSBITMAP_LOAD4_ERROR, "! this=0x%08x; !iFbs", (TUint)this);)
  1744 		return(KErrCouldNotConnect);
  1859 		err = KErrCouldNotConnect;
  1745 		}
  1860 		}
  1746 	Reset();
  1861 	else
  1747 	TUint32* rompointer;
  1862 	    {
  1748 	IsFileInRom(aFile,rompointer);
  1863         Reset();
  1749 	TBool romPointerValid;
  1864         TUint32* rompointer;
  1750 	TInt err = DoLoadFromRom(rompointer, aId, aFileOffset, romPointerValid);
  1865         IsFileInRom(aFile,rompointer);
  1751 	if (!romPointerValid)
  1866         TBool romPointerValid;
  1752 		{
  1867         err = DoLoadFromRom(rompointer, aId, aFileOffset, romPointerValid);
  1753 		err = DoLoad(aFile,aId,aShareIfLoaded,aFileOffset);
  1868         if (!romPointerValid)
  1754 		}
  1869             {
       
  1870             err = DoLoad(aFile,aId,aShareIfLoaded,aFileOffset);
       
  1871             FBS_OST_IF(err!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_LOAD4_ERROR2, "! this=0x%08x; DoLoad() returned %d", (TUint)this, err);)
       
  1872             }
       
  1873 	    }
       
  1874 	FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOAD4_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, err, iHandle, iServerHandle);)
       
  1875 	return err;
  1755 	return err;
  1876 	}
  1756 	}
  1877 
  1757 
  1878 /** Loads and compresses a specific bitmap from an opened multi-bitmap file handle.
  1758 /** Loads and compresses a specific bitmap from an opened multi-bitmap file handle.
  1879 The bitmap may be shared by other font and bitmap server clients.
  1759 The bitmap may be shared by other font and bitmap server clients.
  1887 @publishedAll 
  1767 @publishedAll 
  1888 @released
  1768 @released
  1889 */	
  1769 */	
  1890 EXPORT_C TInt CFbsBitmap::LoadAndCompress(RFile& aFile,TInt32 aId/*=0*/,TBool aShareIfLoaded/*=ETrue*/)
  1770 EXPORT_C TInt CFbsBitmap::LoadAndCompress(RFile& aFile,TInt32 aId/*=0*/,TBool aShareIfLoaded/*=ETrue*/)
  1891 	{
  1771 	{
  1892     FBS_OST(TFullName fileName;)
  1772 	return LoadAndCompress(aFile,aId,aShareIfLoaded,0);
  1893     FBS_OST(aFile.FullName(fileName);)
       
  1894     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS3_ENTRY, "> this=0x%08x; file=%S; id=0x%08x; share=%d", (TUint)this, fileName, aId, aShareIfLoaded);)      
       
  1895 	TInt ret = LoadAndCompress(aFile,aId,aShareIfLoaded,0);
       
  1896     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS3_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, ret, iHandle, iServerHandle);)
       
  1897     return ret;
       
  1898 	}
  1773 	}
  1899 
  1774 
  1900 /** Loads and compresses a specific bitmap from an opened multi-bitmap file handle.
  1775 /** Loads and compresses a specific bitmap from an opened multi-bitmap file handle.
  1901 The bitmap may be shared by other font and bitmap server clients. If the 
  1776 The bitmap may be shared by other font and bitmap server clients. If the 
  1902 bitmap is loaded from ROM then compression is not allowed.
  1777 bitmap is loaded from ROM then compression is not allowed.
  1910 @publishedAll 
  1785 @publishedAll 
  1911 @released
  1786 @released
  1912 */	
  1787 */	
  1913 EXPORT_C TInt CFbsBitmap::LoadAndCompress(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
  1788 EXPORT_C TInt CFbsBitmap::LoadAndCompress(RFile& aFile,TInt32 aId,TBool aShareIfLoaded,TUint aFileOffset)
  1914 	{
  1789 	{
  1915     FBS_OST(TFullName fileName;)
       
  1916     FBS_OST(aFile.FullName(fileName);)
       
  1917     FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS4_ENTRY, "> this=0x%08x; file=%S; id=0x%08x; share=%d", (TUint)this, fileName, aId, aShareIfLoaded);)
       
  1918 	TInt err = Load(aFile,aId,aShareIfLoaded,aFileOffset);
  1790 	TInt err = Load(aFile,aId,aShareIfLoaded,aFileOffset);
  1919 	if (err == KErrNone)
  1791 	if (err == KErrNone)
  1920 		{
  1792 		{
  1921         if (!(iFlags & EIsRomBitmap))
  1793 		err = !(iFlags & EIsRomBitmap) ? Compress() : KErrAccessDenied;
  1922             {
  1794 		}
  1923             err = Compress();
       
  1924             FBS_OST_IF(err!=KErrNone, OstTraceExt2( TRACE_ERROR, CFBSBITMAP_LOADANDCOMPRESS4_ERROR, "! this=0x%08x; Compress() returned %d", (TUint)this, err);)
       
  1925             }
       
  1926         else
       
  1927             {
       
  1928             err = KErrAccessDenied;
       
  1929             FBS_OST(OstTraceExt2( TRACE_ERROR, CFBSBITMAP_LOADANDCOMPRESS4_ERROR2, "! this=0x%08x; Cannot compress bitmap in ROM; iFlags=0x%08x", (TUint)this, (TUint)iFlags);)
       
  1930             }
       
  1931 		}
       
  1932 	FBS_OST(OstTraceExt2( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_LOADANDCOMPRESS4_EXIT, "< this=0x%08x; err=%d", (TUint)this, err);)
       
  1933 	return err;
  1795 	return err;
  1934 	}
  1796 	}
  1935 
  1797 
  1936 /** Gets all the bitmap handles for all the bitmaps stored in the Font Bitmap Server. There is a limit of
  1798 /** Gets all the bitmap handles for all the bitmaps stored in the Font Bitmap Server. There is a limit of
  1937 the number of bitmaps that can be retrieved defined by KMaxBitmapHandleBufferSize. If this limit has been
  1799 the number of bitmaps that can be retrieved defined by KMaxBitmapHandleBufferSize. If this limit has been
  2044 @see CFbsBitmap::BeginDataAccess()
  1906 @see CFbsBitmap::BeginDataAccess()
  2045 @see CFbsBitmap::EndDataAccess()
  1907 @see CFbsBitmap::EndDataAccess()
  2046 */
  1908 */
  2047 EXPORT_C TInt CFbsBitmap::CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, const TAny* aData, TInt aDataSize)
  1909 EXPORT_C TInt CFbsBitmap::CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, const TAny* aData, TInt aDataSize)
  2048 	{
  1910 	{
  2049     TInt err;
       
  2050     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATEEXTENDEDBITMAP_ENTRY, "> this=0x%08x; w=%d; h=%d; dm=%d; type=0x%08x", (TUint)this, aSizeInPixels.iWidth, aSizeInPixels.iHeight, aDispMode, aType.iUid);)
       
  2051 	if (!aData || aDataSize == 0)
  1911 	if (!aData || aDataSize == 0)
  2052 		{
  1912 		{
  2053         FBS_OST(OstTrace1( TRACE_ERROR, CFBSBITMAP_CREATEEXTENDEDBITMAP_ERROR, "! this=0x%08x; (!aData || aDataSize == 0)", (TUint)this);)
  1913 		return KErrArgument;
  2054 		err = KErrArgument;
  1914 		}
  2055 		}
  1915 	TInt err = DoCreate(aSizeInPixels, aDispMode, aType, aDataSize);
  2056 	else
  1916 	if (err == KErrNone)
  2057 	    {
  1917 		{
  2058         err = DoCreate(aSizeInPixels, aDispMode, aType, aDataSize);
  1918 		Mem::Copy(iFbs->iLargeBitmapChunk.Base() + iAddressPointer->iDataOffset, aData, aDataSize);
  2059         if (err == KErrNone)
  1919 		}
  2060             {
       
  2061             Mem::Copy(iFbs->iLargeBitmapChunk.Base() + iAddressPointer->iDataOffset, aData, aDataSize);
       
  2062             }
       
  2063 	    }
       
  2064 	FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATEEXTENDEDBITMAP_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, err, iHandle, iServerHandle);)
       
  2065 	return err;
  1920 	return err;
  2066 	}
  1921 	}
  2067 
  1922 
  2068 /**
  1923 /**
  2069 Creates an extended bitmap. Extended bitmaps are used to store immutable
  1924 Creates an extended bitmap. Extended bitmaps are used to store immutable
  2103 @see CFbsBitmap::EndDataAccess()
  1958 @see CFbsBitmap::EndDataAccess()
  2104 @see MFbsExtendedBitmapInitializer
  1959 @see MFbsExtendedBitmapInitializer
  2105 */
  1960 */
  2106 EXPORT_C TInt CFbsBitmap::CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, TInt aDataSize, MFbsExtendedBitmapInitializer& aInitializer)
  1961 EXPORT_C TInt CFbsBitmap::CreateExtendedBitmap(const TSize& aSizeInPixels, TDisplayMode aDispMode, TUid aType, TInt aDataSize, MFbsExtendedBitmapInitializer& aInitializer)
  2107 	{
  1962 	{
  2108     TInt err; 
       
  2109     FBS_OST(OstTraceExt5( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATEEXTENDEDBITMAP2_ENTRY, "> this=0x%08x; w=%d; h=%d; dm=%d; type=0x%08x;", (TUint)this, aSizeInPixels.iWidth, aSizeInPixels.iHeight, aDispMode, aType.iUid);)
       
  2110 	if (aDataSize == 0)
  1963 	if (aDataSize == 0)
  2111 		{
  1964 		{
  2112         FBS_OST(OstTrace1( TRACE_ERROR, CFBSBITMAP_CREATEEXTENDEDBITMAP2_ERROR, "! this=0x%08x; aDataSize == 0", (TUint)this);)
  1965 		return KErrArgument;
  2113 		err = KErrArgument;
  1966 		}
  2114 		}
  1967 	TInt err = DoCreate(aSizeInPixels, aDispMode, aType, aDataSize);
  2115 	else
  1968 	if (err == KErrNone)
  2116 	    {
  1969 		{
  2117         err = DoCreate(aSizeInPixels, aDispMode, aType, aDataSize);
  1970 		err = aInitializer.InitExtendedBitmap(iFbs->iLargeBitmapChunk.Base() + iAddressPointer->iDataOffset, aDataSize);
  2118         if (err == KErrNone)
  1971 		if (err != KErrNone)
  2119             {
  1972 			{
  2120             err = aInitializer.InitExtendedBitmap(iFbs->iLargeBitmapChunk.Base() + iAddressPointer->iDataOffset, aDataSize);
  1973 			Reset();
  2121             if (err != KErrNone)
  1974 			}
  2122                 {
  1975 		}
  2123                 Reset();
       
  2124                 }
       
  2125             }
       
  2126 	    }
       
  2127 	FBS_OST(OstTraceExt4( GRAPHICS_RESOURCE_MANAGEMENT_FUNCTIONS, CFBSBITMAP_CREATEEXTENDEDBITMAP2_EXIT, "< this=0x%08x; err=%d; iH=0x%08x; iSH=0x%08x", (TUint)this, err, iHandle, iServerHandle);)
       
  2128 	return err;
  1976 	return err;
  2129 	}
  1977 	}
  2130 
  1978 
  2131 /**
  1979 /**
  2132 Gets the UID identifying the data format of an extended bitmap.
  1980 Gets the UID identifying the data format of an extended bitmap.