1 #ifndef DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_H
2 #define DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_H
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <dali/devel-api/common/hash.h>
21 #include <dali/devel-api/common/owner-container.h>
28 class PropertyInputImpl;
34 * The uniform map is used to map a uniform name to a property value.
36 class UniformPropertyMapping
39 typedef unsigned long Hash;
44 UniformPropertyMapping( const std::string& theUniformName, const PropertyInputImpl* thePropertyPtr )
45 : propertyPtr( thePropertyPtr ),
46 uniformName( theUniformName ),
47 uniformNameHash( Dali::CalculateHash( theUniformName ) )
51 UniformPropertyMapping()
52 : propertyPtr( NULL ),
59 const PropertyInputImpl* propertyPtr;
60 std::string uniformName;
65 * The UniformMap class is used to map uniform names to property values. It is available
66 * in all of the classes responsible for rendering:
67 * Actor, Renderer, Geometry, PropertyBuffer, Material, Sampler, Shader.
69 * It can be observed for changes to the mapping table.
77 virtual void UniformMappingsChanged(const UniformMap& mappings) = 0;
91 * Add an observer that watches for changes in the mappings
93 void AddObserver( Observer& observer );
98 void RemoveObserver( Observer& observer );
101 * Add a map to the mappings table.
103 void Add( UniformPropertyMapping* map );
106 * Remove a map from the mappings table
108 void Remove( const std::string& uniformName );
111 * Find a property given the uniform name.
112 * @return The address of the property if it's in the map, or NULL otherwise.
114 const PropertyInputImpl* Find( const std::string& uniformName );
117 * Get the count of uniforms in the map
118 * @return The number of uniform mappings
120 unsigned int Count() const;
123 * @pre index must be in the range 0 :: Count()-1
124 * @param[in] index The index of the element to fetch
125 * @return reference to the element in the map
127 const UniformPropertyMapping& operator[]( unsigned int index ) const;
131 * Helper to call the observers when the mappings have changed
133 void MappingChanged();
136 typedef OwnerContainer< UniformPropertyMapping* > UniformMapContainer;
137 typedef UniformMapContainer::Iterator UniformMapIter;
138 typedef Dali::Vector< Observer* > Observers;
139 typedef Observers::Iterator ObserversIter;
141 UniformMapContainer mUniformMaps; // Owner container of uniform maps
143 Observers mObservers;
147 } // namespace SceneGraph
148 } // namespace Internal
151 #endif // DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_H