Merge "Add initialize resetter to reduce AnimatableProperty life" into devel/master
[platform/core/uifw/dali-core.git] / dali / devel-api / update / frame-callback-interface.h
1 #ifndef DALI_FRAME_CALLBACK_INTERFACE_H
2 #define DALI_FRAME_CALLBACK_INTERFACE_H
3
4 /*
5  * Copyright (c) 2020 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/dali-common.h>
26
27 namespace Dali
28 {
29 class UpdateProxy;
30
31 /**
32  * @brief This interface should be implemented if a callback is required on every frame.
33  *
34  * The Update() method is called from the update-thread after the scene has been updated, and is ready to render.
35  *
36  * As this method is called from the update-thread, no event thread APIs (e.g. Actor::Get...) can be called.
37  * This will invariably lead to crashes.
38  *
39  * Instead, setting and retrieving the values should be done by using the UpdateProxy class returned as a parameter to
40  * the Update() method.
41  *
42  * Actors can be identified using Actor IDs which can be retrieved using Actor::GetId() in the event-thread.
43  * However, calling Actor::GetId() will lead to problems if it is called from the update-thread.
44  * Instead, the Actor IDs should be stored by the implementation of this class or passed via a thread-safe manner from
45  * the event-thread.
46  */
47 class DALI_CORE_API FrameCallbackInterface
48 {
49 public:
50   /**
51    * @brief Called from the update-thread after the scene has been updated, and is ready to render.
52    * @param[in]  updateProxy  Use this to get/set required values for the Actor.
53    * @param[in]  elapsedSeconds  Time elapsed time since the last frame (in seconds)
54    * @see FrameCallbackInterface
55    */
56   virtual void Update(UpdateProxy& updateProxy, float elapsedSeconds) = 0;
57
58 protected:
59   /**
60    * @brief Protected constructor.
61    */
62   FrameCallbackInterface();
63
64   /**
65    * @brief Protected virtual destructor.
66    */
67   virtual ~FrameCallbackInterface();
68
69 public:
70   /// @cond internal
71   class Impl;
72
73 private:
74   std::unique_ptr<Impl> mImpl;
75   /// @endcond
76 };
77
78 } // namespace Dali
79
80 #endif // DALI_FRAME_CALLBACK_INTERFACE_H