X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbenchmark%2Fbenchmark.cpp;h=b1d05d57a33a8ae6177853f18cca027e2bf0f549;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=8ad4c5bebd64ab9affe1254c1e55aa80511b45c7;hpb=312470da17142a335f5f743630b7fc19c0061ead;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/benchmark/benchmark.cpp b/examples/benchmark/benchmark.cpp index 8ad4c5b..b1d05d5 100644 --- a/examples/benchmark/benchmark.cpp +++ b/examples/benchmark/benchmark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 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. @@ -150,13 +150,6 @@ struct VertexWithTexture Vector2 texCoord; }; -VertexWithTexture gQuadWithTexture[] = { - { Vector2( -0.5f, -0.5f ), Vector2( 0.0f, 0.0f ) }, - { Vector2( 0.5f, -0.5f ), Vector2( 1.0f, 0.0f ) }, - { Vector2( -0.5f, 0.5f ), Vector2( 0.0f, 1.0f ) }, - { Vector2( 0.5f, 0.5f ), Vector2( 1.0f, 1.0f ) } -}; - const char* VERTEX_SHADER_TEXTURE = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n attribute mediump vec2 aTexCoord;\n @@ -215,34 +208,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().TouchedSignal().Connect( this, &Benchmark::OnTouch ); + + // Respond to key events + window.KeyEventSignal().Connect( this, &Benchmark::OnKeyEvent ); if( gUseMesh ) { @@ -256,7 +249,7 @@ public: ShowAnimation(); } - bool OnTouch( Actor actor, const TouchData& touch ) + bool OnTouch( Actor actor, const TouchEvent& touch ) { // quit the application mApplication.Quit(); @@ -270,16 +263,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 * mPageCount ); @@ -389,17 +383,17 @@ public: { 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)); - 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)); + mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3(-4.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(0.0f,3.0f)); + mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3(-4.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(3.0f,3.0f)); + mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3(-4.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(6.0f,2.0f)); + mScroll.AnimateBy( Property( mActor[i], Actor::Property::POSITION), Vector3( 12.0f*windowSize.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.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(0.0f,3.0f)); + mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(3.0f,3.0f)); + mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3(-4.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(6.0f,2.0f)); + mScroll.AnimateBy( Property( mImageView[i], Actor::Property::POSITION), Vector3( 12.0f*windowSize.x,0.0f, 0.0f), AlphaFunction::EASE_OUT, TimePeriod(8.0f,2.0f)); } } mScroll.Play(); @@ -414,7 +408,7 @@ public: unsigned int totalColumns = mColumnsPerPage * mPageCount; - float finalZ = Dali::Stage::GetCurrent().GetRenderTaskList().GetTask(0).GetCameraActor().GetCurrentWorldPosition().z; + float finalZ = mApplication.GetWindow().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); @@ -448,6 +442,17 @@ public: mHide.FinishedSignal().Connect( this, &Benchmark::OnAnimationEnd ); } + void OnKeyEvent( const KeyEvent& event ) + { + if( event.GetState() == KeyEvent::DOWN ) + { + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + } + } + private: Application& mApplication;