Add NativeImageSourceQueueX
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles20 / egl-sync-implementation.h
1 #ifndef __DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H__
2 #define __DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H__
3
4 /*
5  * Copyright (c) 2018 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 <EGL/egl.h>
23 #include <EGL/eglext.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/integration-api/gl-sync-abstraction.h>
26
27 // INTERNAL INCLUDES
28 #include <dali/public-api/dali-adaptor-common.h>
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace Adaptor
35 {
36 class EglImplementation;
37
38 class EglSyncObject : public Integration::GlSyncAbstraction::SyncObject
39 {
40 public:
41   /**
42    * Constructor
43    */
44   EglSyncObject( EglImplementation& eglSyncImpl );
45
46   /**
47    * Destructor
48    */
49   virtual ~EglSyncObject();
50
51   /**
52    * @copydoc Dali::Integration::GlSyncAbstraction::SyncObject::IsSynced()
53    */
54   virtual bool IsSynced();
55
56 private:
57 #ifdef _ARCH_ARM_
58   EGLSyncKHR mEglSync;
59 #else
60   int mPollCounter; // Implementations without fence sync use a 3 frame counter
61 #endif
62   EglImplementation& mEglImplementation;
63 };
64
65
66 /**
67  * GlSyncImplementation is a concrete implementation for GlSyncAbstraction.
68  * It provides fence syncing for resources such as FrameBuffers using EGL extensions
69  *
70  * Sync objects are created in the render thread after a render instruction
71  * has been processed (i.e. GL draw calls have completed for a given FB), and
72  * tested in the update
73  */
74 class EglSyncImplementation : public Integration::GlSyncAbstraction
75 {
76 public:
77   /**
78    * Constructor
79    */
80   EglSyncImplementation();
81
82   /**
83    * Destructor
84    */
85   virtual ~EglSyncImplementation();
86
87   /**
88    * Initialize the sync object with the Egl implementation.
89    * @param[in] impl The EGL implementation (to access display)
90    */
91   void Initialize( EglImplementation* impl );
92
93   /**
94    * @copydoc Dali::Integration::GlSyncAbstraction::CreateSyncObject()
95    */
96   virtual SyncObject* CreateSyncObject();
97
98   /**
99    * @copydoc Dali::Integration::GlSyncAbstraction::DestroySyncObject()
100    */
101   virtual void DestroySyncObject(SyncObject* syncObject);
102
103 private:
104   /**
105    * Set up the function pointers
106    */
107   void InitializeEglSync();
108
109 private:
110   typedef Vector<EglSyncObject*>   SyncContainer;
111   typedef SyncContainer::Iterator  SyncIter;
112
113   EglImplementation* mEglImplementation; ///< Egl implementation (to get display)
114   bool mSyncInitialized;        ///< Flag to perform initialization on first use
115   bool mSyncInitializeFailed;   ///< Flag to avoid reloading functions if failed once
116
117   SyncContainer mSyncObjects;
118 };
119
120 } // namespace Adaptor
121 } // namespace Internal
122 } // namespace Dali
123
124 #endif // __DALI_INTERNAL_EGL_ADAPTOR_SYNC_IMPLEMENTATION_H__