License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / update / resources / sync-resource-tracker.h
1 #ifndef __DALI_INTERNAL_SYNC_RESOURCE_TRACKER_H__
2 #define __DALI_INTERNAL_SYNC_RESOURCE_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/internal/update/resources/resource-tracker.h>
22
23 namespace Dali
24 {
25 namespace Integration
26 {
27 class GlSyncAbstraction;
28 }
29
30 namespace Internal
31 {
32
33 namespace SceneGraph
34 {
35 class RenderTracker;
36 class RenderMessageDispatcher;
37 }
38
39 /**
40  * Class to track completion of a resource.
41  * This class is designed to be used on resources that change completion in the render thread.
42  * Used by RenderTasks that render to a framebuffer backed by a native image, i.e. it
43  * needs GlFenceSync to determine when GL has written to the native image.
44  */
45 class SyncResourceTracker : public ResourceTracker
46 {
47 public:
48   /**
49    * Constructor
50    */
51   SyncResourceTracker( Integration::GlSyncAbstraction& glSyncAbstraction,
52                        SceneGraph::RenderMessageDispatcher& renderMessageDispatcher);
53
54   /**
55    * Destructor
56    */
57   virtual ~SyncResourceTracker();
58
59   /**
60    * Second stage initialization.
61    * Creates a RenderTracker object to handle fence sync
62    */
63   virtual void Initialize();
64
65   /**
66    * first stage destruction
67    * Called from CompleteStatusManager when the object is about to be deleted
68    */
69   virtual void OnDestroy();
70
71    /**
72    * Get the render tracker.
73    * @return The render tracker
74    */
75   SceneGraph::RenderTracker* GetRenderTracker();
76
77 protected:
78   /**
79    * Do the reset. Resets the RenderTracker
80    */
81   virtual void DoReset();
82
83   /**
84    * Ignore complete status from update thread
85    */
86   virtual void DoSetComplete();
87
88   /**
89    * Do the IsComplete. Allows derived types to perform their own handling
90    */
91   virtual bool DoIsComplete();
92
93 private:
94
95   /**
96    * Undefined Copy Constructor
97    */
98   SyncResourceTracker(const SyncResourceTracker& rhs);
99
100   /**
101    * @brief Undefined Assignment Operator
102    */
103   SyncResourceTracker& operator=(const SyncResourceTracker& rhs);
104
105 private:
106   Integration::GlSyncAbstraction& mGlSyncAbstraction; ///< The synchronisation interface
107   SceneGraph::RenderMessageDispatcher& mRenderMessageDispatcher; ///< RenderManager message dispatcher
108   SceneGraph::RenderTracker* mRenderTracker; ///< The GL Fence Sync tracker object
109 };
110
111 } // Internal
112 } // Dali
113
114 #endif // __DALI_INTERNAL_SYNC_RESOURCE_TRACKER_H__