1 #ifndef DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali/internal/common/buffer-index.h>
27 #include <dali/internal/update/common/property-owner.h>
28 #include <dali/internal/update/manager/update-proxy-impl.h>
33 class FrameCallbackInterface;
42 class TransformManager;
45 * This class processes all the registered frame-callbacks.
47 class FrameCallbackProcessor : public PropertyOwner::Observer
52 * Construct a new FrameCallbackProcessor.
54 FrameCallbackProcessor( TransformManager& transformManager, Node& rootNode );
57 * Non-virtual Destructor.
59 ~FrameCallbackProcessor();
61 // Movable but not copyable
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&& ) = default; ///< Default move assignment operator.
69 * Adds an implementation of the FrameCallbackInterface.
70 * @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface
71 * @param[in] rootNode A pointer to the root node to apply the FrameCallback to
73 void AddFrameCallback( FrameCallbackInterface* frameCallback, const Node* rootNode );
76 * Removes the specified implementation of FrameCallbackInterface.
77 * @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface to remove.
79 void RemoveFrameCallback( FrameCallbackInterface* frameCallback );
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)
86 void Update( BufferIndex bufferIndex, float elapsedSeconds );
89 * Called by the UpdateManager when the node hierarchy changes.
91 void NodeHierarchyChanged()
93 mNodeHierarchyChanged = true;
98 // From PropertyOwner::Observer
101 * @copydoc PropertyOwner::Observer::PropertyOwnerConnected()
103 virtual void PropertyOwnerConnected( PropertyOwner& owner ) { /* Nothing to do */ }
106 * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
108 virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) { /* Nothing to do */ }
111 * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
113 * Will use this to disconnect the frame-callback if the accompanying node is destroyed
115 virtual void PropertyOwnerDestroyed( PropertyOwner& owner );
119 struct FrameCallbackInfo
122 * Default Constructor
123 * @param[in] frameCallbackObject A pointer to the frame-callback object
124 * @param[in] updateProxyPtr A raw pointer to the newly created updateProxy
125 * @note Ownership of @updateProxyPtr is passed to this class.
127 FrameCallbackInfo( FrameCallbackInterface* frameCallbackObject, UpdateProxy* updateProxyPtr )
128 : frameCallback( frameCallbackObject ),
129 updateProxyImpl( updateProxyPtr )
133 ~FrameCallbackInfo() = default; ///< Default destructor.
135 // Movable but not copyable
136 FrameCallbackInfo( const FrameCallbackInfo& ) = delete; ///< Deleted copy constructor.
137 FrameCallbackInfo( FrameCallbackInfo&& ) = default; ///< Default move constructor.
138 FrameCallbackInfo& operator=( const FrameCallbackInfo& ) = delete; ///< Deleted copy assignment operator.
139 FrameCallbackInfo& operator=( FrameCallbackInfo&& ) = default; ///< Default move assignment operator.
142 FrameCallbackInterface* frameCallback{ nullptr }; ///< Pointer to the implementation of the FrameCallbackInterface.
143 std::unique_ptr< UpdateProxy > updateProxyImpl{ nullptr }; ///< A unique pointer to the implementation of the UpdateProxy.
146 std::vector< FrameCallbackInfo > mFrameCallbacks; ///< A container of all the frame-callbacks & accompanying update-proxies.
148 TransformManager& mTransformManager;
151 bool mNodeHierarchyChanged; ///< Set to true if the node hierarchy changes
154 } // namespace SceneGraph
156 } // namespace Internal
160 #endif // DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H