Merge "Using correct internal formats for image uploading" into devel/graphics
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-graphics.h
1 #ifndef DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
2 #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_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 // INTERNAL INCLUDES
22 #include <dali/integration-api/adaptor-framework/egl-interface.h>
23 #include <dali/internal/graphics/common/egl-image-extensions.h>
24 #include <dali/internal/graphics/common/graphics-interface.h>
25 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
26 #include <dali/internal/graphics/gles/egl-context-helper-implementation.h>
27 #include <dali/internal/graphics/gles/egl-implementation.h>
28 #include <dali/internal/graphics/gles/egl-sync-implementation.h>
29 #include <dali/internal/graphics/gles/gl-implementation.h>
30 #include <dali/internal/graphics/gles/gl-proxy-implementation.h>
31
32 namespace Dali
33 {
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38 class EnvironmentOptions;
39 class ConfigurationManager;
40
41 class EglGraphics : public GraphicsInterface
42 {
43 public:
44   /**
45    * Constructor
46    */
47   EglGraphics(EnvironmentOptions& environmentOptions);
48
49   /**
50    * Destructor
51    */
52   virtual ~EglGraphics();
53
54   /**
55    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize()
56    */
57   void Initialize() override;
58
59   /**
60    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize(bool,bool,bool,int)
61    */
62   void Initialize(bool depth, bool stencil, bool partialRendering, int msaa);
63
64   /**
65    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::ConfigureSurface()
66    */
67   void ConfigureSurface(Dali::RenderSurfaceInterface* surface) override;
68
69   /**
70    * Set gles version
71    * Default version is gles 3.0
72    */
73   void SetGlesVersion(const int32_t glesVersion);
74
75   /**
76    * Set whether the surfaceless context is supported
77    * @param[in] isSupported Whether the surfaceless context is supported
78    */
79   void SetIsSurfacelessContextSupported(const bool isSupported);
80
81   /**
82    * Activate the resource context (shared surfaceless context)
83    */
84   void ActivateResourceContext() override;
85
86   /**
87    * Activate the surface context
88    *
89    * @param[in] surface The surface whose context to be switched to.
90    */
91   void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) override;
92
93   /**
94    * Inform graphics interface that this is the first frame after a resume.
95    * (For debug only)
96    */
97   void SetFirstFrameAfterResume() override;
98
99   /**
100    * Gets the GL abstraction
101    * @return The GL abstraction
102    */
103   Integration::GlAbstraction& GetGlAbstraction() const;
104
105   /**
106    * Gets the implementation of EGL
107    * @return The implementation of EGL
108    */
109   EglImplementation& GetEglImplementation() const;
110
111   /**
112    * Gets the graphics interface for EGL
113    * @return The graphics interface for EGL
114    */
115   EglInterface& GetEglInterface() const;
116
117   /**
118    * @copydoc Dali::Integration::GlAbstraction& GetGlesInterface()
119    */
120   GlImplementation& GetGlesInterface();
121
122   /**
123    * Gets the implementation of GlSyncAbstraction for EGL.
124    * @return The implementation of GlSyncAbstraction for EGL.
125    */
126   EglSyncImplementation& GetSyncImplementation();
127
128   /**
129    * Gets the implementation of GlContextHelperAbstraction for EGL.
130    * @return The implementation of GlContextHelperAbstraction for EGL.
131    */
132   EglContextHelperImplementation& GetContextHelperImplementation();
133
134   /**
135    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetDepthBufferRequired()
136    */
137   Integration::DepthBufferAvailable& GetDepthBufferRequired();
138
139   /**
140    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetStencilBufferRequired()
141    */
142   Integration::StencilBufferAvailable GetStencilBufferRequired();
143
144   /**
145    * Gets the EGL image extension
146    * @return The EGL image extension
147    */
148   EglImageExtensions* GetImageExtensions();
149
150   /**
151    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Shutdown()
152    */
153   void Shutdown() override;
154
155   /**
156    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
157    */
158   void Destroy() override;
159
160   Graphics::Controller& GetController() override;
161
162   bool IsAdvancedBlendEquationSupported() override
163   {
164     return mGLES->IsAdvancedBlendEquationSupported();
165   }
166
167   /**
168    * @return true if graphics subsystem is initialized
169    */
170   bool IsInitialized() override
171   {
172     return mEglImplementation && mEglImplementation->IsGlesInitialized();
173   }
174
175   bool IsResourceContextSupported() override
176   {
177     return mEglImplementation && mEglImplementation->IsSurfacelessContextSupported();
178   }
179
180   uint32_t GetMaxTextureSize() override
181   {
182     return mGLES->GetMaxTextureSize();
183   }
184
185   uint32_t GetShaderLanguageVersion() override
186   {
187     return mGLES->GetShadingLanguageVersion();
188   }
189
190   const char* GetEglImageExtensionString()
191   {
192     return mGLES->GetEglImageExtensionString();
193   }
194
195   void CacheConfigurations(ConfigurationManager& configurationManager) override;
196
197 private:
198   // Eliminate copy and assigned operations
199   EglGraphics(const EglGraphics& rhs) = delete;
200   EglGraphics& operator=(const EglGraphics& rhs) = delete;
201
202   /**
203    * Initialize graphics subsystems
204    */
205   void EglInitialize();
206
207 private:
208   Graphics::EglGraphicsController                 mGraphicsController; ///< Graphics Controller for Dali Core
209   std::unique_ptr<GlImplementation>               mGLES;               ///< GL implementation
210   std::unique_ptr<EglImplementation>              mEglImplementation;  ///< EGL implementation
211   std::unique_ptr<EglImageExtensions>             mEglImageExtensions; ///< EGL image extension
212   std::unique_ptr<EglSyncImplementation>          mEglSync;            ///< GlSyncAbstraction implementation for EGL
213   std::unique_ptr<EglContextHelperImplementation> mEglContextHelper;   ///< GlContextHelperAbstraction implementation for EGL
214
215   int mMultiSamplingLevel; ///< The multiple sampling level
216 };
217
218 } // namespace Adaptor
219
220 } // namespace Internal
221
222 } // namespace Dali
223
224 #endif // DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H