Implemented face culling for SceneGraph::Material
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / context.h
index 1ae8caa..996335f 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/actors/renderable-actor.h>
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/rect.h>
@@ -27,6 +26,7 @@
 #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/material.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>
@@ -282,8 +282,6 @@ public:
 
       LOG_GL("BindTexture GL_TEXTURE_2D %d\n", texture);
       CHECK_GL( mGlAbstraction, mGlAbstraction.BindTexture(GL_TEXTURE_2D, texture) );
-
-      INCREASE_COUNTER(PerformanceMonitor::TEXTURE_STATE_CHANGES);
     }
   }
 
@@ -292,10 +290,9 @@ public:
    */
   void SetDefaultBlendColor()
   {
-    if( !mUsingDefaultBlendColor )
+    if( ! mUsingDefaultBlendColor )
     {
-      LOG_GL( "BlendColor %f %f %f %f\n", 0.0f, 0.0f, 0.0f, 0.0f );
-      CHECK_GL( mGlAbstraction, mGlAbstraction.BlendColor( 0.0f, 0.0f, 0.0f, 0.0f ) );
+      SetCustomBlendColor( Color::TRANSPARENT );
       mUsingDefaultBlendColor = true;
     }
   }
@@ -305,9 +302,13 @@ public:
    */
   void SetCustomBlendColor( const Vector4& color )
   {
-    LOG_GL( "BlendColor %f %f %f %f\n", color.r, color.g, color.b, color.a );
-    CHECK_GL( mGlAbstraction, mGlAbstraction.BlendColor(color.r, color.g, color.b, color.a) );
-    mUsingDefaultBlendColor = false;
+    if( mUsingDefaultBlendColor || mBlendColor != color )
+    {
+      LOG_GL( "BlendColor %f %f %f %f\n", color.r, color.g, color.b, color.a );
+      CHECK_GL( mGlAbstraction, mGlAbstraction.BlendColor( color.r, color.g, color.b, color.a ) );
+      mUsingDefaultBlendColor = false;
+      mBlendColor = color;
+    }
   }
 
   /**
@@ -536,7 +537,7 @@ public:
    * enables GL_CULL_FACE if in any of the face culling modes
    * otherwise disables GL_CULL_FACE
    */
-  void CullFace(CullFaceMode mode)
+  void CullFace( Dali::Material::FaceCullingMode mode )
   {
     // Avoid unnecessary calls to gl
     if(mCullFaceMode != mode)
@@ -544,14 +545,14 @@ public:
       mCullFaceMode = mode;
       switch(mode)
       {
-        case CullNone:
+        case Dali::Material::NONE:
         {
           LOG_GL("Disable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Disable(GL_CULL_FACE) );
           break;
         }
 
-        case CullFront:
+        case Dali::Material::CULL_FRONT:
         {
           LOG_GL("Enable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) );
@@ -560,7 +561,7 @@ public:
           break;
         }
 
-        case CullBack:
+        case Dali::Material::CULL_BACK:
         {
           LOG_GL("Enable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) );
@@ -569,7 +570,7 @@ public:
           break;
         }
 
-        case CullFrontAndBack:
+        case Dali::Material::CULL_BACK_AND_FRONT:
         {
           LOG_GL("Enable GL_CULL_FACE\n");
           CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) );
@@ -1765,6 +1766,7 @@ private: // Data
   bool mScissorTestEnabled;
   bool mStencilBufferEnabled;
   bool mClearColorSet;
+  bool mUsingDefaultBlendColor;
 
   // glBindBuffer() state
   GLuint mBoundArrayBufferId;        ///< The ID passed to glBindBuffer(GL_ARRAY_BUFFER)
@@ -1776,7 +1778,7 @@ private: // Data
   GLuint mBound2dTextureId[ MAX_TEXTURE_UNITS ];  ///< The ID passed to glBindTexture(GL_TEXTURE_2D)
 
   // glBlendColor() state
-  bool mUsingDefaultBlendColor;
+  Vector4 mBlendColor; ///< Blend color
 
   // glBlendFuncSeparate() state
   GLenum mBlendFuncSeparateSrcRGB;   ///< The srcRGB parameter passed to glBlendFuncSeparate()
@@ -1792,7 +1794,7 @@ private: // Data
   Vector4 mClearColor;        ///< clear color
 
   // Face culling mode
-  CullFaceMode mCullFaceMode;
+  Dali::Material::FaceCullingMode mCullFaceMode;
 
   // cached viewport size
   Rect< int > mViewPort;