1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/fbs/fontandbitmapserver/sfbs/fbshelper.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,128 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <e32uid.h>
1.20 +#include <e32svr.h>
1.21 +#include <u32hal.h>
1.22 +#include <fbs.h>
1.23 +#include "UTILS.H"
1.24 +#include "fbshelper.h"
1.25 +#include "fbsrasterizer.h"
1.26 +#include "FbsMessage.H"
1.27 +
1.28 +GLREF_C void Panic(TFbsPanic aPanic);
1.29 +
1.30 +
1.31 +CFbsSessionHelper::CFbsSessionHelper(RFbsSession& aFbs)
1.32 + : CActive(CActive::EPriorityIdle), iFbs(aFbs)
1.33 + {
1.34 + if (CActiveScheduler::Current() != NULL)
1.35 + CActiveScheduler::Add(this);
1.36 +#ifdef __WINS__
1.37 + TUint8* rasterizerSetting = NULL;
1.38 + UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalStringProperty, (TAny*)"FBSRASTERIZER_DLL", &rasterizerSetting);
1.39 + if (rasterizerSetting)
1.40 + {
1.41 + TBuf<80> rasterizerName;
1.42 + rasterizerName.Copy(TPtrC8(rasterizerSetting));
1.43 + const TUidType KFbsRasterizerLibraryUidType(KDynamicLibraryUid, KSharedLibraryUid, KFbsRasterizerLibraryUid);
1.44 + TInt err = iRasterizerLib.Load(rasterizerName, KFbsRasterizerLibraryUidType);
1.45 + if (err == KErrNone)
1.46 + {
1.47 + CFbsRasterizer* (*create)() = reinterpret_cast<CFbsRasterizer*(*)()>(iRasterizerLib.Lookup(1));
1.48 + iRasterizer = create();
1.49 + }
1.50 +#ifdef _DEBUG
1.51 + else
1.52 + {
1.53 + RDebug::Printf("Failed to load extended bitmap rasterizer %s\r\n", rasterizerSetting);
1.54 + }
1.55 +#endif
1.56 + }
1.57 + // else do nothing, as rasterizer is optional
1.58 +#else
1.59 + iRasterizer = CFbsRasterizer::New();
1.60 +#endif
1.61 +#ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
1.62 + TInt err = iDebugMutex.OpenGlobal(KFBSERVDebugMutexName, EOwnerThread);
1.63 + if (err != KErrNone)
1.64 + Panic(EFbsPanicChunkError);
1.65 +#endif
1.66 + }
1.67 +
1.68 +
1.69 +CFbsSessionHelper::~CFbsSessionHelper()
1.70 + {
1.71 + if (IsAdded())
1.72 + Cancel();
1.73 + iBitmaps.Reset();
1.74 + delete iRasterizer;
1.75 +#ifdef __WINS__
1.76 + iRasterizerLib.Close();
1.77 +#endif
1.78 +#ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
1.79 + iDebugMutex.Close();
1.80 +#endif
1.81 + delete iExtraBuffer;
1.82 + }
1.83 +
1.84 +
1.85 +TInt CFbsSessionHelper::AddBitmap(CFbsBitmap& aBitmap)
1.86 + {
1.87 + if (IsAdded())
1.88 + {
1.89 + TInt err = iBitmaps.InsertInAddressOrder(&aBitmap);
1.90 + if (err == KErrNone && !IsActive())
1.91 + {
1.92 + SetActive();
1.93 + iFbs.SendCommand(EFbsMessBitmapNotifyDirty, TIpcArgs(), iStatus);
1.94 + }
1.95 + return err;
1.96 + }
1.97 + return KErrNone;
1.98 + }
1.99 +
1.100 +
1.101 +void CFbsSessionHelper::RemoveBitmap(CFbsBitmap& aBitmap)
1.102 + {
1.103 + if (IsAdded())
1.104 + {
1.105 + TInt index = iBitmaps.FindInAddressOrder(&aBitmap);
1.106 + if (index != KErrNotFound)
1.107 + {
1.108 + iBitmaps.Remove(index);
1.109 + if (iBitmaps.Count() == 0)
1.110 + Cancel();
1.111 + }
1.112 + }
1.113 + }
1.114 +
1.115 +
1.116 +void CFbsSessionHelper::RunL()
1.117 + {
1.118 + if (iStatus == KErrNone && iBitmaps.Count() > 0)
1.119 + {
1.120 + for (TInt i = 0; i < iBitmaps.Count(); ++i)
1.121 + (void)iBitmaps[i]->CleanAddress();
1.122 + SetActive();
1.123 + iFbs.SendCommand(EFbsMessBitmapNotifyDirty, TIpcArgs(), iStatus);
1.124 + }
1.125 + }
1.126 +
1.127 +
1.128 +void CFbsSessionHelper::DoCancel()
1.129 + {
1.130 + iFbs.SendCommand(EFbsMessBitmapCancelNotifyDirty);
1.131 + }