1 #ifndef __DALI_INTERNAL_UNIFORM_META_H__
2 #define __DALI_INTERNAL_UNIFORM_META_H__
5 * Copyright (c) 2014 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.
25 #include <dali/public-api/object/property.h>
26 #include <dali/public-api/shader-effects/shader-effect.h>
27 #include <dali/internal/common/message.h>
28 #include <dali/internal/common/event-to-update.h>
29 #include <dali/internal/render/shaders/shader.h>
43 * Holds the metadata associated with a Shader uniform.
49 typedef Dali::ShaderEffect::UniformCoordinateType CoordinateType;
52 * Create a UniformMeta.
54 static UniformMeta* New( const std::string& name, const PropertyBase& property, CoordinateType coordType )
56 return new UniformMeta( name, property, coordType );
61 * @param [in] meta The UniformMeta to copy.
63 UniformMeta( const UniformMeta& meta )
65 property( meta.property ),
66 coordinateType( meta.coordinateType )
68 memcpy( cacheIndeces, meta.cacheIndeces, sizeof(cacheIndeces) );
72 * Set the coordinate type.
73 * @param [in] coordType The new coordinate type.
75 void SetCoordinateType( CoordinateType coordType )
77 coordinateType = coordType;
85 UniformMeta( const std::string& uniformName, const PropertyBase& prop, CoordinateType coordType )
86 : name( uniformName ),
88 coordinateType( coordType )
90 memset( cacheIndeces, 0, sizeof(cacheIndeces) );
94 UniformMeta& operator=( const UniformMeta& rhs );
98 std::string name; ///< name of uniform to set/animate
100 const PropertyBase& property; ///< reference to the corresponding property
102 unsigned int cacheIndeces[ Log<GEOMETRY_TYPE_LAST>::value ][ SHADER_SUBTYPE_LAST ]; ///< internal program cache index, per program
104 CoordinateType coordinateType; ///< The coordinate type of the uniform
107 // Messages for UniformMeta
109 }; // namespace SceneGraph
111 // value types used by messages
112 template <> struct ParameterType< SceneGraph::UniformMeta::CoordinateType >
113 : public BasicType< SceneGraph::UniformMeta::CoordinateType > {};
118 inline void SetCoordinateTypeMessage( EventToUpdate& eventToUpdate, const UniformMeta& meta, UniformMeta::CoordinateType type )
120 typedef MessageValue1< UniformMeta, UniformMeta::CoordinateType > LocalType;
122 // Reserve some memory inside the message queue
123 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
125 // Construct message in the message queue memory; note that delete should not be called on the return value
126 new (slot) LocalType( &meta, &UniformMeta::SetCoordinateType, type );
129 } // namespace SceneGraph
132 * Used for accessing uniform metadata by property index
134 typedef std::map<Property::Index, const SceneGraph::UniformMeta*> CustomUniformMetaLookup;
136 } // namespace Internal
140 #endif // __DALI_INTERNAL_UNIFORM_META_H__