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