[Tizen] Add performance check logs
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-implementation.h
index ad890ed..bee38dc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_EGL_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.
  */
 
 // EXTERNAL INCLUDES
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/list-wrapper.h>
 #include <dali/public-api/common/vector-wrapper.h>
+
 #include <dali/integration-api/core-enumerations.h>
+#include <dali/internal/graphics/common/egl-include.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/rect.h>
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/adaptor-framework/egl-interface.h>
@@ -34,66 +37,65 @@ namespace Internal
 {
 namespace Adaptor
 {
-
 /**
  * EglImplementation class provides an EGL implementation.
  */
 class EglImplementation : public EglInterface
 {
 public:
-
   /**
    * Constructor
    * @param[in] multiSamplingLevel The Multi-sampling level required
    * @param[in] depthBufferRequired Whether the depth buffer is required
    * @param[in] stencilBufferRequired Whether the stencil buffer is required
+   * @param[in] partialUpdatedRequired Whether the partial update is required
    */
-  EglImplementation( int multiSamplingLevel,
-                     Integration::DepthBufferAvailable depthBufferRequired,
-                     Integration::StencilBufferAvailable stencilBufferRequired );
+  EglImplementation(int                                 multiSamplingLevel,
+                    Integration::DepthBufferAvailable   depthBufferRequired,
+                    Integration::StencilBufferAvailable stencilBufferRequired,
+                    Integration::PartialUpdateAvailable partialUpdateRequired);
 
   /**
    * Destructor
    */
-  virtual ~EglImplementation();
+  ~EglImplementation() override;
 
 public:
-
   /**
-   * (Called from  ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
+   * (Called from RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
    * Initialize GL
    * @param display The display
    * @param isOwnSurface whether the surface is own or not
    * @return true on success, false on failure
    */
-  bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
+  bool InitializeGles(EGLNativeDisplayType display, bool isOwnSurface = true);
 
   /**
     * Create the OpenGL context for the shared resource.
     * @return true if successful
     */
-  virtual bool CreateContext();
+  bool CreateContext() override;
 
   /**
     * Create the OpenGL context for the window.
     * @return true if successful
     */
-  bool CreateWindowContext( EGLContext& mEglContext );
+  bool CreateWindowContext(EGLContext& mEglContext);
 
   /**
     * Destroy the OpenGL context.
     */
-  void DestroyContext( EGLContext& eglContext );
+  void DestroyContext(EGLContext& eglContext);
 
   /**
     * Destroy the OpenGL surface.
     */
-  void DestroySurface( EGLSurface& eglSurface );
+  void DestroySurface(EGLSurface& eglSurface);
 
   /**
    * Make the OpenGL context current
    */
-  virtual void MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext );
+  void MakeContextCurrent(EGLSurface eglSurface, EGLContext eglContext) override;
 
   /**
    * clear the OpenGL context
@@ -106,12 +108,12 @@ public:
    * @param pixmap The pixmap to replace the current surface
    * @param eglSurface The eglSurface to replace the current OpenGL surface.
    */
-  void MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface );
+  void MakeCurrent(EGLNativePixmapType pixmap, EGLSurface eglSurface);
 
   /**
    * Terminate GL
    */
-  virtual void TerminateGles();
+  void TerminateGles() override;
 
   /**
    * Checks if GL is initialised
@@ -122,17 +124,32 @@ public:
   /**
    * Performs an OpenGL swap buffers command
    */
-  virtual void SwapBuffers( EGLSurface& eglSurface );
+  void SwapBuffers(EGLSurface& eglSurface) override;
+
+  /**
+   * Gets current back buffer age
+   */
+  EGLint GetBufferAge(EGLSurface& eglSurface) const;
+
+  /**
+   * Performs an OpenGL set damage command with damaged rects
+   */
+  void SetDamageRegion(EGLSurface& eglSurface, std::vector<Rect<int>>& damagedRects);
+
+  /**
+   * Performs an OpenGL swap buffers command with damaged rects
+   */
+  virtual void SwapBuffers(EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects);
 
   /**
    * Performs an OpenGL copy buffers command
    */
-  virtual void CopyBuffers( EGLSurface& eglSurface );
+  void CopyBuffers(EGLSurface& eglSurface) override;
 
   /**
    * Performs an EGL wait GL command
    */
-  virtual void WaitGL();
+  void WaitGL() override;
 
   /**
    * Choose config of egl
@@ -140,7 +157,7 @@ public:
    * @param colorDepth Bit per pixel value (ex. 32 or 24)
    * @return true if the eglChooseConfig is succeed.
   */
-  bool ChooseConfig( bool isWindowType, ColorDepth depth );
+  bool ChooseConfig(bool isWindowType, ColorDepth depth);
 
   /**
     * Create an OpenGL surface using a window
@@ -148,7 +165,7 @@ public:
     * @param colorDepth Bit per pixel value (ex. 32 or 24)
     * @return Handle to an on-screen EGL window surface (the requester has an ownership of this egl surface)
     */
-  EGLSurface CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
+  EGLSurface CreateSurfaceWindow(EGLNativeWindowType window, ColorDepth depth);
 
   /**
    * Create the OpenGL surface using a pixmap
@@ -156,7 +173,7 @@ public:
    * @param colorDepth Bit per pixel value (ex. 32 or 24)
    * @return Handle to an off-screen EGL pixmap surface (the requester has an ownership of this egl surface)
    */
-  EGLSurface CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
+  EGLSurface CreateSurfacePixmap(EGLNativePixmapType pixmap, ColorDepth depth);
 
   /**
    * Replaces the render surface
@@ -164,7 +181,7 @@ public:
    * @return true if the context was lost due to a change in display
    *         between old surface and new surface
    */
-  bool ReplaceSurfaceWindow( EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext );
+  bool ReplaceSurfaceWindow(EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext);
 
   /**
    * Replaces the render surface
@@ -173,12 +190,12 @@ public:
    * @return true if the context was lost due to a change in x-display
    *         between old surface and new surface
    */
-  bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface );
+  bool ReplaceSurfacePixmap(EGLNativePixmapType pixmap, EGLSurface& eglSurface);
 
   /**
    * Sets gles version
    */
-  void SetGlesVersion( const int32_t glesVersion );
+  void SetGlesVersion(const int32_t glesVersion);
 
   /**
    * Sets Whether the frame is the first after Resume.
@@ -214,43 +231,53 @@ public:
    */
   void WaitClient();
 
-private:
+  /**
+   * @brief Returns whether the partial update is required.
+   * @return true if the partial update is required.
+   */
+  bool IsPartialUpdateRequired() const;
 
-  Vector<EGLint>       mContextAttribs;
+private:
+  Vector<EGLint> mContextAttribs;
 
   EGLNativeDisplayType mEglNativeDisplay;
 
-  EGLNativeWindowType  mEglNativeWindow;
+  EGLNativeWindowType mEglNativeWindow;
 
-  EGLNativePixmapType  mCurrentEglNativePixmap;
+  EGLNativePixmapType mCurrentEglNativePixmap;
 
-  EGLDisplay           mEglDisplay;
-  EGLConfig            mEglConfig;
-  EGLContext           mEglContext;                            ///< The resource context holding assets such as textures to be shared
+  EGLDisplay mEglDisplay;
+  EGLConfig  mEglConfig;
+  EGLContext mEglContext; ///< The resource context holding assets such as textures to be shared
 
   typedef std::vector<EGLContext> EglWindowContextContainer;
-  EglWindowContextContainer mEglWindowContexts;                ///< The EGL context for the window
+  EglWindowContextContainer       mEglWindowContexts; ///< The EGL context for the window
 
-  EGLSurface           mCurrentEglSurface;
-  EGLContext           mCurrentEglContext;
+  EGLSurface mCurrentEglSurface;
+  EGLContext mCurrentEglContext;
 
   typedef std::vector<EGLSurface> EglWindowSurfaceContainer;
-  EglWindowSurfaceContainer mEglWindowSurfaces;                ///< The EGL surface for the window
-
-  int32_t              mMultiSamplingLevel;
-  int32_t              mGlesVersion;
-
-  ColorDepth           mColorDepth;
-
-  bool                 mGlesInitialized;
-  bool                 mIsOwnSurface;
-  bool                 mIsWindow;
-  bool                 mDepthBufferRequired;
-  bool                 mStencilBufferRequired;
-  bool                 mIsSurfacelessContextSupported;
-  bool                 mIsKhrCreateContextSupported;
-
-  uint32_t              mSwapBufferCountAfterResume;
+  EglWindowSurfaceContainer       mEglWindowSurfaces; ///< The EGL surface for the window
+
+  int32_t  mMultiSamplingLevel;
+  int32_t  mGlesVersion;
+  uint32_t mLogThreshold{0};
+
+  ColorDepth mColorDepth;
+
+  bool mGlesInitialized;
+  bool mIsOwnSurface;
+  bool mIsWindow;
+  bool mDepthBufferRequired;
+  bool mStencilBufferRequired;
+  bool mPartialUpdateRequired;
+  bool mIsSurfacelessContextSupported;
+  bool mIsKhrCreateContextSupported;
+  bool mLogEnabled{false};
+
+  uint32_t                           mSwapBufferCountAfterResume;
+  PFNEGLSETDAMAGEREGIONKHRPROC       mEglSetDamageRegionKHR;
+  PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC mEglSwapBuffersWithDamageKHR;
 };
 
 } // namespace Adaptor