[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-buffers.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_BUFFERS_H
2 #define DALI_INTERNAL_SCENE_GRAPH_BUFFERS_H
3
4 /*
5  * Copyright (c) 2021 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/internal/common/buffer-index.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace SceneGraph
29 {
30 /**
31  * Node values (position etc.) are double-buffered.  A SceneGraphBuffers object
32  * can be used to keep track of which buffers are being written or read.
33  */
34 class SceneGraphBuffers
35 {
36 public:
37   static BufferIndex INITIAL_EVENT_BUFFER_INDEX;  // 0
38   static BufferIndex INITIAL_UPDATE_BUFFER_INDEX; // 1
39
40   /**
41    * Create a SceneGraphBuffers object.
42    */
43   SceneGraphBuffers();
44
45   /**
46    * Non-virtual destructor; not intended as a base class.
47    */
48   ~SceneGraphBuffers();
49
50   /**
51    * Retrieve the current event-buffer index.
52    * @return The buffer index.
53    */
54   BufferIndex GetEventBufferIndex() const
55   {
56     return mEventBufferIndex;
57   }
58
59   /**
60    * Retrieve the current update-buffer index.
61    * @return The buffer index.
62    */
63   BufferIndex GetUpdateBufferIndex() const
64   {
65     return mUpdateBufferIndex;
66   }
67
68   /**
69    * Swap the Event & Update buffer indices.
70   */
71   void Swap();
72
73 private:
74   // Undefined
75   SceneGraphBuffers(const SceneGraphBuffers&);
76
77   // Undefined
78   SceneGraphBuffers& operator=(const SceneGraphBuffers& rhs);
79
80 private:
81   BufferIndex mEventBufferIndex;  ///< 0 or 1 (opposite of mUpdateBufferIndex)
82   BufferIndex mUpdateBufferIndex; ///< 0 or 1 (opposite of mEventBufferIndex)
83 };
84
85 } // namespace SceneGraph
86
87 } // namespace Internal
88
89 } // namespace Dali
90
91 #endif // DALI_INTERNAL_SCENE_GRAPH_BUFFERS_H