X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbenchmark%2Fbenchmark.cpp;h=e8755a5ee9e11bee8843e537f27002c869ac454d;hb=694dced621016315f10a5bdbd3f4552f5e29e380;hp=6d137fff1024e15c3aef52bbfc1967bc5c31e608;hpb=374a5a604d448969b042a31cfb6bc22dbe7a0b32;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/benchmark/benchmark.cpp b/examples/benchmark/benchmark.cpp index 6d137ff..e8755a5 100644 --- a/examples/benchmark/benchmark.cpp +++ b/examples/benchmark/benchmark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -16,7 +16,6 @@ */ // EXTERNAL INCLUDES -#include #include // INTERNAL INCLUDES @@ -216,34 +215,34 @@ class Benchmark : public ConnectionTracker public: Benchmark( Application& application ) -: mApplication( application ), - mRowsPerPage( gRowsPerPage ), - mColumnsPerPage( gColumnsPerPage ), - mPageCount( gPageCount ) -{ + : mApplication( application ), + mRowsPerPage( gRowsPerPage ), + mColumnsPerPage( gColumnsPerPage ), + mPageCount( gPageCount ) + { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &Benchmark::Create ); -} - - ~Benchmark() - { - // Nothing to do here; } + ~Benchmark() = default; + // The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { - // Get a handle to the stage - Stage stage = Stage::GetCurrent(); - stage.SetBackgroundColor( Color::WHITE ); - Vector2 stageSize = stage.GetSize(); + // Get a handle to the window + Window window = application.GetWindow(); + window.SetBackgroundColor( Color::WHITE ); + Vector2 windowSize = window.GetSize(); - stage.GetRootLayer().SetDepthTestDisabled(true); + window.GetRootLayer().SetProperty( Layer::Property::DEPTH_TEST, false ); - mSize = Vector3( stageSize.x / mColumnsPerPage, stageSize.y / mRowsPerPage, 0.0f ); + mSize = Vector3( windowSize.x / mColumnsPerPage, windowSize.y / mRowsPerPage, 0.0f ); - // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchSignal().Connect( this, &Benchmark::OnTouch ); + // Respond to a click anywhere on the window + window.GetRootLayer().TouchSignal().Connect( this, &Benchmark::OnTouch ); + + // Respond to key events + window.KeyEventSignal().Connect( this, &Benchmark::OnKeyEvent ); if( gUseMesh ) { @@ -271,16 +270,16 @@ public: void CreateImageViews() { - Stage stage = Stage::GetCurrent(); + Window window = mApplication.GetWindow(); unsigned int actorCount(mRowsPerPage*mColumnsPerPage * mPageCount); mImageView.resize(actorCount); for( size_t i(0); i( mRowsPerPage ) * mColumnsPerPage ) ) { duration = durationPerActor; delay = delayBetweenActors * count; } 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::POSITION, initialPosition ); + mActor[count].SetProperty( Actor::Property::SIZE, Vector3(0.0f,0.0f,0.0f) ); + 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 )); } else { - 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::POSITION, initialPosition ); + mImageView[count].SetProperty( Actor::Property::SIZE, Vector3(0.0f,0.0f,0.0f) ); + 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 )); } @@ -381,26 +381,26 @@ public: void ScrollAnimation() { - Stage stage = Stage::GetCurrent(); - Vector3 stageSize( stage.GetSize() ); + Window window = mApplication.GetWindow(); + Vector3 windowSize( window.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( Actor::Property::WORLD_POSITION ).z; float totalDuration( 5.0f); float durationPerActor( 0.5f ); float delayBetweenActors = ( totalDuration - durationPerActor) / (mRowsPerPage*mColumnsPerPage); @@ -449,6 +449,17 @@ public: 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; @@ -465,15 +476,6 @@ private: 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 ); @@ -503,7 +505,8 @@ int DALI_EXPORT_API main( int argc, char **argv ) } } - RunTest( application ); + Benchmark test( application ); + application.MainLoop(); return 0; }