os/graphics/fbs/fontandbitmapserver/sfbs/fbshelper.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <e32uid.h>
    17 #include <e32svr.h>
    18 #include <u32hal.h>
    19 #include <fbs.h>
    20 #include "UTILS.H"
    21 #include "fbshelper.h"
    22 #include "fbsrasterizer.h"
    23 #include "FbsMessage.H"
    24 
    25 GLREF_C void Panic(TFbsPanic aPanic);
    26 
    27 
    28 CFbsSessionHelper::CFbsSessionHelper(RFbsSession& aFbs)
    29 	: CActive(CActive::EPriorityIdle), iFbs(aFbs)
    30 	{
    31 	if (CActiveScheduler::Current() != NULL)
    32 		CActiveScheduler::Add(this);
    33 #ifdef __WINS__
    34 	TUint8* rasterizerSetting = NULL;
    35 	UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalStringProperty, (TAny*)"FBSRASTERIZER_DLL", &rasterizerSetting);
    36 	if (rasterizerSetting)
    37 		{
    38 		TBuf<80> rasterizerName;
    39 		rasterizerName.Copy(TPtrC8(rasterizerSetting));
    40 		const TUidType KFbsRasterizerLibraryUidType(KDynamicLibraryUid, KSharedLibraryUid, KFbsRasterizerLibraryUid);
    41 		TInt err = iRasterizerLib.Load(rasterizerName, KFbsRasterizerLibraryUidType);
    42 		if (err == KErrNone)
    43 			{
    44 			CFbsRasterizer* (*create)() = reinterpret_cast<CFbsRasterizer*(*)()>(iRasterizerLib.Lookup(1));
    45 			iRasterizer = create();
    46 			}
    47 #ifdef _DEBUG
    48 		else
    49 			{
    50 			RDebug::Printf("Failed to load extended bitmap rasterizer %s\r\n", rasterizerSetting);
    51 			}
    52 #endif
    53 		}
    54 	// else do nothing, as rasterizer is optional
    55 #else
    56 	iRasterizer = CFbsRasterizer::New();
    57 #endif
    58 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
    59 	TInt err = iDebugMutex.OpenGlobal(KFBSERVDebugMutexName, EOwnerThread);
    60 	if (err != KErrNone)
    61 		Panic(EFbsPanicChunkError);
    62 #endif
    63 	}
    64 
    65 
    66 CFbsSessionHelper::~CFbsSessionHelper()
    67 	{
    68 	if (IsAdded())
    69 		Cancel();
    70 	iBitmaps.Reset();
    71 	delete iRasterizer;
    72 #ifdef __WINS__
    73 	iRasterizerLib.Close();
    74 #endif
    75 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
    76 	iDebugMutex.Close();
    77 #endif
    78 	delete iExtraBuffer;
    79 	}
    80 
    81 
    82 TInt CFbsSessionHelper::AddBitmap(CFbsBitmap& aBitmap)
    83 	{
    84 	if (IsAdded())
    85 		{
    86 		TInt err = iBitmaps.InsertInAddressOrder(&aBitmap);
    87 		if (err == KErrNone && !IsActive())
    88 			{
    89 			SetActive();
    90 			iFbs.SendCommand(EFbsMessBitmapNotifyDirty, TIpcArgs(), iStatus);
    91 			}
    92 		return err;
    93 		}
    94 	return KErrNone;
    95 	}
    96 
    97 
    98 void CFbsSessionHelper::RemoveBitmap(CFbsBitmap& aBitmap)
    99 	{
   100 	if (IsAdded())
   101 		{
   102 		TInt index = iBitmaps.FindInAddressOrder(&aBitmap);
   103 		if (index != KErrNotFound)
   104 			{
   105 			iBitmaps.Remove(index);
   106 			if (iBitmaps.Count() == 0)
   107 				Cancel();
   108 			}
   109 		}
   110 	}
   111 
   112 
   113 void CFbsSessionHelper::RunL()
   114 	{
   115 	if (iStatus == KErrNone && iBitmaps.Count() > 0)
   116 		{
   117 		for (TInt i = 0; i < iBitmaps.Count(); ++i)
   118 			(void)iBitmaps[i]->CleanAddress();
   119 		SetActive();
   120 		iFbs.SendCommand(EFbsMessBitmapNotifyDirty, TIpcArgs(), iStatus);
   121 		}
   122 	}
   123 
   124 
   125 void CFbsSessionHelper::DoCancel()
   126 	{
   127 	iFbs.SendCommand(EFbsMessBitmapCancelNotifyDirty);
   128 	}