64
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <stdio.h>
|
|
18 |
#include <stdlib.h>
|
|
19 |
#include <AknsSrvChunkLookup.h>
|
|
20 |
#include <AknsConstants.h>
|
|
21 |
#include <AknsItemDef.h>
|
|
22 |
|
|
23 |
#include "bganimhost.h"
|
|
24 |
#include <platform/ssm/startupdomainpskeys.h>
|
|
25 |
|
|
26 |
typedef void* (*plugingetinterfacefunc)(int);
|
|
27 |
|
|
28 |
const TInt KRefreshTarget = 99;
|
|
29 |
_LIT(KExeCaption,"BG anim host");
|
|
30 |
|
|
31 |
static const TUint KMaxGPUMemUsage = 1024*1024*4;
|
|
32 |
|
|
33 |
|
|
34 |
CBgAnimHost::CBgAnimHost():iIsUIReady(EFalse)
|
|
35 |
{
|
|
36 |
}
|
|
37 |
|
|
38 |
CBgAnimHost::~CBgAnimHost()
|
|
39 |
{
|
|
40 |
iSkinSrv.Close();
|
|
41 |
delete iCurrentPluginDllName;
|
|
42 |
delete iCurrentPluginAssetDir;
|
|
43 |
delete iTimer;
|
|
44 |
delete iTheReaper;
|
|
45 |
delete iDoomBringer;
|
|
46 |
|
|
47 |
ReleasePlugin();
|
|
48 |
|
|
49 |
#if !defined(SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS)
|
|
50 |
delete iSCPropertyListener;
|
|
51 |
#endif
|
|
52 |
delete iHSFgStatusPropertyListener;
|
|
53 |
delete iThemeRepositoryListener;
|
|
54 |
|
|
55 |
iSensorListeners.Close();
|
|
56 |
delete CActiveScheduler::Current();
|
|
57 |
CActiveScheduler::Install(NULL);
|
|
58 |
ReleaseWindowSurface();
|
|
59 |
ReleaseEGL();
|
|
60 |
DestroyWindow();
|
|
61 |
}
|
|
62 |
|
|
63 |
void CBgAnimHost::ConstructL()
|
|
64 |
{
|
|
65 |
User::LeaveIfError(iWsSession.Connect());
|
|
66 |
TUid wgUid;
|
|
67 |
wgUid.iUid = 0x200286D3;
|
|
68 |
TInt id = 0;
|
|
69 |
CApaWindowGroupName::FindByAppUid(wgUid, iWsSession, id);
|
|
70 |
if (id != KErrNotFound)
|
|
71 |
{
|
|
72 |
User::Leave(KErrAlreadyExists);
|
|
73 |
}
|
|
74 |
|
|
75 |
iWsSession.ComputeMode(RWsSession::EPriorityControlDisabled);
|
|
76 |
iWsSession.EnableWindowSizeCacheL();
|
|
77 |
|
|
78 |
CActiveScheduler *ac = new (ELeave) CActiveScheduler;
|
|
79 |
CActiveScheduler::Install(ac);
|
|
80 |
iTimer = CHighResTimer::NewL(TCallBack(TimerFunc, this),CActive::EPriorityStandard);
|
|
81 |
iTheReaper = CHighResTimer::NewL(TCallBack(ReaperFunc, this),CActive::EPriorityStandard);
|
|
82 |
iThemeRepositoryListener = CThemeRepositoryListener::NewL(&iRunning);
|
|
83 |
#if !defined(SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS)
|
|
84 |
iSCPropertyListener = CScreenSaverPropertyListener::NewL(TCallBack(ScreenSaverCallback, this));
|
|
85 |
#endif
|
|
86 |
iHSFgStatusPropertyListener = CFGAppPropertyListener::NewL(TCallBack(FgAppCallback, this));
|
|
87 |
CreateWindowL();
|
|
88 |
|
|
89 |
User::LeaveIfError(iSkinSrv.Connect());
|
|
90 |
// load the initial plugin
|
|
91 |
GetPluginConfigurationL();
|
|
92 |
LoadPluginL();
|
|
93 |
InitEGLL();
|
|
94 |
CreateWindowSurfaceL();
|
|
95 |
|
|
96 |
User::LeaveIfError(iPlugin->gpuresourcesavailable(1));
|
|
97 |
iThemeRepositoryListener->IssueRequest();
|
|
98 |
#if !defined(SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS)
|
|
99 |
iSCPropertyListener->IssueRequest();
|
|
100 |
#endif
|
|
101 |
iHSFgStatusPropertyListener->IssueRequest();
|
|
102 |
}
|
|
103 |
|
|
104 |
void CBgAnimHost::CreateWindowL()
|
|
105 |
{
|
|
106 |
iScreenDevice = new (ELeave) CWsScreenDevice(iWsSession);
|
|
107 |
User::LeaveIfError(iScreenDevice->Construct(0));
|
|
108 |
|
|
109 |
TPixelsAndRotation rot;
|
|
110 |
TInt screenmode = iScreenDevice->CurrentScreenMode();
|
|
111 |
iScreenDevice->GetScreenModeSizeAndRotation(screenmode, rot);
|
|
112 |
if (rot.iRotation == CFbsBitGc::EGraphicsOrientationNormal)
|
|
113 |
{
|
|
114 |
iDisplaySize = rot.iPixelSize;
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
iDisplaySize.iWidth = rot.iPixelSize.iHeight;
|
|
119 |
iDisplaySize.iHeight = rot.iPixelSize.iWidth;
|
|
120 |
}
|
|
121 |
|
|
122 |
iRealDisplaySize = iDisplaySize;
|
|
123 |
iDisplaySize.iWidth/=2;
|
|
124 |
iDisplaySize.iHeight/=2;
|
|
125 |
|
|
126 |
iWindowGroup=RWindowGroup(iWsSession);
|
|
127 |
User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup));
|
|
128 |
iWindowGroup.SetOrdinalPosition(-1,-1000);
|
|
129 |
|
|
130 |
iWindow=RWindow(iWsSession);
|
|
131 |
User::LeaveIfError(iWindow.Construct(iWindowGroup, (TUint32)&iWindow));
|
|
132 |
User::LeaveIfError(iWindow.SetExtentErr(TPoint(0,0),iDisplaySize));
|
|
133 |
iWindow.SetVisible(EFalse);
|
|
134 |
iWindowVisible = EFalse;
|
|
135 |
iWindow.Activate();
|
|
136 |
|
|
137 |
iWindGroupName = CApaWindowGroupName::NewL(iWsSession, iWindowGroup.Identifier());
|
|
138 |
|
|
139 |
TUid wgUid;
|
|
140 |
wgUid.iUid = 0x200286D3;
|
|
141 |
|
|
142 |
iWindGroupName->SetAppUid(wgUid);
|
|
143 |
iWindGroupName->SetCaptionL(KExeCaption);
|
|
144 |
iWindGroupName->SetHidden(ETrue);
|
|
145 |
iWindGroupName->SetAppReady(ETrue);
|
|
146 |
iWindGroupName->SetSystem(ETrue);
|
|
147 |
iWindGroupName->SetWindowGroupName(iWindowGroup);
|
|
148 |
|
|
149 |
iWsSession.Flush();
|
|
150 |
}
|
|
151 |
|
|
152 |
void CBgAnimHost::DestroyWindow()
|
|
153 |
{
|
|
154 |
delete iWindGroupName;
|
|
155 |
iWindow.Close();
|
|
156 |
iWindowGroup.Close();
|
|
157 |
delete iScreenDevice;
|
|
158 |
iWsSession.Close();
|
|
159 |
}
|
|
160 |
|
|
161 |
void CBgAnimHost::InitEGLL()
|
|
162 |
{
|
|
163 |
iEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
164 |
TInt minorVersion;
|
|
165 |
TInt majorVersion;
|
|
166 |
if (!iEGLDisplay)
|
|
167 |
{
|
|
168 |
User::Leave(KErrHardwareNotAvailable);
|
|
169 |
}
|
|
170 |
if( !eglInitialize( iEGLDisplay, &majorVersion, &minorVersion ) )
|
|
171 |
{
|
|
172 |
User::Leave(KErrHardwareNotAvailable);
|
|
173 |
}
|
|
174 |
iEGLInitialized = ETrue;
|
|
175 |
}
|
|
176 |
|
|
177 |
void CBgAnimHost::ReleaseEGL()
|
|
178 |
{
|
|
179 |
if (iEGLInitialized)
|
|
180 |
{
|
|
181 |
eglTerminate( iEGLDisplay );
|
|
182 |
iEGLInitialized = EFalse;
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
void CBgAnimHost::ReleaseWindowSurface(TBool aReleaseObserver)
|
|
187 |
{
|
|
188 |
if (iEGLInitialized && iSurfaceInitialized)
|
|
189 |
{
|
|
190 |
eglDestroyContext( iEGLDisplay, iEGLContext );
|
|
191 |
eglDestroySurface( iEGLDisplay, iEGLSurface );
|
|
192 |
eglMakeCurrent( iEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
|
|
193 |
iWsSession.Flush();
|
|
194 |
|
|
195 |
iSurfaceInitialized = EFalse;
|
|
196 |
|
|
197 |
if (aReleaseObserver && iCompSource)
|
|
198 |
{
|
|
199 |
iCompSource->RemoveObserver(*this);
|
|
200 |
delete iCompSource;
|
|
201 |
iCompSource = NULL;
|
|
202 |
}
|
|
203 |
}
|
|
204 |
}
|
|
205 |
|
|
206 |
const EGLint openvg_surface_attrs[] =
|
|
207 |
{
|
|
208 |
EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE,
|
|
209 |
EGL_NONE
|
|
210 |
};
|
|
211 |
|
|
212 |
const EGLint opengl_es2_context_attrs[] =
|
|
213 |
{
|
|
214 |
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
215 |
EGL_NONE
|
|
216 |
};
|
|
217 |
|
|
218 |
|
|
219 |
void CBgAnimHost::CreateWindowSurfaceL()
|
|
220 |
{
|
|
221 |
const EGLint* conf = iPlugin->getpreferredconfig();
|
|
222 |
|
|
223 |
TInt numItems = 1;
|
|
224 |
while (conf[numItems-1] != EGL_NONE)
|
|
225 |
{
|
|
226 |
numItems++;
|
|
227 |
}
|
|
228 |
|
|
229 |
EGLint* preferredConfig = (EGLint*)malloc(sizeof(EGLint)*numItems);
|
|
230 |
for (TInt count = 0; count < numItems;count++)
|
|
231 |
{
|
|
232 |
EGLint val = conf[count];
|
|
233 |
preferredConfig[count] = val;
|
|
234 |
switch (val)
|
|
235 |
{
|
|
236 |
case EGL_BUFFER_SIZE:
|
|
237 |
if (conf[count+1] != 16)
|
|
238 |
{
|
|
239 |
preferredConfig[count+1] = 16;
|
|
240 |
count++;
|
|
241 |
}
|
|
242 |
break;
|
|
243 |
case EGL_ALPHA_SIZE:
|
|
244 |
if (conf[count+1] != 0)
|
|
245 |
{
|
|
246 |
preferredConfig[count+1] = 0;
|
|
247 |
count++;
|
|
248 |
}
|
|
249 |
|
|
250 |
break;
|
|
251 |
case EGL_RED_SIZE:
|
|
252 |
if (conf[count+1] != 5)
|
|
253 |
{
|
|
254 |
preferredConfig[count+1] = 5;
|
|
255 |
count++;
|
|
256 |
}
|
|
257 |
|
|
258 |
break;
|
|
259 |
case EGL_GREEN_SIZE:
|
|
260 |
if (conf[count+1] != 6)
|
|
261 |
{
|
|
262 |
preferredConfig[count+1] = 6;
|
|
263 |
count++;
|
|
264 |
}
|
|
265 |
|
|
266 |
break;
|
|
267 |
case EGL_BLUE_SIZE:
|
|
268 |
if (conf[count+1] != 5)
|
|
269 |
{
|
|
270 |
preferredConfig[count+1] = 5;
|
|
271 |
count++;
|
|
272 |
}
|
|
273 |
break;
|
|
274 |
default:
|
|
275 |
break;
|
|
276 |
}
|
|
277 |
}
|
|
278 |
|
|
279 |
TInt index = 0;
|
|
280 |
|
|
281 |
// figure out what API was requested
|
|
282 |
EGLint api = EGL_NONE;
|
|
283 |
while (conf[index] != EGL_NONE)
|
|
284 |
{
|
|
285 |
if (conf[index] == EGL_RENDERABLE_TYPE)
|
|
286 |
{
|
|
287 |
if (conf[index+1]&EGL_OPENVG_BIT)
|
|
288 |
{
|
|
289 |
api = EGL_OPENVG_BIT;
|
|
290 |
if (!eglBindAPI(EGL_OPENVG_API))
|
|
291 |
{
|
|
292 |
User::Leave(KErrAbort);
|
|
293 |
}
|
|
294 |
}
|
|
295 |
else if ( (conf[index+1]&EGL_OPENGL_ES_BIT) ||
|
|
296 |
(conf[index+1]&EGL_OPENGL_ES2_BIT) )
|
|
297 |
{
|
|
298 |
api = conf[index+1];
|
|
299 |
if (!eglBindAPI(EGL_OPENGL_ES_API))
|
|
300 |
{
|
|
301 |
User::Leave(KErrAbort);
|
|
302 |
}
|
|
303 |
}
|
|
304 |
index++;
|
|
305 |
}
|
|
306 |
index++;
|
|
307 |
}
|
|
308 |
EGLConfig *configList = NULL;
|
|
309 |
EGLint numConfigs = 0;
|
|
310 |
EGLint configSize = 0;
|
|
311 |
|
|
312 |
// Get the number of possible EGLConfigs
|
|
313 |
if ( !eglGetConfigs( iEGLDisplay, configList, configSize, &numConfigs ) )
|
|
314 |
{
|
|
315 |
User::Leave(KErrAbort);
|
|
316 |
|
|
317 |
}
|
|
318 |
configSize = numConfigs;
|
|
319 |
|
|
320 |
configList = (EGLConfig*)malloc(sizeof(EGLConfig)*configSize);
|
|
321 |
if (!configList)
|
|
322 |
{
|
|
323 |
User::Leave(KErrNoMemory);
|
|
324 |
}
|
|
325 |
|
|
326 |
if( !eglChooseConfig( iEGLDisplay, preferredConfig, configList, configSize, &numConfigs ) )
|
|
327 |
{
|
|
328 |
User::Leave(KErrAbort);
|
|
329 |
}
|
|
330 |
|
|
331 |
TInt confIndex = 0;
|
|
332 |
// we should now have a list of configs matching our preferred attributes
|
|
333 |
for (TInt count = 0;count<numConfigs;count++)
|
|
334 |
{
|
|
335 |
EGLint buffer_size;
|
|
336 |
EGLint red_size;
|
|
337 |
EGLint green_size;
|
|
338 |
EGLint blue_size;
|
|
339 |
EGLint alpha_size;
|
|
340 |
|
|
341 |
eglGetConfigAttrib(iEGLDisplay, configList[count],EGL_BUFFER_SIZE,&buffer_size);
|
|
342 |
eglGetConfigAttrib(iEGLDisplay, configList[count],EGL_RED_SIZE,&red_size);
|
|
343 |
eglGetConfigAttrib(iEGLDisplay, configList[count],EGL_GREEN_SIZE,&green_size);
|
|
344 |
eglGetConfigAttrib(iEGLDisplay, configList[count],EGL_BLUE_SIZE,&blue_size);
|
|
345 |
eglGetConfigAttrib(iEGLDisplay, configList[count],EGL_ALPHA_SIZE,&alpha_size);
|
|
346 |
|
|
347 |
if (buffer_size == 16 && red_size == 5 && green_size == 6 && blue_size == 5 && alpha_size == 0)
|
|
348 |
{
|
|
349 |
confIndex = count;
|
|
350 |
break;
|
|
351 |
}
|
|
352 |
}
|
|
353 |
|
|
354 |
EGLint* context_attrs = NULL;
|
|
355 |
if (api == EGL_OPENGL_ES2_BIT)
|
|
356 |
{
|
|
357 |
context_attrs = (EGLint*)opengl_es2_context_attrs;
|
|
358 |
}
|
|
359 |
|
|
360 |
iEGLContext = eglCreateContext( iEGLDisplay, configList[confIndex], NULL, context_attrs );
|
|
361 |
if( !iEGLContext )
|
|
362 |
{
|
|
363 |
User::Leave(KErrAbort);
|
|
364 |
}
|
|
365 |
|
|
366 |
EGLint* surface_attrs = NULL;
|
|
367 |
#if !defined(__WINS__) // no pre multiplied surfaces on wins (yet)
|
|
368 |
if (api == EGL_OPENVG_BIT)
|
|
369 |
{
|
|
370 |
surface_attrs = (EGLint*)openvg_surface_attrs;
|
|
371 |
}
|
|
372 |
#endif
|
|
373 |
|
|
374 |
iEGLSurface = eglCreateWindowSurface( iEGLDisplay, configList[confIndex], &iWindow, surface_attrs );
|
|
375 |
if( !iEGLSurface )
|
|
376 |
{
|
|
377 |
User::Leave(KErrAbort);
|
|
378 |
}
|
|
379 |
|
|
380 |
eglMakeCurrent( iEGLDisplay, iEGLSurface, iEGLSurface, iEGLContext );
|
|
381 |
|
|
382 |
free(configList);
|
|
383 |
free(preferredConfig);
|
|
384 |
|
|
385 |
FOREVER
|
|
386 |
{
|
|
387 |
TRAPD(cerr, iCompSource = CAlfCompositionSource::NewL(iWindow));
|
|
388 |
if (!cerr)
|
|
389 |
{
|
|
390 |
iCompSource->AddCompositionObserverL(*this);
|
|
391 |
iCompSource->SetIsBackgroundAnim(ETrue);
|
|
392 |
iCompSource->SetExtent(TRect(TPoint(0,0),iRealDisplaySize),0);
|
|
393 |
break;
|
|
394 |
}
|
|
395 |
else
|
|
396 |
{
|
|
397 |
User::After(1000000);
|
|
398 |
}
|
|
399 |
}
|
|
400 |
|
|
401 |
iSurfaceInitialized = ETrue;
|
|
402 |
|
|
403 |
}
|
|
404 |
|
|
405 |
TBool CBgAnimHost::GetPluginConfigurationL()
|
|
406 |
{
|
|
407 |
// dig out the skin config from skin server
|
|
408 |
HBufC* configstr = NULL;
|
|
409 |
CAknsSrvChunkLookup* cl = iSkinSrv.CreateChunkLookupL();
|
|
410 |
CleanupStack::PushL(cl);
|
|
411 |
CAknsStringItemDef* configitem = static_cast<CAknsStringItemDef*>(cl->LookupAndCreateDefL( KAknsIIDPropertyAnimBgParam ));
|
|
412 |
User::LeaveIfNull(configitem);
|
|
413 |
CleanupStack::PushL(configitem);
|
|
414 |
configstr = configitem->String().AllocL();
|
|
415 |
CleanupStack::PopAndDestroy(2); // cl, configitem
|
|
416 |
CleanupStack::PushL(configstr);
|
|
417 |
|
|
418 |
TLex lex(*configstr);
|
|
419 |
HBufC* dllname = lex.NextToken().AllocL();
|
|
420 |
CleanupStack::PushL(dllname);
|
|
421 |
if (!dllname || !dllname->Length())
|
|
422 |
{
|
|
423 |
User::Leave(KErrNotFound);
|
|
424 |
}
|
|
425 |
|
|
426 |
HBufC* assetdir = lex.NextToken().AllocL();
|
|
427 |
CleanupStack::PushL(assetdir);
|
|
428 |
if (!assetdir || !assetdir->Length())
|
|
429 |
{
|
|
430 |
User::Leave(KErrNotFound);
|
|
431 |
}
|
|
432 |
|
|
433 |
TBool confchanged = EFalse;
|
|
434 |
if (!iCurrentPluginDllName || !iCurrentPluginAssetDir ||
|
|
435 |
(iCurrentPluginDllName && !iCurrentPluginDllName->CompareF(*dllname)) ||
|
|
436 |
(iCurrentPluginAssetDir && !iCurrentPluginAssetDir->CompareF(*assetdir)) )
|
|
437 |
|
|
438 |
{
|
|
439 |
confchanged = ETrue;
|
|
440 |
delete iCurrentPluginDllName;
|
|
441 |
delete iCurrentPluginAssetDir;
|
|
442 |
iCurrentPluginDllName = dllname;
|
|
443 |
iCurrentPluginAssetDir = assetdir;
|
|
444 |
CleanupStack::Pop(2); // dllname, assetdir
|
|
445 |
}
|
|
446 |
else
|
|
447 |
{
|
|
448 |
CleanupStack::PopAndDestroy(2); // dllname, assetdir
|
|
449 |
}
|
|
450 |
|
|
451 |
CleanupStack::PopAndDestroy(); // configstr
|
|
452 |
|
|
453 |
return confchanged;
|
|
454 |
}
|
|
455 |
|
|
456 |
void CBgAnimHost::LoadPluginL()
|
|
457 |
{
|
|
458 |
User::LeaveIfError(iPluginLibrary.Load(*iCurrentPluginDllName));
|
|
459 |
plugingetinterfacefunc getif = (plugingetinterfacefunc)iPluginLibrary.Lookup(1);
|
|
460 |
if (!getif)
|
|
461 |
{
|
|
462 |
iPluginLibrary.Close();
|
|
463 |
User::Leave(KErrNotFound);
|
|
464 |
}
|
|
465 |
|
|
466 |
iPlugin = (plugin_export_v1_t*) getif(1);
|
|
467 |
|
|
468 |
TBuf8<256> pluginpath;
|
|
469 |
pluginpath.Copy(*iCurrentPluginAssetDir);
|
|
470 |
User::LeaveIfError(iPlugin->initialize((const char*)pluginpath.PtrZ(), KMaxGPUMemUsage));
|
|
471 |
|
|
472 |
iPlugin->setdisplaydimensions(iDisplaySize.iWidth, iDisplaySize.iHeight);
|
|
473 |
if (iPlugin->desiredsensors && iPlugin->receivesensordata)
|
|
474 |
{
|
|
475 |
const unsigned int* sensors = iPlugin->desiredsensors();
|
|
476 |
while (*sensors)
|
|
477 |
{
|
|
478 |
CSensorListener* listener = NULL;
|
|
479 |
TRAPD(serr, listener = CSensorListener::NewL(this, *sensors++));
|
|
480 |
if (!serr)
|
|
481 |
{
|
|
482 |
iSensorListeners.Append(listener);
|
|
483 |
StartSensorsL();
|
|
484 |
}
|
|
485 |
}
|
|
486 |
}
|
|
487 |
}
|
|
488 |
|
|
489 |
void CBgAnimHost::ReleasePlugin()
|
|
490 |
{
|
|
491 |
if (iPlugin)
|
|
492 |
{
|
|
493 |
while (iSensorListeners.Count())
|
|
494 |
{
|
|
495 |
delete iSensorListeners[0];
|
|
496 |
iSensorListeners.Remove(0);
|
|
497 |
}
|
|
498 |
|
|
499 |
iPlugin->gpuresourcesavailable(0);
|
|
500 |
iPlugin->destroy();
|
|
501 |
free(iPlugin);
|
|
502 |
iPlugin = NULL;
|
|
503 |
iPluginLibrary.Close();
|
|
504 |
}
|
|
505 |
}
|
|
506 |
|
|
507 |
void CBgAnimHost::NewFrame()
|
|
508 |
{
|
|
509 |
if (!iRunning && !iDoomBringer)
|
|
510 |
{
|
|
511 |
iDoomBringer = CHighResTimer::NewL(TCallBack(DoomBringerFunc, this),CActive::EPriorityStandard);
|
|
512 |
iDoomBringer->CallBack(5000);
|
|
513 |
}
|
|
514 |
|
|
515 |
if (iRunning && iDoomBringer)
|
|
516 |
{
|
|
517 |
delete iDoomBringer;
|
|
518 |
iDoomBringer = NULL;
|
|
519 |
}
|
|
520 |
if (!iSurfaceInitialized)
|
|
521 |
{
|
|
522 |
return;
|
|
523 |
}
|
|
524 |
if (!iIsUIReady)
|
|
525 |
{
|
|
526 |
TInt lValOfNoUse;
|
|
527 |
TInt err = RProperty::Get( KPSUidStartup,
|
|
528 |
KPSStartupUiPhase,
|
|
529 |
lValOfNoUse);
|
|
530 |
if (err == KErrNotFound)
|
|
531 |
{
|
|
532 |
iTimer->CallBack(500);
|
|
533 |
return;
|
|
534 |
}
|
|
535 |
// make window visible now that we are ready for drawing
|
|
536 |
if(!iWindowVisible)
|
|
537 |
{
|
|
538 |
iWindow.SetVisible(ETrue);
|
|
539 |
iWindowVisible = ETrue;
|
|
540 |
}
|
|
541 |
}
|
|
542 |
iIsUIReady = ETrue;
|
|
543 |
TTime start;
|
|
544 |
start.UniversalTime();
|
|
545 |
iPlugin->produceframe();
|
|
546 |
eglSwapBuffers(iEGLDisplay, iEGLSurface);
|
|
547 |
TTime end;
|
|
548 |
end.UniversalTime();
|
|
549 |
TInt64 elapsed = end.MicroSecondsFrom(start).Int64();
|
|
550 |
elapsed/=1000; // convert to milliseconds
|
|
551 |
|
|
552 |
TInt nextcallback = KRefreshTarget-(TInt)elapsed;
|
|
553 |
if (nextcallback < 1)
|
|
554 |
nextcallback = 1;
|
|
555 |
|
|
556 |
iTimer->CallBack(nextcallback);
|
|
557 |
}
|
|
558 |
|
|
559 |
void CBgAnimHost::Kill()
|
|
560 |
{
|
|
561 |
if (!iRunning)
|
|
562 |
{
|
|
563 |
CActiveScheduler::Stop();
|
|
564 |
}
|
|
565 |
else
|
|
566 |
{
|
|
567 |
delete iDoomBringer;
|
|
568 |
iDoomBringer = NULL;
|
|
569 |
}
|
|
570 |
|
|
571 |
return;
|
|
572 |
}
|
|
573 |
|
|
574 |
TInt CBgAnimHost::DoomBringerFunc(TAny* aPtr)
|
|
575 |
{
|
|
576 |
CBgAnimHost* me = (CBgAnimHost*)(aPtr);
|
|
577 |
me->Kill();
|
|
578 |
return ETrue;
|
|
579 |
}
|
|
580 |
|
|
581 |
TInt CBgAnimHost::TimerFunc(TAny* aPtr)
|
|
582 |
{
|
|
583 |
CBgAnimHost* me = (CBgAnimHost*)(aPtr);
|
|
584 |
me->NewFrame();
|
|
585 |
return ETrue;
|
|
586 |
}
|
|
587 |
|
|
588 |
TInt CBgAnimHost::ReaperFunc(TAny* aPtr)
|
|
589 |
{
|
|
590 |
CBgAnimHost* me = (CBgAnimHost*)(aPtr);
|
|
591 |
me->CompositionTargetHidden();
|
|
592 |
return ETrue;
|
|
593 |
}
|
|
594 |
|
|
595 |
|
|
596 |
void CBgAnimHost::ExecuteL()
|
|
597 |
{
|
|
598 |
// finally start our timer and scheduler...
|
|
599 |
iTimer->CallBack(100);
|
|
600 |
iTimerRunning = ETrue;
|
|
601 |
iRunning = ETrue;
|
|
602 |
// we only want to receive skin change messages
|
|
603 |
// after we have been properly initialized
|
|
604 |
// and running, close the session without observer
|
|
605 |
// and re-open with observer
|
|
606 |
iSkinSrv.Close();
|
|
607 |
User::LeaveIfError(iSkinSrv.Connect(this));
|
|
608 |
CActiveScheduler::Start();
|
|
609 |
}
|
|
610 |
|
|
611 |
void CBgAnimHost::FrameReady(TInt /*aScreenNumber*/)
|
|
612 |
{
|
|
613 |
}
|
|
614 |
|
|
615 |
void CBgAnimHost::RunningLowOnGraphicsMemory()
|
|
616 |
{
|
|
617 |
/* iThemeRepositoryListener->GPuMemLow(ETrue);
|
|
618 |
CompositionTargetHidden();*/
|
|
619 |
}
|
|
620 |
|
|
621 |
|
|
622 |
void CBgAnimHost::GraphicsMemoryGood()
|
|
623 |
{
|
|
624 |
/* CompositionTargetVisible();
|
|
625 |
iThemeRepositoryListener->GPuMemLow(EFalse);*/
|
|
626 |
}
|
|
627 |
|
|
628 |
void CBgAnimHost::CompositionTargetHidden()
|
|
629 |
{
|
|
630 |
if (!iSurfaceInitialized)
|
|
631 |
{
|
|
632 |
// don't bother if we are already in
|
|
633 |
// a correct state..
|
|
634 |
return;
|
|
635 |
}
|
|
636 |
|
|
637 |
// release gpu resources...
|
|
638 |
iTimer->Cancel();
|
|
639 |
iTimerRunning = EFalse;
|
|
640 |
iPlugin->gpuresourcesavailable(0);
|
|
641 |
ReleaseWindowSurface(EFalse);
|
|
642 |
StopSensors();
|
|
643 |
}
|
|
644 |
|
|
645 |
void CBgAnimHost::CompositionTargetVisible()
|
|
646 |
{
|
|
647 |
if (!iRunning && !iDoomBringer)
|
|
648 |
{
|
|
649 |
iDoomBringer = CHighResTimer::NewL(TCallBack(DoomBringerFunc, this),CActive::EPriorityStandard);
|
|
650 |
iDoomBringer->CallBack(5000);
|
|
651 |
}
|
|
652 |
|
|
653 |
if (iSurfaceInitialized || iHiddenDueSC || iReaped)
|
|
654 |
{
|
|
655 |
// don't bother if we are already in
|
|
656 |
// a correct state, or if we are hidden by
|
|
657 |
// the screensaver
|
|
658 |
return;
|
|
659 |
}
|
|
660 |
|
|
661 |
if (!iSurfaceInitialized && iCompSource)
|
|
662 |
{
|
|
663 |
iCompSource->RemoveObserver(*this);
|
|
664 |
delete iCompSource;
|
|
665 |
iCompSource = NULL;
|
|
666 |
}
|
|
667 |
|
|
668 |
TRAPD(err,CreateWindowSurfaceL());
|
|
669 |
// reclaim gpu resources
|
|
670 |
if (!err)
|
|
671 |
{
|
|
672 |
iPlugin->gpuresourcesavailable(1);
|
|
673 |
iPlugin->setfaded(iHSFgStatusPropertyListener->GetHSFGStatus());
|
|
674 |
iTimer->CallBack(1);
|
|
675 |
iTimerRunning = ETrue;
|
|
676 |
}
|
|
677 |
TRAP_IGNORE(StartSensorsL());
|
|
678 |
}
|
|
679 |
|
|
680 |
void CBgAnimHost::HandleScreenSaverEvent()
|
|
681 |
{
|
|
682 |
#if !defined(SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS)
|
|
683 |
TInt scStatus = iSCPropertyListener->GetScreenSaverStatus();
|
|
684 |
|
|
685 |
if (scStatus)
|
|
686 |
{
|
|
687 |
// screensaver is ON
|
|
688 |
iHiddenDueSC = ETrue;
|
|
689 |
CompositionTargetHidden();
|
|
690 |
}
|
|
691 |
else
|
|
692 |
{
|
|
693 |
// screensaver is OFF
|
|
694 |
iHiddenDueSC = EFalse;
|
|
695 |
CompositionTargetVisible();
|
|
696 |
}
|
|
697 |
#endif
|
|
698 |
}
|
|
699 |
|
|
700 |
void CBgAnimHost::StartSensorsL()
|
|
701 |
{
|
|
702 |
for (TInt count = 0; count < iSensorListeners.Count(); count++)
|
|
703 |
{
|
|
704 |
iSensorListeners[count]->StartListeningL();
|
|
705 |
}
|
|
706 |
}
|
|
707 |
|
|
708 |
void CBgAnimHost::StopSensors()
|
|
709 |
{
|
|
710 |
for (TInt count = 0; count < iSensorListeners.Count(); count++)
|
|
711 |
{
|
|
712 |
iSensorListeners[count]->StopListening();
|
|
713 |
}
|
|
714 |
}
|
|
715 |
|
|
716 |
void CBgAnimHost::HandleFGAppEvent()
|
|
717 |
{
|
|
718 |
if (!iRunning && !iDoomBringer)
|
|
719 |
{
|
|
720 |
iDoomBringer = CHighResTimer::NewL(TCallBack(DoomBringerFunc, this),CActive::EPriorityStandard);
|
|
721 |
iDoomBringer->CallBack(5000);
|
|
722 |
}
|
|
723 |
|
|
724 |
if (iPlugin && iPlugin->setfaded)
|
|
725 |
{
|
|
726 |
iPlugin->setfaded(iHSFgStatusPropertyListener->GetHSFGStatus());
|
|
727 |
if (!iHSFgStatusPropertyListener->GetHSFGStatus())
|
|
728 |
{
|
|
729 |
// reap the anim in 5 seconds...
|
|
730 |
// 5 seconds is probably just allright
|
|
731 |
// to have enought time for the plugin to fade out...
|
|
732 |
iReaped = ETrue;
|
|
733 |
iTheReaper->CallBack(5000);
|
|
734 |
}
|
|
735 |
else
|
|
736 |
{
|
|
737 |
iReaped = EFalse;
|
|
738 |
iTheReaper->Cancel();
|
|
739 |
CompositionTargetVisible();
|
|
740 |
}
|
|
741 |
}
|
|
742 |
}
|
|
743 |
|
|
744 |
TInt CBgAnimHost::ScreenSaverCallback(TAny* aPtr)
|
|
745 |
{
|
|
746 |
CBgAnimHost* me = (CBgAnimHost*) aPtr;
|
|
747 |
me->HandleScreenSaverEvent();
|
|
748 |
return EFalse;
|
|
749 |
}
|
|
750 |
|
|
751 |
TInt CBgAnimHost::FgAppCallback(TAny* aPtr)
|
|
752 |
{
|
|
753 |
CBgAnimHost* me = (CBgAnimHost*) aPtr;
|
|
754 |
me->HandleFGAppEvent();
|
|
755 |
return EFalse;
|
|
756 |
}
|
|
757 |
|
|
758 |
void CBgAnimHost::DataReceived( CSensrvChannel& aChannel, TInt aCount, TInt aDataLost )
|
|
759 |
{
|
|
760 |
if (iPlugin && iPlugin->receivesensordata)
|
|
761 |
{
|
|
762 |
iPlugin->receivesensordata((void*)&aChannel, aCount, aDataLost);
|
|
763 |
}
|
|
764 |
}
|
|
765 |
|
|
766 |
void CBgAnimHost::DataError( CSensrvChannel& /*aChannel*/, TSensrvErrorSeverity /*aError*/ )
|
|
767 |
{
|
|
768 |
}
|
|
769 |
|
|
770 |
void CBgAnimHost::GetDataListenerInterfaceL( TUid /*aInterfaceUid*/, TAny*& /*aInterface*/)
|
|
771 |
{
|
|
772 |
}
|
|
773 |
|
|
774 |
void CBgAnimHost::SkinContentChanged()
|
|
775 |
{
|
|
776 |
}
|
|
777 |
|
|
778 |
void CBgAnimHost::SkinConfigurationChanged( const TAknsSkinStatusConfigurationChangeReason aReason )
|
|
779 |
{
|
|
780 |
if (aReason == EAknsSkinStatusConfigurationDeployed && iPlugin)
|
|
781 |
{
|
|
782 |
// okay, the skin has changed, let's check that should we load a different
|
|
783 |
// animation plugin
|
|
784 |
TBool changed = EFalse;
|
|
785 |
TRAPD(err, changed = GetPluginConfigurationL());
|
|
786 |
if (err || !changed)
|
|
787 |
{
|
|
788 |
// plugin configuration has not changed, or there is not animation
|
|
789 |
// in the theme, just return
|
|
790 |
return;
|
|
791 |
}
|
|
792 |
|
|
793 |
CompositionTargetHidden();
|
|
794 |
ReleasePlugin();
|
|
795 |
|
|
796 |
TRAP_IGNORE(LoadPluginL());
|
|
797 |
CompositionTargetVisible();
|
|
798 |
}
|
|
799 |
}
|
|
800 |
|
|
801 |
void CBgAnimHost::SkinPackageChanged( const TAknsSkinStatusPackageChangeReason /*aReason*/ )
|
|
802 |
{
|
|
803 |
}
|