1 #ifndef DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_H
2 #define DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_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/devel-api/threading/mutex.h>
26 #include <dali/devel-api/update/frame-callback-interface.h>
27 #include <dali/internal/common/owner-pointer.h>
28 #include <dali/internal/update/common/property-owner.h>
29 #include <dali/internal/update/manager/update-proxy-impl.h>
41 class TransformManager;
44 * This is the update-thread owned entity of the FrameCallbackInterface.
45 * @see Dali::FrameCallbackInterface
47 class FrameCallback final : public PropertyOwner::Observer
52 * Creates a new FrameCallback.
53 * @param[in] frameCallbackInterface A reference to the FrameCallbackInterface implementation
54 * @return A new FrameCallback.
56 static FrameCallback* New( FrameCallbackInterface& frameCallbackInterface );
59 * Non-virtual Destructor.
64 * Called from the update-thread when connecting to the scene-graph.
65 * @param[in] transformManager The transform Manager
66 * @param[in] rootNode The rootNode of this frame-callback
68 void ConnectToSceneGraph( TransformManager& transformManager, Node& rootNode );
70 // Movable but not copyable
72 FrameCallback( const FrameCallback& ) = delete; ///< Deleted copy constructor.
73 FrameCallback( FrameCallback&& ) = default; ///< Default move constructor.
74 FrameCallback& operator=( const FrameCallback& ) = delete; ///< Deleted copy assignment operator.
75 FrameCallback& operator=( FrameCallback&& ) = default; ///< Default move assignment operator.
78 * Called from the update-thread after the scene has been updated, and is ready to render.
79 * @param[in] bufferIndex The bufferIndex to use
80 * @param[in] elapsedSeconds Time elapsed time since the last frame (in seconds)
81 * @param[in] nodeHierarchyChanged Whether the node hierarchy has changed
82 * @return Whether to continue calling this FrameCallback or not.
84 bool Update( BufferIndex bufferIndex, float elapsedSeconds, bool nodeHierarchyChanged );
87 * Invalidates this FrameCallback and will no longer be associated with the FrameCallbackInterface.
88 * @note This method is thread-safe.
93 * Comparison operator between a FrameCallback and a FrameCallbackInterface pointer.
94 * @param[in] iFace The FrameCallbackInterface pointer to compare with
95 * @return True if iFace matches our internally stored FrameCallbackInterface.
97 inline bool operator==( const FrameCallbackInterface* iFace )
99 return mFrameCallbackInterface == iFace;
104 // From PropertyOwner::Observer
107 * @copydoc PropertyOwner::Observer::PropertyOwnerConnected()
109 virtual void PropertyOwnerConnected( PropertyOwner& owner ) { /* Nothing to do */ }
112 * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
114 virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) { /* Nothing to do */ }
117 * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
119 * Will use this to disconnect the frame-callback if the accompanying node is destroyed
121 virtual void PropertyOwnerDestroyed( PropertyOwner& owner );
127 * @param[in] frameCallbackInterface A pointer to the FrameCallbackInterface implementation
129 FrameCallback( FrameCallbackInterface* frameCallbackInterface );
134 std::unique_ptr< UpdateProxy > mUpdateProxy{ nullptr }; ///< A unique pointer to the implementation of the UpdateProxy.
135 FrameCallbackInterface* mFrameCallbackInterface;
139 * Checks if FrameCallback store iFace internally.
140 * @param[in] frameCallback Reference to the owner-pointer of frame-callback
141 * @param[in] iFace The FrameCallbackInterface pointer
142 * @return True if iFace matches the internally stored FrameCallbackInterface.
144 inline bool operator==( const OwnerPointer< FrameCallback >& frameCallback, const FrameCallbackInterface* iFace )
146 return *frameCallback == iFace;
149 } // namespace SceneGraph
151 } // namespace Internal
155 #endif // DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_H