From bf5385db6f03350c5d4cc7377313dcdfeaf164f2 Mon Sep 17 00:00:00 2001 From: Chu Hoang Date: Fri, 2 Oct 2015 15:05:40 +0100 Subject: [PATCH] Added nine patch images to Benchmark example. --- examples/benchmark/benchmark.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- resources/images/button-disabled.9.png | Bin 0 -> 783 bytes resources/images/button-down-disabled.9.png | Bin 0 -> 720 bytes resources/images/button-down.9.png | Bin 0 -> 844 bytes resources/images/button-up-1.9.png | Bin 0 -> 897 bytes resources/images/button-up-10.9.png | Bin 0 -> 943 bytes resources/images/button-up-11.9.png | Bin 0 -> 942 bytes resources/images/button-up-12.9.png | Bin 0 -> 939 bytes resources/images/button-up-13.9.png | Bin 0 -> 948 bytes resources/images/button-up-14.9.png | Bin 0 -> 934 bytes resources/images/button-up-15.9.png | Bin 0 -> 939 bytes resources/images/button-up-16.9.png | Bin 0 -> 953 bytes resources/images/button-up-17.9.png | Bin 0 -> 941 bytes resources/images/button-up-2.9.png | Bin 0 -> 997 bytes resources/images/button-up-3.9.png | Bin 0 -> 982 bytes resources/images/button-up-4.9.png | Bin 0 -> 982 bytes resources/images/button-up-5.9.png | Bin 0 -> 996 bytes resources/images/button-up-6.9.png | Bin 0 -> 989 bytes resources/images/button-up-7.9.png | Bin 0 -> 985 bytes resources/images/button-up-8.9.png | Bin 0 -> 983 bytes resources/images/button-up-9.9.png | Bin 0 -> 942 bytes resources/images/selection-popup-bg.1.9.png | Bin 0 -> 748 bytes resources/images/selection-popup-bg.10.9.png | Bin 0 -> 537 bytes resources/images/selection-popup-bg.11.9.png | Bin 0 -> 541 bytes resources/images/selection-popup-bg.12.9.png | Bin 0 -> 624 bytes resources/images/selection-popup-bg.13.9.png | Bin 0 -> 514 bytes resources/images/selection-popup-bg.14.9.png | Bin 0 -> 535 bytes resources/images/selection-popup-bg.15.9.png | Bin 0 -> 591 bytes resources/images/selection-popup-bg.16.9.png | Bin 0 -> 622 bytes resources/images/selection-popup-bg.17.9.png | Bin 0 -> 602 bytes resources/images/selection-popup-bg.18.9.png | Bin 0 -> 490 bytes resources/images/selection-popup-bg.19.9.png | Bin 0 -> 574 bytes resources/images/selection-popup-bg.2.9.png | Bin 0 -> 755 bytes resources/images/selection-popup-bg.20.9.png | Bin 0 -> 634 bytes resources/images/selection-popup-bg.21.9.png | Bin 0 -> 632 bytes resources/images/selection-popup-bg.22.9.png | Bin 0 -> 622 bytes resources/images/selection-popup-bg.23.9.png | Bin 0 -> 610 bytes resources/images/selection-popup-bg.24.9.png | Bin 0 -> 593 bytes resources/images/selection-popup-bg.25.9.png | Bin 0 -> 562 bytes resources/images/selection-popup-bg.26.9.png | Bin 0 -> 614 bytes resources/images/selection-popup-bg.27.9.png | Bin 0 -> 615 bytes resources/images/selection-popup-bg.28.9.png | Bin 0 -> 537 bytes resources/images/selection-popup-bg.29.9.png | Bin 0 -> 625 bytes resources/images/selection-popup-bg.3.9.png | Bin 0 -> 708 bytes resources/images/selection-popup-bg.30.9.png | Bin 0 -> 500 bytes resources/images/selection-popup-bg.31.9.png | Bin 0 -> 535 bytes resources/images/selection-popup-bg.32.9.png | Bin 0 -> 619 bytes resources/images/selection-popup-bg.33.9.png | Bin 0 -> 628 bytes resources/images/selection-popup-bg.4.9.png | Bin 0 -> 672 bytes resources/images/selection-popup-bg.5.9.png | Bin 0 -> 657 bytes resources/images/selection-popup-bg.6.9.png | Bin 0 -> 538 bytes resources/images/selection-popup-bg.7.9.png | Bin 0 -> 487 bytes resources/images/selection-popup-bg.8.9.png | Bin 0 -> 497 bytes resources/images/selection-popup-bg.9.9.png | Bin 0 -> 511 bytes 54 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 resources/images/button-disabled.9.png create mode 100644 resources/images/button-down-disabled.9.png create mode 100644 resources/images/button-down.9.png create mode 100644 resources/images/button-up-1.9.png create mode 100644 resources/images/button-up-10.9.png create mode 100644 resources/images/button-up-11.9.png create mode 100644 resources/images/button-up-12.9.png create mode 100644 resources/images/button-up-13.9.png create mode 100644 resources/images/button-up-14.9.png create mode 100644 resources/images/button-up-15.9.png create mode 100644 resources/images/button-up-16.9.png create mode 100644 resources/images/button-up-17.9.png create mode 100644 resources/images/button-up-2.9.png create mode 100644 resources/images/button-up-3.9.png create mode 100644 resources/images/button-up-4.9.png create mode 100644 resources/images/button-up-5.9.png create mode 100644 resources/images/button-up-6.9.png create mode 100644 resources/images/button-up-7.9.png create mode 100644 resources/images/button-up-8.9.png create mode 100644 resources/images/button-up-9.9.png create mode 100644 resources/images/selection-popup-bg.1.9.png create mode 100644 resources/images/selection-popup-bg.10.9.png create mode 100644 resources/images/selection-popup-bg.11.9.png create mode 100644 resources/images/selection-popup-bg.12.9.png create mode 100644 resources/images/selection-popup-bg.13.9.png create mode 100644 resources/images/selection-popup-bg.14.9.png create mode 100644 resources/images/selection-popup-bg.15.9.png create mode 100644 resources/images/selection-popup-bg.16.9.png create mode 100644 resources/images/selection-popup-bg.17.9.png create mode 100644 resources/images/selection-popup-bg.18.9.png create mode 100644 resources/images/selection-popup-bg.19.9.png create mode 100644 resources/images/selection-popup-bg.2.9.png create mode 100644 resources/images/selection-popup-bg.20.9.png create mode 100644 resources/images/selection-popup-bg.21.9.png create mode 100644 resources/images/selection-popup-bg.22.9.png create mode 100644 resources/images/selection-popup-bg.23.9.png create mode 100644 resources/images/selection-popup-bg.24.9.png create mode 100644 resources/images/selection-popup-bg.25.9.png create mode 100644 resources/images/selection-popup-bg.26.9.png create mode 100644 resources/images/selection-popup-bg.27.9.png create mode 100644 resources/images/selection-popup-bg.28.9.png create mode 100644 resources/images/selection-popup-bg.29.9.png create mode 100644 resources/images/selection-popup-bg.3.9.png create mode 100644 resources/images/selection-popup-bg.30.9.png create mode 100644 resources/images/selection-popup-bg.31.9.png create mode 100644 resources/images/selection-popup-bg.32.9.png create mode 100644 resources/images/selection-popup-bg.33.9.png create mode 100644 resources/images/selection-popup-bg.4.9.png create mode 100644 resources/images/selection-popup-bg.5.9.png create mode 100644 resources/images/selection-popup-bg.6.9.png create mode 100644 resources/images/selection-popup-bg.7.9.png create mode 100644 resources/images/selection-popup-bg.8.9.png create mode 100644 resources/images/selection-popup-bg.9.9.png 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