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