DALi Version 2.0.1
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / frame-callback-processor.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H
3
4 /*
5  * Copyright (c) 2018 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 // EXTERNAL INCLUDES
22 #include <memory>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali/internal/common/buffer-index.h>
27 #include <dali/internal/common/owner-pointer.h>
28 #include <dali/internal/update/manager/scene-graph-frame-callback.h>
29 #include <dali/internal/update/manager/update-proxy-impl.h>
30
31 namespace Dali
32 {
33
34 class FrameCallbackInterface;
35
36 namespace Internal
37 {
38
39 namespace SceneGraph
40 {
41
42 class Node;
43 class TransformManager;
44 class UpdateManager;
45
46 /**
47  * This class processes all the registered frame-callbacks.
48  */
49 class FrameCallbackProcessor
50 {
51 public:
52
53   /**
54    * Construct a new FrameCallbackProcessor.
55    * @param[in]  updateManager     A reference to the UpdateManager
56    * @param[in]  transformManager  A reference to the TransformManager
57    */
58   FrameCallbackProcessor( UpdateManager& updateManager, TransformManager& transformManager );
59
60   /**
61    * Non-virtual Destructor.
62    */
63   ~FrameCallbackProcessor();
64
65   // Movable but not copyable
66
67   FrameCallbackProcessor( const FrameCallbackProcessor& )            = delete;  ///< Deleted copy constructor.
68   FrameCallbackProcessor( FrameCallbackProcessor&& )                 = default; ///< Default move constructor.
69   FrameCallbackProcessor& operator=( const FrameCallbackProcessor& ) = delete;  ///< Deleted copy assignment operator.
70   FrameCallbackProcessor& operator=( FrameCallbackProcessor&& )      = default; ///< Default move assignment operator.
71
72   /**
73    * Adds an implementation of the FrameCallbackInterface.
74    * @param[in]  frameCallback  An OwnerPointer to the SceneGraph FrameCallback object
75    * @param[in]  rootNode       A pointer to the root node to apply the FrameCallback to
76    */
77   void AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode );
78
79   /**
80    * Removes the specified implementation of FrameCallbackInterface.
81    * @param[in]  frameCallback  A pointer to the implementation of the FrameCallbackInterface to remove.
82    */
83   void RemoveFrameCallback( FrameCallbackInterface* frameCallback );
84
85   /**
86    * Called on Update by the UpdateManager.
87    * @param[in]  bufferIndex     The bufferIndex to use
88    * @param[in]  elapsedSeconds  Time elapsed time since the last frame (in seconds)
89    */
90   void Update( BufferIndex bufferIndex, float elapsedSeconds );
91
92   /**
93    * Called by the UpdateManager when the node hierarchy changes.
94    */
95   void NodeHierarchyChanged()
96   {
97     mNodeHierarchyChanged = true;
98   }
99
100 private:
101
102   std::vector< OwnerPointer< FrameCallback > > mFrameCallbacks; ///< A container of all the frame-callbacks & accompanying update-proxies.
103
104   UpdateManager& mUpdateManager;
105
106   TransformManager& mTransformManager;
107
108   bool mNodeHierarchyChanged; ///< Set to true if the node hierarchy changes
109 };
110
111 } // namespace SceneGraph
112
113 } // namespace Internal
114
115 } // namespace Dali
116
117 #endif // DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H