Commit 2567061a91613e24c06300cf75f4953117b7f119
Committed by
Tom Robinson
1 parent
5fb28e6d
Update the homescreen benchmark to use text visuals.
Change-Id: I155be5a4dda65b3d8886d30961857f0f9743d592 Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
Showing
1 changed file
with
44 additions
and
13 deletions
examples/homescreen-benchmark/homescreen-benchmark.cpp
| @@ -21,6 +21,10 @@ | @@ -21,6 +21,10 @@ | ||
| 21 | #include <sstream> | 21 | #include <sstream> |
| 22 | #include <iostream> | 22 | #include <iostream> |
| 23 | 23 | ||
| 24 | +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h> | ||
| 25 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | ||
| 26 | +#include <dali-toolkit/devel-api/visuals/text-visual-properties.h> | ||
| 27 | + | ||
| 24 | using namespace Dali; | 28 | using namespace Dali; |
| 25 | using Dali::Toolkit::TextLabel; | 29 | using Dali::Toolkit::TextLabel; |
| 26 | 30 | ||
| @@ -48,6 +52,7 @@ const bool DEFAULT_OPT_USE_TABLEVIEW ( true ); | @@ -48,6 +52,7 @@ const bool DEFAULT_OPT_USE_TABLEVIEW ( true ); | ||
| 48 | const bool DEFAULT_OPT_BATCHING_ENABLED ( true ); | 52 | const bool DEFAULT_OPT_BATCHING_ENABLED ( true ); |
| 49 | const bool DEFAULT_OPT_ICON_LABELS ( true ); | 53 | const bool DEFAULT_OPT_ICON_LABELS ( true ); |
| 50 | const IconType DEFAULT_OPT_ICON_TYPE ( IMAGEVIEW ); | 54 | const IconType DEFAULT_OPT_ICON_TYPE ( IMAGEVIEW ); |
| 55 | +const bool DEFAULT_OPT_USE_TEXT_LABEL ( false ); | ||
| 51 | 56 | ||
| 52 | // The image/label area tries to make sure the positioning will be relative to previous sibling | 57 | // The image/label area tries to make sure the positioning will be relative to previous sibling |
| 53 | const float IMAGE_AREA ( 0.60f ); | 58 | const float IMAGE_AREA ( 0.60f ); |
| @@ -113,7 +118,8 @@ public: | @@ -113,7 +118,8 @@ public: | ||
| 113 | mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ), | 118 | mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ), |
| 114 | mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ), | 119 | mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ), |
| 115 | mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS ), | 120 | mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS ), |
| 116 | - mIconType( DEFAULT_OPT_ICON_TYPE ) | 121 | + mIconType( DEFAULT_OPT_ICON_TYPE ), |
| 122 | + mUseTextLabel( DEFAULT_OPT_USE_TEXT_LABEL ) | ||
| 117 | { | 123 | { |
| 118 | } | 124 | } |
| 119 | 125 | ||
| @@ -124,6 +130,7 @@ public: | @@ -124,6 +130,7 @@ public: | ||
| 124 | bool mBatchingEnabled; | 130 | bool mBatchingEnabled; |
| 125 | bool mIconLabelsEnabled; | 131 | bool mIconLabelsEnabled; |
| 126 | IconType mIconType; | 132 | IconType mIconType; |
| 133 | + bool mUseTextLabel; | ||
| 127 | }; | 134 | }; |
| 128 | 135 | ||
| 129 | // animation script data | 136 | // animation script data |
| @@ -253,7 +260,7 @@ public: | @@ -253,7 +260,7 @@ public: | ||
| 253 | return button; | 260 | return button; |
| 254 | } | 261 | } |
| 255 | 262 | ||
| 256 | - void AddIconsToPage( Actor page ) | 263 | + void AddIconsToPage( Actor page, bool useTextLabel ) |
| 257 | { | 264 | { |
| 258 | Size stageSize( Stage::GetCurrent().GetSize() ); | 265 | Size stageSize( Stage::GetCurrent().GetSize() ); |
| 259 | const float scaledHeight = stageSize.y * PAGE_SCALE_FACTOR_Y; | 266 | const float scaledHeight = stageSize.y * PAGE_SCALE_FACTOR_Y; |
| @@ -307,15 +314,34 @@ public: | @@ -307,15 +314,34 @@ public: | ||
| 307 | if( mConfig.mIconLabelsEnabled ) | 314 | if( mConfig.mIconLabelsEnabled ) |
| 308 | { | 315 | { |
| 309 | // create label | 316 | // create label |
| 310 | - Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( DEMO_APPS_NAMES[currentIconIndex] ); | ||
| 311 | - textLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | ||
| 312 | - textLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | ||
| 313 | - textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); | ||
| 314 | - textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // White. | ||
| 315 | - textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f ); | ||
| 316 | - textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | ||
| 317 | - textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" ); | ||
| 318 | - icon.Add( textLabel ); | 317 | + if( useTextLabel ) |
| 318 | + { | ||
| 319 | + Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( DEMO_APPS_NAMES[currentIconIndex] ); | ||
| 320 | + textLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | ||
| 321 | + textLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | ||
| 322 | + textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); | ||
| 323 | + textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // White. | ||
| 324 | + textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f ); | ||
| 325 | + textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | ||
| 326 | + textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" ); | ||
| 327 | + icon.Add( textLabel ); | ||
| 328 | + } | ||
| 329 | + else | ||
| 330 | + { | ||
| 331 | + Property::Map map; | ||
| 332 | + map.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT ). | ||
| 333 | + Add( Toolkit::TextVisual::Property::TEXT, DEMO_APPS_NAMES[currentIconIndex] ). | ||
| 334 | + Add( Toolkit::TextVisual::Property::TEXT_COLOR, Color::WHITE ). | ||
| 335 | + Add( Toolkit::TextVisual::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f ). | ||
| 336 | + Add( Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT, "CENTER" ). | ||
| 337 | + Add( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, "TOP" ); | ||
| 338 | + | ||
| 339 | + Toolkit::Control control = Toolkit::Control::New(); | ||
| 340 | + control.SetProperty( Toolkit::Control::Property::BACKGROUND, map ); | ||
| 341 | + control.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | ||
| 342 | + control.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | ||
| 343 | + icon.Add( control ); | ||
| 344 | + } | ||
| 319 | } | 345 | } |
| 320 | 346 | ||
| 321 | iconView.Add( icon ); | 347 | iconView.Add( icon ); |
| @@ -363,7 +389,7 @@ public: | @@ -363,7 +389,7 @@ public: | ||
| 363 | Actor page = AddPage(); | 389 | Actor page = AddPage(); |
| 364 | 390 | ||
| 365 | // Populate icons. | 391 | // Populate icons. |
| 366 | - AddIconsToPage( page ); | 392 | + AddIconsToPage( page, mConfig.mUseTextLabel ); |
| 367 | 393 | ||
| 368 | // Move page 'a little bit up'. | 394 | // Move page 'a little bit up'. |
| 369 | page.SetParentOrigin( ParentOrigin::CENTER ); | 395 | page.SetParentOrigin( ParentOrigin::CENTER ); |
| @@ -454,6 +480,7 @@ void RunTest( Application& application, const HomescreenBenchmark::Config& confi | @@ -454,6 +480,7 @@ void RunTest( Application& application, const HomescreenBenchmark::Config& confi | ||
| 454 | PrintHelp( "-disable-batching", " Disables geometry batching" ); | 480 | PrintHelp( "-disable-batching", " Disables geometry batching" ); |
| 455 | PrintHelp( "-disable-icon-labels", " Disables labels for each icon" ); | 481 | PrintHelp( "-disable-icon-labels", " Disables labels for each icon" ); |
| 456 | PrintHelp( "-use-checkbox", " Uses checkboxes for icons" ); | 482 | PrintHelp( "-use-checkbox", " Uses checkboxes for icons" ); |
| 483 | + PrintHelp( "-use-text-label", " Uses TextLabel instead of a TextVisual" ); | ||
| 457 | return; | 484 | return; |
| 458 | } | 485 | } |
| 459 | 486 | ||
| @@ -499,7 +526,11 @@ int DALI_EXPORT_API main( int argc, char **argv ) | @@ -499,7 +526,11 @@ int DALI_EXPORT_API main( int argc, char **argv ) | ||
| 499 | { | 526 | { |
| 500 | config.mIconType = CHECKBOX; | 527 | config.mIconType = CHECKBOX; |
| 501 | } | 528 | } |
| 502 | - else if ( arg.compare( "--help" ) == 0 ) | 529 | + else if( arg.compare("--use-text-label" ) == 0) |
| 530 | + { | ||
| 531 | + config.mUseTextLabel = true; | ||
| 532 | + } | ||
| 533 | + else if( arg.compare( "--help" ) == 0 ) | ||
| 503 | { | 534 | { |
| 504 | printHelpAndExit = true; | 535 | printHelpAndExit = true; |
| 505 | } | 536 | } |