{
TestApplication application;
- Handle handle = WeightObject::New();;
+ Handle handle = WeightObject::New();
DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
+ // process the message so scene object is added to update manager
+ application.SendNotification();
+ application.Render(0);
+
+ // no message to release scene object in this scenario
+
+ END_TEST;
+}
+
+int UtcDaliHandleWeightNew2(void)
+{
+ TestApplication application;
+
+ // scope for the weight object
+ {
+ Handle handle = WeightObject::New();
+ DALI_TEST_CHECK( handle.GetProperty<float>(WeightObject::WEIGHT) == 0.0f );
+
+ // process the message so scene object is added to update manager
+ application.SendNotification();
+ application.Render(0);
+ }
+ // handle out of scope so object gets destroyed
+ // process the message so update manager destroys the scene object
+ application.SendNotification();
+ application.Render(0);
+
END_TEST;
}
#define __DALI_OWNER_CONTAINER_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
}
/**
+ * Erase an object from OwnerContainer
+ * @param object to remove
+ */
+ inline void EraseObject( T object )
+ {
+ DALI_ASSERT_DEBUG( object && "NULL object not allowed" );
+
+ Iterator iter = Vector< T >::Begin();
+ const ConstIterator endIter = Vector< T >::End();
+ for ( ; iter != endIter; ++iter )
+ {
+ if ( *iter == object )
+ {
+ Erase( iter );
+ return;
+ }
+ }
+ }
+
+ /**
* Release the ownership of an object, without deleting it.
* @param[in] position A dereferencable iterator to an element in mContainer.
* @post iterators are invalidated by this method.
void RemoveRenderTracker( Render::RenderTracker* renderTracker )
{
- DALI_ASSERT_DEBUG( renderTracker != NULL );
- for(RenderTrackerIter iter = mRenderTrackers.Begin(), end = mRenderTrackers.End(); iter != end; ++iter)
- {
- if( *iter == renderTracker )
- {
- mRenderTrackers.Erase( iter );
- break;
- }
- }
+ mRenderTrackers.EraseObject( renderTracker );
}
void UpdateTrackers()
void RenderManager::RemoveRenderer( Render::Renderer* renderer )
{
- DALI_ASSERT_DEBUG( NULL != renderer );
-
- RendererOwnerContainer& renderers = mImpl->rendererContainer;
-
- // Find the renderer
- for ( RendererOwnerIter iter = renderers.Begin(); iter != renderers.End(); ++iter )
- {
- if ( *iter == renderer )
- {
- renderers.Erase( iter ); // Renderer found; now destroy it
- break;
- }
- }
+ mImpl->rendererContainer.EraseObject( renderer );
}
void RenderManager::AddSampler( Render::Sampler* sampler )
void RenderManager::RemoveSampler( Render::Sampler* sampler )
{
- DALI_ASSERT_DEBUG( NULL != sampler );
-
- SamplerOwnerContainer& samplers = mImpl->samplerContainer;
-
- // Find the sampler
- for ( SamplerOwnerIter iter = samplers.Begin(); iter != samplers.End(); ++iter )
- {
- if ( *iter == sampler )
- {
- samplers.Erase( iter ); // Sampler found; now destroy it
- break;
- }
- }
+ mImpl->samplerContainer.EraseObject( sampler );
}
void RenderManager::AddTexture( Render::Texture* texture )
void RenderManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer )
{
- DALI_ASSERT_DEBUG( NULL != propertyBuffer );
-
- PropertyBufferOwnerContainer& propertyBuffers = mImpl->propertyBufferContainer;
-
- // Find the sampler
- for ( PropertyBufferOwnerIter iter = propertyBuffers.Begin(); iter != propertyBuffers.End(); ++iter )
- {
- if ( *iter == propertyBuffer )
- {
- propertyBuffers.Erase( iter ); // Property buffer found; now destroy it
- break;
- }
- }
+ mImpl->propertyBufferContainer.EraseObject( propertyBuffer );
}
void RenderManager::SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format )
void RenderManager::RemoveGeometry( Render::Geometry* geometry )
{
- DALI_ASSERT_DEBUG( NULL != geometry );
-
- GeometryOwnerContainer& geometries = mImpl->geometryContainer;
-
- // Find the geometry
- for ( GeometryOwnerIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
- {
- if ( *iter == geometry )
- {
- geometries.Erase( iter ); // Geometry found; now destroy it
- break;
- }
- }
+ mImpl->geometryContainer.EraseObject( geometry );
}
void RenderManager::AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
template < class T >
inline void EraseUsingDiscardQueue( OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex )
{
+ DALI_ASSERT_DEBUG( object && "NULL object not allowed" );
+
typename OwnerContainer<T*>::Iterator iter = container.Begin();
const typename OwnerContainer<T*>::ConstIterator endIter = container.End();
for ( ; iter != endIter; ++iter )
void UpdateManager::RemoveObject( PropertyOwner* object )
{
- DALI_ASSERT_DEBUG( NULL != object );
-
- OwnerContainer< PropertyOwner* >& customObjects = mImpl->customObjects;
-
- // Find the object and destroy it
- for ( OwnerContainer< PropertyOwner* >::Iterator iter = customObjects.Begin(); iter != customObjects.End(); ++iter )
- {
- PropertyOwner* current = *iter;
- if ( current == object )
- {
- customObjects.Erase( iter );
- return;
- }
- }
-
- // Should not reach here
- DALI_ASSERT_DEBUG(false);
+ mImpl->customObjects.EraseObject( object );
}
void UpdateManager::AddAnimation( Animation* animation )
void UpdateManager::RemovePropertyNotification( PropertyNotification* propertyNotification )
{
- PropertyNotificationContainer &propertyNotifications = mImpl->propertyNotifications;
- PropertyNotificationIter iter = propertyNotifications.Begin();
-
- while ( iter != propertyNotifications.End() )
- {
- if( *iter == propertyNotification )
- {
- propertyNotifications.Erase(iter);
- break;
- }
- ++iter;
- }
+ mImpl->propertyNotifications.EraseObject( propertyNotification );
}
void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode )
void UpdateManager::RemoveShader( Shader* shader )
{
- DALI_ASSERT_DEBUG(shader != NULL);
-
// Find the shader and destroy it
EraseUsingDiscardQueue( mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
}
void UpdateManager::RemoveRenderer( Renderer* renderer )
{
- DALI_ASSERT_DEBUG( renderer != NULL );
-
- renderer->DisconnectFromSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
-
// Find the renderer and destroy it
EraseUsingDiscardQueue( mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ // Need to remove the render object as well
+ renderer->DisconnectFromSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
}
void UpdateManager::SetPanGestureProcessor( PanGesture* panGestureProcessor )
void UpdateManager::AddTextureSet( TextureSet* textureSet )
{
DALI_ASSERT_DEBUG( NULL != textureSet );
+
mImpl->textureSets.PushBack( textureSet );
}
void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
{
- DALI_ASSERT_DEBUG( textureSet != NULL );
-
- // Find the texture and destroy it
- TextureSetOwner& textures = mImpl->textureSets;
- for ( TextureSetIter iter = textures.Begin(), endIter = textures.End(); iter != endIter; ++iter )
- {
- if ( *iter == textureSet )
- {
- textures.Erase( iter );
- return;
- }
- }
+ mImpl->textureSets.EraseObject( textureSet );
}
RenderTaskList* UpdateManager::GetRenderTaskList( bool systemLevel )