#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/type-registry-impl.h>
+#include <dali/internal/common/const-string.h>
using Dali::Internal::SceneGraph::AnimatableProperty;
using Dali::Internal::SceneGraph::PropertyBase;
const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
OwnerPointer<SceneGraph::UniformPropertyMapping> map =
- new SceneGraph::UniformPropertyMapping(std::move(uniformName), propertyPtr);
+ new SceneGraph::UniformPropertyMapping(ConstString(uniformName), propertyPtr);
// Message takes ownership of Uniform map (and will delete it after copy)
AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, map );
}
void Object::RemoveUniformMapping( const std::string& uniformName ) const
{
const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
- RemoveUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, uniformName);
+ RemoveUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, ConstString(uniformName));
}
void Object::ApplyConstraint( ConstraintBase& constraint )
{
continue;
}
- format->components[i].name = component.first.stringKey;
+ format->components[i].name = ConstString(component.first.stringKey);
// enums are stored in the map as int
Property::Type type = Property::Type( component.second.Get<int>() );
const uint32_t attributeCount = vertexBuffer->GetAttributeCount();
for( uint32_t j = 0; j < attributeCount; ++j )
{
- const std::string& attributeName = vertexBuffer->GetAttributeName( j );
+ auto attributeName = vertexBuffer->GetAttributeName( j );
uint32_t index = program.RegisterCustomAttribute( attributeName );
GLint location = program.GetCustomAttributeLocation( index );
if( -1 == location )
{
- DALI_LOG_WARNING( "Attribute not found in the shader: %s\n", attributeName.c_str() );
+ DALI_LOG_WARNING( "Attribute not found in the shader: %s\n", attributeName.GetCString() );
}
attributeLocation.PushBack( location );
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/render/renderers/render-sampler.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
+#include <dali/internal/common/const-string.h>
namespace Dali
{
struct Component
{
- std::string name;
+ ConstString name;
uint32_t offset;
uint32_t size;
Property::Type type;
* @param[in] index The index of the attribute
* @return The name of the attribute
*/
- inline const std::string& GetAttributeName( uint32_t index ) const
+ inline ConstString GetAttributeName( uint32_t index ) const
{
DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
return mFormat->components[index].name;
return GetCustomAttributeLocation( type );
}
-uint32_t Program::RegisterCustomAttribute( const std::string& name )
+uint32_t Program::RegisterCustomAttribute( ConstString name )
{
uint32_t index = 0;
// find the value from cache
if( location == ATTRIB_UNKNOWN )
{
- location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetAttribLocation( mProgramId, mAttributeLocations[ attributeIndex ].first.c_str() ) );
+ location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetAttribLocation( mProgramId, mAttributeLocations[ attributeIndex ].first.GetCString() ) );
mAttributeLocations[ attributeIndex ].second = location;
- LOG_GL( "GetAttributeLocation(program=%d,%s) = %d\n", mProgramId, mAttributeLocations[ attributeIndex ].first.c_str(), mAttributeLocations[ attributeIndex ].second );
+ LOG_GL( "GetAttributeLocation(program=%d,%s) = %d\n", mProgramId, mAttributeLocations[ attributeIndex ].first.GetCString(), mAttributeLocations[ attributeIndex ].second );
}
return location;
}
-uint32_t Program::RegisterUniform( const std::string& name )
+uint32_t Program::RegisterUniform( ConstString name )
{
uint32_t index = 0;
// find the value from cache
if( location == UNIFORM_NOT_QUERIED )
{
- location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetUniformLocation( mProgramId, mUniformLocations[ uniformIndex ].first.c_str() ) );
+ location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetUniformLocation( mProgramId, mUniformLocations[ uniformIndex ].first.GetCString() ) );
mUniformLocations[ uniformIndex ].second = location;
- LOG_GL( "GetUniformLocation(program=%d,%s) = %d\n", mProgramId, mUniformLocations[ uniformIndex ].first.c_str(), mUniformLocations[ uniformIndex ].second );
+ LOG_GL( "GetUniformLocation(program=%d,%s) = %d\n", mProgramId, mUniformLocations[ uniformIndex ].first.GetCString(), mUniformLocations[ uniformIndex ].second );
}
return location;
mAttributeLocations.reserve( ATTRIB_TYPE_LAST );
for( uint32_t i = 0; i < ATTRIB_TYPE_LAST; ++i )
{
- RegisterCustomAttribute( gStdAttribs[i] );
+ RegisterCustomAttribute( ConstString(gStdAttribs[i]) );
}
// reserve space for standard uniforms
// reset built in uniform names in cache
for( uint32_t i = 0; i < UNIFORM_TYPE_LAST; ++i )
{
- RegisterUniform( gStdUniforms[ i ] );
+ RegisterUniform( ConstString(gStdUniforms[ i ]) );
}
// reset values
#include <dali/public-api/object/ref-object.h>
#include <dali/integration-api/gl-abstraction.h>
#include <dali/internal/common/shader-data.h>
+#include <dali/internal/common/const-string.h>
namespace Dali
{
* @param [in] name attribute name
* @return the index of the attribute name in local cache
*/
- uint32_t RegisterCustomAttribute( const std::string& name );
+ uint32_t RegisterCustomAttribute( ConstString name );
/**
* Gets the location of a pre-registered attribute.
* @param [in] name uniform name
* @return the index of the uniform name in local cache
*/
- uint32_t RegisterUniform( const std::string& name );
+ uint32_t RegisterUniform( ConstString name );
/**
* Gets the location of a pre-registered uniform.
Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
// location caches
- using NameLocationPair = std::pair<std::string, GLint>;
+ using NameLocationPair = std::pair<ConstString, GLint>;
using Locations = std::vector<NameLocationPair>;
Locations mAttributeLocations; ///< attribute location cache
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/internal/common/const-string.h>
namespace Dali
{
new (slot) LocalType( &owner, &PropertyOwner::AddUniformMapping, map );
}
-inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const std::string& uniformName )
+inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, ConstString uniformName )
{
- using LocalType = MessageValue1<PropertyOwner, std::string>;
+ using LocalType = MessageValue1<PropertyOwner, ConstString>;
// Reserve some memory inside the message queue
uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/internal/common/const-string.h>
namespace Dali
{
mUniformMaps.Add( map.Release() );
}
-void PropertyOwner::RemoveUniformMapping( const std::string& uniformName )
+void PropertyOwner::RemoveUniformMapping( const ConstString& uniformName )
{
mUniformMaps.Remove( uniformName );
}
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/common/uniform-map.h>
#include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
+#include <dali/internal/common/const-string.h>
namespace Dali
/**
* @copydoc UniformMap::Remove
*/
- virtual void RemoveUniformMapping( const std::string& uniformName );
+ virtual void RemoveUniformMapping( const ConstString& uniformName );
/**
* Get the mappings table
{
namespace SceneGraph
{
-UniformMap::UniformMap() = default;
-
-UniformMap::~UniformMap()
-{
- // Nothing to do - let the owner container delete the maps
-}
void UniformMap::AddObserver( Observer& observer )
{
void UniformMap::Add( UniformPropertyMapping* newMap )
{
- UniformPropertyMapping::Hash nameHash = CalculateHash( newMap->uniformName );
-
bool found = false;
for( UniformMapIter iter = mUniformMaps.Begin() ;
++iter )
{
UniformPropertyMapping* map = *iter;
- if( map->uniformNameHash == nameHash )
+ if( map->uniformName == newMap->uniformName )
{
- if( map->uniformName == newMap->uniformName )
- {
- found = true;
- // Mapping already exists - update it.
- map->propertyPtr = newMap->propertyPtr;
- break;
- }
+ found = true;
+ // Mapping already exists - update it.
+ map->propertyPtr = newMap->propertyPtr;
+ break;
}
}
MappingChanged();
}
-void UniformMap::Remove( const std::string& uniformName )
+void UniformMap::Remove( ConstString uniformName )
{
- UniformPropertyMapping::Hash nameHash = CalculateHash( uniformName );
-
bool found=false;
for( UniformMapIter iter = mUniformMaps.Begin() ;
++iter )
{
UniformPropertyMapping* map = *iter;
- if( map->uniformNameHash == nameHash )
+ if( map->uniformName == uniformName )
{
- if( map->uniformName == uniformName )
- {
- mUniformMaps.Erase( iter );
- found = true;
- break;
- }
+ mUniformMaps.Erase( iter );
+ found = true;
+ break;
}
}
}
}
-const PropertyInputImpl* UniformMap::Find( const std::string& uniformName )
+const PropertyInputImpl* UniformMap::Find( ConstString uniformName )
{
- UniformPropertyMapping::Hash nameHash = CalculateHash( uniformName );
-
for( UniformMapIter iter = mUniformMaps.Begin() ;
iter != mUniformMaps.End() ;
++iter )
{
UniformPropertyMapping* map = *iter;
- if( map->uniformNameHash == nameHash )
+ if( map->uniformName == uniformName )
{
- if( map->uniformName == uniformName )
- {
- return map->propertyPtr;
- }
+ return map->propertyPtr;
}
}
return nullptr;
// INTERNAL INCLUDES
#include <dali/devel-api/common/hash.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/internal/common/const-string.h>
namespace Dali
{
class UniformPropertyMapping
{
public:
- using Hash = unsigned long;
-
/**
* Constructor
*/
- UniformPropertyMapping(std::string theUniformName, const PropertyInputImpl* thePropertyPtr)
+ UniformPropertyMapping(ConstString theUniformName, const PropertyInputImpl* thePropertyPtr)
: propertyPtr(thePropertyPtr),
- uniformName(std::move(theUniformName)),
- uniformNameHash(Dali::CalculateHash(theUniformName))
- {
- }
-
- UniformPropertyMapping()
- : propertyPtr( nullptr ),
- uniformName( "" ),
- uniformNameHash( 0 )
+ uniformName(theUniformName)
{
}
+ UniformPropertyMapping() = default;
- const PropertyInputImpl* propertyPtr;
- std::string uniformName;
- Hash uniformNameHash;
+ const PropertyInputImpl* propertyPtr{nullptr};
+ ConstString uniformName;
};
/**
};
/**
- * Constructor
- */
- UniformMap();
-
- /**
- * Destructor
- */
- ~UniformMap();
-
- /**
* Add an observer that watches for changes in the mappings
*/
void AddObserver( Observer& observer );
/**
* Remove a map from the mappings table
*/
- void Remove( const std::string& uniformName );
+ void Remove( ConstString uniformName );
/**
* Find a property given the uniform name.
* @return The address of the property if it's in the map, or NULL otherwise.
*/
- const PropertyInputImpl* Find( const std::string& uniformName );
+ const PropertyInputImpl* Find( ConstString uniformName );
/**
* Get the count of uniforms in the map
mRegenerateUniformMap = 2;
}
-void Node::RemoveUniformMapping( const std::string& uniformName )
+void Node::RemoveUniformMapping( const ConstString& uniformName )
{
PropertyOwner::RemoveUniformMapping( uniformName );
mRegenerateUniformMap = 2;
/**
* @copydoc UniformMap::Remove
*/
- void RemoveUniformMapping( const std::string& uniformName ) override;
+ void RemoveUniformMapping( const ConstString& uniformName ) override;
/**
* @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
for( UniformMap::SizeType i = 0, count=uniformMap.Count(); i<count; ++i )
{
- UniformPropertyMapping::Hash nameHash = uniformMap[i].uniformNameHash;
bool found = false;
for( CollectedUniformMap::Iterator iter = localMap.Begin() ; iter != localMap.End() ; ++iter )
{
const UniformPropertyMapping* map = (*iter);
- if( map->uniformNameHash == nameHash )
+ if( map->uniformName == uniformMap[i].uniformName )
{
- if( map->uniformName == uniformMap[i].uniformName )
- {
- found = true;
- break;
- }
+ found = true;
+ break;
}
}
if( !found )