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