From: Chu Hoang Date: Fri, 2 Oct 2015 14:05:40 +0000 (+0100) Subject: Added nine patch images to Benchmark example. X-Git-Tag: dali_1.1.6~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F48989%2F2;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Added nine patch images to Benchmark example. use the --use-ninepatch command flag to use nine patch images. Change-Id: Ie14eacdf938066343a1d75f6738a3c1dd65a7e81 --- diff --git a/examples/benchmark/benchmark.cpp b/examples/benchmark/benchmark.cpp index 9e4a22d..f673c49 100644 --- a/examples/benchmark/benchmark.cpp +++ b/examples/benchmark/benchmark.cpp @@ -84,7 +84,64 @@ const char* IMAGE_PATH[] = { DALI_IMAGE_DIR "gallery-medium-53.jpg", }; +const char* NINEPATCH_IMAGE_PATH[] = { + DALI_IMAGE_DIR "selection-popup-bg.1.9.png", + DALI_IMAGE_DIR "selection-popup-bg.2.9.png", + DALI_IMAGE_DIR "selection-popup-bg.3.9.png", + DALI_IMAGE_DIR "selection-popup-bg.4.9.png", + DALI_IMAGE_DIR "selection-popup-bg.5.9.png", + DALI_IMAGE_DIR "selection-popup-bg.6.9.png", + DALI_IMAGE_DIR "selection-popup-bg.7.9.png", + DALI_IMAGE_DIR "selection-popup-bg.8.9.png", + DALI_IMAGE_DIR "selection-popup-bg.9.9.png", + DALI_IMAGE_DIR "selection-popup-bg.10.9.png", + DALI_IMAGE_DIR "selection-popup-bg.11.9.png", + DALI_IMAGE_DIR "selection-popup-bg.12.9.png", + DALI_IMAGE_DIR "selection-popup-bg.13.9.png", + DALI_IMAGE_DIR "selection-popup-bg.14.9.png", + DALI_IMAGE_DIR "selection-popup-bg.15.9.png", + DALI_IMAGE_DIR "selection-popup-bg.16.9.png", + DALI_IMAGE_DIR "selection-popup-bg.17.9.png", + DALI_IMAGE_DIR "selection-popup-bg.18.9.png", + DALI_IMAGE_DIR "selection-popup-bg.19.9.png", + DALI_IMAGE_DIR "selection-popup-bg.20.9.png", + DALI_IMAGE_DIR "selection-popup-bg.21.9.png", + DALI_IMAGE_DIR "selection-popup-bg.22.9.png", + DALI_IMAGE_DIR "selection-popup-bg.23.9.png", + DALI_IMAGE_DIR "selection-popup-bg.24.9.png", + DALI_IMAGE_DIR "selection-popup-bg.25.9.png", + DALI_IMAGE_DIR "selection-popup-bg.26.9.png", + DALI_IMAGE_DIR "selection-popup-bg.27.9.png", + DALI_IMAGE_DIR "selection-popup-bg.28.9.png", + DALI_IMAGE_DIR "selection-popup-bg.29.9.png", + DALI_IMAGE_DIR "selection-popup-bg.30.9.png", + DALI_IMAGE_DIR "selection-popup-bg.31.9.png", + DALI_IMAGE_DIR "selection-popup-bg.32.9.png", + DALI_IMAGE_DIR "selection-popup-bg.33.9.png", + DALI_IMAGE_DIR "button-disabled.9.png", + DALI_IMAGE_DIR "button-down.9.png", + DALI_IMAGE_DIR "button-down-disabled.9.png", + DALI_IMAGE_DIR "button-up-1.9.png", + DALI_IMAGE_DIR "button-up-2.9.png", + DALI_IMAGE_DIR "button-up-3.9.png", + DALI_IMAGE_DIR "button-up-4.9.png", + DALI_IMAGE_DIR "button-up-5.9.png", + DALI_IMAGE_DIR "button-up-6.9.png", + DALI_IMAGE_DIR "button-up-7.9.png", + DALI_IMAGE_DIR "button-up-8.9.png", + DALI_IMAGE_DIR "button-up-9.9.png", + DALI_IMAGE_DIR "button-up-10.9.png", + DALI_IMAGE_DIR "button-up-11.9.png", + DALI_IMAGE_DIR "button-up-12.9.png", + DALI_IMAGE_DIR "button-up-13.9.png", + DALI_IMAGE_DIR "button-up-14.9.png", + DALI_IMAGE_DIR "button-up-15.9.png", + DALI_IMAGE_DIR "button-up-16.9.png", + DALI_IMAGE_DIR "button-up-17.9.png", +}; + const unsigned int NUM_IMAGES = sizeof(IMAGE_PATH) / sizeof(char*); +const unsigned int NUM_NINEPATCH_IMAGES = sizeof(NINEPATCH_IMAGE_PATH) / sizeof(char*); const float ANIMATION_TIME ( 5.0f ); // animation length in seconds @@ -149,14 +206,25 @@ Geometry& QuadMesh() return mesh; } +bool gUseMesh(false); +bool gUseImageView(false); +bool gNinePatch(false); +unsigned int gRowsPerPage(25); +unsigned int gColumnsPerPage( 25 ); +unsigned int gPageCount(13); + Renderer CreateRenderer( unsigned int index ) { - static Renderer renderers[NUM_IMAGES]; + + int numImages = !gNinePatch ? NUM_IMAGES : NUM_NINEPATCH_IMAGES; + static Renderer* renderers = new Renderer[numImages]; if( !renderers[index] ) { //Create the renderer Shader shader = Shader::New( VERTEX_SHADER_TEXTURE, FRAGMENT_SHADER_TEXTURE ); - Image image = ResourceImage::New(IMAGE_PATH[index]); + + const char* imagePath = !gNinePatch ? IMAGE_PATH[index] : NINEPATCH_IMAGE_PATH[index]; + Image image = ResourceImage::New(imagePath); Sampler textureSampler = Sampler::New( image, "sTexture" ); Material material = Material::New( shader ); material.AddSampler(textureSampler); @@ -174,13 +242,6 @@ Actor CreateMeshActor( unsigned int index) return meshActor; } -bool gUseMesh(false); -bool gUseImageView(false); -unsigned int gRowsPerPage(25); -unsigned int gColumnsPerPage( 25 ); -unsigned int gPageCount(13); - - } // 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: @@ -189,6 +250,7 @@ unsigned int gPageCount(13); // -p NumberOfPages (Modifies the nimber of pages ) // --use-imageview ( Use ImageView instead of ImageActor ) // --use-mesh ( Use new renderer API (as ImageView) but shares renderers between actors when possible ) +// --use-nine-patch ( Use nine patch images ) // class Benchmark : public ConnectionTracker @@ -248,6 +310,11 @@ public: return true; } + const char* ImagePath( int i ) + { + return !gNinePatch ? IMAGE_PATH[i % NUM_IMAGES] : NINEPATCH_IMAGE_PATH[i % NUM_NINEPATCH_IMAGES]; + } + void CreateImageActors() { Stage stage = Stage::GetCurrent(); @@ -256,7 +323,7 @@ public: for( size_t i(0); i