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 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.
22 #include <dali/public-api/math/matrix.h>
23 #include <dali/public-api/math/quaternion.h>
24 #include <dali/public-api/math/vector3.h>
32 // The number of buffers per scene-graph property
33 static const unsigned int NUM_SCENE_GRAPH_BUFFERS = 2;
35 // Buffer index used when reading off-stage values
36 static const unsigned int ARBITRARY_OFF_STAGE_BUFFER = 0;
42 * Templated class for a double-buffered value.
43 * This simplifies init code, and forces explicit initialization.
50 DoubleBuffered(const T& val)
56 inline T& operator[](const size_t i)
58 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
63 inline const T& operator[](const size_t i) const
65 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
73 DoubleBuffered<T>(const DoubleBuffered<T>&);
76 DoubleBuffered<T>& operator=(const DoubleBuffered<T>& rhs);
85 * Templated class for a double-buffered value, initialized with 3 value parameters.
86 * This simplifies init code, and forces explicit initialization.
88 template <typename T, typename P>
93 DoubleBuffered3(const T& val)
99 DoubleBuffered3(P val1, P val2, P val3)
100 : mValue1(val1, val2, val3),
101 mValue2(val1, val2, val3)
105 inline T& operator[](const size_t i)
107 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
109 return *(&mValue1+i);
112 inline const T& operator[](const size_t i) const
114 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
116 return *(&mValue1+i);
122 DoubleBuffered3<T,P>(const DoubleBuffered3<T,P>&);
125 DoubleBuffered3<T,P>& operator=(const DoubleBuffered3<T,P>& rhs);
134 * Templated class for a double-buffered value, initialized with 4 value parameters.
135 * This simplifies init code, and forces explicit initialization.
137 template <typename T, typename P>
138 class DoubleBuffered4
142 DoubleBuffered4(const T& val)
148 DoubleBuffered4(P val1, P val2, P val3, P val4)
149 : mValue1(val1, val2, val3, val4),
150 mValue2(val1, val2, val3, val4)
154 inline T& operator[](const size_t i)
156 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
158 return *(&mValue1+i);
161 inline const T& operator[](const size_t i) const
163 DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
165 return *(&mValue1+i);
171 DoubleBuffered4<T,P>(const DoubleBuffered4<T,P>&);
174 DoubleBuffered4<T,P>& operator=(const DoubleBuffered4<T,P>& rhs);
182 typedef DoubleBuffered<int> DoubleBufferedInt;
183 typedef DoubleBuffered<float> DoubleBufferedFloat;
184 typedef DoubleBuffered<bool> DoubleBufferedBool;
186 typedef DoubleBuffered3<Vector3,float> DoubleBufferedVector3;
187 typedef DoubleBuffered4<Vector4,float> DoubleBufferedVector4;
189 typedef DoubleBuffered4<Quaternion, float> DoubleBufferedQuaternion;
191 typedef DoubleBuffered<Matrix> DoubleBufferedMatrix;
193 } // namespace SceneGraph
195 } // namespace Internal
199 #endif // __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__