Commit 28854be72245e7687daa98e0e2e117d2f669154e

Authored by Tom Robinson
1 parent 19369b28

Geometry Batching

A reduction in GL calls can be observed when running the example with the following options for comparison:

DALI_GLES_CALL_TIME=1 DALI_GLES_CALL_TIME_ACCUMULATE=1 homescreen-benchmark.example –disable-icon-labels
&
DALI_GLES_CALL_TIME=1 DALI_GLES_CALL_TIME_ACCUMULATE=1 homescreen-benchmark.example –disable-icon-labels –disable-batching

                 W/O Batching      W/ Batching     % Improvement
Bind buffers       0.00             11.88             N/A
Bind textures      4.03              5.6             -26%
Draw calls        27.31             10.06            +63%
Uniform sets      53.88             10.06            +81%

Note: Larger improvements can be seen when the bottleneck is within the Render thread (instead of Update).

Change-Id: I294665299f2d7d8149563f1ea7fed730aed53da6
examples/homescreen-benchmark/homescreen-benchmark.cpp
1 1 /*
2   - * Copyright (c) 2014 Samsung Electronics Co., Ltd.
  2 + * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
... ... @@ -15,8 +15,9 @@
15 15 *
16 16 */
17 17  
  18 +// EXTERNAL INCLUDES
18 19 #include <dali-toolkit/dali-toolkit.h>
19   -
  20 +#include <sstream>
20 21 #include <iostream>
21 22  
22 23 using namespace Dali;
... ... @@ -24,319 +25,54 @@ using Dali::Toolkit::TextLabel;
24 25  
25 26 namespace
26 27 {
27   -const char* IMAGE_PATH[] = {
28   - DEMO_IMAGE_DIR "application-icon-0.png",
29   - DEMO_IMAGE_DIR "application-icon-100.png",
30   - DEMO_IMAGE_DIR "application-icon-101.png",
31   - DEMO_IMAGE_DIR "application-icon-102.png",
32   - DEMO_IMAGE_DIR "application-icon-103.png",
33   - DEMO_IMAGE_DIR "application-icon-104.png",
34   - DEMO_IMAGE_DIR "application-icon-105.png",
35   - DEMO_IMAGE_DIR "application-icon-106.png",
36   - DEMO_IMAGE_DIR "application-icon-107.png",
37   - DEMO_IMAGE_DIR "application-icon-108.png",
38   - DEMO_IMAGE_DIR "application-icon-109.png",
39   - DEMO_IMAGE_DIR "application-icon-10.png",
40   - DEMO_IMAGE_DIR "application-icon-110.png",
41   - DEMO_IMAGE_DIR "application-icon-111.png",
42   - DEMO_IMAGE_DIR "application-icon-112.png",
43   - DEMO_IMAGE_DIR "application-icon-113.png",
44   - DEMO_IMAGE_DIR "application-icon-114.png",
45   - DEMO_IMAGE_DIR "application-icon-115.png",
46   - DEMO_IMAGE_DIR "application-icon-116.png",
47   - DEMO_IMAGE_DIR "application-icon-117.png",
48   - DEMO_IMAGE_DIR "application-icon-118.png",
49   - DEMO_IMAGE_DIR "application-icon-119.png",
50   - DEMO_IMAGE_DIR "application-icon-11.png",
51   - DEMO_IMAGE_DIR "application-icon-120.png",
52   - DEMO_IMAGE_DIR "application-icon-121.png",
53   - DEMO_IMAGE_DIR "application-icon-122.png",
54   - DEMO_IMAGE_DIR "application-icon-123.png",
55   - DEMO_IMAGE_DIR "application-icon-124.png",
56   - DEMO_IMAGE_DIR "application-icon-125.png",
57   - DEMO_IMAGE_DIR "application-icon-126.png",
58   - DEMO_IMAGE_DIR "application-icon-127.png",
59   - DEMO_IMAGE_DIR "application-icon-128.png",
60   - DEMO_IMAGE_DIR "application-icon-129.png",
61   - DEMO_IMAGE_DIR "application-icon-12.png",
62   - DEMO_IMAGE_DIR "application-icon-130.png",
63   - DEMO_IMAGE_DIR "application-icon-131.png",
64   - DEMO_IMAGE_DIR "application-icon-132.png",
65   - DEMO_IMAGE_DIR "application-icon-133.png",
66   - DEMO_IMAGE_DIR "application-icon-134.png",
67   - DEMO_IMAGE_DIR "application-icon-135.png",
68   - DEMO_IMAGE_DIR "application-icon-136.png",
69   - DEMO_IMAGE_DIR "application-icon-137.png",
70   - DEMO_IMAGE_DIR "application-icon-138.png",
71   - DEMO_IMAGE_DIR "application-icon-139.png",
72   - DEMO_IMAGE_DIR "application-icon-13.png",
73   - DEMO_IMAGE_DIR "application-icon-140.png",
74   - DEMO_IMAGE_DIR "application-icon-141.png",
75   - DEMO_IMAGE_DIR "application-icon-142.png",
76   - DEMO_IMAGE_DIR "application-icon-143.png",
77   - DEMO_IMAGE_DIR "application-icon-144.png",
78   - DEMO_IMAGE_DIR "application-icon-145.png",
79   - DEMO_IMAGE_DIR "application-icon-146.png",
80   - DEMO_IMAGE_DIR "application-icon-147.png",
81   - DEMO_IMAGE_DIR "application-icon-14.png",
82   - DEMO_IMAGE_DIR "application-icon-15.png",
83   - DEMO_IMAGE_DIR "application-icon-16.png",
84   - DEMO_IMAGE_DIR "application-icon-17.png",
85   - DEMO_IMAGE_DIR "application-icon-18.png",
86   - DEMO_IMAGE_DIR "application-icon-19.png",
87   - DEMO_IMAGE_DIR "application-icon-1.png",
88   - DEMO_IMAGE_DIR "application-icon-20.png",
89   - DEMO_IMAGE_DIR "application-icon-21.png",
90   - DEMO_IMAGE_DIR "application-icon-22.png",
91   - DEMO_IMAGE_DIR "application-icon-23.png",
92   - DEMO_IMAGE_DIR "application-icon-24.png",
93   - DEMO_IMAGE_DIR "application-icon-25.png",
94   - DEMO_IMAGE_DIR "application-icon-26.png",
95   - DEMO_IMAGE_DIR "application-icon-27.png",
96   - DEMO_IMAGE_DIR "application-icon-28.png",
97   - DEMO_IMAGE_DIR "application-icon-29.png",
98   - DEMO_IMAGE_DIR "application-icon-2.png",
99   - DEMO_IMAGE_DIR "application-icon-30.png",
100   - DEMO_IMAGE_DIR "application-icon-31.png",
101   - DEMO_IMAGE_DIR "application-icon-32.png",
102   - DEMO_IMAGE_DIR "application-icon-33.png",
103   - DEMO_IMAGE_DIR "application-icon-34.png",
104   - DEMO_IMAGE_DIR "application-icon-35.png",
105   - DEMO_IMAGE_DIR "application-icon-36.png",
106   - DEMO_IMAGE_DIR "application-icon-37.png",
107   - DEMO_IMAGE_DIR "application-icon-38.png",
108   - DEMO_IMAGE_DIR "application-icon-39.png",
109   - DEMO_IMAGE_DIR "application-icon-3.png",
110   - DEMO_IMAGE_DIR "application-icon-40.png",
111   - DEMO_IMAGE_DIR "application-icon-41.png",
112   - DEMO_IMAGE_DIR "application-icon-42.png",
113   - DEMO_IMAGE_DIR "application-icon-43.png",
114   - DEMO_IMAGE_DIR "application-icon-44.png",
115   - DEMO_IMAGE_DIR "application-icon-45.png",
116   - DEMO_IMAGE_DIR "application-icon-46.png",
117   - DEMO_IMAGE_DIR "application-icon-47.png",
118   - DEMO_IMAGE_DIR "application-icon-48.png",
119   - DEMO_IMAGE_DIR "application-icon-49.png",
120   - DEMO_IMAGE_DIR "application-icon-4.png",
121   - DEMO_IMAGE_DIR "application-icon-50.png",
122   - DEMO_IMAGE_DIR "application-icon-51.png",
123   - DEMO_IMAGE_DIR "application-icon-52.png",
124   - DEMO_IMAGE_DIR "application-icon-53.png",
125   - DEMO_IMAGE_DIR "application-icon-54.png",
126   - DEMO_IMAGE_DIR "application-icon-55.png",
127   - DEMO_IMAGE_DIR "application-icon-56.png",
128   - DEMO_IMAGE_DIR "application-icon-57.png",
129   - DEMO_IMAGE_DIR "application-icon-58.png",
130   - DEMO_IMAGE_DIR "application-icon-59.png",
131   - DEMO_IMAGE_DIR "application-icon-5.png",
132   - DEMO_IMAGE_DIR "application-icon-60.png",
133   - DEMO_IMAGE_DIR "application-icon-61.png",
134   - DEMO_IMAGE_DIR "application-icon-62.png",
135   - DEMO_IMAGE_DIR "application-icon-63.png",
136   - DEMO_IMAGE_DIR "application-icon-64.png",
137   - DEMO_IMAGE_DIR "application-icon-65.png",
138   - DEMO_IMAGE_DIR "application-icon-66.png",
139   - DEMO_IMAGE_DIR "application-icon-67.png",
140   - DEMO_IMAGE_DIR "application-icon-68.png",
141   - DEMO_IMAGE_DIR "application-icon-69.png",
142   - DEMO_IMAGE_DIR "application-icon-6.png",
143   - DEMO_IMAGE_DIR "application-icon-70.png",
144   - DEMO_IMAGE_DIR "application-icon-71.png",
145   - DEMO_IMAGE_DIR "application-icon-72.png",
146   - DEMO_IMAGE_DIR "application-icon-73.png",
147   - DEMO_IMAGE_DIR "application-icon-74.png",
148   - DEMO_IMAGE_DIR "application-icon-75.png",
149   - DEMO_IMAGE_DIR "application-icon-76.png",
150   - DEMO_IMAGE_DIR "application-icon-77.png",
151   - DEMO_IMAGE_DIR "application-icon-78.png",
152   - DEMO_IMAGE_DIR "application-icon-79.png",
153   - DEMO_IMAGE_DIR "application-icon-7.png",
154   - DEMO_IMAGE_DIR "application-icon-80.png",
155   - DEMO_IMAGE_DIR "application-icon-81.png",
156   - DEMO_IMAGE_DIR "application-icon-82.png",
157   - DEMO_IMAGE_DIR "application-icon-83.png",
158   - DEMO_IMAGE_DIR "application-icon-84.png",
159   - DEMO_IMAGE_DIR "application-icon-85.png",
160   - DEMO_IMAGE_DIR "application-icon-86.png",
161   - DEMO_IMAGE_DIR "application-icon-87.png",
162   - DEMO_IMAGE_DIR "application-icon-88.png",
163   - DEMO_IMAGE_DIR "application-icon-89.png",
164   - DEMO_IMAGE_DIR "application-icon-8.png",
165   - DEMO_IMAGE_DIR "application-icon-90.png",
166   - DEMO_IMAGE_DIR "application-icon-91.png",
167   - DEMO_IMAGE_DIR "application-icon-92.png",
168   - DEMO_IMAGE_DIR "application-icon-93.png",
169   - DEMO_IMAGE_DIR "application-icon-94.png",
170   - DEMO_IMAGE_DIR "application-icon-95.png",
171   - DEMO_IMAGE_DIR "application-icon-96.png",
172   - DEMO_IMAGE_DIR "application-icon-97.png",
173   - DEMO_IMAGE_DIR "application-icon-98.png",
174   - DEMO_IMAGE_DIR "application-icon-99.png",
175   - DEMO_IMAGE_DIR "application-icon-9.png",
176   - NULL
177   -};
  28 +
  29 +const char* IMAGE_PATH_PREFIX ( DEMO_IMAGE_DIR "application-icon-" );
  30 +const char* IMAGE_PATH_POSTFIX ( ".png" );
  31 +const int TOTAL_ICON_DEFINITIONS ( 147 );
  32 +
  33 +const char* BACKGROUND_IMAGE ( DEMO_IMAGE_DIR "background-3.jpg" );
  34 +const float PAGE_SCALE_FACTOR_X ( 0.95f );
  35 +const float PAGE_SCALE_FACTOR_Y ( 0.95f );
  36 +const float PAGE_DURATION_SCALE_FACTOR ( 10.0f ); ///< Time-scale factor, larger = animation is slower
  37 +
  38 +const float DEFAULT_OPT_ROW_COUNT ( 5 );
  39 +const float DEFAULT_OPT_COL_COUNT ( 4 );
  40 +const float DEFAULT_OPT_PAGE_COUNT ( 10 );
  41 +const bool DEFAULT_OPT_USE_TABLEVIEW ( true );
  42 +const bool DEFAULT_OPT_BATCHING_ENABLED ( true );
  43 +const bool DEFAULT_OPT_ICON_LABELS ( true );
  44 +
  45 +// The image/label area tries to make sure the positioning will be relative to previous sibling
  46 +const float IMAGE_AREA ( 0.60f );
  47 +const float LABEL_AREA ( 0.50f );
178 48  
179 49 /**
180   - * Random words used as unique application names
  50 + * Random words used as unique application names.
  51 + * The number matches the value of TOTAL_ICON_DEFINITIONS.
181 52 */
182 53 const char* DEMO_APPS_NAMES[] =
183 54 {
184   - "Achdyer",
185   - "Achtortor",
186   - "Ackirlor",
187   - "Ackptin",
188   - "Aighte",
189   - "Akala",
190   - "Alealdny",
191   - "Angash",
192   - "Anglor",
193   - "Anveraugh",
194   - "Ardangas",
195   - "Ardug",
196   - "Ardworu",
197   - "Ascerald",
198   - "Ash'ach",
199   - "Athiund",
200   - "Aughm",
201   - "Aughtheryer",
202   - "Awitad",
203   - "Banengon",
204   - "Banhinat",
205   - "Belrisash",
206   - "Bilorm",
207   - "Bleustcer",
208   - "Bliagelor",
209   - "Blorynton",
210   - "Booten",
211   - "Bripolqua",
212   - "Bryray",
213   - "Burust",
214   - "Cataikel",
215   - "Cerilwar",
216   - "Cerl",
217   - "Certin",
218   - "Checerper",
219   - "Chegit",
220   - "Cheirat",
221   - "Che'rak",
222   - "Cheves",
223   - "Chiperath",
224   - "Chralerack",
225   - "Chram",
226   - "Clyimen",
227   - "Coqueang",
228   - "Craennther",
229   - "Cykage",
230   - "Dalek",
231   - "Darhkel",
232   - "Daril",
233   - "Darpban",
234   - "Dasrad",
235   - "Deeqskel",
236   - "Delurnther",
237   - "Denalda",
238   - "Derynkel",
239   - "Deurnos",
240   - "Doyaryke",
241   - "Draithon",
242   - "Drantess",
243   - "Druardny",
244   - "Dynsaytor",
245   - "Dytinris",
246   - "Eeni",
247   - "Elmryn",
248   - "Emgha",
249   - "Emiton",
250   - "Emworeng",
251   - "Endnys",
252   - "Enessray",
253   - "Engyer",
254   - "En'rady",
255   - "Enthount",
256   - "Enundem",
257   - "Essina",
258   - "Faughald",
259   - "Fiummos",
260   - "Garash",
261   - "Garight",
262   - "Garrynath",
263   - "Ghalora",
264   - "Ghatan",
265   - "Gibanis",
266   - "Hatdyn",
267   - "Heesban",
268   - "Hesub",
269   - "Hinkelenth",
270   - "Hirryer",
271   - "Ideinta",
272   - "Im'eld",
273   - "Ina'ir",
274   - "Ing'moro",
275   - "Ingormess",
276   - "Ingshy",
277   - "Issath",
278   - "Issendris",
279   - "Issey",
280   - "Issum",
281   - "Itenthbel",
282   - "K'ackves",
283   - "Kagdra",
284   - "Kalbankim",
285   - "Kal'enda",
286   - "Kimest",
287   - "Kimundeng",
288   - "Koachlor",
289   - "Kuren",
290   - "Kygver",
291   - "Kyning",
292   - "Laiyach",
293   - "Lasuzu",
294   - "Lekew",
295   - "Lerengom",
296   - "Lertan",
297   - "Liadem",
298   - "Liathar",
299   - "Liephden",
300   - "Likellor",
301   - "Loightmos",
302   - "Loromum",
303   - "Lorr",
304   - "Lortas",
305   - "Lyerr",
306   - "Maustbur",
307   - "Menvor",
308   - "Meusten",
309   - "Mirodskel",
310   - "Morhatrod",
311   - "Moserbel",
312   - "Mosorrad",
313   - "Mosraye",
314   - "Mosth",
315   - "Neabar",
316   - "Neerdem",
317   - "Nichqua",
318   - "Nudraough",
319   - "Nuyim",
320   - "Nycha",
321   - "Nyia",
322   - "Nyjac",
323   - "Nystondar",
324   - "Okine",
325   - "Oldit",
326   - "Om'mose",
327   - "Onye",
328   - "Ososrak",
329   - "Pecertin",
330   - "Perrd",
331   - "Phutorny",
332   - "Puizlye",
333   - "Quirantai",
334   - NULL
  55 + "Achdyer", "Aughm", "Cerl", "Daril", "Emgha", "Ghatan", "Issum", "Lertan", "Mosorrad",
  56 + "Achtortor", "Aughtheryer", "Certin", "Darpban", "Emiton", "Gibanis", "Itenthbel", "Liadem", "Mosraye",
  57 + "Ackirlor", "Awitad", "Checerper", "Dasrad", "Emworeng", "Hatdyn", "K'ackves", "Liathar", "Mosth",
  58 + "Ackptin", "Banengon", "Chegit", "Deeqskel", "Endnys", "Heesban", "Kagdra", "Liephden", "Neabar",
  59 + "Aighte", "Banhinat", "Cheirat", "Delurnther", "Enessray", "Hesub", "Kalbankim", "Likellor", "Neerdem",
  60 + "Akala", "Belrisash", "Che'rak", "Denalda", "Engyer", "Hinkelenth", "Kal'enda", "Loightmos", "Nichqua",
  61 + "Alealdny", "Bilorm", "Cheves", "Derynkel", "En'rady", "Hirryer", "Kimest", "Loromum", "Nudraough",
  62 + "Angash", "Bleustcer", "Chiperath", "Deurnos", "Enthount", "Ideinta", "Kimundeng", "Lorr", "Nuyim",
  63 + "Anglor", "Bliagelor", "Chralerack", "Doyaryke", "Enundem", "Im'eld", "Koachlor", "Lortas", "Nycha",
  64 + "Anveraugh", "Blorynton", "Chram", "Draithon", "Essina", "Ina'ir", "Kuren", "Lyerr", "Nyia",
  65 + "Ardangas", "Booten", "Clyimen", "Drantess", "Faughald", "Ing'moro", "Kygver", "Maustbur", "Nyjac",
  66 + "Ardug", "Bripolqua", "Coqueang", "Druardny", "Fiummos", "Ingormess", "Kyning", "Menvor", "Nystondar",
  67 + "Ardworu", "Bryray", "Craennther", "Dynsaytor", "Garash", "Ingshy", "Laiyach", "Meusten", "Okine",
  68 + "Ascerald", "Burust", "Cykage", "Dytinris", "Garight", "Issath", "Lasuzu", "Mirodskel", "Oldit",
  69 + "Ash'ach", "Cataikel", "Dalek", "Eeni", "Garrynath", "Issendris", "Lekew", "Morhatrod", "Om'mose",
  70 + "Athiund", "Cerilwar", "Darhkel", "Elmryn", "Ghalora", "Issey", "Lerengom", "Moserbel", "Onye",
  71 + "Ososrak", "Pecertin", "Perrd"
335 72 };
336 73  
337   -// this code comes from command-line-options.cpp. the reason it's here is to
338   -// keep consistent the extra-help formatting when '--help' used
339   -
  74 +// This code comes from command-line-options.cpp. the reason it's here is to
  75 +// keep consistent the extra-help formatting when '--help' used.
340 76 void PrintHelp( const char * const opt, const char * const optDescription)
341 77 {
342 78 const std::ios_base::fmtflags flags = std::cout.flags();
... ... @@ -348,74 +84,70 @@ void PrintHelp( const char * const opt, const char * const optDescription)
348 84 std::cout.flags( flags );
349 85 }
350 86  
351   -const float PAGE_SCALE_FACTOR_X ( 0.95f );
352   -const float PAGE_SCALE_FACTOR_Y ( 0.95f );
353   -const float PAGE_DURATION_SCALE_FACTOR ( 2.0f ); // time-scale factor, larger = animation is slower
354   -
355   -const float DEFAULT_OPT_ROW_COUNT ( 5 );
356   -const float DEFAULT_OPT_COL_COUNT ( 4 );
357   -const float DEFAULT_OPT_PAGE_COUNT ( 10 );
358   -const bool DEFAULT_OPT_USETABLEVIEW ( false );
359   -
360 87 }
361 88  
362   -// This example is a benchmark that mimics the paged applications list of the homescreen app
363   -//
  89 +/**
  90 + * @brief This example is a benchmark that mimics the paged applications list of the homescreen application.
  91 + */
364 92 class HomescreenBenchmark : public ConnectionTracker
365 93 {
366 94 public:
367 95  
368 96 // Config structure passed to the constructor. It makes easier to increase number
369   - // of setup parameters if needed
  97 + // of setup parameters if needed.
370 98 struct Config
371 99 {
372 100 Config() :
373 101 mRows( DEFAULT_OPT_ROW_COUNT ),
374 102 mCols( DEFAULT_OPT_COL_COUNT ),
375 103 mPageCount( DEFAULT_OPT_PAGE_COUNT ),
376   - mUseTableView( DEFAULT_OPT_USETABLEVIEW )
  104 + mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ),
  105 + mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ),
  106 + mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS )
377 107 {
378 108 }
379 109  
380   - int mRows;
381   - int mCols;
382   - int mPageCount;
383   - bool mUseTableView;
  110 + int mRows;
  111 + int mCols;
  112 + int mPageCount;
  113 + bool mTableViewEnabled;
  114 + bool mBatchingEnabled;
  115 + bool mIconLabelsEnabled;
384 116 };
385 117  
386 118 // animation script data
387 119 struct ScriptData
388 120 {
389 121 ScriptData( int pages, float duration, bool flick )
  122 + : mPages( pages ),
  123 + mDuration( duration ),
  124 + mFlick( flick )
390 125 {
391   - mPages = pages;
392   - mDuration = duration;
393   - mFlick = flick;
394 126 }
395 127  
396   - int mPages; // number of pages to scroll
397   - float mDuration; // duration
398   - bool mFlick; // use flick or 'one-by-one' scroll
  128 + int mPages; ///< Number of pages to scroll
  129 + float mDuration; ///< Duration
  130 + bool mFlick; ///< Use flick or 'one-by-one' scroll
399 131 };
400 132  
401 133 HomescreenBenchmark( Application& application, const Config& config )
402 134 : mApplication( application ),
403 135 mConfig( config ),
  136 + mScriptFrame( 0 ),
404 137 mCurrentPage( 0 )
405 138 {
406   - // Connect to the Application's Init signal
  139 + // Connect to the Application's Init signal.
407 140 mApplication.InitSignal().Connect( this, &HomescreenBenchmark::Create );
408 141 }
409 142  
410 143 ~HomescreenBenchmark()
411 144 {
412   - // Nothing to do here;
413 145 }
414 146  
415   - // The Init signal is received once (only) during the Application lifetime
  147 + // The Init signal is received once (only) during the Application lifetime.
416 148 void Create( Application& application )
417 149 {
418   - // create benchmark script
  150 + // Create benchmark script
419 151 CreateScript();
420 152  
421 153 // Get a handle to the stage
... ... @@ -427,35 +159,37 @@ public:
427 159 mScrollParent.SetParentOrigin( ParentOrigin::CENTER );
428 160  
429 161 // create background
430   - Toolkit::ImageView background = Toolkit::ImageView::New( DEMO_IMAGE_DIR "background-3.jpg");
431   - Stage::GetCurrent().Add(background);
  162 + Toolkit::ImageView background = Toolkit::ImageView::New( BACKGROUND_IMAGE );
  163 + Stage::GetCurrent().Add( background );
432 164 background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
433 165 background.SetAnchorPoint( AnchorPoint::CENTER );
434 166 background.SetParentOrigin( ParentOrigin::CENTER );
435 167  
436 168 PopulatePages();
437 169  
438   - stage.Add(mScrollParent);
  170 + stage.Add( mScrollParent );
439 171  
440   - // Respond to a click anywhere on the stage
  172 + // Respond to a click anywhere on the stage.
441 173 stage.GetRootLayer().TouchSignal().Connect( this, &HomescreenBenchmark::OnTouch );
442 174 }
443 175  
444 176 bool OnTouch( Actor actor, const TouchData& touch )
445 177 {
446   - // quit the application
  178 + // Quit the application.
447 179 mApplication.Quit();
448 180 return true;
449 181 }
450 182  
451 183 Actor AddPage()
452 184 {
453   - // create root page actor
  185 + // Create root page actor.
454 186 Actor pageActor;
455 187  
456   - if( mConfig.mUseTableView )
  188 + if( mConfig.mTableViewEnabled )
457 189 {
458 190 Toolkit::TableView tableView = Toolkit::TableView::New( mConfig.mRows, mConfig.mCols );
  191 +
  192 + // Create geometry batcher for table view.
459 193 tableView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.5f ) );
460 194 pageActor = tableView;
461 195 }
... ... @@ -468,38 +202,33 @@ public:
468 202 pageActor.SetParentOrigin( ParentOrigin::CENTER );
469 203 pageActor.SetAnchorPoint( AnchorPoint::CENTER );
470 204 pageActor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
471   - pageActor.SetSizeModeFactor(Vector3( PAGE_SCALE_FACTOR_X, PAGE_SCALE_FACTOR_Y, 1.0f ) );
  205 + pageActor.SetSizeModeFactor( Vector3( PAGE_SCALE_FACTOR_X, PAGE_SCALE_FACTOR_Y, 1.0f ) );
472 206 return pageActor;
473 207 }
474 208  
475   - void AddIconsToPage(Actor page)
  209 + void AddIconsToPage( Actor page )
476 210 {
477 211 Size stageSize( Stage::GetCurrent().GetSize() );
478 212 const float scaledHeight = stageSize.y * PAGE_SCALE_FACTOR_Y;
479 213 const float scaledWidth = stageSize.x * PAGE_SCALE_FACTOR_X;
480   -
481 214 const float PADDING = stageSize.y / 64.0f;
482   - const float ROW_HEIGHT = ( scaledHeight - (PADDING*2.0f) ) / (float)mConfig.mRows;
483   - const float COL_WIDTH = ( scaledWidth - (PADDING*2.0f) ) / (float)mConfig.mCols;
  215 + const float ROW_HEIGHT = ( scaledHeight - (PADDING*2.0f) ) / static_cast<float>( mConfig.mRows );
  216 + const float COL_WIDTH = ( scaledWidth - (PADDING*2.0f) ) / static_cast<float>( mConfig.mCols );
484 217  
485   - // the image/label area tries to make sure the positioning will be relative to previous sibling
486   - const float IMAGE_AREA = 0.60f;
487   - const float LABEL_AREA = 0.50f;
  218 + Vector2 dpi = Stage::GetCurrent().GetDpi();
488 219  
489 220 static int currentIconIndex = 0;
490 221  
491   - Vector2 dpi = Stage::GetCurrent().GetDpi();
492   -
493 222 for( int y = 0; y < mConfig.mRows; ++y )
494 223 {
495 224 for( int x = 0; x < mConfig.mCols; ++x )
496 225 {
497   - // create parent icon view
  226 + // Create parent icon view
498 227 Toolkit::Control iconView = Toolkit::Control::New();
499 228 iconView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
500 229 iconView.SetParentOrigin( ParentOrigin::TOP_LEFT );
501 230  
502   - if( !mConfig.mUseTableView )
  231 + if( !mConfig.mTableViewEnabled )
503 232 {
504 233 float rowX = x * COL_WIDTH + PADDING;
505 234 float rowY = y * ROW_HEIGHT + PADDING;
... ... @@ -512,31 +241,45 @@ public:
512 241 iconView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
513 242 }
514 243  
515   - // create image view
516   - Toolkit::ImageView imageView = Toolkit::ImageView::New( IMAGE_PATH[currentIconIndex] );
  244 + // Create empty image to avoid early renderer creation
  245 + Toolkit::ImageView imageView = Toolkit::ImageView::New();
  246 +
  247 + // Auto-generate the Icons image URL.
  248 + Property::Map map;
  249 + std::stringstream imagePath;
  250 + imagePath << IMAGE_PATH_PREFIX << currentIconIndex << IMAGE_PATH_POSTFIX;
  251 + map[ Dali::Toolkit::BatchImageVisual::Property::URL ] = imagePath.str();
  252 +
  253 + // Enable/disable batching
  254 + map[ Toolkit::Visual::Property::BATCHING_ENABLED ] = mConfig.mBatchingEnabled;
  255 +
  256 + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
517 257 imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
518 258 imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
519 259 imageView.SetAnchorPoint( AnchorPoint::CENTER );
520 260 imageView.SetParentOrigin( ParentOrigin::CENTER );
521   - imageView.SetSizeModeFactor( Vector3(IMAGE_AREA, IMAGE_AREA, 1.0f) );
  261 + imageView.SetSizeModeFactor( Vector3( IMAGE_AREA, IMAGE_AREA, 1.0f ) );
522 262  
523   - // create label
524   - Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( DEMO_APPS_NAMES[currentIconIndex] );
525   - textLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER );
526   - textLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
527   -
528   - textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
529   - textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
530   - textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, (((float)( ROW_HEIGHT * LABEL_AREA ) * 72.0f) / (dpi.y))*0.25f );
531   - textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
532   - textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" );
  263 + if( mConfig.mIconLabelsEnabled )
  264 + {
  265 + // create label
  266 + Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( DEMO_APPS_NAMES[currentIconIndex] );
  267 + textLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER );
  268 + textLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
  269 + textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
  270 + textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // White.
  271 + textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f );
  272 + textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
  273 + textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" );
  274 + imageView.Add( textLabel );
  275 + }
533 276  
534 277 iconView.Add( imageView );
535   - imageView.Add( textLabel );
  278 + page.Add( iconView );
536 279  
537   - page.Add(iconView);
538   -
539   - if( !IMAGE_PATH[ ++currentIconIndex ] )
  280 + // We only have images and names for a certain number of icons.
  281 + // Wrap around if we have used them all.
  282 + if( ++currentIconIndex == TOTAL_ICON_DEFINITIONS )
540 283 {
541 284 currentIconIndex = 0;
542 285 }
... ... @@ -546,58 +289,62 @@ public:
546 289  
547 290 void CreateScript()
548 291 {
549   - const int lastPage = mConfig.mPageCount-1;
550   - const int halfA = lastPage/2;
551   - const int halfB = lastPage/2 + lastPage%2;
552   - mScriptFrameData.push_back( ScriptData( lastPage, 1.5f, true));
553   - mScriptFrameData.push_back( ScriptData( -lastPage, 1.5f, true ));
554   - mScriptFrameData.push_back( ScriptData( halfA, 1.0f, true ));
555   - mScriptFrameData.push_back( ScriptData( halfB, 1.0f, true ));
556   - mScriptFrameData.push_back( ScriptData( -lastPage, 0.5f, false ));
557   - mScriptFrameData.push_back( ScriptData( halfA, 0.5f, false ));
558   - mScriptFrameData.push_back( ScriptData( halfB, 1.0f, true ));
559   - mScriptFrameData.push_back( ScriptData( -halfA, 1.0f, true ));
560   - mScriptFrameData.push_back( ScriptData( 1, 0.1f, true ));
561   - mScriptFrameData.push_back( ScriptData( -1, 0.1f, true ));
562   - mScriptFrameData.push_back( ScriptData( 1, 0.1f, true ));
563   - mScriptFrameData.push_back( ScriptData( -1, 0.1f, true ));
564   - mScriptFrameData.push_back( ScriptData( 1, 0.1f, true ));
565   - mScriptFrameData.push_back( ScriptData( -1, 0.1f, true ));
566   - mScriptFrameData.push_back( ScriptData( halfA, 1.0f, true ));
  292 + const int lastPage = mConfig.mPageCount - 1;
  293 + const int halfA = lastPage / 2;
  294 + const int halfB = lastPage / 2 + lastPage % 2;
  295 + mScriptFrameData.push_back( ScriptData( lastPage, 1.5f, true ) );
  296 + mScriptFrameData.push_back( ScriptData( -lastPage, 1.5f, true ) );
  297 + mScriptFrameData.push_back( ScriptData( halfA, 1.0f, true ) );
  298 + mScriptFrameData.push_back( ScriptData( halfB, 1.0f, true ) );
  299 + mScriptFrameData.push_back( ScriptData( -lastPage, 0.5f, false ) );
  300 + mScriptFrameData.push_back( ScriptData( halfA, 0.5f, false ) );
  301 + mScriptFrameData.push_back( ScriptData( halfB, 1.0f, true ) );
  302 + mScriptFrameData.push_back( ScriptData( -halfA, 1.0f, true ) );
  303 + mScriptFrameData.push_back( ScriptData( 1, 0.1f, true ) );
  304 + mScriptFrameData.push_back( ScriptData( -1, 0.1f, true ) );
  305 + mScriptFrameData.push_back( ScriptData( 1, 0.1f, true ) );
  306 + mScriptFrameData.push_back( ScriptData( -1, 0.1f, true ) );
  307 + mScriptFrameData.push_back( ScriptData( 1, 0.1f, true ) );
  308 + mScriptFrameData.push_back( ScriptData( -1, 0.1f, true ) );
  309 + mScriptFrameData.push_back( ScriptData( halfA, 1.0f, true ) );
567 310 }
568 311  
569 312 void PopulatePages()
570 313 {
571 314 Vector3 stageSize( Stage::GetCurrent().GetSize() );
572   - const float SCALED_HEIGHT = stageSize.y * PAGE_SCALE_FACTOR_Y;
573 315  
574 316 for( int i = 0; i < mConfig.mPageCount; ++i )
575 317 {
576   - // create page
  318 + // Create page.
577 319 Actor page = AddPage();
578 320  
579   - // populate icons
580   - AddIconsToPage(page);
  321 + // Populate icons.
  322 + AddIconsToPage( page );
581 323  
582   - // move page 'a little bit up'
  324 + // Move page 'a little bit up'.
583 325 page.SetParentOrigin( ParentOrigin::CENTER );
584 326 page.SetAnchorPoint( AnchorPoint::CENTER );
585   - page.SetPosition( Vector3(stageSize.x*i, -0.30f*( stageSize.y-SCALED_HEIGHT ), 0.0f) );
  327 + page.SetPosition( Vector3( stageSize.x * i, 0.0f, 0.0f ) );
586 328 mScrollParent.Add( page );
  329 +
  330 + if( mConfig.mTableViewEnabled && mConfig.mBatchingEnabled )
  331 + {
  332 + page.SetProperty( Actor::Property::BATCH_PARENT, true );
  333 + }
587 334 }
588 335  
589   - mScrollParent.SetOpacity( 0.0f );
590   - mScrollParent.SetScale( Vector3(0.0f, 0.0f, 0.0f) );
  336 + mScrollParent.SetOpacity( 1.0f );
  337 + mScrollParent.SetScale( Vector3::ONE );
591 338  
592   - // fade in
  339 + // Fade in.
593 340 ShowAnimation();
594 341 }
595 342  
596 343 void ShowAnimation()
597 344 {
598   - mShowAnimation = Animation::New(1.0f);
599   - mShowAnimation.AnimateTo( Property(mScrollParent, Actor::Property::COLOR_ALPHA), 1.0f, AlphaFunction::EASE_IN_OUT );
600   - mShowAnimation.AnimateTo( Property(mScrollParent, Actor::Property::SCALE), Vector3(1.0f, 1.0f, 1.0f), AlphaFunction::EASE_IN_OUT );
  345 + mShowAnimation = Animation::New( 1.0f );
  346 + mShowAnimation.AnimateTo( Property( mScrollParent, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN_OUT );
  347 + mShowAnimation.AnimateTo( Property( mScrollParent, Actor::Property::SCALE ), Vector3::ONE, AlphaFunction::EASE_IN_OUT );
601 348 mShowAnimation.FinishedSignal().Connect( this, &HomescreenBenchmark::OnAnimationEnd );
602 349 mShowAnimation.Play();
603 350 }
... ... @@ -606,16 +353,17 @@ public:
606 353 {
607 354 duration *= PAGE_DURATION_SCALE_FACTOR;
608 355 Vector3 stageSize( Stage::GetCurrent().GetSize() );
609   - mScrollAnimation = Animation::New(duration);
  356 + mScrollAnimation = Animation::New( duration );
610 357 if( flick )
611 358 {
612   - mScrollAnimation.AnimateBy( Property(mScrollParent, Actor::Property::POSITION), Vector3(-stageSize.x*pages, 0.0f, 0.0f), AlphaFunction::EASE_IN_OUT );
  359 + mScrollAnimation.AnimateBy( Property( mScrollParent, Actor::Property::POSITION ), Vector3( -stageSize.x * pages, 0.0f, 0.0f ), AlphaFunction::EASE_IN_OUT );
613 360 }
614 361 else
615 362 {
616   - for( int i = 0; i < abs(pages); ++i )
  363 + int totalPages = abs( pages );
  364 + for( int i = 0; i < totalPages; ++i )
617 365 {
618   - mScrollAnimation.AnimateBy( Property(mScrollParent, Actor::Property::POSITION), Vector3(pages < 0 ? stageSize.x : -stageSize.x, 0.0f, 0.0f), AlphaFunction::EASE_IN_OUT, TimePeriod(duration*i, duration) );
  366 + mScrollAnimation.AnimateBy( Property( mScrollParent, Actor::Property::POSITION ), Vector3( pages < 0 ? stageSize.x : -stageSize.x, 0.0f, 0.0f ), AlphaFunction::EASE_IN_OUT, TimePeriod( duration * i, duration ) );
619 367 }
620 368 }
621 369 mScrollAnimation.FinishedSignal().Connect( this, &HomescreenBenchmark::OnAnimationEnd );
... ... @@ -625,13 +373,7 @@ public:
625 373  
626 374 void OnAnimationEnd( Animation& source )
627 375 {
628   - if( source == mShowAnimation )
629   - {
630   - ScriptData& frame = mScriptFrameData[0];
631   - ScrollPages( frame.mPages, frame.mDuration, frame.mFlick );
632   - mScriptFrame = 1;
633   - }
634   - else if( mScriptFrame < mScriptFrameData.size() && source == mScrollAnimation )
  376 + if( mScriptFrame < mScriptFrameData.size() )
635 377 {
636 378 ScriptData& frame = mScriptFrameData[mScriptFrame];
637 379 ScrollPages( frame.mPages, frame.mDuration, frame.mFlick );
... ... @@ -644,18 +386,14 @@ public:
644 386 }
645 387  
646 388 private:
647   - Application& mApplication;
648 389  
  390 + Application& mApplication;
649 391 Actor mScrollParent;
650   -
651 392 Animation mShowAnimation;
652 393 Animation mScrollAnimation;
653   -
654 394 Config mConfig;
655   -
656 395 std::vector<ScriptData> mScriptFrameData;
657 396 size_t mScriptFrame;
658   -
659 397 int mCurrentPage;
660 398 };
661 399  
... ... @@ -665,26 +403,27 @@ void RunTest( Application&amp; application, const HomescreenBenchmark::Config&amp; confi
665 403  
666 404 if( printHelpAndExit )
667 405 {
668   - PrintHelp( "c<num>", " Number of columns");
669   - PrintHelp( "r<num>", " Number of rows");
670   - PrintHelp( "p<num>", " Number of pages ( must be greater than 1 )");
671   - PrintHelp( "-use-tableview", " Uses TableView for layouting");
  406 + PrintHelp( "c<num>", " Number of columns" );
  407 + PrintHelp( "r<num>", " Number of rows" );
  408 + PrintHelp( "p<num>", " Number of pages ( must be greater than 1 )" );
  409 + PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting (must be enabled for batching)" );
  410 + PrintHelp( "-disable-batching", " Disables geometry batching" );
  411 + PrintHelp( "-disable-icon-labels", " Disables labels for each icon" );
672 412 return;
673 413 }
674 414  
675 415 application.MainLoop();
676 416 }
677 417  
678   -// Entry point for Linux & Tizen applications
679   -//
  418 +// Entry point for Linux & Tizen applications.
680 419 int DALI_EXPORT_API main( int argc, char **argv )
681 420 {
682   - // default settings
  421 + // Default settings.
683 422 HomescreenBenchmark::Config config;
684 423  
685 424 bool printHelpAndExit = false;
686 425  
687   - for( int i(1) ; i < argc; ++i )
  426 + for( int i = 1 ; i < argc; ++i )
688 427 {
689 428 std::string arg( argv[i] );
690 429 if( arg.compare( 0, 2, "-r" ) == 0 )
... ... @@ -699,15 +438,22 @@ int DALI_EXPORT_API main( int argc, char **argv )
699 438 {
700 439 config.mPageCount = atoi( arg.substr( 2 ).c_str() );
701 440 }
702   - else if( arg.compare( "--use-tableview" ) == 0 )
  441 + else if( arg.compare( "--disable-tableview" ) == 0 )
  442 + {
  443 + config.mTableViewEnabled = false;
  444 + }
  445 + else if( arg.compare( "--disable-batching" ) == 0 )
703 446 {
704   - config.mUseTableView = true;
  447 + config.mBatchingEnabled = false;
  448 + }
  449 + else if( arg.compare( "--disable-icon-labels" ) == 0 )
  450 + {
  451 + config.mIconLabelsEnabled = false;
705 452 }
706 453 else if( arg.compare( "--help" ) == 0 )
707 454 {
708 455 printHelpAndExit = true;
709 456 }
710   -
711 457 }
712 458  
713 459 Application application = Application::New( &argc, &argv );
... ...