Create 1 shared 1x1 white BitmapImage instead of 1 per item 31/31531/1 accepted/tizen/common/20141211.150204 accepted/tizen/mobile/20141216.080617 accepted/tizen/tv/20141215.043914 accepted/tizen/wearable/20141215.104627 submit/tizen/20141211.140945
authorAndrew Cox <andrew.cox@partner.samsung.com>
Fri, 5 Dec 2014 13:31:43 +0000 (13:31 +0000)
committerAndrew Cox <andrew.cox@partner.samsung.com>
Fri, 5 Dec 2014 13:34:45 +0000 (13:34 +0000)
The way this was written, we had hundreds of identical 1x1 BitmapImages
for item checkboxes live during a scroll.

Change-Id: I0529c803476103d8fbff3f1fb88b5d6d549ccbcc
Signed-off-by: Andrew Cox <andrew.cox@partner.samsung.com>
examples/item-view/item-view-example.cpp

index 9697cc72d0e67d15753173131482da95a7f8ab7c..b006c5feccba33fc099dc603940c5253e6ed2436 100644 (file)
@@ -349,6 +349,9 @@ public:
     // Set the title and icon to the current layout
     SetLayoutTitle();
     SetLayoutImage();
+
+    // Store one 1x1 white image for multiple items to share for backgrounds:
+    mWhiteImage = BitmapImage::WHITE();
   }
 
   Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocusNavigationDirection direction )
@@ -905,7 +908,7 @@ public: // From ItemFactory
 
     // Add a checkbox child actor; invisible until edit-mode is enabled
 
-    ImageActor checkbox = ImageActor::New( BitmapImage::WHITE() );
+    ImageActor checkbox = ImageActor::New( mWhiteImage );
     checkbox.SetName( "CheckBox" );
     checkbox.SetColor( Vector4(0.0f,0.0f,0.0f,0.6f) );
     checkbox.SetParentOrigin( ParentOrigin::TOP_RIGHT );
@@ -1131,6 +1134,7 @@ private:
 
   unsigned int mAlphaFuncIndex;
   TextView mAlphaFunctionText;
+  BitmapImage mWhiteImage;
 };
 
 void RunTest(Application& app)