From: Agnelo Vaz Date: Fri, 11 Nov 2016 11:42:01 +0000 (+0000) Subject: Control::UnregisterVisual does not remove renderers from actor X-Git-Tag: dali_1.2.15~15^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=f4a28993f3f77f15015e5c9b4e1bedd06e23b926;hp=ccd53048e482f41b00ad1daa7664b3781d6b7626 Control::UnregisterVisual does not remove renderers from actor Adding test to prove renderer is removed when removing a visual from the stage (via it's control). Change-Id: I15442793e7715ba7b1c7660b306919be6bd9be1d --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 343b930..afb82a9 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -478,8 +478,9 @@ int UtcDaliControlBackgroundProperties(void) // Deprecated Properties control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW ); - DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >() == Color::YELLOW ); - DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >() == control.GetBackgroundColor() ); + DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW , TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION ); + control.ClearBackground(); Property::Map deprecatedImageMap; @@ -487,7 +488,8 @@ int UtcDaliControlBackgroundProperties(void) control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap ); propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE ); resultMap = propValue.GetMap(); - DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >() == "TestImage" ); + DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION ); + control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap ); DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 2ed0c4c..4a29efc 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -1118,11 +1118,23 @@ int UtcDaliControlImplRegisterUnregisterVisual(void) // Register index with a color visual dummyImpl.RegisterVisual( index, visual ); + tet_infoline( "Add control with visual to stage and check renderer count is 1" ); + Stage::GetCurrent().Add( dummy ); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual ); + DALI_TEST_EQUALS( dummy.GetRendererCount(), 1, TEST_LOCATION ); // Unregister visual dummyImpl.UnregisterVisual( index ); + tet_infoline( "Remove control with visual from stage and check renderer count is 0" ); + Stage::GetCurrent().Remove( dummy ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( dummy.GetRendererCount(), 0, TEST_LOCATION ); DALI_TEST_CHECK( !dummyImpl.GetVisual( index ) ); END_TEST; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 8a70c7d..c0bb0b1 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -1630,3 +1630,50 @@ int UtcDaliGradientVisualBlendMode(void) END_TEST; } + +int UtcDaliVisualRendererRemovalAndReAddition(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualRendererRemoval" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base visual = factory.CreateVisual( propertyMap ); + + visual.SetDepthIndex( 1.f ); + + DummyControl dummyControl = DummyControl::New(); + DummyControlImpl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); + DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION ); + + dummyControl.SetSize(200.f, 200.f); + tet_infoline( "Add control with visual to stage and check renderer count is 1" ); + + Stage::GetCurrent().Add( dummyControl ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION ); + + tet_infoline( "Remove control with visual from stage and check renderer count is 0" ); + Stage::GetCurrent().Remove( dummyControl ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION ); + + tet_infoline( "Re-add control with visual to stage and check renderer count is still 1" ); + + Stage::GetCurrent().Add( dummyControl ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index ec56a2f..f777b00 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -599,8 +599,7 @@ void Control::ClearBackground() { if( mImpl->mBackgroundVisual ) { - Actor self( Self() ); - Toolkit::GetImplementation( mImpl->mBackgroundVisual ).SetOffStage( self ); + UnregisterVisual( Toolkit::Control::Property::BACKGROUND ); mImpl->mBackgroundVisual.Reset(); } mImpl->mBackgroundColor = Color::TRANSPARENT; @@ -783,11 +782,14 @@ void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visu void Control::UnregisterVisual( Property::Index index ) { - RegisteredVisualContainer::Iterator iter; - if ( FindVisual( index, mImpl->mVisuals, iter ) ) - { - mImpl->mVisuals.Erase( iter ); - } + RegisteredVisualContainer::Iterator iter; + if ( FindVisual( index, mImpl->mVisuals, iter ) ) + { + Actor self( Self() ); + Toolkit::GetImplementation((*iter)->visual).SetOffStage( self ); + (*iter)->visual.Reset(); + mImpl->mVisuals.Erase( iter ); + } } Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const