egl/sfegltest/src/main.cpp
branchbug235_bringup_0
changeset 210 da03feddbab7
parent 208 7df094ed4a3f
child 211 3804ba25b23f
--- a/egl/sfegltest/src/main.cpp	Fri Oct 22 11:59:21 2010 +0100
+++ b/egl/sfegltest/src/main.cpp	Fri Oct 22 22:19:05 2010 +0100
@@ -23,100 +23,49 @@
 // Amount of time for which to run the app
 static const TInt KAppRunDuration = 5000000;
 
-class CWsRedrawHandler;
-
 class CWsCanvas: public CBase
 {
 public:
 	static CWsCanvas* NewL(TInt, const TPoint&);
 	~CWsCanvas();
 
-	void DrawNow();
-	void Redraw();
-	void Draw(const TRect&);
+	RWsSession& Session() { return iWs; }
+	RWindow& Window() { return iWin; }
+    const TSize& ScreenSize() const { return iSz; }
 
-	RWsSession& Session() {return iWs;}
-	RWindow& Window() {return iWin;}
-	RWindowGroup& Group() {return iGrp;}
-	CWindowGc* Gc() {return iGc;}
-	CWsScreenDevice* Screen() {return iScr;}
-    inline TSize ScreenSize() const;
-	
 private:
 	CWsCanvas(TInt, const TPoint&);
 	void ConstructL();
-	
+
 private:
-    TInt iScrId;
-	TPoint iPos;
+    const TInt iScrId;
+	const TPoint iPos;
 	TSize iSz;
 	RWsSession iWs;
 	RWindowGroup iGrp;
 	RWindow iWin;
 	CWsScreenDevice* iScr;
 	CWindowGc* iGc;
-	CWsRedrawHandler* iRedrawHandler;
 };
 
-class CWsRedrawHandler: public CActive
-{
-public:
-	CWsRedrawHandler(CWsCanvas&);
-	~CWsRedrawHandler();
-	
-	void RunL();
-	void DoCancel();
-	
-private:
-	CWsCanvas& iCanvas;	
-};
-
-class CWsApp: public CBase
-    {
-public:
-	static CWsApp* NewL();
-	~CWsApp();
-	void Start();
-	void Stop();
-	
-private:
-	static TInt TimerCallBack(TAny* aApp);
-
-private:
-	CWsApp();
-    void ConstructL();
-    
-    CPeriodic* iTimer;
-    CWsCanvas* iAppView;    
-	CEGLRendering* iDemo;	
-	TBool iCallWindow;	
-	
-    TPoint iQvgaPos;
-    TPoint iQhdPos;
-	TBool iQhd;
-	TPoint iPos;
-	TSize iSz;
-	TInt iScrId;
-    };
-
 /**
  * Create a canvas to draw to.
- * 
+ *
  * @param aScrId	Screen number to use
  * @param aPos		Position on screen to use
  */
 CWsCanvas* CWsCanvas::NewL(TInt aScrId, const TPoint& aPos)
 	{
-	CWsCanvas* c = new(ELeave) CWsCanvas(aScrId, aPos);
-	CleanupStack::PushL(c);
-	c->ConstructL();
-	CleanupStack::Pop(c);
-
-	return c;
+	CWsCanvas* self = new (ELeave) CWsCanvas(aScrId, aPos);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
 	}
 
-CWsCanvas::CWsCanvas(TInt aScrId, const TPoint& aPos):
-	iScrId(aScrId), iPos(aPos)
+CWsCanvas::CWsCanvas(TInt aScrId, const TPoint& aPos)
+    :   iScrId(aScrId)
+    ,   iPos(aPos)
 	{
 	}
 
@@ -126,18 +75,17 @@
 	delete iScr;
 	iGrp.Close();
 	iWin.Close();
-	delete iRedrawHandler;
 	iWs.Close();
 	}
 
 /**
  * Construct the application canvas.
- * 
+ *
  * Here we setup the collaboration with the Window Server.  We want to get a window
  * on the appropriate screen, and setup a redraw handler so we can re-paint our window
  * when the Window Server wants us to.
  */
-void CWsCanvas::ConstructL()	
+void CWsCanvas::ConstructL()
 	{
 	TInt err = iWs.Connect();
 	User::LeaveIfError(err);
@@ -148,7 +96,7 @@
 
 	err = iScr->CreateContext(iGc);
 	User::LeaveIfError(err);
-	
+
 	iGrp = RWindowGroup(iWs);
 	err = iGrp.Construct(0xbadf00d, ETrue, iScr);
 	User::LeaveIfError(err);
@@ -156,114 +104,69 @@
 	iWin = RWindow(iWs);
 	err = iWin.Construct(iGrp, (TUint32)this);
 	User::LeaveIfError(err);
-	
+
 	iSz = iScr->SizeInPixels();
 	iWin.SetExtent(iPos, iSz);
 	iWin.SetBackgroundColor();
 	iWin.Activate();
-	
-	iWs.Flush();
-
-	iRedrawHandler = new(ELeave) CWsRedrawHandler(*this);
-	iWs.SetFocusScreen(iScrId);
-	}
-
-void CWsCanvas::DrawNow()
-	{
-	iWin.Invalidate();
-	Redraw();
-	}
-
-void CWsCanvas::Redraw()
-	{
-	iWin.BeginRedraw();
-	iGc->Activate(iWin);
-	Draw(TRect(TPoint(), iSz));
-	iGc->Deactivate();
-	iWin.EndRedraw();
 
 	iWs.Flush();
-	}
 
-void CWsCanvas::Draw(const TRect& /*aRect*/)
-	{
-	}
-
-inline TSize CWsCanvas::ScreenSize() const
-    {
-    return iSz;
-    }
-
-CWsRedrawHandler::CWsRedrawHandler(CWsCanvas& aCanvas):
-        CActive(CActive::EPriorityStandard),
-        iCanvas(aCanvas)
-	{
-	CActiveScheduler::Add(this);
-	
-	iStatus = KRequestPending;	
-	iCanvas.Session().RedrawReady(&iStatus);
-	SetActive();
-	}
-
-CWsRedrawHandler::~CWsRedrawHandler()
-	{
-	Cancel();
+	iWs.SetFocusScreen(iScrId);
 	}
+	
+class CWsApp : public CBase
+    {
+public:
+    static CWsApp* NewL();
+    ~CWsApp();
+    void Start();
+    void Stop();
 
-void CWsRedrawHandler::RunL()
-	{
-	TWsRedrawEvent e;
-	iCanvas.Session().GetRedraw(e);
-	if (e.Handle() == (TInt) &iCanvas)
-		{
-		iCanvas.Redraw();		
-		}
+private:
+    static TInt TimerCallBack(TAny* aApp);
 
-	iStatus = KRequestPending;
-	iCanvas.Session().RedrawReady(&iStatus);
-	SetActive();
-	}
+private:
+    CWsApp();
+    void ConstructL();
 
-void CWsRedrawHandler::DoCancel()
-	{
-	iCanvas.Session().RedrawReadyCancel();
-	}
+private:
+    CPeriodic* iTimer;
+    CWsCanvas* iAppView;
+    CEGLRendering* iDemo;
+    TPoint iPos;
+    TSize iSz;
+    TInt iScrId;
+    };
 
-
-CWsApp::CWsApp():
-	iQvgaPos(160,60),
-	iQhdPos(0,0),
-	iQhd(ETrue)
+CWsApp::CWsApp()
 	{
 	}
 
 CWsApp* CWsApp::NewL()
 	{
-	RDebug::Printf("CWsApp::NewL()");
-	CWsApp* app = new(ELeave) CWsApp;
-	CleanupStack::PushL(app);
-	app->ConstructL();
-	CleanupStack::Pop(app);
-	
-	return app;
+	RDebug::Printf("[EBT] CWsApp::NewL");
+	CWsApp* self = new (ELeave) CWsApp;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
 	}
 
 /**
  * Constructor for CWsApp
- * 
+ *
  * @note This constructor looks at the command line argument, if any, supplied when
- * 		 launching the application.  If specified, its used as the screen number to
- * 		 target the output of the program.  By default, screen 0 is used.
+ *		 launching the application.  If specified, its used as the screen number to
+ *		 target the output of the program.  By default, screen 0 is used.
  */
 void CWsApp::ConstructL()
     {
-	RDebug::Printf("CWsApp::ConstructL()");
-	
+	RDebug::Printf("[EBT] CWsApp::ConstructL");
+
 	// Set a timer to stop the application after a short time
 	iTimer = CPeriodic::NewL(CActive::EPriorityIdle);
 	iTimer->Start(KAppRunDuration, KAppRunDuration, TCallBack(TimerCallBack,this));
-	
-    iPos = iQhd? iQhdPos : iQvgaPos;
 
 	iScrId = KDefaultScreenNo;
 	if (User::CommandLineLength() > 0)
@@ -272,81 +175,73 @@
 		User::CommandLine(arg);
 		iScrId = (TInt)(arg[0]-'0');
 		}
-	RDebug::Printf("CWsApp::ConstructL() 1");	    
+
+	RDebug::Printf("[EBT] CWsApp::ConstructL 1");
 	iAppView = CWsCanvas::NewL(iScrId, iPos);
-	RDebug::Printf("CWsApp::ConstructL() 2");	    
-	iDemo = CEGLRendering::NewL(iAppView->Window(), iQhd);
-	RDebug::Printf("CWsApp::ConstructL() 3");	    
+	RDebug::Printf("[EBT] CWsApp::ConstructL 2");
+	iDemo = CEGLRendering::NewL(iAppView->Window());
+	RDebug::Printf("[EBT] CWsApp::ConstructL 3");
 	iDemo->Start();
-	RDebug::Printf("CWsApp::ConstructL() 4");	    
-
+	RDebug::Printf("[EBT] CWsApp::ConstructL 4");
 	iSz = iAppView->ScreenSize();
-	RDebug::Printf("CWsApp::ConstructL() 5");	    
-
-	//Connstruct dialog Box
-	// Get a 212x76 pixel box in the centre of the window.
-	TRect rcDialog(TRect(iPos, iSz));
-
-#ifdef PORTRAIT_MODE
-	rcDialog.Shrink((rcDialog.Width() - 76) / 2, (rcDialog.Height() - 212) / 2);
-#else	
-	rcDialog.Shrink((rcDialog.Width() - 212) / 2, (rcDialog.Height() - 76) / 2);
-#endif
-
-	iCallWindow = EFalse;
+	RDebug::Printf("[EBT] CWsApp::ConstructL 5");
 	}
 
 TInt CWsApp::TimerCallBack(TAny* aApp)
     {
+    RDebug::Printf("[EBT] CWsApp::TimerCallBack");
     reinterpret_cast<CWsApp*>(aApp)->Stop();
     return KErrNone;
     }
 
 void CWsApp::Start()
 	{
-	RDebug::Printf("CWsApp::Start");
+	RDebug::Printf("[EBT] CWsApp::Start");
 	CActiveScheduler::Start();
 	}
 
 void CWsApp::Stop()
 	{
-	CActiveScheduler::Stop();
+    RDebug::Printf("[EBT] CWsApp::Stop");
+    CActiveScheduler::Stop();
 	}
 
 CWsApp::~CWsApp()
-	{	
+	{
+    RDebug::Printf("[EBT] CWsApp::~CWsApp");
 	delete iDemo;
+    RDebug::Printf("[EBT] CWsApp::~CWsApp 1");
 	delete iAppView;
+    RDebug::Printf("[EBT] CWsApp::~CWsApp 2");
 	delete iTimer;
+    RDebug::Printf("[EBT] CWsApp::~CWsApp 3");
 	}
 
 /**
  * Application second level entry point.
- * 
+ *
  * Launches the application specific class CWsApp and calls Start() on it.
- * 
+ *
  * @pre Active scheduler established.
  */
 void MainL()
 	{
-	RDebug::Printf("ebt ::MainL");
+	RDebug::Printf("[EBT] ::MainL");
 	CWsApp* app = CWsApp::NewL();
 	CleanupStack::PushL(app);
-
     app->Start();
-    
 	CleanupStack::PopAndDestroy(1, app);
 	}
 
 /**
  * Application entry point.
- * 
+ *
  * This sets up the application environment active scheduler and runs MainL under a trap
  * harness.
  */
 GLDEF_C TInt E32Main()
     {
-	RDebug::Printf("ebt ::E32Main");
+	RDebug::Printf("[EBT] ::E32Main");
 
 	CTrapCleanup* tc = CTrapCleanup::New();
 	if (!tc)
@@ -363,8 +258,9 @@
 
 	CActiveScheduler::Install(as);
 	TRAPD(err, MainL());
-	
+
 	delete as;
 	delete tc;
 	return err;
     }
+