1 #ifndef DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
2 #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
5 * Copyright (c) 2023 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;
70 * Set whether the surfaceless context is supported
71 * @param[in] isSupported Whether the surfaceless context is supported
73 void SetIsSurfacelessContextSupported(const bool isSupported);
76 * Activate the resource context (shared surfaceless context)
78 void ActivateResourceContext() override;
81 * Activate the surface context
83 * @param[in] surface The surface whose context to be switched to.
85 void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) override;
88 * This is called after all the surfaces have been rendered.
90 * @note This should not be called if uploading resource only without rendering any surface.
92 void PostRender() override;
95 * Inform graphics interface that this is the first frame after a resume.
98 void SetFirstFrameAfterResume() override;
101 * Gets the GL abstraction
102 * @return The GL abstraction
104 Integration::GlAbstraction& GetGlAbstraction() const;
107 * Gets the implementation of EGL
108 * @return The implementation of EGL
110 EglImplementation& GetEglImplementation() const;
113 * Gets the graphics interface for EGL
114 * @return The graphics interface for EGL
116 EglInterface& GetEglInterface() const;
119 * @copydoc Dali::Integration::GlAbstraction& GetGlesInterface()
121 GlImplementation& GetGlesInterface();
124 * Gets the implementation of GlSyncAbstraction for EGL.
125 * @return The implementation of GlSyncAbstraction for EGL.
127 EglSyncImplementation& GetSyncImplementation();
130 * Gets the implementation of GlContextHelperAbstraction for EGL.
131 * @return The implementation of GlContextHelperAbstraction for EGL.
133 EglContextHelperImplementation& GetContextHelperImplementation();
136 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetDepthBufferRequired()
138 Integration::DepthBufferAvailable& GetDepthBufferRequired();
141 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetStencilBufferRequired()
143 Integration::StencilBufferAvailable GetStencilBufferRequired();
146 * Gets the EGL image extension
147 * @return The EGL image extension
149 EglImageExtensions* GetImageExtensions();
152 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Shutdown()
154 void Shutdown() override;
157 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
159 void Destroy() override;
161 Graphics::Controller& GetController() override;
163 bool IsAdvancedBlendEquationSupported() override
165 return mGLES->IsAdvancedBlendEquationSupported();
168 bool IsMultisampledRenderToTextureSupported() override
170 return mGLES->IsMultisampledRenderToTextureSupported();
174 * @return true if graphics subsystem is initialized
176 bool IsInitialized() override
178 return mEglImplementation && mEglImplementation->IsGlesInitialized();
181 bool IsResourceContextSupported() override
183 return mEglImplementation && mEglImplementation->IsSurfacelessContextSupported();
186 uint32_t GetMaxTextureSize() override
188 return mGLES->GetMaxTextureSize();
191 uint8_t GetMaxTextureSamples() override
193 return mGLES->GetMaxTextureSamples();
196 uint32_t GetShaderLanguageVersion() override
198 return mGLES->GetShadingLanguageVersion();
201 bool ApplyNativeFragmentShader(std::string& shader, const char* customSamplerType)
203 return mGLES->ApplyNativeFragmentShader(shader, customSamplerType);
206 void CacheConfigurations(ConfigurationManager& configurationManager) override;
209 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::FrameStart()
211 void FrameStart() override;
214 * @copydoc Dali::Internal::Adaptor::GraphicsInterface::LogMemoryPools()
216 void LogMemoryPools() override;
219 // Eliminate copy and assigned operations
220 EglGraphics(const EglGraphics& rhs) = delete;
221 EglGraphics& operator=(const EglGraphics& rhs) = delete;
224 * Initialize graphics subsystems
226 void EglInitialize();
229 Graphics::EglGraphicsController mGraphicsController; ///< Graphics Controller for Dali Core
230 std::unique_ptr<GlImplementation> mGLES; ///< GL implementation
231 std::unique_ptr<EglImplementation> mEglImplementation; ///< EGL implementation
232 std::unique_ptr<EglImageExtensions> mEglImageExtensions; ///< EGL image extension
233 std::unique_ptr<EglSyncImplementation> mEglSync; ///< GlSyncAbstraction implementation for EGL
234 std::unique_ptr<EglContextHelperImplementation> mEglContextHelper; ///< GlContextHelperAbstraction implementation for EGL
236 int mMultiSamplingLevel; ///< The multiple sampling level
239 } // namespace Adaptor
241 } // namespace Internal
245 #endif // DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H