[Tizen] CleanUp gles version setter + Get exact FBO MSAA sample level
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-graphics.h
index 410395c..88558ba 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/integration-api/adaptor-framework/egl-interface.h>
 #include <dali/internal/graphics/common/egl-image-extensions.h>
 #include <dali/internal/graphics/common/graphics-interface.h>
-#include <dali/internal/graphics/gles/gl-implementation.h>
-#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
+#include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
 #include <dali/internal/graphics/gles/egl-context-helper-implementation.h>
 #include <dali/internal/graphics/gles/egl-implementation.h>
 #include <dali/internal/graphics/gles/egl-sync-implementation.h>
+#include <dali/internal/graphics/gles/gl-implementation.h>
+#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 namespace Adaptor
 {
+class EnvironmentOptions;
+class ConfigurationManager;
 
 class EglGraphics : public GraphicsInterface
 {
 public:
-
   /**
    * Constructor
    */
-  EglGraphics();
+  EglGraphics(EnvironmentOptions& environmentOptions);
 
   /**
    * Destructor
@@ -54,25 +54,48 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize()
    */
-  void Initialize( EnvironmentOptions* environmentOptions ) override;
+  void Initialize() override;
 
   /**
-   * Creates the graphics interface for EGL
-   * @return The graphics interface for EGL
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize(bool,bool,bool,int)
    */
-  EglInterface* Create();
+  void Initialize(bool depth, bool stencil, bool partialRendering, int msaa);
 
   /**
-   * Set gles version
-   * Default version is gles 3.0
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::ConfigureSurface()
    */
-  void SetGlesVersion( const int32_t glesVersion );
+  void ConfigureSurface(Dali::RenderSurfaceInterface* surface) override;
 
   /**
    * Set whether the surfaceless context is supported
    * @param[in] isSupported Whether the surfaceless context is supported
    */
-  void SetIsSurfacelessContextSupported( const bool isSupported );
+  void SetIsSurfacelessContextSupported(const bool isSupported);
+
+  /**
+   * Activate the resource context (shared surfaceless context)
+   */
+  void ActivateResourceContext() override;
+
+  /**
+   * Activate the surface context
+   *
+   * @param[in] surface The surface whose context to be switched to.
+   */
+  void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) override;
+
+  /**
+   * This is called after all the surfaces have been rendered.
+   *
+   * @note This should not be called if uploading resource only without rendering any surface.
+   */
+  void PostRender() override;
+
+  /**
+   * Inform graphics interface that this is the first frame after a resume.
+   * (For debug only)
+   */
+  void SetFirstFrameAfterResume() override;
 
   /**
    * Gets the GL abstraction
@@ -126,34 +149,81 @@ public:
   EglImageExtensions* GetImageExtensions();
 
   /**
-   * Sets fixed damaged areas for partial rendering. This overrides automatic partial rendering.
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Shutdown()
    */
-  void SetDamagedAreas( std::vector<Dali::Rect<int>>& areas );
+  void Shutdown() override;
 
   /**
-   * Instructs egl implementation to do full swap regardless of stored data, resets the data.
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
    */
-  void SetFullSwapNextFrame();
+  void Destroy() override;
+
+  Graphics::Controller& GetController() override;
+
+  bool IsAdvancedBlendEquationSupported() override
+  {
+    return mGLES->IsAdvancedBlendEquationSupported();
+  }
+
+  bool IsMultisampledRenderToTextureSupported() override
+  {
+    return mGLES->IsMultisampledRenderToTextureSupported();
+  }
 
   /**
-   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
+   * @return true if graphics subsystem is initialized
    */
-  void Destroy() override;
+  bool IsInitialized() override
+  {
+    return mEglImplementation && mEglImplementation->IsGlesInitialized();
+  }
+
+  bool IsResourceContextSupported() override
+  {
+    return mEglImplementation && mEglImplementation->IsSurfacelessContextSupported();
+  }
+
+  uint32_t GetMaxTextureSize() override
+  {
+    return mGLES->GetMaxTextureSize();
+  }
+
+  uint8_t GetMaxTextureSamples() override
+  {
+    return mGLES->GetMaxTextureSamples();
+  }
+
+  uint32_t GetShaderLanguageVersion() override
+  {
+    return mGLES->GetShadingLanguageVersion();
+  }
+
+  bool ApplyNativeFragmentShader(std::string& shader, const char* customSamplerType)
+  {
+    return mGLES->ApplyNativeFragmentShader(shader, customSamplerType);
+  }
+
+  void CacheConfigurations(ConfigurationManager& configurationManager) override;
 
 private:
   // Eliminate copy and assigned operations
   EglGraphics(const EglGraphics& rhs) = delete;
   EglGraphics& operator=(const EglGraphics& rhs) = delete;
 
+  /**
+   * Initialize graphics subsystems
+   */
+  void EglInitialize();
 
 private:
-  std::unique_ptr< GlImplementation > mGLES;                    ///< GL implementation
-  std::unique_ptr< EglImplementation > mEglImplementation;      ///< EGL implementation
-  std::unique_ptr< EglImageExtensions > mEglImageExtensions;    ///< EGL image extension
-  std::unique_ptr< EglSyncImplementation > mEglSync;            ///< GlSyncAbstraction implementation for EGL
-  std::unique_ptr< EglContextHelperImplementation > mEglContextHelper; ///< GlContextHelperAbstraction implementation for EGL
-
-  int mMultiSamplingLevel;                                      ///< The multiple sampling level
+  Graphics::EglGraphicsController                 mGraphicsController; ///< Graphics Controller for Dali Core
+  std::unique_ptr<GlImplementation>               mGLES;               ///< GL implementation
+  std::unique_ptr<EglImplementation>              mEglImplementation;  ///< EGL implementation
+  std::unique_ptr<EglImageExtensions>             mEglImageExtensions; ///< EGL image extension
+  std::unique_ptr<EglSyncImplementation>          mEglSync;            ///< GlSyncAbstraction implementation for EGL
+  std::unique_ptr<EglContextHelperImplementation> mEglContextHelper;   ///< GlContextHelperAbstraction implementation for EGL
+
+  int mMultiSamplingLevel; ///< The multiple sampling level
 };
 
 } // namespace Adaptor