uifw/EikStd/dlgsrc/aknformphysics.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 17 a1caeb42b3a3
child 20 d48ab3b357f1
--- a/uifw/EikStd/dlgsrc/aknformphysics.cpp	Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/EikStd/dlgsrc/aknformphysics.cpp	Tue Aug 31 15:28:30 2010 +0300
@@ -23,7 +23,7 @@
 #include <coecntrl.h>
 #include <coemain.h>
 #include <eikdpage.h>
-#include "akntrace.h"
+
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -55,13 +55,11 @@
 CAknFormPhysics* CAknFormPhysics::NewL( CEikDialogPage& aParent, 
     CAknRecordingGc& aRecordingGc )
     {
-    _AKNTRACE_FUNC_ENTER;
     CAknFormPhysics* self = new ( ELeave ) CAknFormPhysics( aParent, 
         aRecordingGc );
     CleanupStack::PushL( self );
     self->ConstructL();
     CleanupStack::Pop( self );
-    _AKNTRACE_FUNC_EXIT;    
     return self;
     }
 
@@ -72,9 +70,7 @@
 //
 CAknFormPhysics::~CAknFormPhysics()
     {
-    _AKNTRACE_FUNC_ENTER;
     delete iPhysics;
-    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -85,12 +81,10 @@
 void CAknFormPhysics::InitPhysicsL( const TSize& aWorldSize, 
     const TSize& aViewSize, const TPoint& aViewCenter )
     {
-    _AKNTRACE_FUNC_ENTER;
     iPhysics->InitPhysicsL( aWorldSize, aViewSize, EFalse );
     iViewCenter = aViewCenter;
     iWorldSize = aWorldSize;
     iViewSize = aViewSize;
-    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -100,10 +94,8 @@
 //
 void CAknFormPhysics::Stop()
     {
-    _AKNTRACE_FUNC_ENTER;
     iPhysics->StopPhysics();
     iPhysics->ResetFriction();
-    _AKNTRACE_FUNC_EXIT;
     }
     
 
@@ -114,16 +106,19 @@
 TBool CAknFormPhysics::StartFlick( const TPoint& aLength, 
                                    const TTime& aStartTime )
     {
-    _AKNTRACE_FUNC_ENTER;
-    TPoint drag( aLength );
-
-    if ( iPhysics->StartPhysics( drag, aStartTime ) )
+    if (  PhysicsAllowed() )
         {
-        return ETrue;
+        TPoint drag( aLength );
+        if ( iPhysics->StartPhysics( drag, aStartTime ) )
+            {
+            // reset benchmark variables
+            iStartTime.HomeTime();
+            iFrameCount = 0;
+            return ETrue;
+            }
         }
 
     PhysicEmulationEnded();
-    _AKNTRACE_FUNC_EXIT;
     return EFalse;
     }
 
@@ -164,12 +159,10 @@
 //
 void CAknFormPhysics::SetPanningPosition( const TPoint& aDelta )
     {
-    _AKNTRACE_FUNC_ENTER;
-    if ( iPhysics )
+    if (  PhysicsAllowed() && iPhysics )
         {
         iPhysics->RegisterPanningPosition( aDelta );
         }
-    _AKNTRACE_FUNC_EXIT;
     }
 
 
@@ -181,13 +174,32 @@
                                            TBool aDrawNow,
                                            TUint /*aFlags*/ )
     {
-    _AKNTRACE_FUNC_ENTER;
-    _AKNTRACE( "The Position of aNewPosition are: ( %d, %d ) ", 
-    		aNewPosition.iX, aNewPosition.iY );
+    if ( !PhysicsAllowed() )
+        {
+        return;
+        }
+    TInt fps = 0;
+    iViewCenter = aNewPosition;
 
-    iViewCenter = aNewPosition;
-    iParent.ScrollCacheByPixels( iViewCenter.iY, aDrawNow );
-    _AKNTRACE_FUNC_EXIT;
+    // benchmark / debug part
+    if ( iFrameCount != -1 )
+        {
+        ++iFrameCount;
+        TTime now;
+        now.HomeTime();
+        
+        TInt64 duration = now.MicroSecondsFrom( iStartTime ).Int64();
+        
+        if ( duration > 0 )
+            {
+            fps = iFrameCount * 1000000 / duration;
+            }
+        }
+
+    TBuf<128> msg;
+    msg.Format( _L( "%dfps" ), fps );
+
+    iParent.ScrollCacheByPixels( iViewCenter.iY, msg, aDrawNow );
     }
 
 
@@ -197,9 +209,8 @@
 //
 void CAknFormPhysics::PhysicEmulationEnded()
     {
-    _AKNTRACE_FUNC_ENTER;
     iParent.Synchronize();
-    _AKNTRACE_FUNC_EXIT;
+    iFrameCount = -1;
     }
 
 
@@ -271,4 +282,13 @@
     {
     return iViewCenter;
     }
-	
+
+
+// ---------------------------------------------------------------------------
+// CAknFormPhysics::PhysicsAllowed
+// ---------------------------------------------------------------------------
+//
+TBool CAknFormPhysics::PhysicsAllowed() const
+    {
+    return ETrue;
+    }