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