Commit bf5385db6f03350c5d4cc7377313dcdfeaf164f2
1 parent
283d2906
Added nine patch images to Benchmark example.
use the --use-ninepatch command flag to use nine patch images. Change-Id: Ie14eacdf938066343a1d75f6738a3c1dd65a7e81
Showing
54 changed files
with
84 additions
and
14 deletions
examples/benchmark/benchmark.cpp
| ... | ... | @@ -84,7 +84,64 @@ const char* IMAGE_PATH[] = { |
| 84 | 84 | DALI_IMAGE_DIR "gallery-medium-53.jpg", |
| 85 | 85 | }; |
| 86 | 86 | |
| 87 | +const char* NINEPATCH_IMAGE_PATH[] = { | |
| 88 | + DALI_IMAGE_DIR "selection-popup-bg.1.9.png", | |
| 89 | + DALI_IMAGE_DIR "selection-popup-bg.2.9.png", | |
| 90 | + DALI_IMAGE_DIR "selection-popup-bg.3.9.png", | |
| 91 | + DALI_IMAGE_DIR "selection-popup-bg.4.9.png", | |
| 92 | + DALI_IMAGE_DIR "selection-popup-bg.5.9.png", | |
| 93 | + DALI_IMAGE_DIR "selection-popup-bg.6.9.png", | |
| 94 | + DALI_IMAGE_DIR "selection-popup-bg.7.9.png", | |
| 95 | + DALI_IMAGE_DIR "selection-popup-bg.8.9.png", | |
| 96 | + DALI_IMAGE_DIR "selection-popup-bg.9.9.png", | |
| 97 | + DALI_IMAGE_DIR "selection-popup-bg.10.9.png", | |
| 98 | + DALI_IMAGE_DIR "selection-popup-bg.11.9.png", | |
| 99 | + DALI_IMAGE_DIR "selection-popup-bg.12.9.png", | |
| 100 | + DALI_IMAGE_DIR "selection-popup-bg.13.9.png", | |
| 101 | + DALI_IMAGE_DIR "selection-popup-bg.14.9.png", | |
| 102 | + DALI_IMAGE_DIR "selection-popup-bg.15.9.png", | |
| 103 | + DALI_IMAGE_DIR "selection-popup-bg.16.9.png", | |
| 104 | + DALI_IMAGE_DIR "selection-popup-bg.17.9.png", | |
| 105 | + DALI_IMAGE_DIR "selection-popup-bg.18.9.png", | |
| 106 | + DALI_IMAGE_DIR "selection-popup-bg.19.9.png", | |
| 107 | + DALI_IMAGE_DIR "selection-popup-bg.20.9.png", | |
| 108 | + DALI_IMAGE_DIR "selection-popup-bg.21.9.png", | |
| 109 | + DALI_IMAGE_DIR "selection-popup-bg.22.9.png", | |
| 110 | + DALI_IMAGE_DIR "selection-popup-bg.23.9.png", | |
| 111 | + DALI_IMAGE_DIR "selection-popup-bg.24.9.png", | |
| 112 | + DALI_IMAGE_DIR "selection-popup-bg.25.9.png", | |
| 113 | + DALI_IMAGE_DIR "selection-popup-bg.26.9.png", | |
| 114 | + DALI_IMAGE_DIR "selection-popup-bg.27.9.png", | |
| 115 | + DALI_IMAGE_DIR "selection-popup-bg.28.9.png", | |
| 116 | + DALI_IMAGE_DIR "selection-popup-bg.29.9.png", | |
| 117 | + DALI_IMAGE_DIR "selection-popup-bg.30.9.png", | |
| 118 | + DALI_IMAGE_DIR "selection-popup-bg.31.9.png", | |
| 119 | + DALI_IMAGE_DIR "selection-popup-bg.32.9.png", | |
| 120 | + DALI_IMAGE_DIR "selection-popup-bg.33.9.png", | |
| 121 | + DALI_IMAGE_DIR "button-disabled.9.png", | |
| 122 | + DALI_IMAGE_DIR "button-down.9.png", | |
| 123 | + DALI_IMAGE_DIR "button-down-disabled.9.png", | |
| 124 | + DALI_IMAGE_DIR "button-up-1.9.png", | |
| 125 | + DALI_IMAGE_DIR "button-up-2.9.png", | |
| 126 | + DALI_IMAGE_DIR "button-up-3.9.png", | |
| 127 | + DALI_IMAGE_DIR "button-up-4.9.png", | |
| 128 | + DALI_IMAGE_DIR "button-up-5.9.png", | |
| 129 | + DALI_IMAGE_DIR "button-up-6.9.png", | |
| 130 | + DALI_IMAGE_DIR "button-up-7.9.png", | |
| 131 | + DALI_IMAGE_DIR "button-up-8.9.png", | |
| 132 | + DALI_IMAGE_DIR "button-up-9.9.png", | |
| 133 | + DALI_IMAGE_DIR "button-up-10.9.png", | |
| 134 | + DALI_IMAGE_DIR "button-up-11.9.png", | |
| 135 | + DALI_IMAGE_DIR "button-up-12.9.png", | |
| 136 | + DALI_IMAGE_DIR "button-up-13.9.png", | |
| 137 | + DALI_IMAGE_DIR "button-up-14.9.png", | |
| 138 | + DALI_IMAGE_DIR "button-up-15.9.png", | |
| 139 | + DALI_IMAGE_DIR "button-up-16.9.png", | |
| 140 | + DALI_IMAGE_DIR "button-up-17.9.png", | |
| 141 | +}; | |
| 142 | + | |
| 87 | 143 | const unsigned int NUM_IMAGES = sizeof(IMAGE_PATH) / sizeof(char*); |
| 144 | +const unsigned int NUM_NINEPATCH_IMAGES = sizeof(NINEPATCH_IMAGE_PATH) / sizeof(char*); | |
| 88 | 145 | |
| 89 | 146 | const float ANIMATION_TIME ( 5.0f ); // animation length in seconds |
| 90 | 147 | |
| ... | ... | @@ -149,14 +206,25 @@ Geometry& QuadMesh() |
| 149 | 206 | return mesh; |
| 150 | 207 | } |
| 151 | 208 | |
| 209 | +bool gUseMesh(false); | |
| 210 | +bool gUseImageView(false); | |
| 211 | +bool gNinePatch(false); | |
| 212 | +unsigned int gRowsPerPage(25); | |
| 213 | +unsigned int gColumnsPerPage( 25 ); | |
| 214 | +unsigned int gPageCount(13); | |
| 215 | + | |
| 152 | 216 | Renderer CreateRenderer( unsigned int index ) |
| 153 | 217 | { |
| 154 | - static Renderer renderers[NUM_IMAGES]; | |
| 218 | + | |
| 219 | + int numImages = !gNinePatch ? NUM_IMAGES : NUM_NINEPATCH_IMAGES; | |
| 220 | + static Renderer* renderers = new Renderer[numImages]; | |
| 155 | 221 | if( !renderers[index] ) |
| 156 | 222 | { |
| 157 | 223 | //Create the renderer |
| 158 | 224 | Shader shader = Shader::New( VERTEX_SHADER_TEXTURE, FRAGMENT_SHADER_TEXTURE ); |
| 159 | - Image image = ResourceImage::New(IMAGE_PATH[index]); | |
| 225 | + | |
| 226 | + const char* imagePath = !gNinePatch ? IMAGE_PATH[index] : NINEPATCH_IMAGE_PATH[index]; | |
| 227 | + Image image = ResourceImage::New(imagePath); | |
| 160 | 228 | Sampler textureSampler = Sampler::New( image, "sTexture" ); |
| 161 | 229 | Material material = Material::New( shader ); |
| 162 | 230 | material.AddSampler(textureSampler); |
| ... | ... | @@ -174,13 +242,6 @@ Actor CreateMeshActor( unsigned int index) |
| 174 | 242 | return meshActor; |
| 175 | 243 | } |
| 176 | 244 | |
| 177 | -bool gUseMesh(false); | |
| 178 | -bool gUseImageView(false); | |
| 179 | -unsigned int gRowsPerPage(25); | |
| 180 | -unsigned int gColumnsPerPage( 25 ); | |
| 181 | -unsigned int gPageCount(13); | |
| 182 | - | |
| 183 | - | |
| 184 | 245 | } |
| 185 | 246 | // Test application to compare performance between ImageActor and ImageView |
| 186 | 247 | // 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); |
| 189 | 250 | // -p NumberOfPages (Modifies the nimber of pages ) |
| 190 | 251 | // --use-imageview ( Use ImageView instead of ImageActor ) |
| 191 | 252 | // --use-mesh ( Use new renderer API (as ImageView) but shares renderers between actors when possible ) |
| 253 | +// --use-nine-patch ( Use nine patch images ) | |
| 192 | 254 | |
| 193 | 255 | // |
| 194 | 256 | class Benchmark : public ConnectionTracker |
| ... | ... | @@ -248,6 +310,11 @@ public: |
| 248 | 310 | return true; |
| 249 | 311 | } |
| 250 | 312 | |
| 313 | + const char* ImagePath( int i ) | |
| 314 | + { | |
| 315 | + return !gNinePatch ? IMAGE_PATH[i % NUM_IMAGES] : NINEPATCH_IMAGE_PATH[i % NUM_NINEPATCH_IMAGES]; | |
| 316 | + } | |
| 317 | + | |
| 251 | 318 | void CreateImageActors() |
| 252 | 319 | { |
| 253 | 320 | Stage stage = Stage::GetCurrent(); |
| ... | ... | @@ -256,7 +323,7 @@ public: |
| 256 | 323 | |
| 257 | 324 | for( size_t i(0); i<actorCount; ++i ) |
| 258 | 325 | { |
| 259 | - Image image = ResourceImage::New(IMAGE_PATH[i % NUM_IMAGES]); | |
| 326 | + Image image = ResourceImage::New(ImagePath(i)); | |
| 260 | 327 | mActor[i] = ImageActor::New(image); |
| 261 | 328 | mActor[i].SetSize(Vector3(0.0f,0.0f,0.0f)); |
| 262 | 329 | mActor[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); |
| ... | ... | @@ -272,7 +339,7 @@ public: |
| 272 | 339 | |
| 273 | 340 | for( size_t i(0); i<actorCount; ++i ) |
| 274 | 341 | { |
| 275 | - Image image = ResourceImage::New(IMAGE_PATH[i % NUM_IMAGES]); | |
| 342 | + Image image = ResourceImage::New(ImagePath(i)); | |
| 276 | 343 | mImageView[i] = ImageView::New(image); |
| 277 | 344 | mImageView[i].SetSize(Vector3(0.0f,0.0f,0.0f)); |
| 278 | 345 | mImageView[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); |
| ... | ... | @@ -287,7 +354,8 @@ public: |
| 287 | 354 | mActor.resize(actorCount); |
| 288 | 355 | for( size_t i(0); i<actorCount; ++i ) |
| 289 | 356 | { |
| 290 | - mActor[i] = CreateMeshActor(i % NUM_IMAGES); | |
| 357 | + size_t numImages = !gNinePatch ? NUM_IMAGES : NUM_NINEPATCH_IMAGES; | |
| 358 | + mActor[i] = CreateMeshActor(i % numImages); | |
| 291 | 359 | mActor[i].SetSize(0.0f,0.0f,0.0f); |
| 292 | 360 | |
| 293 | 361 | stage.Add(mActor[i]); |
| ... | ... | @@ -472,6 +540,10 @@ int main( int argc, char **argv ) |
| 472 | 540 | { |
| 473 | 541 | gUseImageView = true; |
| 474 | 542 | } |
| 543 | + else if( arg.compare("--nine-patch" ) == 0) | |
| 544 | + { | |
| 545 | + gNinePatch = true; | |
| 546 | + } | |
| 475 | 547 | else if( arg.compare(0, 2, "-r" ) == 0) |
| 476 | 548 | { |
| 477 | 549 | gRowsPerPage = atoi( arg.substr( 2, arg.size()).c_str()); |
| ... | ... | @@ -484,8 +556,6 @@ int main( int argc, char **argv ) |
| 484 | 556 | { |
| 485 | 557 | gPageCount = atoi( arg.substr( 2, arg.size()).c_str()); |
| 486 | 558 | } |
| 487 | - | |
| 488 | - | |
| 489 | 559 | } |
| 490 | 560 | |
| 491 | 561 | RunTest( application ); | ... | ... |
resources/images/button-disabled.9.png
0 → 100644
783 Bytes
resources/images/button-down-disabled.9.png
0 → 100644
720 Bytes
resources/images/button-down.9.png
0 → 100644
844 Bytes
resources/images/button-up-1.9.png
0 → 100644
897 Bytes
resources/images/button-up-10.9.png
0 → 100644
943 Bytes
resources/images/button-up-11.9.png
0 → 100644
942 Bytes
resources/images/button-up-12.9.png
0 → 100644
939 Bytes
resources/images/button-up-13.9.png
0 → 100644
948 Bytes
resources/images/button-up-14.9.png
0 → 100644
934 Bytes
resources/images/button-up-15.9.png
0 → 100644
939 Bytes
resources/images/button-up-16.9.png
0 → 100644
953 Bytes
resources/images/button-up-17.9.png
0 → 100644
941 Bytes
resources/images/button-up-2.9.png
0 → 100644
997 Bytes
resources/images/button-up-3.9.png
0 → 100644
982 Bytes
resources/images/button-up-4.9.png
0 → 100644
982 Bytes
resources/images/button-up-5.9.png
0 → 100644
996 Bytes
resources/images/button-up-6.9.png
0 → 100644
989 Bytes
resources/images/button-up-7.9.png
0 → 100644
985 Bytes
resources/images/button-up-8.9.png
0 → 100644
983 Bytes
resources/images/button-up-9.9.png
0 → 100644
942 Bytes
resources/images/selection-popup-bg.1.9.png
0 → 100644
748 Bytes
resources/images/selection-popup-bg.10.9.png
0 → 100644
537 Bytes
resources/images/selection-popup-bg.11.9.png
0 → 100644
541 Bytes
resources/images/selection-popup-bg.12.9.png
0 → 100644
624 Bytes
resources/images/selection-popup-bg.13.9.png
0 → 100644
514 Bytes
resources/images/selection-popup-bg.14.9.png
0 → 100644
535 Bytes
resources/images/selection-popup-bg.15.9.png
0 → 100644
591 Bytes
resources/images/selection-popup-bg.16.9.png
0 → 100644
622 Bytes
resources/images/selection-popup-bg.17.9.png
0 → 100644
602 Bytes
resources/images/selection-popup-bg.18.9.png
0 → 100644
490 Bytes
resources/images/selection-popup-bg.19.9.png
0 → 100644
574 Bytes
resources/images/selection-popup-bg.2.9.png
0 → 100644
755 Bytes
resources/images/selection-popup-bg.20.9.png
0 → 100644
634 Bytes
resources/images/selection-popup-bg.21.9.png
0 → 100644
632 Bytes
resources/images/selection-popup-bg.22.9.png
0 → 100644
622 Bytes
resources/images/selection-popup-bg.23.9.png
0 → 100644
610 Bytes
resources/images/selection-popup-bg.24.9.png
0 → 100644
593 Bytes
resources/images/selection-popup-bg.25.9.png
0 → 100644
562 Bytes
resources/images/selection-popup-bg.26.9.png
0 → 100644
614 Bytes
resources/images/selection-popup-bg.27.9.png
0 → 100644
615 Bytes
resources/images/selection-popup-bg.28.9.png
0 → 100644
537 Bytes
resources/images/selection-popup-bg.29.9.png
0 → 100644
625 Bytes
resources/images/selection-popup-bg.3.9.png
0 → 100644
708 Bytes
resources/images/selection-popup-bg.30.9.png
0 → 100644
500 Bytes
resources/images/selection-popup-bg.31.9.png
0 → 100644
535 Bytes
resources/images/selection-popup-bg.32.9.png
0 → 100644
619 Bytes
resources/images/selection-popup-bg.33.9.png
0 → 100644
628 Bytes
resources/images/selection-popup-bg.4.9.png
0 → 100644
672 Bytes
resources/images/selection-popup-bg.5.9.png
0 → 100644
657 Bytes
resources/images/selection-popup-bg.6.9.png
0 → 100644
538 Bytes
resources/images/selection-popup-bg.7.9.png
0 → 100644
487 Bytes
resources/images/selection-popup-bg.8.9.png
0 → 100644
497 Bytes
resources/images/selection-popup-bg.9.9.png
0 → 100644
511 Bytes