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