Changed benchmark to use ImageView by default 07/53407/3
authorFerran Sole <ferran.sole@samsung.com>
Fri, 4 Dec 2015 13:11:29 +0000 (13:11 +0000)
committerFerran Sole <ferran.sole@samsung.com>
Wed, 16 Dec 2015 10:55:54 +0000 (10:55 +0000)
-ImageView is used by default
-ImageActor can still be used if the command line option "--use-image-actor" is specified
-Fixed bug on HideAnimation

Change-Id: Ib9664b7a99a142681bfdbe9ebb3ab457069d6cf7

examples/benchmark/benchmark.cpp

index 576f404..7b257cf 100644 (file)
@@ -207,7 +207,7 @@ Geometry& QuadMesh()
 }
 
 bool gUseMesh(false);
-bool gUseImageView(false);
+bool gUseImageActor(false);
 bool gNinePatch(false);
 unsigned int gRowsPerPage(25);
 unsigned int gColumnsPerPage( 25 );
@@ -243,11 +243,11 @@ Actor CreateMeshActor( unsigned int index)
 
 }
 // Test application to compare performance between ImageActor and ImageView
-// By default, the application consist of 10 pages of 25x25 ImageActors, this can be modified using the following command line arguments:
+// By default, the application consist of 10 pages of 25x25 Image views, this can be modified using the following command line arguments:
 // -r NumberOfRows  (Modifies the number of rows per page)
 // -c NumberOfColumns (Modifies the number of columns per page)
 // -p NumberOfPages (Modifies the nimber of pages )
-// --use-imageview ( Use ImageView instead of ImageActor )
+// --use-image-actor ( Use ImageActor instead of ImageView )
 // --use-mesh ( Use new renderer API (as ImageView) but shares renderers between actors when possible )
 // --nine-patch ( Use nine patch images )
 
@@ -290,13 +290,13 @@ public:
     {
       CreateMeshActors();
     }
-    else if( gUseImageView )
+    else if( gUseImageActor )
     {
-      CreateImageViews();
+      CreateImageActors();
     }
     else
     {
-      CreateImageActors();
+      CreateImageViews();
     }
 
     ShowAnimation();
@@ -406,15 +406,7 @@ public:
           duration = durationPerActor;
           delay = delayBetweenActors * count;
         }
-        if( gUseImageView )
-        {
-          mImageView[count].SetPosition( initialPosition );
-          mImageView[count].SetSize( Vector3(0.0f,0.0f,0.0f) );
-          mImageView[count].SetOrientation( Quaternion( Radian(0.0f),Vector3::XAXIS));
-          mShow.AnimateTo( Property( mImageView[count], Actor::Property::POSITION), Vector3(xpos+mSize.x*0.5f, ypos+mSize.y*0.5f, 0.0f), AlphaFunction::EASE_OUT_BACK, TimePeriod( delay, duration ));
-          mShow.AnimateTo( Property( mImageView[count], Actor::Property::SIZE), mSize, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay, duration ));
-        }
-        else
+        if( gUseImageActor || gUseMesh )
         {
           mActor[count].SetPosition( initialPosition );
           mActor[count].SetSize( Vector3(0.0f,0.0f,0.0f) );
@@ -422,6 +414,14 @@ public:
           mShow.AnimateTo( Property( mActor[count], Actor::Property::POSITION), Vector3(xpos+mSize.x*0.5f, ypos+mSize.y*0.5f, 0.0f), AlphaFunction::EASE_OUT_BACK, TimePeriod( delay, duration ));
           mShow.AnimateTo( Property( mActor[count], Actor::Property::SIZE), mSize, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay, duration ));
         }
+        else
+        {
+          mImageView[count].SetPosition( initialPosition );
+          mImageView[count].SetSize( Vector3(0.0f,0.0f,0.0f) );
+          mImageView[count].SetOrientation( Quaternion( Radian(0.0f),Vector3::XAXIS));
+          mShow.AnimateTo( Property( mImageView[count], Actor::Property::POSITION), Vector3(xpos+mSize.x*0.5f, ypos+mSize.y*0.5f, 0.0f), AlphaFunction::EASE_OUT_BACK, TimePeriod( delay, duration ));
+          mShow.AnimateTo( Property( mImageView[count], Actor::Property::SIZE), mSize, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay, duration ));
+        }
         ++count;
       }
     }
@@ -438,20 +438,20 @@ public:
     size_t actorCount( mRowsPerPage*mColumnsPerPage*mPageCount);
     for( size_t i(0); i<actorCount; ++i )
     {
-      if( gUseImageView )
-      {
-        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(0.0f,3.0f));
-        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(3.0f,3.0f));
-        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(6.0f,2.0f));
-        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3( 12.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(8.0f,2.0f));
-      }
-      else
+      if( gUseImageActor || gUseMesh )
       {
         mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(0.0f,3.0f));
         mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(3.0f,3.0f));
         mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(6.0f,2.0f));
         mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3( 12.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(8.0f,2.0f));
       }
+      else
+      {
+        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(0.0f,3.0f));
+        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(3.0f,3.0f));
+        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(6.0f,2.0f));
+        mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3( 12.0f*stageSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(8.0f,2.0f));
+      }
     }
     mScroll.Play();
     mScroll.FinishedSignal().Connect( this, &Benchmark::OnAnimationEnd );
@@ -465,6 +465,7 @@ public:
 
     unsigned int totalColumns = mColumnsPerPage * mPageCount;
 
+    float finalZ = Dali::Stage::GetCurrent().GetRenderTaskList().GetTask(0).GetCameraActor().GetCurrentWorldPosition().z;
     float totalDuration( 5.0f);
     float durationPerActor( 0.5f );
     float delayBetweenActors = ( totalDuration - durationPerActor) / (mRowsPerPage*mColumnsPerPage);
@@ -480,15 +481,15 @@ public:
           delay = delayBetweenActors * count;
         }
 
-        if( gUseImageView )
+        if( gUseImageActor || gUseMesh )
         {
-          mHide.AnimateTo( Property( mImageView[count], Actor::Property::ORIENTATION),  Quaternion( Radian( Degree( 70.0f ) ), Vector3::XAXIS ), AlphaFunction::EASE_OUT, TimePeriod( delay, duration ));
-          mHide.AnimateBy( Property( mImageView[count], Actor::Property::POSITION_Z), 1000.0f, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay +delayBetweenActors*actorsPerPage + duration, duration ));
+          mHide.AnimateTo( Property( mActor[count], Actor::Property::ORIENTATION),  Quaternion( Radian( Degree( 70.0f ) ), Vector3::XAXIS ), AlphaFunction::EASE_OUT, TimePeriod( delay, duration ));
+          mHide.AnimateBy( Property( mActor[count], Actor::Property::POSITION_Z), finalZ, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay +delayBetweenActors*actorsPerPage + duration, duration ));
         }
         else
         {
-          mHide.AnimateTo( Property( mActor[count], Actor::Property::ORIENTATION),  Quaternion( Radian( Degree( 70.0f ) ), Vector3::XAXIS ), AlphaFunction::EASE_OUT, TimePeriod( delay, duration ));
-          mHide.AnimateBy( Property( mActor[count], Actor::Property::POSITION_Z), 1000.0f, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay +delayBetweenActors*actorsPerPage + duration, duration ));
+          mHide.AnimateTo( Property( mImageView[count], Actor::Property::ORIENTATION),  Quaternion( Radian( Degree( 70.0f ) ), Vector3::XAXIS ), AlphaFunction::EASE_OUT, TimePeriod( delay, duration ));
+          mHide.AnimateBy( Property( mImageView[count], Actor::Property::POSITION_Z), finalZ, AlphaFunction::EASE_OUT_BACK, TimePeriod( delay +delayBetweenActors*actorsPerPage + duration, duration ));
         }
         ++count;
       }
@@ -534,9 +535,9 @@ int main( int argc, char **argv )
     {
       gUseMesh = true;
     }
-    else if( arg.compare("--use-imageview") == 0)
+    else if( arg.compare("--use-image-actor") == 0)
     {
-      gUseImageView = true;
+      gUseImageActor = true;
     }
     else if( arg.compare("--nine-patch" ) == 0)
     {