Merge "DALi Version 1.0.20" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / update / common / double-buffered.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/math/matrix.h>
23 #include <dali/public-api/math/quaternion.h>
24 #include <dali/public-api/math/vector3.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 // The number of buffers per scene-graph property
33 static const unsigned int NUM_SCENE_GRAPH_BUFFERS = 2;
34
35 // Buffer index used when reading off-stage values
36 static const unsigned int ARBITRARY_OFF_STAGE_BUFFER = 0;
37
38 namespace SceneGraph
39 {
40
41 /**
42  * Templated class for a double-buffered value.
43  */
44 template <typename T>
45 class DoubleBuffered
46 {
47 public:
48
49   DoubleBuffered()
50   : mValue1(),
51     mValue2()
52   {
53   }
54
55   DoubleBuffered(const T& val)
56   : mValue1(val),
57     mValue2(val)
58   {
59   }
60
61   inline T& operator[](const size_t i)
62   {
63     DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
64
65     return *(&mValue1+i);
66   }
67
68   inline const T& operator[](const size_t i) const
69   {
70     DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
71
72     return *(&mValue1+i);
73   }
74
75 private:
76
77   // Undefined
78   DoubleBuffered<T>(const DoubleBuffered<T>&);
79
80   // Undefined
81   DoubleBuffered<T>& operator=(const DoubleBuffered<T>& rhs);
82
83 private:
84
85   T mValue1;
86   T mValue2;
87 };
88
89 } // namespace SceneGraph
90
91 } // namespace Internal
92
93 } // namespace Dali
94
95 #endif // __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H__