1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/public-api/math/matrix.h>
22 #include <dali/public-api/math/quaternion.h>
23 #include <dali/public-api/math/vector3.h>
31 // The number of buffers per scene-graph property
32 static const unsigned int NUM_SCENE_GRAPH_BUFFERS = 2;
34 // Buffer index used when reading off-stage values
35 static const unsigned int ARBITRARY_OFF_STAGE_BUFFER = 0;
41 * Templated class for a double-buffered value.
42 * This simplifies init code, and forces explicit initialization.
49 DoubleBuffered(const T& val)
55 inline T& operator[](const size_t i)
57 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
62 inline const T& operator[](const size_t i) const
64 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
72 DoubleBuffered<T>(const DoubleBuffered<T>&);
75 DoubleBuffered<T>& operator=(const DoubleBuffered<T>& rhs);
84 * Templated class for a double-buffered value, initialized with 3 value parameters.
85 * This simplifies init code, and forces explicit initialization.
87 template <typename T, typename P>
92 DoubleBuffered3(const T& val)
98 DoubleBuffered3(P val1, P val2, P val3)
99 : mValue1(val1, val2, val3),
100 mValue2(val1, val2, val3)
104 inline T& operator[](const size_t i)
106 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
108 return *(&mValue1+i);
111 inline const T& operator[](const size_t i) const
113 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
115 return *(&mValue1+i);
121 DoubleBuffered3<T,P>(const DoubleBuffered3<T,P>&);
124 DoubleBuffered3<T,P>& operator=(const DoubleBuffered3<T,P>& rhs);
133 * Templated class for a double-buffered value, initialized with 4 value parameters.
134 * This simplifies init code, and forces explicit initialization.
136 template <typename T, typename P>
137 class DoubleBuffered4
141 DoubleBuffered4(const T& val)
147 DoubleBuffered4(P val1, P val2, P val3, P val4)
148 : mValue1(val1, val2, val3, val4),
149 mValue2(val1, val2, val3, val4)
153 inline T& operator[](const size_t i)
155 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
157 return *(&mValue1+i);
160 inline const T& operator[](const size_t i) const
162 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
164 return *(&mValue1+i);
170 DoubleBuffered4<T,P>(const DoubleBuffered4<T,P>&);
173 DoubleBuffered4<T,P>& operator=(const DoubleBuffered4<T,P>& rhs);
181 typedef DoubleBuffered<int> DoubleBufferedInt;
182 typedef DoubleBuffered<float> DoubleBufferedFloat;
183 typedef DoubleBuffered<bool> DoubleBufferedBool;
185 typedef DoubleBuffered3<Vector3,float> DoubleBufferedVector3;
186 typedef DoubleBuffered4<Vector4,float> DoubleBufferedVector4;
188 typedef DoubleBuffered4<Quaternion, float> DoubleBufferedQuaternion;
190 typedef DoubleBuffered<Matrix> DoubleBufferedMatrix;
192 } // namespace SceneGraph
194 } // namespace Internal
198 #endif // __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__