From ccd53048e482f41b00ad1daa7664b3781d6b7626 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 9 Nov 2016 18:32:36 +0000 Subject: [PATCH] Removed VisualBase::RemoveAndReset() method. This method is no longer required - in general, for new controls, RegisterVisual will perform the required task of ensuring SetOffStage() is called for visuals that get replaced. Change-Id: I64ad3f527676ee875e8c622c536d446f0d9f04b7 Signed-off-by: David Steele --- .../src/dali-toolkit/utc-Dali-SuperBlurView.cpp | 63 ++++++++++++++++++++-- .../src/dali-toolkit/utc-Dali-VideoView.cpp | 2 +- .../src/dali-toolkit/utc-Dali-Visual.cpp | 40 -------------- .../devel-api/visual-factory/visual-base.cpp | 9 ---- .../devel-api/visual-factory/visual-base.h | 9 ---- .../super-blur-view/super-blur-view-impl.cpp | 8 ++- .../controls/video-view/video-view-impl.cpp | 7 ++- .../internal/visuals/visual-factory-impl.h | 10 +++- dali-toolkit/public-api/controls/control-impl.cpp | 18 ++++--- 9 files changed, 89 insertions(+), 77 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp index 3c121c0..20d5f44 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -223,14 +223,71 @@ int UtcDaliSuperBlurViewSetImage(void) Wait(application); DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION ); - application.SendNotification(); - application.Render(); + Wait(application); + Stage::GetCurrent().Remove( blurView ); + } + + END_TEST; +} + +int UtcDaliSuperBlurViewSetImage2(void) +{ + ToolkitTestApplication application; + Stage stage = Stage::GetCurrent(); + + tet_infoline(" UtcDaliSuperBlurViewSetImage2 - test setting a second image "); + + SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); + blurView.SetSize( 100.f, 100.f ); + + tet_infoline("Call SetImage and add blurview to stage"); + Image inputImage = CreateSolidColorImage( application, Color::GREEN, 50, 50 ); + blurView.SetImage( inputImage ); + + // start multiple guassian blur call, each guassian blur creates two render tasks + DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2); + { + // create image renderers for the original image and each blurred image + stage.Add( blurView ); + Wait(application); + DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION ); + + tet_infoline("Wait for a second to allow blur to finish"); + Wait(application, 1000); + + tet_infoline("Remove from stage"); Stage::GetCurrent().Remove( blurView ); } + tet_infoline("Test that there are no render tasks remaining"); + DALI_TEST_EQUALS(blurView.GetRendererCount(), 0, TEST_LOCATION ); + + tet_infoline("Call SetImage a second time and add blurview back to stage"); + Image inputImage2 = CreateSolidColorImage( application, Color::CYAN, 50, 50 ); + blurView.SetImage( inputImage2 ); + // start multiple guassian blur call, each guassian blur creates two render tasks + DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2); + + { + // create image renderers for the original image and each blurred image + Stage::GetCurrent().Add( blurView ); + Wait(application); + DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION ); + + tet_infoline("Wait for a second to allow blur to finish"); + Wait(application, 1000); + + tet_infoline("Remove from stage"); + Stage::GetCurrent().Remove( blurView ); + } + + tet_infoline("Test that there are no render tasks remaining"); + DALI_TEST_EQUALS(blurView.GetRendererCount(), 0, TEST_LOCATION ); + END_TEST; } + int UtcDaliSuperBlurViewSetProperty(void) { ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 21e201b..d6128c5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -129,7 +129,7 @@ int UtcDaliVideoViewProperty1b(void) view.SetProperty( VideoView::Property::VIDEO, Property::Map() .Add("rendererType", "IMAGE") .Add("url", "video.mpg") // Note, videoView doesn't use this url - .Add("RENDERER_TARGET", "windowSurfaceTarget" ) + .Add("RENDERING_TARGET", "windowSurfaceTarget" ) .Add("width", 100) .Add("height", 100) ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 75b4838..8a70c7d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -321,46 +321,6 @@ int UtcDaliVisualSetOnOffStage(void) END_TEST; } -int UtcDaliVisualRemoveAndReset(void) -{ - ToolkitTestApplication application; - tet_infoline( "intUtcDaliVisualRemoveAndReset" ); - - VisualFactory factory = VisualFactory::Get(); - - DummyControl actor = DummyControl::New(); - DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); - - actor.SetSize(200.f, 200.f); - Stage::GetCurrent().Add( actor ); - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - - Visual::Base imageVisual; - // test calling RemoveAndReset with an empty handle - try - { - imageVisual.RemoveAndReset( actor ); - tet_result(TET_PASS); - } - catch (DaliException& exception) - { - tet_result(TET_FAIL); - } - - Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200)); - imageVisual = factory.CreateVisual(image); - dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, imageVisual ); - DALI_TEST_CHECK( imageVisual ); - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); - - imageVisual.RemoveAndReset( actor ); - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); // visual is removed from actor - DALI_TEST_CHECK( !imageVisual ); // visual is reset - - END_TEST; -} int UtcDaliVisualGetPropertyMap1(void) { diff --git a/dali-toolkit/devel-api/visual-factory/visual-base.cpp b/dali-toolkit/devel-api/visual-factory/visual-base.cpp index f2f2f8c..c5b822d 100644 --- a/dali-toolkit/devel-api/visual-factory/visual-base.cpp +++ b/dali-toolkit/devel-api/visual-factory/visual-base.cpp @@ -91,15 +91,6 @@ float Visual::Base::GetDepthIndex() const return GetImplementation( *this ).GetDepthIndex(); } -void Visual::Base::RemoveAndReset( Actor& actor ) -{ - if( actor && *this ) - { - GetImplementation(*this).SetOffStage( actor ); - } - Reset(); -} - void Visual::Base::CreatePropertyMap( Property::Map& map ) const { GetImplementation( *this ).CreatePropertyMap( map ); diff --git a/dali-toolkit/devel-api/visual-factory/visual-base.h b/dali-toolkit/devel-api/visual-factory/visual-base.h index 4196276..7cfadbf 100644 --- a/dali-toolkit/devel-api/visual-factory/visual-base.h +++ b/dali-toolkit/devel-api/visual-factory/visual-base.h @@ -177,15 +177,6 @@ public: float GetDepthIndex() const; /** - * @brief Remove the renderer from the actor and reset the visual self. - * - * This function can be called with an empty handle. If the visual is empty, this is a no-op. - * - * @param[in] actor The actor to be set off stage. - */ - void RemoveAndReset( Actor& actor ); - - /** * @brief Create the property map representing this visual. * * @param[out] map The visual property map. diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index 305db7d..3141edc 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp @@ -172,9 +172,8 @@ void SuperBlurView::SetImage(Image inputImage) mInputImage = inputImage; Actor self( Self() ); - mVisuals[0].RemoveAndReset( self ); mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage ); - RegisterVisual( 0, mVisuals[0] ); + RegisterVisual( 0, mVisuals[0] ); // Will clean up previously registered visuals for this index. mVisuals[0].SetDepthIndex(0); SetShaderEffect( mVisuals[0] ); @@ -282,9 +281,8 @@ void SuperBlurView::OnSizeSet( const Vector3& targetSize ) mBlurredImage[i-1] = FrameBufferImage::New( mTargetSize.width/std::pow(2.f,exponent) , mTargetSize.height/std::pow(2.f,exponent), GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT ); - mVisuals[i].RemoveAndReset( self ); - mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] ); - RegisterVisual( i, mVisuals[i] ); + mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] ); + RegisterVisual( i, mVisuals[i] ); // Will clean up existing visual with same index. mVisuals[i].SetDepthIndex( i ); SetShaderEffect( mVisuals[i] ); } diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index bd03bf2..51bf9a2 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -506,7 +506,12 @@ void VideoView::SetWindowSurfaceTarget() int curPos = mVideoPlayer.GetPlayPosition(); mSetRenderingTarget = true; - mVisual.RemoveAndReset( self ); + + if( mVisual ) + { + Toolkit::GetImplementation(mVisual).SetOffStage(self); + mVisual.Reset(); + } mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); mVideoPlayer.SetUrl( mUrl ); diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.h b/dali-toolkit/internal/visuals/visual-factory-impl.h index d3a28d0..030512e 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.h +++ b/dali-toolkit/internal/visuals/visual-factory-impl.h @@ -105,7 +105,10 @@ private: template< class ParameterType0, class ParameterType1 > void InitializeVisual( Actor& actor, Toolkit::Visual::Base& visual, ParameterType0& param0, ParameterType1& param1 ) { - visual.RemoveAndReset( actor ); + if( actor ) + { + Toolkit::GetImplementation(visual).SetOffStage( actor ); + } visual = Toolkit::VisualFactory::Get().CreateVisual( param0, param1 ); if( visual && actor && actor.OnStage() ) { @@ -125,7 +128,10 @@ void InitializeVisual( Actor& actor, Toolkit::Visual::Base& visual, ParameterTyp template< class ParameterType > void InitializeVisual( Actor& actor, Toolkit::Visual::Base& visual, ParameterType& param ) { - visual.RemoveAndReset( actor ); + if( actor && visual ) + { + Toolkit::GetImplementation(visual).SetOffStage( actor ); + } visual = Toolkit::VisualFactory::Get().CreateVisual( param ); if( visual && actor && actor.OnStage() ) { diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 7444e44..ec56a2f 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -597,8 +597,12 @@ void Control::SetBackgroundImage( Image image ) void Control::ClearBackground() { - Actor self( Self() ); - mImpl->mBackgroundVisual.RemoveAndReset( self ); + if( mImpl->mBackgroundVisual ) + { + Actor self( Self() ); + Toolkit::GetImplementation( mImpl->mBackgroundVisual ).SetOffStage( self ); + mImpl->mBackgroundVisual.Reset(); + } mImpl->mBackgroundColor = Color::TRANSPARENT; } @@ -779,11 +783,11 @@ 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 ) ) + { + mImpl->mVisuals.Erase( iter ); + } } Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const -- 2.7.4