+// Called by a Visual when it's resource is ready
+void Control::Impl::ResourceReady( Visual::Base& object)
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady replacements pending[%d]\n", mRemoveVisuals.Count() );
+
+ Actor self = mControlImpl.Self();
+
+ // A resource is ready, find resource in the registered visuals container and get its index
+ for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter )
+ {
+ Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
+
+ if( &object == ®isteredVisualImpl )
+ {
+ RegisteredVisualContainer::Iterator visualToRemoveIter;
+ // Find visual with the same index in the removal container
+ // Set if off stage as it's replacement is now ready.
+ // Remove if from removal list as now removed from stage.
+ // Set Pending flag on the ready visual to false as now ready.
+ if( FindVisual( (*registeredIter)->index, mRemoveVisuals, visualToRemoveIter ) )
+ {
+ (*registeredIter)->pending = false;
+ Toolkit::GetImplementation( (*visualToRemoveIter)->visual ).SetOffStage( self );
+ mRemoveVisuals.Erase( visualToRemoveIter );
+ }
+ break;
+ }
+ }
+
+ // A visual is ready so control may need relayouting if staged
+ if ( self.OnStage() )
+ {
+ mControlImpl.RelayoutRequest();
+ }
+
+ // Emit signal if all enabled visuals registered by the control are ready.
+ if( IsResourceReady() )
+ {
+ Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
+ mResourceReadySignal.Emit( handle );
+ }
+}
+
+bool Control::Impl::IsResourceReady() const
+{
+ // Iterate through and check all the enabled visuals are ready
+ for( auto visualIter = mVisuals.Begin();
+ visualIter != mVisuals.End(); ++visualIter )
+ {
+ const Toolkit::Visual::Base visual = (*visualIter)->visual;
+ const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+
+ // one of the enabled visuals is not ready
+ if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+Toolkit::Visual::ResourceStatus Control::Impl::GetVisualResourceStatus( Property::Index index ) const
+{
+ RegisteredVisualContainer::Iterator iter;
+ if ( FindVisual( index, mVisuals, iter ) )
+ {
+ const Toolkit::Visual::Base visual = (*iter)->visual;
+ const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+ return visualImpl.GetResourceStatus( );
+ }
+
+ return Toolkit::Visual::ResourceStatus::PREPARING;
+}
+