64
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Implements CHuiStatic, static data access and utility
|
|
15 |
* functions such as timing.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include "uiacceltk/HuiStatic.h" // Class definition
|
|
22 |
#include "uiacceltk/HuiUtil.h"
|
|
23 |
#include "uiacceltk/HuiEnv.h"
|
|
24 |
#include "HuiRenderPlugin.h"
|
|
25 |
#include "huistatictlsdata.h"
|
|
26 |
#include "uiacceltk/HuiProbe.h"
|
|
27 |
#include <e32math.h>
|
|
28 |
#include <eikenv.h>
|
|
29 |
#include <flogger.h>
|
|
30 |
#include <AknsUtils.h>
|
|
31 |
#include <AknUtils.h>
|
|
32 |
#include <AknBidiTextUtils.h>
|
|
33 |
#include <bidivisual.h>
|
|
34 |
#include "alfappfwproxyops.h"
|
|
35 |
|
|
36 |
#ifdef HUI_DEBUG_TRACK_DRAWING
|
|
37 |
#include "alfloggingconfiguration.h"
|
|
38 |
#include "alfcommanddebug.h"
|
|
39 |
#endif
|
|
40 |
|
|
41 |
// Global writeable data, used in HW instead of TLS which relatively slow
|
|
42 |
#ifndef __WINSCW__
|
|
43 |
TTlsData globalWriteableData;
|
|
44 |
#endif
|
|
45 |
|
|
46 |
void CleanupWg(TAny* aWg)
|
|
47 |
{
|
|
48 |
RWindowGroup* wg = static_cast<RWindowGroup*>(aWg);
|
|
49 |
delete wg;
|
|
50 |
}
|
|
51 |
|
|
52 |
/** Dummy implementation for HuiProbe, to be used when external probe is not set */
|
|
53 |
NONSHARABLE_CLASS(TFakeProbe) : public MHuiProbe
|
|
54 |
{
|
|
55 |
public:
|
|
56 |
virtual void ReportObjectLifeCycleEvent(const MHuiSessionObject&, TLifecycleEvent) {}
|
|
57 |
virtual void ReportProgramFlowEvent(TProgramFlowPoint, TProgramFlowEvent) {}
|
|
58 |
virtual void ReportProgramFlowEvent(const MHuiSessionObject&, TProgramFlowPoint, TProgramFlowEvent) {}
|
|
59 |
void ReportFrameRate(TInt) const {}
|
|
60 |
void AssociateWithCurrentSession(MHuiSessionObject&) {}
|
|
61 |
};
|
|
62 |
|
|
63 |
|
|
64 |
NONSHARABLE_CLASS(CAppFwProxy): public CBase
|
|
65 |
{
|
|
66 |
public:
|
|
67 |
class CAlfGuardedSynchCall: public CActive
|
|
68 |
{
|
|
69 |
public:
|
|
70 |
CAlfGuardedSynchCall(const TAlfCommandParams& aParams):CActive(CActive::EPriorityStandard), iPckg(aParams), iPtr(0,0)
|
|
71 |
{
|
|
72 |
CActiveScheduler::Add(this);
|
|
73 |
iStatus = KErrNotFound;
|
|
74 |
}
|
|
75 |
|
|
76 |
static TInt DoGuardedOpErrL(const TAlfCommandParams& aInParams,
|
|
77 |
TDes8& aOutParams,
|
|
78 |
RNotifier& aNotifier,
|
|
79 |
const TDesC8* aInParams2 = 0 // ugly extension, really
|
|
80 |
)
|
|
81 |
{
|
|
82 |
CAlfGuardedSynchCall* me = new (ELeave) CAlfGuardedSynchCall(aInParams);
|
|
83 |
|
|
84 |
CleanupStack::PushL(me);
|
|
85 |
User::LeaveIfError(me->iTimer.CreateLocal());
|
|
86 |
me->iRetBuf = aOutParams.AllocL();
|
|
87 |
me->iPtr.Set((TUint8*)me->iRetBuf->Ptr(),0,aOutParams.MaxSize());
|
|
88 |
if (aInParams2)
|
|
89 |
{
|
|
90 |
me->iAltInBuf = aInParams2->AllocL();
|
|
91 |
}
|
|
92 |
CleanupStack::Pop(); // me
|
|
93 |
|
|
94 |
if (aInParams2)
|
|
95 |
{
|
|
96 |
aNotifier.StartNotifierAndGetResponse(me->iStatus,
|
|
97 |
TUid::Uid(KAlfAppFwProxyUid),
|
|
98 |
*me->iAltInBuf, me->iPtr);
|
|
99 |
}
|
|
100 |
else
|
|
101 |
{
|
|
102 |
aNotifier.StartNotifierAndGetResponse(me->iStatus,
|
|
103 |
TUid::Uid(KAlfAppFwProxyUid),
|
|
104 |
me->iPckg, me->iPtr);
|
|
105 |
}
|
|
106 |
|
|
107 |
me->iTimer.After(me->iTimerStatus, 100000); // 100ms
|
|
108 |
User::WaitForRequest(me->iStatus, me->iTimerStatus);
|
|
109 |
TBool timedOut = (me->iStatus == KRequestPending);
|
|
110 |
|
|
111 |
me->iTimer.Cancel(); // Cancel timer anyway
|
|
112 |
|
|
113 |
if (!timedOut)
|
|
114 |
{
|
|
115 |
TInt err = me->iStatus.Int();
|
|
116 |
User::WaitForRequest(me->iTimerStatus);
|
|
117 |
aOutParams.Copy(*me->iRetBuf);
|
|
118 |
delete me;
|
|
119 |
return err;
|
|
120 |
}
|
|
121 |
else
|
|
122 |
{
|
|
123 |
me->SetActive();
|
|
124 |
return KErrTimedOut;
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
static void DoGuardedOpL(const TAlfCommandParams& aInParams,
|
|
129 |
TDes8& aOutParams,
|
|
130 |
RNotifier& aNotifier,
|
|
131 |
const TDesC8* aInParams2 = 0 // ugly extension, really
|
|
132 |
)
|
|
133 |
{
|
|
134 |
TInt err = DoGuardedOpErrL(aInParams, aOutParams, aNotifier, aInParams2);
|
|
135 |
User::LeaveIfError(err);
|
|
136 |
}
|
|
137 |
|
|
138 |
static TInt DoGuardedOp(const TAlfCommandParams& aInParams,
|
|
139 |
TDes8& aOutParams,
|
|
140 |
RNotifier& aNotifier)
|
|
141 |
{
|
|
142 |
TInt ret = KErrNone;
|
|
143 |
TInt err = KErrNone;
|
|
144 |
TRAP(ret, err = DoGuardedOpErrL(aInParams, aOutParams, aNotifier);)
|
|
145 |
if (ret == KErrNone)
|
|
146 |
{
|
|
147 |
ret = err;
|
|
148 |
}
|
|
149 |
return ret;
|
|
150 |
}
|
|
151 |
|
|
152 |
~CAlfGuardedSynchCall()
|
|
153 |
{
|
|
154 |
Cancel();
|
|
155 |
delete iRetBuf;
|
|
156 |
delete iAltInBuf;
|
|
157 |
iTimer.Close();
|
|
158 |
}
|
|
159 |
|
|
160 |
void RunL()
|
|
161 |
{
|
|
162 |
delete this;
|
|
163 |
}
|
|
164 |
|
|
165 |
void DoCancel()
|
|
166 |
{
|
|
167 |
// Cancel will call User::WaitForRequest for iStatus (if this ao is active)
|
|
168 |
}
|
|
169 |
|
|
170 |
TPckgC<TAlfCommandParams> iPckg;
|
|
171 |
HBufC8* iRetBuf;
|
|
172 |
HBufC8* iAltInBuf;
|
|
173 |
TPtr8 iPtr;
|
|
174 |
RTimer iTimer;
|
|
175 |
TRequestStatus iTimerStatus;
|
|
176 |
};
|
|
177 |
|
|
178 |
class CAlfLayoutListener: public CActive
|
|
179 |
{
|
|
180 |
public:
|
|
181 |
CAlfLayoutListener(CAppFwProxy& aNotif):CActive(CActive::EPriorityStandard), iNotif(aNotif)
|
|
182 |
{
|
|
183 |
CActiveScheduler::Add(this);
|
|
184 |
iStatus = KErrNotFound;
|
|
185 |
}
|
|
186 |
|
|
187 |
~CAlfLayoutListener()
|
|
188 |
{
|
|
189 |
Cancel();
|
|
190 |
}
|
|
191 |
|
|
192 |
void RunL()
|
|
193 |
{
|
|
194 |
iNotif.iLayoutMirrored = (iStatus.Int() > 0);
|
|
195 |
SetActive();
|
|
196 |
TAlfCommandParams params={EAlfIsMirrorred,0,0,0};
|
|
197 |
iParams() = params;
|
|
198 |
iNotif.iNotif.StartNotifierAndGetResponse(iStatus,TUid::Uid(KAlfAppFwProxyUid), iParams, iAwkwardApiDummy);
|
|
199 |
}
|
|
200 |
|
|
201 |
void DoCancel()
|
|
202 |
{
|
|
203 |
// just wait for notifier completion
|
|
204 |
User::WaitForRequest(iStatus);
|
|
205 |
}
|
|
206 |
|
|
207 |
private:
|
|
208 |
CAppFwProxy& iNotif;
|
|
209 |
|
|
210 |
TBuf8<1> iAwkwardApiDummy;
|
|
211 |
TPckgBuf<TAlfCommandParams> iParams;
|
|
212 |
};
|
|
213 |
|
|
214 |
CAppFwProxy():iLayoutMirrored(KErrNotFound)
|
|
215 |
{}
|
|
216 |
|
|
217 |
~CAppFwProxy()
|
|
218 |
{
|
|
219 |
if (iConnected)
|
|
220 |
{
|
|
221 |
iNotif.Close();
|
|
222 |
delete iLayoutUpdateAo;
|
|
223 |
}
|
|
224 |
}
|
|
225 |
|
|
226 |
TBool Connect()
|
|
227 |
{
|
|
228 |
if (!iConnected)
|
|
229 |
{
|
|
230 |
// perhaps should check also whether eikon server / notifier server exists..
|
|
231 |
// This is currently unsafe (synch) call to a process that may be blocked by window server, keep fingers crossed
|
|
232 |
iConnected = (iNotif.Connect() == KErrNone);
|
|
233 |
}
|
|
234 |
return iConnected;
|
|
235 |
}
|
|
236 |
|
|
237 |
TBool LayoutMirrored()
|
|
238 |
{
|
|
239 |
if ( Connect() && iLayoutMirrored == KErrNotFound)
|
|
240 |
{
|
|
241 |
TRequestStatus status;
|
|
242 |
TAlfCommandParams inParams={EAlfIsMirrorred,0,0,0};
|
|
243 |
TBuf8<1> outParams;
|
|
244 |
TInt ret = CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif );
|
|
245 |
|
|
246 |
// order updates
|
|
247 |
iLayoutUpdateAo = new CAlfLayoutListener(*this);
|
|
248 |
if (iLayoutUpdateAo)
|
|
249 |
{
|
|
250 |
TRAP_IGNORE(iLayoutUpdateAo->RunL());
|
|
251 |
}
|
|
252 |
|
|
253 |
iLayoutMirrored = ret > 0;
|
|
254 |
}
|
|
255 |
|
|
256 |
return iLayoutMirrored==KErrNotFound?EFalse:iLayoutMirrored;
|
|
257 |
}
|
|
258 |
|
|
259 |
TInt SoftKeyOrientation()
|
|
260 |
{
|
|
261 |
TInt ret = 0;
|
|
262 |
if ( Connect() )
|
|
263 |
{
|
|
264 |
TAlfCommandParams inParams={EAlfCbaLocation,0,0,0};
|
|
265 |
TBuf8<1> outParams;
|
|
266 |
ret = CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif );
|
|
267 |
}
|
|
268 |
|
|
269 |
return ret;
|
|
270 |
}
|
|
271 |
|
|
272 |
TRect LayoutMetricsRect(TInt aType)
|
|
273 |
{
|
|
274 |
TRect ret=TRect(0,0,0,0);
|
|
275 |
if ( Connect() )
|
|
276 |
{
|
|
277 |
TAlfCommandParams inParams={EAlfLayoutMetricsRect,aType,0,0};
|
|
278 |
TPckg<TRect> outParams(ret);
|
|
279 |
CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif );
|
|
280 |
}
|
|
281 |
|
|
282 |
return ret;
|
|
283 |
}
|
|
284 |
|
|
285 |
TInt GetCachedColor(TRgb& aRgb, const TAknsItemID& aID,
|
|
286 |
const TInt aIndex )
|
|
287 |
{
|
|
288 |
if ( Connect() )
|
|
289 |
{
|
|
290 |
TAlfCommandParams inParams={EAlfGetCachedColor,aID.iMajor,aID.iMinor,aIndex};
|
|
291 |
TPckg<TRgb> outParams(aRgb);
|
|
292 |
return CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif);
|
|
293 |
}
|
|
294 |
|
|
295 |
return KErrCouldNotConnect;
|
|
296 |
}
|
|
297 |
|
|
298 |
void GetSkinBitmapL(CFbsBitmap* aBitmap, CFbsBitmap* aMask, const TAknsItemID& aID, const TDesC& aFileName, TInt aBitmapId,
|
|
299 |
TInt aMaskId, const TSize& aSize, TScaleMode aScaleMode)
|
|
300 |
{
|
|
301 |
if ( Connect() )
|
|
302 |
{
|
|
303 |
TAlfCommandParams fakeParams={0,0,0,0};
|
|
304 |
TAlfCommandParams2 inParams={EAlfGetSkinBitmap,aID.iMajor,aID.iMinor,aBitmapId,aMaskId,aFileName, aSize, aScaleMode};
|
|
305 |
TPckgC<TAlfCommandParams2> inBuf(inParams);
|
|
306 |
TInt2 handles = {0,0};
|
|
307 |
TPckg<TInt2> outParams(handles);
|
|
308 |
CAlfGuardedSynchCall::DoGuardedOpL( fakeParams, outParams , iNotif, &inBuf );
|
|
309 |
if (!handles.iInt1)
|
|
310 |
{
|
|
311 |
User::Leave(KErrNotFound);
|
|
312 |
}
|
|
313 |
User::LeaveIfError(aBitmap->Duplicate(handles.iInt1));
|
|
314 |
if ( aMask && handles.iInt2 )
|
|
315 |
{
|
|
316 |
User::LeaveIfError(aMask->Duplicate(handles.iInt2));
|
|
317 |
}
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
void GetSkinBackgroundBitmapL(CFbsBitmap* aBitmap, const TAknsItemID& aID )
|
|
322 |
{
|
|
323 |
if ( Connect() )
|
|
324 |
{
|
|
325 |
TAlfCommandParams inParams={EAlfGetSkinBackgroundBitmap,aID.iMajor,aID.iMinor,0};
|
|
326 |
TInt handle = 0;
|
|
327 |
TPckg<TInt> outParams(handle);
|
|
328 |
CAlfGuardedSynchCall::DoGuardedOpL( inParams, outParams , iNotif );
|
|
329 |
User::LeaveIfError(aBitmap->Duplicate(handle));
|
|
330 |
}
|
|
331 |
}
|
|
332 |
|
|
333 |
void GetCachedSkinItemDataArrayL(const TAknsItemID& aID, TInt aType, TAlfCachedSkinItemArray& aArray)
|
|
334 |
{
|
|
335 |
if ( Connect() )
|
|
336 |
{
|
|
337 |
TAlfCommandParams inParams={EGetCachedSkinItemData,aID.iMajor,aID.iMinor,aType};
|
|
338 |
TPckg<TAlfCachedSkinItemArray> outParams(aArray);
|
|
339 |
CAlfGuardedSynchCall::DoGuardedOpL( inParams, outParams , iNotif );
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
public:
|
|
344 |
TBool iLayoutMirrored;
|
|
345 |
RNotifier iNotif;
|
|
346 |
TBool iConnected;
|
|
347 |
CAlfLayoutListener* iLayoutUpdateAo;
|
|
348 |
};
|
|
349 |
|
|
350 |
CHuiStatic* CHuiStatic::NewLC(CHuiEnv* aPrimaryEnv)
|
|
351 |
{
|
|
352 |
CHuiStatic* self = new (ELeave) CHuiStatic();
|
|
353 |
CleanupStack::PushL(self);
|
|
354 |
self->ConstructL(aPrimaryEnv);
|
|
355 |
return self;
|
|
356 |
}
|
|
357 |
|
|
358 |
|
|
359 |
CHuiStatic* CHuiStatic::NewL(CHuiEnv* aPrimaryEnv)
|
|
360 |
{
|
|
361 |
CHuiStatic* self = NewLC(aPrimaryEnv);
|
|
362 |
CleanupStack::Pop(self);
|
|
363 |
return self;
|
|
364 |
}
|
|
365 |
|
|
366 |
|
|
367 |
CHuiStatic::CHuiStatic()
|
|
368 |
{
|
|
369 |
}
|
|
370 |
|
|
371 |
|
|
372 |
void CHuiStatic::ConstructL(CHuiEnv* aPrimaryEnv)
|
|
373 |
{
|
|
374 |
iData = new (ELeave) TTlsData();
|
|
375 |
|
|
376 |
iData->iPrimaryEnv = aPrimaryEnv;
|
|
377 |
iData->iIdCounter = -1;
|
|
378 |
iData->iTimeFactor = 1.0;
|
|
379 |
iData->iIsFirstUpdateTime = ETrue;
|
|
380 |
iData->iFirstUpdateTime.UniversalTime();
|
|
381 |
iData->iUniversalTime.UniversalTime();
|
|
382 |
iData->iRealUniversalTime.UniversalTime();
|
|
383 |
iData->iLastFpsTime.UniversalTime();
|
|
384 |
iData->DoInitL(); // make sure that we have infra even CCoeEnv was not there
|
|
385 |
|
|
386 |
// Re-construct the virtual table for iFakeProbe
|
|
387 |
iData->iFakeProbe = new (ELeave) TFakeProbe;
|
|
388 |
|
|
389 |
iData->iAppFwProxy = new (ELeave) CAppFwProxy;
|
|
390 |
|
|
391 |
//Register for environment change ( here system time change ) event notification
|
|
392 |
iChangeNotifier = CEnvironmentChangeNotifier::NewL(0, TCallBack(CHuiStatic::SettingChangedCallBack, this));
|
|
393 |
iChangeNotifier->Start();
|
|
394 |
|
|
395 |
#ifdef HUI_DEBUG_TRACK_DRAWING
|
|
396 |
iData->iCommandDebugger = CAlfCommandDebug::NewL();
|
|
397 |
#endif
|
|
398 |
|
|
399 |
#ifndef __WINSCW__
|
|
400 |
globalWriteableData = *iData;
|
|
401 |
#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
|
|
402 |
// For testing purposes, test data needs to be included into TLS
|
|
403 |
// because test cases require information stored in TLS.
|
|
404 |
if ( !Dll::Tls() )
|
|
405 |
{
|
|
406 |
Dll::SetTls( iData );
|
|
407 |
}
|
|
408 |
#endif
|
|
409 |
#else
|
|
410 |
Dll::SetTls(iData);
|
|
411 |
#endif
|
|
412 |
|
|
413 |
#ifndef WIN32
|
|
414 |
#ifdef HUI_DEBUG_WITH_PRINTF
|
|
415 |
EnableLogging();
|
|
416 |
#endif
|
|
417 |
#endif
|
|
418 |
}
|
|
419 |
|
|
420 |
|
|
421 |
CHuiStatic::~CHuiStatic()
|
|
422 |
{
|
|
423 |
#ifdef HUI_DEBUG_TRACK_DRAWING
|
|
424 |
delete iData->iCommandDebugger;
|
|
425 |
iData->iCommandDebugger = NULL;
|
|
426 |
#endif
|
|
427 |
|
|
428 |
if(iData)
|
|
429 |
{
|
|
430 |
if(iData->iFakeProbe)
|
|
431 |
{
|
|
432 |
delete iData->iFakeProbe;
|
|
433 |
iData->iFakeProbe = NULL;
|
|
434 |
}
|
|
435 |
iData->iLogFile.Close();
|
|
436 |
delete iData->iAppFwProxy;
|
|
437 |
iData->Disconnect();
|
|
438 |
}
|
|
439 |
iChangeNotifier->Cancel();
|
|
440 |
delete iChangeNotifier;
|
|
441 |
#if defined( __WINSCW__ ) || defined( USE_MODULE_TEST_HOOKS_FOR_ALF )
|
|
442 |
Dll::FreeTls();
|
|
443 |
#endif
|
|
444 |
delete iData;
|
|
445 |
}
|
|
446 |
|
|
447 |
|
|
448 |
EXPORT_C TTlsData* CHuiStatic::Data()
|
|
449 |
{
|
|
450 |
#ifndef __WINSCW__
|
|
451 |
return &globalWriteableData;
|
|
452 |
#else
|
|
453 |
return static_cast<TTlsData*>(Dll::Tls());
|
|
454 |
#endif
|
|
455 |
}
|
|
456 |
|
|
457 |
|
|
458 |
void CHuiStatic::UpdateTime(TTlsData* aData)
|
|
459 |
{
|
|
460 |
ASSERT( aData );
|
|
461 |
// Updates the toolkit's time counters. This includes the toolkit's
|
|
462 |
// realtime clock, the internal absolute clock (which is affected by the
|
|
463 |
// time factor), the amount of elapsed time since last UpdateTime()
|
|
464 |
// invocation, and the amount of elapsed time since the first UpdateTime()
|
|
465 |
// invocation (which was done in the beginning of the first refresh).
|
|
466 |
|
|
467 |
if(aData->iIsFirstUpdateTime)
|
|
468 |
{
|
|
469 |
aData->iIsFirstUpdateTime = EFalse;
|
|
470 |
aData->iFirstUpdateTime.UniversalTime();
|
|
471 |
aData->iUniversalTime = aData->iFirstUpdateTime;
|
|
472 |
aData->iRealUniversalTime = aData->iUniversalTime;
|
|
473 |
return;
|
|
474 |
}
|
|
475 |
|
|
476 |
TTime now;
|
|
477 |
now.UniversalTime();
|
|
478 |
|
|
479 |
// Advance the toolkit's internal clock, applying the time factor.
|
|
480 |
if(!aData->iTimePaused)
|
|
481 |
{
|
|
482 |
aData->iInternalElapsed = now.MicroSecondsFrom(aData->iRealUniversalTime).Int64();
|
|
483 |
aData->iInternalElapsed = (TInt64)((TReal32)aData->iInternalElapsed * aData->iTimeFactor);
|
|
484 |
aData->iUniversalTime += TTimeIntervalMicroSeconds(aData->iInternalElapsed);
|
|
485 |
}
|
|
486 |
else
|
|
487 |
{
|
|
488 |
aData->iInternalElapsed = aData->iInternalElapsedBeforePausing;
|
|
489 |
aData->iInternalElapsedBeforePausing = 0;
|
|
490 |
}
|
|
491 |
|
|
492 |
aData->iRealUniversalTime = now;
|
|
493 |
}
|
|
494 |
|
|
495 |
|
|
496 |
TUint32 CHuiStatic::MilliSecondsSinceUpdateTime()
|
|
497 |
{
|
|
498 |
TTlsData* data = Data();
|
|
499 |
|
|
500 |
TTime now;
|
|
501 |
now.UniversalTime();
|
|
502 |
|
|
503 |
return now.MicroSecondsFrom(data->iRealUniversalTime).Int64() / 1000;
|
|
504 |
}
|
|
505 |
|
|
506 |
|
|
507 |
EXPORT_C CHuiEnv& CHuiStatic::Env()
|
|
508 |
{
|
|
509 |
if(!Data())
|
|
510 |
{
|
|
511 |
THuiPanic::Panic(THuiPanic::EStaticDataNotCreated);
|
|
512 |
}
|
|
513 |
return *Data()->iPrimaryEnv;
|
|
514 |
}
|
|
515 |
|
|
516 |
|
|
517 |
EXPORT_C CHuiRenderPlugin& CHuiStatic::Renderer()
|
|
518 |
{
|
|
519 |
if(!Data() || !Data()->iRenderer)
|
|
520 |
{
|
|
521 |
HUI_DEBUG(_L("CHuiStatic::Renderer() - Static data or renderer not specified."));
|
|
522 |
THuiPanic::Panic(THuiPanic::EStaticInvalidRenderer);
|
|
523 |
}
|
|
524 |
return *Data()->iRenderer;
|
|
525 |
}
|
|
526 |
|
|
527 |
|
|
528 |
void CHuiStatic::SetRenderer(CHuiRenderPlugin& aRenderer)
|
|
529 |
{
|
|
530 |
if(!Data())
|
|
531 |
{
|
|
532 |
THuiPanic::Panic(THuiPanic::EStaticDataNotCreated);
|
|
533 |
}
|
|
534 |
Data()->iRenderer = &aRenderer;
|
|
535 |
}
|
|
536 |
|
|
537 |
|
|
538 |
// @TODO SHOULD THIS BE MODIFIED SOMEHOW, OR IS THIS EXPORT OK???
|
|
539 |
EXPORT_C CHuiBitgdiRenderPlugin& CHuiStatic::BitgdiRenderer()
|
|
540 |
{
|
|
541 |
CHuiRenderPlugin* renderer = &Renderer();
|
|
542 |
if(renderer->Id() != EHuiRenderPluginBitgdi)
|
|
543 |
{
|
|
544 |
HUI_DEBUG(_L("CHuiStatic::BitgdiRenderer() - Renderer cannot be used as Bitgdi renderer."));
|
|
545 |
THuiPanic::Panic(THuiPanic::EStaticInvalidRenderer);
|
|
546 |
}
|
|
547 |
return *reinterpret_cast< CHuiBitgdiRenderPlugin* >(renderer);
|
|
548 |
}
|
|
549 |
|
|
550 |
|
|
551 |
EXPORT_C CHuiVg10RenderPlugin& CHuiStatic::Vg10Renderer()
|
|
552 |
{
|
|
553 |
CHuiRenderPlugin* renderer = &Renderer();
|
|
554 |
if(renderer->Id() != EHuiRenderPluginVg10)
|
|
555 |
{
|
|
556 |
HUI_DEBUG(_L("CHuiStatic::Vg10Renderer() - Renderer cannot be used as Vg10 renderer."));
|
|
557 |
THuiPanic::Panic(THuiPanic::EStaticInvalidRenderer);
|
|
558 |
}
|
|
559 |
return *reinterpret_cast< CHuiVg10RenderPlugin* >(renderer);
|
|
560 |
}
|
|
561 |
|
|
562 |
|
|
563 |
EXPORT_C CHuiGles10RenderPlugin& CHuiStatic::Gles10Renderer()
|
|
564 |
{
|
|
565 |
CHuiRenderPlugin* renderer = &Renderer();
|
|
566 |
if(renderer->Id() != EHuiRenderPluginGles10 &&
|
|
567 |
renderer->Id() != EHuiRenderPluginGles11) // compatible
|
|
568 |
{
|
|
569 |
HUI_DEBUG(_L("CHuiStatic::Gles10Renderer() - Renderer cannot be used as Gles10 renderer."));
|
|
570 |
THuiPanic::Panic(THuiPanic::EStaticInvalidRenderer);
|
|
571 |
}
|
|
572 |
return *reinterpret_cast< CHuiGles10RenderPlugin* >(renderer);
|
|
573 |
}
|
|
574 |
|
|
575 |
|
|
576 |
EXPORT_C CHuiGles11RenderPlugin& CHuiStatic::Gles11Renderer()
|
|
577 |
{
|
|
578 |
CHuiRenderPlugin* renderer = &Renderer();
|
|
579 |
if(renderer->Id() != EHuiRenderPluginGles11)
|
|
580 |
{
|
|
581 |
HUI_DEBUG(_L("CHuiStatic::Gles11Renderer() - Renderer cannot be used as Gles11 renderer."));
|
|
582 |
THuiPanic::Panic(THuiPanic::EStaticInvalidRenderer);
|
|
583 |
}
|
|
584 |
return *reinterpret_cast< CHuiGles11RenderPlugin* >(renderer);
|
|
585 |
}
|
|
586 |
|
|
587 |
|
|
588 |
EXPORT_C CHuiGles20RenderPlugin& CHuiStatic::Gles20Renderer()
|
|
589 |
{
|
|
590 |
CHuiRenderPlugin* renderer = &Renderer();
|
|
591 |
if(renderer->Id() != EHuiRenderPluginGles20)
|
|
592 |
{
|
|
593 |
HUI_DEBUG(_L("CHuiStatic::Gles20Renderer() - Renderer cannot be used as Gles20 renderer."));
|
|
594 |
THuiPanic::Panic(THuiPanic::EStaticInvalidRenderer);
|
|
595 |
}
|
|
596 |
return *reinterpret_cast< CHuiGles20RenderPlugin* >(renderer);
|
|
597 |
}
|
|
598 |
|
|
599 |
|
|
600 |
EXPORT_C MHuiRenderSurface* CHuiStatic::CurrentRenderSurface()
|
|
601 |
{
|
|
602 |
if(!Data())
|
|
603 |
{
|
|
604 |
HUI_DEBUG(_L("CHuiStatic::CurrentRenderSurface() - Static data or current render surface not specified. Panicking."));
|
|
605 |
THuiPanic::Panic(THuiPanic::EStaticCurrentRenderSurfaceNotSpecified);
|
|
606 |
}
|
|
607 |
return Data()->iCurrentRenderSurface;
|
|
608 |
}
|
|
609 |
|
|
610 |
|
|
611 |
EXPORT_C void CHuiStatic::SetCurrentRenderSurface(MHuiRenderSurface* aSurface)
|
|
612 |
{
|
|
613 |
Data()->iCurrentRenderSurface = aSurface;
|
|
614 |
}
|
|
615 |
|
|
616 |
|
|
617 |
EXPORT_C void CHuiStatic::EnableLogging(TBool aEnable)
|
|
618 |
{
|
|
619 |
TTlsData* data = Data();
|
|
620 |
|
|
621 |
if(aEnable && !data->iLogEnabled)
|
|
622 |
{
|
|
623 |
data->iLogEnabled = ETrue;
|
|
624 |
|
|
625 |
// debug code only
|
|
626 |
TFileName filename;
|
|
627 |
filename.Append('e');
|
|
628 |
filename.Append(':');
|
|
629 |
filename.Append('\\');
|
|
630 |
filename.Append(_L("HuiMessages.log"));
|
|
631 |
|
|
632 |
if(data->iLogFile.Replace(*data->iFs, filename, EFileWrite) != KErrNone)
|
|
633 |
{
|
|
634 |
RDebug::Print(_L("CHuiStatic::EnableLogging() - Could not open log file e:HuiMessages.log for writing. Trying c: .."));
|
|
635 |
_LIT(KFileName2, "c:\\HuiMessages.log");
|
|
636 |
if(data->iLogFile.Replace(*data->iFs, KFileName2, EFileWrite) != KErrNone)
|
|
637 |
{
|
|
638 |
RDebug::Print(_L("CHuiStatic::EnableLogging() - Could not open log file c:HuiMessages.log for writing. Logging disabled."));
|
|
639 |
data->iLogEnabled = EFalse;
|
|
640 |
}
|
|
641 |
else
|
|
642 |
{
|
|
643 |
RDebug::Print(_L("CHuiStatic::EnableLogging() - Enabled Logging to c \"HuiMessages.log\"."));
|
|
644 |
Printf(_L("CHuiStatic::EnableLogging() - Enabled Logging to \"HuiMessages.log\"."));
|
|
645 |
}
|
|
646 |
}
|
|
647 |
else
|
|
648 |
{
|
|
649 |
RDebug::Print(_L("CHuiStatic::EnableLogging() - Enabled Logging to mmc \"HuiMessages.log\"."));
|
|
650 |
Printf(_L("CHuiStatic::EnableLogging() - Enabled Logging to mmc \"HuiMessages.log\"."));
|
|
651 |
}
|
|
652 |
}
|
|
653 |
else if(!aEnable && data->iLogEnabled)
|
|
654 |
{
|
|
655 |
data->iLogFile.Close();
|
|
656 |
data->iLogEnabled = EFalse;
|
|
657 |
}
|
|
658 |
else
|
|
659 |
{
|
|
660 |
// for PC lint
|
|
661 |
}
|
|
662 |
}
|
|
663 |
|
|
664 |
|
|
665 |
EXPORT_C TBool CHuiStatic::Logging()
|
|
666 |
{
|
|
667 |
return Data()->iLogEnabled;
|
|
668 |
}
|
|
669 |
|
|
670 |
|
|
671 |
EXPORT_C void CHuiStatic::ContinueRefresh()
|
|
672 |
{
|
|
673 |
TTlsData* data = Data();
|
|
674 |
if(data && data->iPrimaryEnv)
|
|
675 |
{
|
|
676 |
data->iPrimaryEnv->ContinueRefresh();
|
|
677 |
}
|
|
678 |
}
|
|
679 |
|
|
680 |
|
|
681 |
void CHuiStatic::UpdateTime()
|
|
682 |
{
|
|
683 |
// Updates the toolkit's time counters. This includes the toolkit's
|
|
684 |
// realtime clock, the internal absolute clock (which is affected by the
|
|
685 |
// time factor), the amount of elapsed time since last UpdateTime()
|
|
686 |
// invocation, and the amount of elapsed time since the first UpdateTime()
|
|
687 |
// invocation (which was done in the beginning of the first refresh).
|
|
688 |
|
|
689 |
TTlsData* data = Data();
|
|
690 |
|
|
691 |
UpdateTime(data);
|
|
692 |
}
|
|
693 |
|
|
694 |
|
|
695 |
EXPORT_C const TTime& CHuiStatic::Time()
|
|
696 |
{
|
|
697 |
return Data()->iUniversalTime;
|
|
698 |
}
|
|
699 |
|
|
700 |
|
|
701 |
EXPORT_C void CHuiStatic::SetTimeFactor(TReal32 aTimeFactor) __SOFTFP
|
|
702 |
{
|
|
703 |
TTlsData* data = Data();
|
|
704 |
|
|
705 |
if(data)
|
|
706 |
{
|
|
707 |
if(aTimeFactor < 0)
|
|
708 |
{
|
|
709 |
aTimeFactor = 0;
|
|
710 |
}
|
|
711 |
|
|
712 |
if(data->iTimeFactor == 0 && aTimeFactor != 0)
|
|
713 |
{
|
|
714 |
// Continuing from a paused state
|
|
715 |
UpdateTime(data);
|
|
716 |
}
|
|
717 |
|
|
718 |
data->iTimeFactor = aTimeFactor;
|
|
719 |
}
|
|
720 |
}
|
|
721 |
|
|
722 |
|
|
723 |
EXPORT_C TReal32 CHuiStatic::TimeFactor() __SOFTFP
|
|
724 |
{
|
|
725 |
TTlsData* data = Data();
|
|
726 |
|
|
727 |
if(data)
|
|
728 |
{
|
|
729 |
return data->iTimeFactor;
|
|
730 |
}
|
|
731 |
return 1.0;
|
|
732 |
}
|
|
733 |
|
|
734 |
|
|
735 |
EXPORT_C void CHuiStatic::PauseTime()
|
|
736 |
{
|
|
737 |
TTlsData* data = Data();
|
|
738 |
|
|
739 |
if(data)
|
|
740 |
{
|
|
741 |
// Update internal elapsed
|
|
742 |
UpdateTime(data);
|
|
743 |
// Cache internal elapsed in internal time passed before pausing
|
|
744 |
data->iInternalElapsedBeforePausing = data->iInternalElapsed;
|
|
745 |
// Pause timing
|
|
746 |
data->iTimePaused = ETrue;
|
|
747 |
}
|
|
748 |
}
|
|
749 |
|
|
750 |
|
|
751 |
EXPORT_C void CHuiStatic::ContinueTime()
|
|
752 |
{
|
|
753 |
TTlsData* data = Data();
|
|
754 |
|
|
755 |
if(data && data->iTimePaused)
|
|
756 |
{
|
|
757 |
UpdateTime(data);
|
|
758 |
data->iTimePaused = EFalse;
|
|
759 |
}
|
|
760 |
}
|
|
761 |
|
|
762 |
|
|
763 |
EXPORT_C TBool CHuiStatic::TimePaused()
|
|
764 |
{
|
|
765 |
TTlsData* data = Data();
|
|
766 |
|
|
767 |
if(data)
|
|
768 |
{
|
|
769 |
return data->iTimePaused;
|
|
770 |
}
|
|
771 |
return EFalse;
|
|
772 |
}
|
|
773 |
|
|
774 |
|
|
775 |
EXPORT_C TReal32 CHuiStatic::ElapsedSeconds() __SOFTFP
|
|
776 |
{
|
|
777 |
TTlsData* data = Data();
|
|
778 |
|
|
779 |
if(data)
|
|
780 |
{
|
|
781 |
#ifdef EKA2
|
|
782 |
return data->iInternalElapsed / 1.0e6;
|
|
783 |
#else
|
|
784 |
return data->iInternalElapsed.GetTReal() / 1.0e6;
|
|
785 |
#endif
|
|
786 |
}
|
|
787 |
return 0;
|
|
788 |
}
|
|
789 |
|
|
790 |
|
|
791 |
EXPORT_C TReal32 CHuiStatic::SecondsSinceStart() __SOFTFP
|
|
792 |
{
|
|
793 |
TTlsData* data = Data();
|
|
794 |
if(!data)
|
|
795 |
{
|
|
796 |
// Time has not begun yet.
|
|
797 |
return 0;
|
|
798 |
}
|
|
799 |
|
|
800 |
// Calculate difference between internal absolute clock and the first update time.
|
|
801 |
TInt64 delta = data->iUniversalTime.MicroSecondsFrom(data->iFirstUpdateTime).Int64();
|
|
802 |
#ifdef EKA2
|
|
803 |
return delta / 1.0e6;
|
|
804 |
#else
|
|
805 |
return delta.GetTReal() / 1.0e6;
|
|
806 |
#endif
|
|
807 |
}
|
|
808 |
|
|
809 |
|
|
810 |
EXPORT_C TUint32 CHuiStatic::MilliSecondsSinceStart()
|
|
811 |
{
|
|
812 |
// This will wrap around in approx. 50 days.
|
|
813 |
TTlsData* data = Data();
|
|
814 |
if(data)
|
|
815 |
{
|
|
816 |
// Calculate difference between internal absolute clock and the first update time.
|
|
817 |
TInt64 delta = data->iUniversalTime.MicroSecondsFrom(data->iFirstUpdateTime).Int64();
|
|
818 |
return delta / 1000;
|
|
819 |
}
|
|
820 |
return 0;
|
|
821 |
|
|
822 |
}
|
|
823 |
|
|
824 |
|
|
825 |
TInt CHuiStatic::GenerateId()
|
|
826 |
{
|
|
827 |
TTlsData* data = Data();
|
|
828 |
|
|
829 |
// The ID counter counts backwards.
|
|
830 |
TInt id = data->iIdCounter;
|
|
831 |
|
|
832 |
if(data->iIdCounter == KMinTInt)
|
|
833 |
{
|
|
834 |
// Wrap around to stay negative.
|
|
835 |
data->iIdCounter = -1;
|
|
836 |
}
|
|
837 |
else
|
|
838 |
{
|
|
839 |
--data->iIdCounter;
|
|
840 |
}
|
|
841 |
|
|
842 |
return id;
|
|
843 |
}
|
|
844 |
|
|
845 |
|
|
846 |
void CHuiStatic::ReportNewFrame()
|
|
847 |
{
|
|
848 |
TTlsData* data = Data();
|
|
849 |
data->iFrameCounter++;
|
|
850 |
data->iCurrentFrameCounter++;
|
|
851 |
}
|
|
852 |
|
|
853 |
|
|
854 |
EXPORT_C TUint CHuiStatic::FrameCount()
|
|
855 |
{
|
|
856 |
TTlsData* data = Data();
|
|
857 |
return data->iFrameCounter;
|
|
858 |
}
|
|
859 |
|
|
860 |
|
|
861 |
EXPORT_C TReal32 CHuiStatic::AverageFrameRate() __SOFTFP
|
|
862 |
{
|
|
863 |
return 0;
|
|
864 |
}
|
|
865 |
|
|
866 |
|
|
867 |
EXPORT_C TReal32 CHuiStatic::FrameRate() __SOFTFP
|
|
868 |
{
|
|
869 |
|
|
870 |
TTlsData* data = Data();
|
|
871 |
|
|
872 |
TTime now;
|
|
873 |
now.UniversalTime();
|
|
874 |
|
|
875 |
// If very little time has passed, don't calculate a new value yet.
|
|
876 |
TTimeIntervalMicroSeconds msFromLast = 0;
|
|
877 |
msFromLast = now.MicroSecondsFrom(data->iLastFpsTime);
|
|
878 |
if(msFromLast < TTimeIntervalMicroSeconds(TInt64(1e6)))
|
|
879 |
{
|
|
880 |
// Do not recalculate yet.
|
|
881 |
#ifdef SYMBIAN_BUILD_GCE
|
|
882 |
return 0; // to ignore the value if time is not elapsed
|
|
883 |
#else
|
|
884 |
return data->iLastFps;
|
|
885 |
#endif
|
|
886 |
}
|
|
887 |
|
|
888 |
if(data->iCurrentFrameCounter == 0)
|
|
889 |
{
|
|
890 |
data->iLastFpsTime = now;
|
|
891 |
return 0;
|
|
892 |
}
|
|
893 |
|
|
894 |
TInt64 delta = now.MicroSecondsFrom(data->iLastFpsTime).Int64();
|
|
895 |
|
|
896 |
TReal32 fps = 0;
|
|
897 |
#ifdef EKA2
|
|
898 |
TReal32 elapsed = delta / 1.0e6;
|
|
899 |
#else
|
|
900 |
TReal32 elapsed = delta.GetTReal() / 1.0e6;
|
|
901 |
#endif
|
|
902 |
|
|
903 |
if(elapsed > 0)
|
|
904 |
{
|
|
905 |
fps = (TReal32)data->iCurrentFrameCounter / elapsed;
|
|
906 |
}
|
|
907 |
|
|
908 |
data->iLastFps = fps;
|
|
909 |
data->iCurrentFrameCounter = 0;
|
|
910 |
data->iLastFpsTime = now;
|
|
911 |
|
|
912 |
return fps;
|
|
913 |
}
|
|
914 |
|
|
915 |
|
|
916 |
EXPORT_C void CHuiStatic::Printf(TRefByValue<const TDesC8> aFormat, ...)
|
|
917 |
{
|
|
918 |
TTlsData* data = Data();
|
|
919 |
// Bail out early if logging is disabled.
|
|
920 |
if(!data || !data->iLogEnabled)
|
|
921 |
{
|
|
922 |
#ifdef _DEBUG
|
|
923 |
// redirect to RDebug output if we are debugging
|
|
924 |
TUint total = 0;
|
|
925 |
TUint free = HuiUtil::FreeMemory(&total);
|
|
926 |
TBuf8<256> buf;
|
|
927 |
VA_LIST list;
|
|
928 |
VA_START(list, aFormat);
|
|
929 |
buf.FormatList(aFormat, list);
|
|
930 |
VA_END(list);
|
|
931 |
RDebug::Print(_L("(%i/%i KB) %s"), free/1024, total/1024, &buf);
|
|
932 |
#endif
|
|
933 |
// Already gone?
|
|
934 |
return;
|
|
935 |
}
|
|
936 |
TTime now;
|
|
937 |
now.UniversalTime();
|
|
938 |
TInt32 elapsed = (TInt32)(now.MicroSecondsFrom(data->iFirstUpdateTime).Int64() / 1000);
|
|
939 |
|
|
940 |
TBuf8<100> memData;
|
|
941 |
TUint total = 0;
|
|
942 |
TUint free = HuiUtil::FreeMemory(&total);
|
|
943 |
memData.Format(_L8("% 2d,%03d (%i/%i KB) "), elapsed / 1000,
|
|
944 |
elapsed % 1000,
|
|
945 |
free/1024, total/1024);
|
|
946 |
|
|
947 |
TBuf8<512> buf;
|
|
948 |
VA_LIST list;
|
|
949 |
VA_START(list, aFormat);
|
|
950 |
buf.FormatList(aFormat, list);
|
|
951 |
VA_END(list);
|
|
952 |
buf.Insert(0, memData);
|
|
953 |
buf.Append(_L8("\n"));
|
|
954 |
|
|
955 |
data->iLogFile.Write(buf);
|
|
956 |
data->iLogFile.Flush();
|
|
957 |
}
|
|
958 |
|
|
959 |
|
|
960 |
EXPORT_C void CHuiStatic::Printf(TRefByValue<const TDesC16> aFormat, ...)
|
|
961 |
{
|
|
962 |
TTlsData* data = Data();
|
|
963 |
// Bail out early if logging is disabled.
|
|
964 |
if(!data || !data->iLogEnabled)
|
|
965 |
{
|
|
966 |
#ifdef _DEBUG
|
|
967 |
// redirect to RDebug output if we are debugging
|
|
968 |
TBuf16<512> buf;
|
|
969 |
TUint total; TUint free = HuiUtil::FreeMemory(&total);
|
|
970 |
VA_LIST list;
|
|
971 |
VA_START(list, aFormat);
|
|
972 |
buf.FormatList(aFormat, list);
|
|
973 |
VA_END(list);
|
|
974 |
RDebug::Print(_L("(%i/%i KB) %S"), free/1024, total/1024, &buf);
|
|
975 |
#endif
|
|
976 |
// Already gone?
|
|
977 |
return;
|
|
978 |
}
|
|
979 |
TTime now;
|
|
980 |
now.UniversalTime();
|
|
981 |
TInt32 elapsed = (TInt32)(now.MicroSecondsFrom(data->iFirstUpdateTime).Int64() / 1000);
|
|
982 |
|
|
983 |
TBuf16<100> memData;
|
|
984 |
TUint total = 0;
|
|
985 |
TUint free = HuiUtil::FreeMemory(&total);
|
|
986 |
memData.Format(_L16("% 2d,%03d (%i/%i KB) "), elapsed / 1000,
|
|
987 |
elapsed % 1000,
|
|
988 |
free/1024, total/1024);
|
|
989 |
|
|
990 |
TBuf16<512> buf;
|
|
991 |
VA_LIST list;
|
|
992 |
VA_START(list, aFormat);
|
|
993 |
buf.FormatList(aFormat, list);
|
|
994 |
VA_END(list);
|
|
995 |
buf.Insert(0, memData);
|
|
996 |
buf.Append(_L16("\n"));
|
|
997 |
|
|
998 |
TBuf8<512> buf8;
|
|
999 |
buf8.SetLength(buf.Length());
|
|
1000 |
for(TInt i = 0; i < buf.Length(); ++i)
|
|
1001 |
{
|
|
1002 |
buf8[i] = TUint8(buf[i]);
|
|
1003 |
}
|
|
1004 |
|
|
1005 |
data->iLogFile.Write(buf8);
|
|
1006 |
data->iLogFile.Flush();
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
|
|
1010 |
EXPORT_C void CHuiStatic::Tic(TInt aClock)
|
|
1011 |
{
|
|
1012 |
if(aClock < 0 || aClock >= KMaxClocks)
|
|
1013 |
{
|
|
1014 |
THuiPanic::Panic(THuiPanic::EStaticInvalidClock);
|
|
1015 |
}
|
|
1016 |
|
|
1017 |
TTlsData* data = Data();
|
|
1018 |
data->iClocks[aClock].UniversalTime();
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
|
|
1022 |
EXPORT_C TReal32 CHuiStatic::Toc(TInt aClock) __SOFTFP
|
|
1023 |
{
|
|
1024 |
if(aClock < 0 || aClock >= KMaxClocks)
|
|
1025 |
{
|
|
1026 |
THuiPanic::Panic(THuiPanic::EStaticInvalidClock);
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
TTlsData* data = Data();
|
|
1030 |
|
|
1031 |
TTime now;
|
|
1032 |
now.UniversalTime();
|
|
1033 |
|
|
1034 |
TInt64 delta = now.MicroSecondsFrom(data->iClocks[aClock]).Int64();
|
|
1035 |
#ifdef EKA2
|
|
1036 |
return delta / 1.0e6;
|
|
1037 |
#else
|
|
1038 |
return delta.GetTReal() / 1.0e6;
|
|
1039 |
#endif
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
|
|
1043 |
EXPORT_C RFs& CHuiStatic::FsSession()
|
|
1044 |
{
|
|
1045 |
TTlsData* data = Data();
|
|
1046 |
__ASSERT_ALWAYS(data, User::Panic(_L("HUI"),0));
|
|
1047 |
return *data->iFs;
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
EXPORT_C RWsSession& CHuiStatic::WsSession()
|
|
1051 |
{
|
|
1052 |
TTlsData* data = Data();
|
|
1053 |
__ASSERT_ALWAYS(data, User::Panic(_L("HUI"),0));
|
|
1054 |
return *data->iWsSession;
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
EXPORT_C CWsScreenDevice* CHuiStatic::ScreenDevice( TInt aScreenNumber )
|
|
1058 |
{
|
|
1059 |
TTlsData* data = Data();
|
|
1060 |
__ASSERT_ALWAYS(data, User::Panic(_L("HUI"),0));
|
|
1061 |
return data->WsScreenDevice(aScreenNumber);
|
|
1062 |
}
|
|
1063 |
|
|
1064 |
EXPORT_C RWindowGroup* CHuiStatic::RootWin( TInt aScreenNumber )
|
|
1065 |
{
|
|
1066 |
TTlsData* data = Data();
|
|
1067 |
__ASSERT_ALWAYS(data, User::Panic(_L("HUI"),0));
|
|
1068 |
return data->RootWin(aScreenNumber);
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
EXPORT_C void CHuiStatic::SetLayoutTransitionTime( TInt aTime )
|
|
1072 |
{
|
|
1073 |
TTlsData* data = Data();
|
|
1074 |
if(data)
|
|
1075 |
{
|
|
1076 |
data->iLayoutTransitionTime = aTime;
|
|
1077 |
}
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
|
|
1081 |
EXPORT_C TInt CHuiStatic::LayoutTransitionTime()
|
|
1082 |
{
|
|
1083 |
TTlsData* data = Data();
|
|
1084 |
if(data)
|
|
1085 |
{
|
|
1086 |
return data->iLayoutTransitionTime;
|
|
1087 |
}
|
|
1088 |
return 0;
|
|
1089 |
}
|
|
1090 |
|
|
1091 |
EXPORT_C void CHuiStatic::SetProbe(MHuiProbe* aProbe)
|
|
1092 |
{
|
|
1093 |
TTlsData* data = Data();
|
|
1094 |
if(data)
|
|
1095 |
{
|
|
1096 |
data->iProbe = aProbe;
|
|
1097 |
}
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
MHuiProbe& CHuiStatic::Probe()
|
|
1101 |
{
|
|
1102 |
TTlsData* data = Data();
|
|
1103 |
|
|
1104 |
if ( !data )
|
|
1105 |
{
|
|
1106 |
THuiPanic::Panic(THuiPanic::EStaticDataNotCreated);
|
|
1107 |
}
|
|
1108 |
|
|
1109 |
if(data->iProbe)
|
|
1110 |
{
|
|
1111 |
return *(data->iProbe);
|
|
1112 |
}
|
|
1113 |
return *(data->iFakeProbe);
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
EXPORT_C MAknsSkinInstance* CHuiStatic::SkinInstance()
|
|
1117 |
{
|
|
1118 |
if (CCoeEnv::Static())
|
|
1119 |
{
|
|
1120 |
return AknsUtils::SkinInstance();
|
|
1121 |
}
|
|
1122 |
return 0;
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
TBool CHuiStatic::LayoutMirrored()
|
|
1126 |
{
|
|
1127 |
if (CCoeEnv::Static())
|
|
1128 |
{
|
|
1129 |
return AknLayoutUtils::LayoutMirrored();
|
|
1130 |
}
|
|
1131 |
else
|
|
1132 |
{
|
|
1133 |
TTlsData* data = Data();
|
|
1134 |
return data->iAppFwProxy->LayoutMirrored();
|
|
1135 |
}
|
|
1136 |
}
|
|
1137 |
|
|
1138 |
TInt CHuiStatic::CbaLocation()
|
|
1139 |
{
|
|
1140 |
if (CCoeEnv::Static())
|
|
1141 |
{
|
|
1142 |
return AknLayoutUtils::CbaLocation();
|
|
1143 |
}
|
|
1144 |
else
|
|
1145 |
{
|
|
1146 |
TTlsData* data = Data();
|
|
1147 |
return data->iAppFwProxy->SoftKeyOrientation();
|
|
1148 |
}
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
void CHuiStatic::LayoutMetricsRect(TInt aType, TRect& aRect)
|
|
1152 |
{
|
|
1153 |
if (CCoeEnv::Static())
|
|
1154 |
{
|
|
1155 |
(void)AknLayoutUtils::LayoutMetricsRect((AknLayoutUtils::TAknLayoutMetrics)aType, aRect);
|
|
1156 |
}
|
|
1157 |
else
|
|
1158 |
{
|
|
1159 |
TTlsData* data = Data();
|
|
1160 |
aRect = data->iAppFwProxy->LayoutMetricsRect(aType);
|
|
1161 |
}
|
|
1162 |
}
|
|
1163 |
|
|
1164 |
TInt CHuiStatic::GetCachedColor(TRgb& aRgb, const TAknsItemID& aID,
|
|
1165 |
const TInt aIndex )
|
|
1166 |
{
|
|
1167 |
MAknsSkinInstance* skin = SkinInstance();
|
|
1168 |
if (skin)
|
|
1169 |
{
|
|
1170 |
return AknsUtils::GetCachedColor(skin, aRgb, aID, aIndex );
|
|
1171 |
}
|
|
1172 |
else
|
|
1173 |
{
|
|
1174 |
TTlsData* data = Data();
|
|
1175 |
return data->iAppFwProxy->GetCachedColor(aRgb, aID, aIndex );
|
|
1176 |
}
|
|
1177 |
}
|
|
1178 |
|
|
1179 |
TBool CHuiStatic::ConvertToVisualAndClipL(
|
|
1180 |
TDes& aLogicalText,
|
|
1181 |
const CFont& aFont,
|
|
1182 |
TInt aMaxWidthInPixels,
|
|
1183 |
TInt aMaxClippedWidthInPixels )
|
|
1184 |
{
|
|
1185 |
if (CCoeEnv::Static())
|
|
1186 |
{
|
|
1187 |
return AknBidiTextUtils::ConvertToVisualAndClipL(
|
|
1188 |
aLogicalText,
|
|
1189 |
aFont,
|
|
1190 |
aMaxWidthInPixels,
|
|
1191 |
aMaxClippedWidthInPixels );
|
|
1192 |
}
|
|
1193 |
else
|
|
1194 |
{
|
|
1195 |
if ( !aLogicalText.Length() )
|
|
1196 |
{
|
|
1197 |
aLogicalText = KNullDesC; // null text
|
|
1198 |
return EFalse;
|
|
1199 |
}
|
|
1200 |
|
|
1201 |
HBufC* visualBuffer = HBufC::NewLC(
|
|
1202 |
aLogicalText.Length() + KAknBidiExtraSpacePerLine );
|
|
1203 |
|
|
1204 |
TPtr ptr = visualBuffer->Des();
|
|
1205 |
|
|
1206 |
TInt chars = aLogicalText.Length();
|
|
1207 |
|
|
1208 |
TBool clipped = EFalse;
|
|
1209 |
|
|
1210 |
TChar clipChar = 0xffff;
|
|
1211 |
|
|
1212 |
// TextCount() converts text to visual form and then checks it
|
|
1213 |
if ( aFont.TextCount( aLogicalText, aMaxWidthInPixels ) < chars )
|
|
1214 |
{
|
|
1215 |
clipped = ETrue;
|
|
1216 |
|
|
1217 |
TInt clipCharWidth = 0;
|
|
1218 |
// Not enough space even for clip char alone - return empty descriptor.
|
|
1219 |
if ( aMaxClippedWidthInPixels < clipCharWidth )
|
|
1220 |
{
|
|
1221 |
aLogicalText = KNullDesC; // null text
|
|
1222 |
CleanupStack::PopAndDestroy(); // visual buf
|
|
1223 |
return ETrue;
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
// Check how many characters fit in given space with truncation char.
|
|
1227 |
// We need to give this information to TBidiLogicalToVisual.
|
|
1228 |
chars = aFont.TextCount(
|
|
1229 |
aLogicalText, aMaxClippedWidthInPixels - clipCharWidth );
|
|
1230 |
|
|
1231 |
// This is "avkon rule": should not insert ellipsis right after a space.
|
|
1232 |
if ( chars > 1 &&
|
|
1233 |
aLogicalText[chars - 1] == ' ' &&
|
|
1234 |
aLogicalText[chars - 2] != ' ' )
|
|
1235 |
{
|
|
1236 |
chars--;
|
|
1237 |
}
|
|
1238 |
}
|
|
1239 |
|
|
1240 |
TBidirectionalState::TRunInfo* array =
|
|
1241 |
new TBidirectionalState::TRunInfo[chars];
|
|
1242 |
|
|
1243 |
TBidiLogicalToVisual converter(
|
|
1244 |
aLogicalText,
|
|
1245 |
array,
|
|
1246 |
chars ) ;
|
|
1247 |
|
|
1248 |
TInt count = converter.Reorder();
|
|
1249 |
|
|
1250 |
if (count > chars)
|
|
1251 |
{
|
|
1252 |
delete array;
|
|
1253 |
array = 0;
|
|
1254 |
array = new TBidirectionalState::TRunInfo[chars];
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
if (array)
|
|
1258 |
{
|
|
1259 |
TBidiLogicalToVisual converter = TBidiLogicalToVisual( aLogicalText, array, chars );
|
|
1260 |
converter.Reorder();
|
|
1261 |
TPtr ptr = visualBuffer->Des();
|
|
1262 |
converter.GetVisualLine( ptr, 0, chars, clipChar );
|
|
1263 |
}
|
|
1264 |
|
|
1265 |
aLogicalText = *visualBuffer;
|
|
1266 |
|
|
1267 |
CleanupStack::PopAndDestroy();
|
|
1268 |
return clipped;
|
|
1269 |
}
|
|
1270 |
}
|
|
1271 |
|
|
1272 |
HBufC* CHuiStatic::ConvertToVisualAndWrapToArrayL(
|
|
1273 |
const TDesC& aLogicalText,
|
|
1274 |
TInt aLineWidth,
|
|
1275 |
const CFont& aFont,
|
|
1276 |
CArrayFix<TPtrC>& aWrappedArray )
|
|
1277 |
{
|
|
1278 |
if (CCoeEnv::Static())
|
|
1279 |
{
|
|
1280 |
return AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
|
|
1281 |
aLogicalText,
|
|
1282 |
aLineWidth,
|
|
1283 |
aFont,
|
|
1284 |
aWrappedArray);
|
|
1285 |
}
|
|
1286 |
else
|
|
1287 |
{
|
|
1288 |
// will not be supported ever
|
|
1289 |
HBufC* ret = aLogicalText.AllocLC();
|
|
1290 |
aWrappedArray.AppendL(ret->Des());
|
|
1291 |
CleanupStack::Pop();
|
|
1292 |
return ret;
|
|
1293 |
}
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
CFbsBitmap* CHuiStatic::GetBgBitmapLC(const TAknsItemID& aID)
|
|
1297 |
{
|
|
1298 |
CFbsBitmap * bitmap = new (ELeave) CFbsBitmap();
|
|
1299 |
CleanupStack::PushL(bitmap);
|
|
1300 |
|
|
1301 |
TTlsData* data = Data();
|
|
1302 |
data->iAppFwProxy->GetSkinBackgroundBitmapL(bitmap, aID);
|
|
1303 |
|
|
1304 |
return bitmap;
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
void CHuiStatic::GetMaskedBitmapL(const TAknsItemID& aID, CFbsBitmap*& aBitmap, CFbsBitmap*& aBitmapMask,
|
|
1308 |
const TDesC& aFileName, TInt aBitmapId, TInt aMaskId, const TSize& aSize, TScaleMode aScaleMode)
|
|
1309 |
{
|
|
1310 |
CFbsBitmap * bitmap = new (ELeave) CFbsBitmap();
|
|
1311 |
CleanupStack::PushL(bitmap);
|
|
1312 |
|
|
1313 |
CFbsBitmap * mask = new (ELeave) CFbsBitmap();
|
|
1314 |
CleanupStack::PushL(mask);
|
|
1315 |
|
|
1316 |
TTlsData* data = Data();
|
|
1317 |
data->iAppFwProxy->GetSkinBitmapL(bitmap, mask, aID, aFileName, aBitmapId, aMaskId, aSize, aScaleMode );
|
|
1318 |
|
|
1319 |
// Transfer the ownership
|
|
1320 |
if (mask->Handle())
|
|
1321 |
{
|
|
1322 |
aBitmapMask = mask;
|
|
1323 |
CleanupStack::Pop(); //mask
|
|
1324 |
}
|
|
1325 |
else
|
|
1326 |
{
|
|
1327 |
CleanupStack::PopAndDestroy(); //mask
|
|
1328 |
}
|
|
1329 |
aBitmap = bitmap;
|
|
1330 |
CleanupStack::Pop(); //bitmap
|
|
1331 |
}
|
|
1332 |
|
|
1333 |
CAknsItemData* CHuiStatic::GetCachedSkinItemDataL(const TAknsItemID& aID, TInt aDataType)
|
|
1334 |
{
|
|
1335 |
CAknsImageTableItemData* skindata = 0;
|
|
1336 |
if (aDataType == EAknsITImageTable) // only image table for framebrush supported
|
|
1337 |
{
|
|
1338 |
TTlsData* data = Data();
|
|
1339 |
TAlfCachedSkinItemArray array;
|
|
1340 |
data->iAppFwProxy->GetCachedSkinItemDataArrayL(aID, aDataType, array);
|
|
1341 |
if (array.iCount)
|
|
1342 |
{
|
|
1343 |
skindata = CAknsImageTableItemData::NewL();
|
|
1344 |
CleanupStack::PushL(skindata);
|
|
1345 |
skindata->SetImagesL(array.iCount, array.iImages);
|
|
1346 |
CleanupStack::Pop();
|
|
1347 |
}
|
|
1348 |
}
|
|
1349 |
return skindata;
|
|
1350 |
}
|
|
1351 |
|
|
1352 |
TInt CHuiStatic::SettingChangedCallBack(TAny* aInstance)
|
|
1353 |
{
|
|
1354 |
return ((CHuiStatic *)aInstance)->DoChange();
|
|
1355 |
}
|
|
1356 |
|
|
1357 |
TInt CHuiStatic::DoChange()
|
|
1358 |
{
|
|
1359 |
TInt change = iChangeNotifier->Change();
|
|
1360 |
TTlsData* data = Data();
|
|
1361 |
if(!data)
|
|
1362 |
{
|
|
1363 |
// Time has not begun yet.
|
|
1364 |
return 0;
|
|
1365 |
}
|
|
1366 |
if (change & EChangesLocale)
|
|
1367 |
{
|
|
1368 |
data->iIsFirstUpdateTime = ETrue;
|
|
1369 |
UpdateTime();
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
if (change & EChangesSystemTime)
|
|
1373 |
{
|
|
1374 |
data->iIsFirstUpdateTime = ETrue;
|
|
1375 |
UpdateTime();
|
|
1376 |
}
|
|
1377 |
|
|
1378 |
return 1;
|
|
1379 |
}
|