[3.0] Modify texture bind for OES_EGL_image_external
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / context.h
index 16782e3..136f09b 100644 (file)
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/math/vector4.h>
+#include <dali/public-api/rendering/renderer.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/gl-abstraction.h>
 #include <dali/integration-api/gl-defines.h>
-#include <dali/devel-api/rendering/renderer.h>
 #include <dali/internal/render/common/performance-monitor.h>
 #include <dali/internal/render/gl-resources/texture-units.h>
 #include <dali/internal/render/gl-resources/frame-buffer-state-cache.h>
@@ -286,6 +286,29 @@ public:
   }
 
   /**
+   * Wrapper for OpenGL ES 2.0 glBindTexture( target )
+   */
+  void BindTexture( int target, GLuint texture )
+  {
+    if (mBound2dTextureId[ mActiveTextureUnit ] != texture)
+    {
+      mBound2dTextureId[ mActiveTextureUnit ] = texture;
+
+      LOG_GL("BindTexture target(%d) %d\n", target, texture);
+      CHECK_GL( mGlAbstraction, mGlAbstraction.BindTexture(target, texture) );
+    }
+  }
+
+  /**
+   * Wrapper for OpenGL ES 2.0 glBindTexture(GL_TEXTURE_CUBE_MAP)
+   */
+  void BindCubeMapTexture( GLuint texture )
+  {
+    LOG_GL("BindTexture GL_TEXTURE_CUBE_MAP %d\n", texture);
+    CHECK_GL( mGlAbstraction, mGlAbstraction.BindTexture(GL_TEXTURE_CUBE_MAP, texture) );
+  }
+
+  /**
    * Wrapper for OpenGL ES 2.0 glBlendColor()
    */
   void SetDefaultBlendColor()
@@ -537,7 +560,7 @@ public:
    * enables GL_CULL_FACE if in any of the face culling modes
    * otherwise disables GL_CULL_FACE
    */
-  void CullFace( Dali::Renderer::FaceCullingMode mode )
+  void CullFace( Dali::FaceCullingMode::Type mode )
   {
     // Avoid unnecessary calls to gl
     if(mCullFaceMode != mode)
@@ -545,14 +568,14 @@ public:
       mCullFaceMode = mode;
       switch(mode)
       {
-        case Dali::Renderer::NONE:
+        case Dali::FaceCullingMode::NONE:
         {
           LOG_GL("Disable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Disable(GL_CULL_FACE) );
           break;
         }
 
-        case Dali::Renderer::CULL_FRONT:
+        case Dali::FaceCullingMode::FRONT:
         {
           LOG_GL("Enable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) );
@@ -561,7 +584,7 @@ public:
           break;
         }
 
-        case Dali::Renderer::CULL_BACK:
+        case Dali::FaceCullingMode::BACK:
         {
           LOG_GL("Enable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) );
@@ -570,7 +593,7 @@ public:
           break;
         }
 
-        case Dali::Renderer::CULL_BACK_AND_FRONT:
+        case Dali::FaceCullingMode::FRONT_AND_BACK:
         {
           LOG_GL("Enable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) );
@@ -664,8 +687,12 @@ public:
    */
   void DepthFunc(GLenum func)
   {
-    LOG_GL("DepthFunc %x\n", func);
-    CHECK_GL( mGlAbstraction, mGlAbstraction.DepthFunc(func) );
+    if( func != mDepthFunction )
+    {
+      mDepthFunction = func;
+      LOG_GL("DepthFunc %x\n", func);
+      CHECK_GL( mGlAbstraction, mGlAbstraction.DepthFunc(func) );
+    }
   }
 
   /**
@@ -1721,11 +1748,13 @@ private: // Data
   GLenum mBlendEquationSeparateModeRGB;    ///< Controls RGB blend mode
   GLenum mBlendEquationSeparateModeAlpha;  ///< Controls Alpha blend mode
 
+  GLenum mDepthFunction;  ///The depth function
+
   GLint mMaxTextureSize;      ///< return value from GetIntegerv(GL_MAX_TEXTURE_SIZE)
   Vector4 mClearColor;        ///< clear color
 
   // Face culling mode
-  Dali::Renderer::FaceCullingMode mCullFaceMode;
+  Dali::FaceCullingMode::Type mCullFaceMode;
 
   // cached viewport size
   Rect< int > mViewPort;