First public contribution.
1 // Copyright (c) 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
22 #include "cglplanets.h"
23 #include "glplanetsapp.h"
25 const TInt KTimeBetweenFrames = 100000; // 100 ms
27 const TInt KBringToFront = 1;
28 const TInt KTerminate = 2;
31 CGLPlanets* CGLPlanets::NewL(RWindow& aWindow, TPtrC aBackgroundColor, CGLPlanetsAppUi* aApplication, TPtrC aParentQueueName)
33 CGLPlanets* self = new (ELeave)CGLPlanets(aWindow, aApplication);
34 self->ConstructL(aBackgroundColor, aParentQueueName);
38 CGLPlanets::CGLPlanets(RWindow& aWindow, CGLPlanetsAppUi* aApplication) : iWindow(aWindow),
39 iApplication(aApplication)
44 CGLPlanets::~CGLPlanets()
47 delete iEglEnvironment;
49 iParentMsgQueue.Send(KTerminate);
50 iParentMsgQueue.Close();
56 void CGLPlanets::ConstructL(TPtrC aBackgroundColor, TPtrC aParentQueueName)
58 iTimer = CPeriodic::NewL(CActive::EPriorityIdle);
59 iEglEnvironment = CEglEnvironment::NewL(iWindow);
60 iModel = CModel::NewL(iEglEnvironment->Display(), iEglEnvironment->Surface(), aBackgroundColor);
61 User::LeaveIfError(iMsgQueue.OpenGlobal(aBackgroundColor));
62 User::LeaveIfError(iParentMsgQueue.OpenGlobal(aParentQueueName));
63 // inform test app that the message queues are ready
64 RProcess::Rendezvous(KErrNone);
67 void CGLPlanets::Start()
69 // redraw the screen periodically
70 iTimer->Start(0, KTimeBetweenFrames, TCallBack(TimerCallBack, this));
73 TInt CGLPlanets::TimerCallBack(TAny* aGLPlanet)
75 static_cast<CGLPlanets*>(aGLPlanet)->Render();
79 void CGLPlanets::Render()
82 iMsgQueue.ReceiveBlocking(msg); // Receive info from the test
83 iModel->DrawToBuffer(iTime++);
84 iEglEnvironment->DrawToWindow();
89 TUint32 then = User::FastCounter();
90 iApplication->BringToFront();
91 TUint32 now = User::FastCounter();
92 TUint32 time = (now - then);
93 iParentMsgQueue.Send(time);
98 iApplication->Terminate();
103 void CGLPlanets::Stop()