1 #ifndef DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
2 #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
38 class EnvironmentOptions;
39 class ConfigurationManager;
41 class EglGraphics : public GraphicsInterface
47 EglGraphics(EnvironmentOptions& environmentOptions);
52 virtual ~EglGraphics();
55 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize()
57 void Initialize() override;
60 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize(bool,bool,bool,int)
62 void Initialize(bool depth, bool stencil, bool partialRendering, int msaa);
65 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::ConfigureSurface()
67 void ConfigureSurface(Dali::RenderSurfaceInterface* surface) override;
71 * Default version is gles 3.0
73 void SetGlesVersion(const int32_t glesVersion);
76 * Set whether the surfaceless context is supported
77 * @param[in] isSupported Whether the surfaceless context is supported
79 void SetIsSurfacelessContextSupported(const bool isSupported);
82 * Activate the resource context (shared surfaceless context)
84 void ActivateResourceContext() override;
87 * Activate the surface context
89 * @param[in] surface The surface whose context to be switched to.
91 void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) override;
94 * Inform graphics interface that this is the first frame after a resume.
97 void SetFirstFrameAfterResume() override;
100 * Gets the GL abstraction
101 * @return The GL abstraction
103 Integration::GlAbstraction& GetGlAbstraction() const;
106 * Gets the implementation of EGL
107 * @return The implementation of EGL
109 EglImplementation& GetEglImplementation() const;
112 * Gets the graphics interface for EGL
113 * @return The graphics interface for EGL
115 EglInterface& GetEglInterface() const;
118 * @copydoc Dali::Integration::GlAbstraction& GetGlesInterface()
120 GlImplementation& GetGlesInterface();
123 * Gets the implementation of GlSyncAbstraction for EGL.
124 * @return The implementation of GlSyncAbstraction for EGL.
126 EglSyncImplementation& GetSyncImplementation();
129 * Gets the implementation of GlContextHelperAbstraction for EGL.
130 * @return The implementation of GlContextHelperAbstraction for EGL.
132 EglContextHelperImplementation& GetContextHelperImplementation();
135 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetDepthBufferRequired()
137 Integration::DepthBufferAvailable& GetDepthBufferRequired();
140 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetStencilBufferRequired()
142 Integration::StencilBufferAvailable GetStencilBufferRequired();
145 * Gets the EGL image extension
146 * @return The EGL image extension
148 EglImageExtensions* GetImageExtensions();
151 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Shutdown()
153 void Shutdown() override;
156 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
158 void Destroy() override;
160 Graphics::Controller& GetController() override;
162 bool IsAdvancedBlendEquationSupported() override
164 return mGLES->IsAdvancedBlendEquationSupported();
168 * @return true if graphics subsystem is initialized
170 bool IsInitialized() override
172 return mEglImplementation && mEglImplementation->IsGlesInitialized();
175 bool IsResourceContextSupported() override
177 return mEglImplementation && mEglImplementation->IsSurfacelessContextSupported();
180 uint32_t GetMaxTextureSize() override
182 return mGLES->GetMaxTextureSize();
185 uint32_t GetShaderLanguageVersion() override
187 return mGLES->GetShadingLanguageVersion();
190 const char* GetEglImageExtensionString()
192 return mGLES->GetEglImageExtensionString();
195 void CacheConfigurations(ConfigurationManager& configurationManager) override;
198 // Eliminate copy and assigned operations
199 EglGraphics(const EglGraphics& rhs) = delete;
200 EglGraphics& operator=(const EglGraphics& rhs) = delete;
203 * Initialize graphics subsystems
205 void EglInitialize();
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
215 int mMultiSamplingLevel; ///< The multiple sampling level
218 } // namespace Adaptor
220 } // namespace Internal
224 #endif // DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H