/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// EXTERNAL INCLUDES
-#include <dali/devel-api/rendering/renderer.h>
#include <dali-toolkit/dali-toolkit.h>
// INTERNAL INCLUDES
);
bool gUseMesh(false);
-bool gUseImageActor(false);
bool gNinePatch(false);
unsigned int gRowsPerPage(25);
unsigned int gColumnsPerPage( 25 );
}
}
-// Test application to compare performance between ImageActor and ImageView
+// Test application to compare performance between using a mesh and ImageView
// 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-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 )
// Respond to a click anywhere on the stage
stage.GetRootLayer().TouchSignal().Connect( this, &Benchmark::OnTouch );
+ // Respond to key events
+ stage.KeyEventSignal().Connect( this, &Benchmark::OnKeyEvent );
+
if( gUseMesh )
{
CreateMeshActors();
}
- else if( gUseImageActor )
- {
- CreateImageActors();
- }
else
{
CreateImageViews();
return !gNinePatch ? IMAGE_PATH[i % NUM_IMAGES] : NINEPATCH_IMAGE_PATH[i % NUM_NINEPATCH_IMAGES];
}
- void CreateImageActors()
- {
- Stage stage = Stage::GetCurrent();
- unsigned int actorCount(mRowsPerPage*mColumnsPerPage * mPageCount);
- mActor.resize(actorCount);
-
- for( size_t i(0); i<actorCount; ++i )
- {
- Image image = ResourceImage::New(ImagePath(i));
- mActor[i] = ImageActor::New(image);
- mActor[i].SetSize(Vector3(0.0f,0.0f,0.0f));
- mActor[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
- stage.Add(mActor[i]);
- }
- }
-
void CreateImageViews()
{
Stage stage = Stage::GetCurrent();
float delay = 0.0f;
float duration = 0.0f;
- if( count < mRowsPerPage*mColumnsPerPage )
+ if( count < ( static_cast< size_t >( mRowsPerPage ) * mColumnsPerPage ) )
{
duration = durationPerActor;
delay = delayBetweenActors * count;
}
- if( gUseImageActor || gUseMesh )
+ if( gUseMesh )
{
mActor[count].SetPosition( initialPosition );
mActor[count].SetSize( Vector3(0.0f,0.0f,0.0f) );
- mActor[count].SetOrientation( Quaternion( Radian(0.0f),Vector3::XAXIS));
+ mActor[count].SetProperty( Actor::Property::ORIENTATION, Quaternion( Radian(0.0f),Vector3::XAXIS) );
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 ));
}
{
mImageView[count].SetPosition( initialPosition );
mImageView[count].SetSize( Vector3(0.0f,0.0f,0.0f) );
- mImageView[count].SetOrientation( Quaternion( Radian(0.0f),Vector3::XAXIS));
+ mImageView[count].SetProperty( Actor::Property::ORIENTATION, 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 ));
}
Vector3 stageSize( stage.GetSize() );
mScroll = Animation::New(10.0f);
- size_t actorCount( mRowsPerPage*mColumnsPerPage*mPageCount);
+ size_t actorCount( static_cast< size_t >( mRowsPerPage ) * mColumnsPerPage * mPageCount );
for( size_t i(0); i<actorCount; ++i )
{
- if( gUseImageActor || gUseMesh )
+ if( 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));
unsigned int totalColumns = mColumnsPerPage * mPageCount;
- float finalZ = Dali::Stage::GetCurrent().GetRenderTaskList().GetTask(0).GetCameraActor().GetCurrentWorldPosition().z;
+ float finalZ = Dali::Stage::GetCurrent().GetRenderTaskList().GetTask(0).GetCameraActor().GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).z;
float totalDuration( 5.0f);
float durationPerActor( 0.5f );
float delayBetweenActors = ( totalDuration - durationPerActor) / (mRowsPerPage*mColumnsPerPage);
delay = delayBetweenActors * count;
}
- if( gUseImageActor || gUseMesh )
+ if( gUseMesh )
{
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 ));
mHide.FinishedSignal().Connect( this, &Benchmark::OnAnimationEnd );
}
+ void OnKeyEvent( const KeyEvent& event )
+ {
+ if( event.state == KeyEvent::Down )
+ {
+ if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
+ {
+ mApplication.Quit();
+ }
+ }
+ }
+
private:
Application& mApplication;
Animation mHide;
};
-void RunTest( Application& application )
-{
- Benchmark test( application );
-
- application.MainLoop();
-}
-
-// Entry point for Linux & Tizen applications
-//
int DALI_EXPORT_API main( int argc, char **argv )
{
Application application = Application::New( &argc, &argv );
{
gUseMesh = true;
}
- else if( arg.compare("--use-image-actor") == 0)
- {
- gUseImageActor = true;
- }
else if( arg.compare("--nine-patch" ) == 0)
{
gNinePatch = true;
}
}
- RunTest( application );
+ Benchmark test( application );
+ application.MainLoop();
return 0;
}