Merge "Use existing callback ID for recurring callbacks" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-implementation.h
index e299da7..8a23ef1 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_EGL_IMPLEMENTATION_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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/list-wrapper.h>
+#include <dali/public-api/common/vector-wrapper.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>
 #include <dali/integration-api/core-enumerations.h>
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/egl-interface.h>
+#include <dali/integration-api/adaptor-framework/egl-interface.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
 namespace Adaptor
@@ -48,20 +50,22 @@ public:
    * @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 );
+                     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
@@ -73,7 +77,7 @@ public:
     * 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.
@@ -94,7 +98,7 @@ public:
   /**
    * Make the OpenGL context current
    */
-  virtual void MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext );
+  void MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext ) override;
 
   /**
    * clear the OpenGL context
@@ -112,7 +116,7 @@ public:
   /**
    * Terminate GL
    */
-  virtual void TerminateGles();
+  void TerminateGles() override;
 
   /**
    * Checks if GL is initialised
@@ -123,24 +127,40 @@ 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
    * @param isWindowType whether the config for window or pixmap
    * @param colorDepth Bit per pixel value (ex. 32 or 24)
+   * @return true if the eglChooseConfig is succeed.
   */
-  void ChooseConfig( bool isWindowType, ColorDepth depth );
+  bool ChooseConfig( bool isWindowType, ColorDepth depth );
 
   /**
     * Create an OpenGL surface using a window
@@ -176,6 +196,16 @@ public:
   bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface );
 
   /**
+   * Sets gles version
+   */
+  void SetGlesVersion( const int32_t glesVersion );
+
+  /**
+   * Sets Whether the frame is the first after Resume.
+   */
+  void SetFirstFrameAfterResume();
+
+  /**
    * returns the display with which this object was initialized
    * @return the EGL Display.
    */
@@ -187,6 +217,29 @@ public:
    */
   EGLContext GetContext() const;
 
+  /**
+   * Returns the gles version
+   * @return the gles version
+   */
+  int32_t GetGlesVersion() const;
+
+  /**
+   * Returns whether the surfaceless context is supported
+   * @return true if the surfaceless context is supported
+   */
+  bool IsSurfacelessContextSupported() const;
+
+  /**
+   * @brief Wait until all rendering calls for the currently context are executed
+   */
+  void WaitClient();
+
+  /**
+   * @brief Returns whether the partial update is required.
+   * @return true if the partial update is required.
+   */
+  bool IsPartialUpdateRequired() const;
+
 private:
 
   Vector<EGLint>       mContextAttribs;
@@ -205,11 +258,13 @@ private:
   EglWindowContextContainer mEglWindowContexts;                ///< The EGL context for the window
 
   EGLSurface           mCurrentEglSurface;
+  EGLContext           mCurrentEglContext;
 
   typedef std::vector<EGLSurface> EglWindowSurfaceContainer;
   EglWindowSurfaceContainer mEglWindowSurfaces;                ///< The EGL surface for the window
 
-  int                  mMultiSamplingLevel;
+  int32_t              mMultiSamplingLevel;
+  int32_t              mGlesVersion;
 
   ColorDepth           mColorDepth;
 
@@ -218,6 +273,14 @@ private:
   bool                 mIsWindow;
   bool                 mDepthBufferRequired;
   bool                 mStencilBufferRequired;
+  bool                 mPartialUpdateRequired;
+  bool                 mIsSurfacelessContextSupported;
+  bool                 mIsKhrCreateContextSupported;
+
+  uint32_t              mSwapBufferCountAfterResume;
+  PFNEGLSETDAMAGEREGIONKHRPROC mEglSetDamageRegionKHR;
+  PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC mEglSwapBuffersWithDamageKHR;
+
 };
 
 } // namespace Adaptor