[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-tracker.h
1 #ifndef DALI_INTERNAL_RENDER_RENDER_TRACKER_H
2 #define DALI_INTERNAL_RENDER_RENDER_TRACKER_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 #include <dali/graphics-api/graphics-controller.h>
22 #include <dali/internal/common/message.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Render
29 {
30 /**
31  * This class is used to communicate with Fence Sync objects, keeping access solely in
32  * the RenderThread to avoid having mutual exclusion locks or messages back to the UpdateThread.
33  */
34 class RenderTracker
35 {
36 public:
37   /**
38    * Constructor
39    */
40   RenderTracker();
41
42   /**
43    * Destructor
44    */
45   ~RenderTracker();
46
47   /**
48    * Creates a sync object for this tracker. Will delete any existing sync object.
49    *
50    * @param[in] graphicsController The graphics subsystem
51    */
52   Graphics::SyncObject* CreateSyncObject(Graphics::Controller& graphicsController);
53
54   /**
55    * Check the Sync objects. This is called from Render Thread.
56    * If the SyncObject has been triggered, then atomically set the sync trigger
57    */
58   void PollSyncObject();
59
60   /**
61    * Check the sync trigger. This is called from Update Thread, so atomically reads the sync trigger
62    * It clears the sync trigger if it was set.
63    * @return true if the tracker has been synced
64    */
65   bool IsSynced();
66
67   /**
68    * Atomically reset the sync trigger. This may be called from any thread
69    */
70   void ResetSyncFlag();
71
72   /**
73    * Atomically sets the sync trigger. This may be called from any thread
74    */
75   void SetSyncFlag();
76
77 private:
78   Graphics::Controller*                     mGraphicsController; ///<  The graphics subsystem
79   Graphics::UniquePtr<Graphics::SyncObject> mSyncObject;         ///< Associated sync object
80   volatile int                              mSyncTrigger;        ///< Trigger that update thread can read
81 };
82
83 } // namespace Render
84
85 } // namespace Internal
86
87 } // namespace Dali
88
89 #endif // DALI_INTERNAL_RENDER_RENDER_TRACKER_H