From: thothamon Date: Thu, 10 May 2018 14:05:36 +0000 (+0100) Subject: Add check for whether the Renderer has been created. X-Git-Tag: dali_1.3.25~7^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=35ee945a45d0f0d2db4a3db2e66074bf2926b1ab Add check for whether the Renderer has been created. - the Renderer is not created until after an actor has been added to the Stage - add test case 'UtcDaliImageVisualAnimateOpacity02' which checks whether the Renderer is resident before the actor is staged but after a transition has been created. Change-Id: Ib9d450d98d8c482ff3396ddaea7b2e720d385d4e --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp index 8b17338..5cbfc89 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp @@ -890,6 +890,95 @@ int UtcDaliImageVisualAnimateOpacity(void) END_TEST; } + + +int UtcDaliImageVisualAnimateOpacity02(void) +{ + ToolkitTestApplication application; + tet_infoline( "Animate image visual opacity" ); + + application.GetPlatform().SetClosestImageSize( Vector2(100, 100) ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE); + propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert("opacity", 0.5f); + propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true); + Visual::Base visual = factory.CreateVisual( propertyMap ); + + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); + + actor.SetSize(2000, 2000); + actor.SetParentOrigin(ParentOrigin::CENTER); + actor.SetColor(Color::BLACK); + + tet_infoline( "Test that the opacity doesn't animate when actor not staged" ); + + Property::Array array; + + Property::Map map; + map["target"] = "testVisual"; + map["property"] = "opacity"; + map["initialValue"] = 0.0f; + map["targetValue"] = 1.0f; + map["animator"] = Property::Map() + .Add("alphaFunction", "LINEAR") + .Add("timePeriod", Property::Map() + .Add("delay", 0.0f) + .Add("duration", 4.0f)); + + Property::Map map2; + map2["target"] = "testVisual"; + map2["property"] = "size"; + map2["targetValue"] = Vector2(1.0f, 1.0f); + + array.Add( map ).Add(map2); + + Dali::Toolkit::TransitionData transition = TransitionData::New( array ); + Animation animation = dummyImpl.CreateTransition( transition ); + + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); // Ensure animation starts + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); + + animation = dummyImpl.CreateTransition( transition ); + animation.Play(); + + application.SendNotification(); + application.Render(0); // Ensure animation starts + application.Render(2000u); // Halfway point through animation + application.SendNotification(); // Handle any signals + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::ON, TEST_LOCATION ); + + Vector4 color; + DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) ); + DALI_TEST_EQUALS( color.a, 0.5f, TEST_LOCATION ); + + application.Render(2001u); // end + application.SendNotification(); // ensure animation finished signal is sent + + DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) ); + DALI_TEST_EQUALS( color.a, 1.0f, TEST_LOCATION ); + + blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE ); + DALI_TEST_EQUALS( blendModeValue.Get(), (int)BlendMode::AUTO, TEST_LOCATION ); + + END_TEST; +} + + + int UtcDaliImageVisualAnimatePixelArea(void) { ToolkitTestApplication application; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index af3aac4..5619cd9 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -736,6 +736,7 @@ Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& visual.GetName().c_str(), typeInfo?typeInfo.GetName().c_str():"Unknown" ); #endif Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual ); + visualImpl.AnimateProperty( transition, *animator ); } else diff --git a/dali-toolkit/internal/visuals/visual-base-impl.cpp b/dali-toolkit/internal/visuals/visual-base-impl.cpp index 064b13d..3dad561 100755 --- a/dali-toolkit/internal/visuals/visual-base-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-impl.cpp @@ -699,17 +699,20 @@ void Visual::Base::SetupBlendMode( Animation& transition, bool isInitialOpaque, // turned off after the animation ends if the final value is opaque if( ! isInitialOpaque || mImpl->mMixColor.a < 1.0f ) { - mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); - - if( animating == true && mImpl->mMixColor.a >= 1.0f ) + if( mImpl->mRenderer ) { - // When it becomes opaque, set the blend mode back to automatically - if( ! mImpl->mBlendSlotDelegate ) + mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); + + if( animating == true && mImpl->mMixColor.a >= 1.0f ) { - mImpl->mBlendSlotDelegate = new SlotDelegate(this); + // When it becomes opaque, set the blend mode back to automatically + if( ! mImpl->mBlendSlotDelegate ) + { + mImpl->mBlendSlotDelegate = new SlotDelegate(this); + } + transition.FinishedSignal().Connect( *(mImpl->mBlendSlotDelegate), + &Visual::Base::OnMixColorFinished ); } - transition.FinishedSignal().Connect( *(mImpl->mBlendSlotDelegate), - &Visual::Base::OnMixColorFinished ); } } } diff --git a/dali-toolkit/internal/visuals/visual-base-impl.h b/dali-toolkit/internal/visuals/visual-base-impl.h index 00c397d..4839551 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.h +++ b/dali-toolkit/internal/visuals/visual-base-impl.h @@ -217,6 +217,9 @@ public: * If the visual isn't staged (i.e. it doesn't have a renderer), * then this will not add an animation. * + * If the animator is valid and the transition handle is empty - it will + * be created. + * * @param[in] transition The animation to create or attach to * @param[in] animator The animation parameters of the property. */