(FrameCallback) All values now local & baking of the value supported
[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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/update/common/property-owner.h>
25
26 namespace Dali
27 {
28
29 class FrameCallbackInterface;
30
31 namespace Internal
32 {
33
34 class UpdateProxy;
35
36 namespace SceneGraph
37 {
38
39 class Node;
40 class TransformManager;
41
42 /**
43  * This class processes all the registered frame-callbacks.
44  */
45 class FrameCallbackProcessor : public PropertyOwner::Observer
46 {
47 public:
48
49   /**
50    * Construct a new FrameCallbackProcessor.
51    */
52   FrameCallbackProcessor( TransformManager& transformManager, Node& rootNode );
53
54   /**
55    * Non-virtual Destructor.
56    */
57   ~FrameCallbackProcessor();
58
59   // Movable but not copyable
60
61   FrameCallbackProcessor( const FrameCallbackProcessor& )            = delete;  ///< Deleted copy constructor.
62   FrameCallbackProcessor( FrameCallbackProcessor&& )                 = default; ///< Default move constructor.
63   FrameCallbackProcessor& operator=( const FrameCallbackProcessor& ) = delete;  ///< Deleted copy assignment operator.
64   FrameCallbackProcessor& operator=( FrameCallbackProcessor&& )      = default; ///< Default move assignment operator.
65
66   /**
67    * Adds an implementation of the FrameCallbackInterface.
68    * @param[in]  frameCallback  A pointer to the implementation of the FrameCallbackInterface
69    * @param[in]  rootNode       A pointer to the root node to apply the FrameCallback to
70    */
71   void AddFrameCallback( FrameCallbackInterface* frameCallback, const Node* rootNode );
72
73   /**
74    * Removes the specified implementation of FrameCallbackInterface.
75    * @param[in]  frameCallback  A pointer to the implementation of the FrameCallbackInterface to remove.
76    */
77   void RemoveFrameCallback( FrameCallbackInterface* frameCallback );
78
79   /**
80    * Called on Update by the UpdateManager.
81    * @param[in]  bufferIndex     The bufferIndex to use
82    * @param[in]  elapsedSeconds  Time elapsed time since the last frame (in seconds)
83    */
84   void Update( BufferIndex bufferIndex, float elapsedSeconds );
85
86   /**
87    * Called by the UpdateManager when the node hierarchy changes.
88    */
89   void NodeHierarchyChanged()
90   {
91     mNodeHierarchyChanged = true;
92   }
93
94 private:
95
96   // From PropertyOwner::Observer
97
98   /**
99    * @copydoc PropertyOwner::Observer::PropertyOwnerConnected()
100    */
101   virtual void PropertyOwnerConnected( PropertyOwner& owner ) { /* Nothing to do */ }
102
103   /**
104    * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
105    */
106   virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) { /* Nothing to do */ }
107
108   /**
109    * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
110    *
111    * Will use this to disconnect the frame-callback if the accompanying node is destroyed
112    */
113   virtual void PropertyOwnerDestroyed( PropertyOwner& owner );
114
115 private:
116
117   struct FrameCallbackInfo
118   {
119     FrameCallbackInterface* frameCallback;
120     UpdateProxy* updateProxyImpl;
121   };
122
123   std::vector< FrameCallbackInfo > mFrameCallbacks;
124
125   TransformManager& mTransformManager;
126   Node& mRootNode;
127
128   bool mNodeHierarchyChanged;
129 };
130
131 } // namespace SceneGraph
132
133 } // namespace Internal
134
135 } // namespace Dali
136
137 #endif // DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H