Added property to Renderer to specify the depth function 04/68504/5
authorFerran Sole <ferran.sole@samsung.com>
Thu, 5 May 2016 08:24:15 +0000 (09:24 +0100)
committerFerran Sole <ferran.sole@samsung.com>
Mon, 9 May 2016 14:07:26 +0000 (15:07 +0100)
- New property in Renderer to specify whether to enable depth testing
  and which depth function to use if enabled

Change-Id: I2964a0796209d711eb185ccf2be3d7ec1f8b202d

13 files changed:
automated-tests/src/dali-devel/utc-Dali-Renderer.cpp
automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h
dali/devel-api/rendering/renderer.h
dali/internal/common/type-abstraction-enums.h
dali/internal/event/rendering/renderer-impl.cpp
dali/internal/event/rendering/renderer-impl.h
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/gl-resources/context.cpp
dali/internal/render/gl-resources/context.h
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/update/rendering/scene-graph-renderer.cpp
dali/internal/update/rendering/scene-graph-renderer.h

index 7b26c80..6059540 100644 (file)
@@ -1862,3 +1862,152 @@ int UtcDaliRendererSetIndexRange(void)
 
   END_TEST;
 }
+
+
+int UtcDaliRendererSetDepthFunction(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test setting the depth function");
+
+  Geometry geometry = CreateQuadGeometry();
+  Shader shader = CreateShader();
+  Renderer renderer = Renderer::New( geometry, shader );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage stage = Stage::GetCurrent();
+  stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
+  stage.Add(actor);
+
+  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+  glAbstraction.EnableEnableDisableCallTrace(true);
+  glAbstraction.EnableDepthFunctionCallTrace(true);
+
+  TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
+
+  std::ostringstream depthTestStr;
+  depthTestStr << GL_DEPTH_TEST;
+
+  //OFF
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::OFF);
+    glEnableDisableStack.Reset();
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    //Depth testing should be disabled
+    DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", depthTestStr.str().c_str() ) );
+  }
+
+  //GL_NEVER
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
+
+    glEnableDisableStack.Reset();
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", depthTestStr.str().c_str() ) );
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_NEVER;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_ALWAYS
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_ALWAYS;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_LESS
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_LESS;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_GREATER
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_GREATER;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_EQUAL
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_EQUAL;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_NOTEQUAL
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_NOTEQUAL;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_LEQUAL
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_LEQUAL;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  //GL_GEQUAL
+  {
+    renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
+
+    glDepthFunctionStack.Reset();
+    application.SendNotification();
+    application.Render();
+
+    std::ostringstream depthFunctionStr;
+    depthFunctionStr << GL_GEQUAL;
+    DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
+  }
+
+  END_TEST;
+}
index 1fe97c1..a40d776 100644 (file)
@@ -389,6 +389,9 @@ public:
 
   inline void DepthFunc(GLenum func)
   {
+    std::stringstream out;
+    out << func;
+    mDepthFunctionTrace.PushCall("DepthFunc", out.str());
   }
 
   inline void DepthMask(GLboolean flag)
@@ -1634,6 +1637,11 @@ public: // TEST FUNCTIONS
   inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
   inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
 
+  //Methods for Depth function verification
+  inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
+  inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
+  inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
+
   template <typename T>
   inline bool GetUniformValue( const char* name, T& value ) const
   {
@@ -1850,6 +1858,7 @@ private:
   TraceCallStack mTextureTrace;
   TraceCallStack mTexParamaterTrace;
   TraceCallStack mDrawTrace;
+  TraceCallStack mDepthFunctionTrace;
 
   // Shaders & Uniforms
   GLuint mLastShaderIdUsed;
index 3d8efed..9581b91 100644 (file)
@@ -128,6 +128,27 @@ enum Type
 
 } // namespace DepthWriteMode
 
+namespace DepthFunction
+{
+
+/**
+ * @brief Depth functions
+ */
+enum Type
+{
+  OFF,          ///< Depth test is disabled
+  NEVER,        ///< Depth test never passes
+  ALWAYS,       ///< Depth test always passes
+  LESS,         ///< Depth test passes if the incoming depth value is less than the stored depth value
+  GREATER,      ///< Depth test passes if the incoming depth value is greater than the stored depth value
+  EQUAL,        ///< Depth test passes if the incoming depth value is equal to the stored depth value
+  NOT_EQUAL,    ///< Depth test passes if the incoming depth value is not equal to the stored depth value
+  LESS_EQUAL,   ///< Depth test passes if the incoming depth value is less than or equal to the stored depth value
+  GREATER_EQUAL ///< Depth test passes if the incoming depth value is greater than or equal to the stored depth value
+};
+
+} // namespace DepthFunction
+
 /**
  * @brief Renderer is a handle to an object used to show content by combining a Geometry, a TextureSet and a shader
  */
@@ -225,7 +246,14 @@ public:
        * @see DepthWriteMode
        * @note The default value is DepthWriteMode::AUTO
        */
-      DEPTH_WRITE_MODE
+      DEPTH_WRITE_MODE,
+
+      /**
+       * @brief name "depthFunction", type INTEGER
+       * @see DepthFunction
+       * @note The default value is DepthFunction::LESS
+       */
+      DEPTH_FUNCTION
     };
   };
 
index 0b65d0a..e1b9a89 100644 (file)
@@ -31,6 +31,7 @@ namespace Internal
 template <> struct ParameterType< Dali::FaceCullingMode::Type > : public BasicType< Dali::FaceCullingMode::Type > {};
 template <> struct ParameterType< Dali::BlendMode::Type > : public BasicType< Dali::BlendMode::Type > {};
 template <> struct ParameterType< Dali::DepthWriteMode::Type > : public BasicType< Dali::DepthWriteMode::Type > {};
+template <> struct ParameterType< Dali::DepthFunction::Type > : public BasicType< Dali::DepthFunction::Type > {};
 
 } //namespace Internal
 
index e2367ea..301a0ff 100644 (file)
@@ -54,6 +54,7 @@ DALI_PROPERTY( "blendPreMultipliedAlpha",         BOOLEAN,   true, false,  false
 DALI_PROPERTY( "indexRangeFirst",                 INTEGER,   true, false,  false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
 DALI_PROPERTY( "indexRangeCount",                 INTEGER,   true, false,  false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
 DALI_PROPERTY( "depthWriteMode",                  INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
+DALI_PROPERTY( "depthFunction",                   INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_FUNCTION )
 DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
 
 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
@@ -473,6 +474,19 @@ void Renderer::SetDefaultProperty( Property::Index index,
 
       break;
     }
+    case Dali::Renderer::Property::DEPTH_FUNCTION:
+    {
+      int value;
+      propertyValue.Get( value );
+      DepthFunction::Type depthFunction = static_cast<DepthFunction::Type>(value);
+      if( depthFunction != mDepthFunction )
+      {
+        mDepthFunction = depthFunction;
+        SetDepthFunctionMessage( GetEventThreadServices(), *mSceneObject, depthFunction );
+      }
+
+      break;
+    }
   }
 }
 
@@ -586,6 +600,11 @@ Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
       value = mDepthWriteMode;
       break;
     }
+    case Dali::Renderer::Property::DEPTH_FUNCTION:
+    {
+      value = mDepthFunction;
+      break;
+    }
   }
   return value;
 }
@@ -675,6 +694,7 @@ Renderer::Renderer()
   mBlendMode( BlendMode::AUTO ),
   mBlendingOptions(),
   mDepthWriteMode( DepthWriteMode::AUTO ),
+  mDepthFunction( DepthFunction::LESS ),
   mPremultipledAlphaEnabled( false )
 {
 }
index b43a582..2b3686d 100644 (file)
@@ -318,6 +318,7 @@ private: // data
   BlendMode::Type mBlendMode;                       ///< Local copy of blending mode
   BlendingOptions mBlendingOptions;                 ///< Local copy of blending options bitmask
   Dali::DepthWriteMode::Type mDepthWriteMode;       ///< Local copy of depth write mode
+  Dali::DepthFunction::Type mDepthFunction;         ///< Local copy of depth function
 
   bool mPremultipledAlphaEnabled : 1;               ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
 };
index 879dba8..e67f985 100644 (file)
@@ -40,6 +40,71 @@ namespace Render
 {
 
 /**
+ * Helper to set the depth function
+ * @param[in] context The GL context
+ * @param[in] depthFunction The depth function
+ */
+inline void SetDepthFunction( Context& context, DepthFunction::Type depthFunction )
+{
+  switch( depthFunction )
+  {
+    case DepthFunction::OFF:
+    {
+      context.EnableDepthBuffer( false );
+      break;
+    }
+    case DepthFunction::NEVER:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_NEVER );
+      break;
+    }
+    case DepthFunction::ALWAYS:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_ALWAYS );
+      break;
+    }
+    case DepthFunction::LESS:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_LESS );
+      break;
+    }
+    case DepthFunction::GREATER:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_GREATER );
+      break;
+    }
+    case DepthFunction::EQUAL:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_EQUAL );
+      break;
+    }
+    case DepthFunction::NOT_EQUAL:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_NOTEQUAL );
+      break;
+    }
+    case DepthFunction::LESS_EQUAL:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_LEQUAL );
+      break;
+    }
+    case DepthFunction::GREATER_EQUAL:
+    {
+      context.EnableDepthBuffer( true );
+      context.DepthFunc( GL_GEQUAL );
+      break;
+    }
+  }
+}
+
+/**
  * Sets up the scissor test if required.
  * @param[in] renderList The render list from which to get the clipping flag
  * @param[in] context The context
@@ -148,6 +213,7 @@ inline void ProcessRenderList(
         context.DepthMask( ( depthWriteMode == DepthWriteMode::AUTO && item.mIsOpaque ) ||
                            ( depthWriteMode == DepthWriteMode::ON ) );
 
+        SetDepthFunction( context, item.mRenderer->GetDepthFunction() );
         item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
                                 item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
       }
index 29b7758..be82555 100644 (file)
@@ -91,6 +91,7 @@ Context::Context(Integration::GlAbstraction& glAbstraction)
   mBlendFuncSeparateDstAlpha(GL_ZERO),
   mBlendEquationSeparateModeRGB( GL_FUNC_ADD ),
   mBlendEquationSeparateModeAlpha( GL_FUNC_ADD ),
+  mDepthFunction( GL_LESS ),
   mMaxTextureSize(0),
   mClearColor(Color::WHITE),    // initial color, never used until it's been set by the user
   mCullFaceMode( FaceCullingMode::NONE ),
index 8d6747d..29d06d2 100644 (file)
@@ -664,8 +664,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,6 +1725,8 @@ 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
 
index 8791f4d..b1df84e 100644 (file)
@@ -116,9 +116,10 @@ Renderer* Renderer::New( SceneGraph::RenderDataProvider* dataProvider,
                          const Vector4* blendColor,
                          FaceCullingMode::Type faceCullingMode,
                          bool preMultipliedAlphaEnabled,
-                         DepthWriteMode::Type depthWriteMode )
+                         DepthWriteMode::Type depthWriteMode,
+                         DepthFunction::Type depthFunction )
 {
-  return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode );
+  return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthFunction );
 }
 
 Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
@@ -127,7 +128,8 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
                     const Vector4* blendColor,
                     FaceCullingMode::Type faceCullingMode,
                     bool preMultipliedAlphaEnabled,
-                    DepthWriteMode::Type depthWriteMode )
+                    DepthWriteMode::Type depthWriteMode,
+                    DepthFunction::Type depthFunction )
 : mRenderDataProvider( dataProvider ),
   mContext(NULL),
   mTextureCache( NULL ),
@@ -138,6 +140,7 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
   mBlendingOptions(),
   mFaceCullingMode( faceCullingMode  ),
   mDepthWriteMode( depthWriteMode ),
+  mDepthFunction( depthFunction ),
   mIndexedDrawFirstElement( 0 ),
   mIndexedDrawElementsCount( 0 ),
   mUpdateAttributesLocation( true ),
@@ -438,6 +441,16 @@ DepthWriteMode::Type Renderer::GetDepthWriteMode() const
   return mDepthWriteMode;
 }
 
+void Renderer::SetDepthFunction( DepthFunction::Type depthFunction )
+{
+  mDepthFunction = depthFunction;
+}
+
+DepthFunction::Type Renderer::GetDepthFunction() const
+{
+  return mDepthFunction;
+}
+
 void Renderer::Render( Context& context,
                        SceneGraph::TextureCache& textureCache,
                        BufferIndex bufferIndex,
index 3573047..c9997b0 100644 (file)
@@ -83,6 +83,7 @@ public:
    * @param[in] faceCullingMode The face-culling mode.
    * @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied.
    * @param[in] depthWriteMode Depth buffer write mode
+   * @param[in] depthFunction Depth function
    */
   static Renderer* New( SceneGraph::RenderDataProvider* dataProviders,
                         Render::Geometry* geometry,
@@ -90,7 +91,8 @@ public:
                         const Vector4* blendColor,
                         FaceCullingMode::Type faceCullingMode,
                         bool preMultipliedAlphaEnabled,
-                        DepthWriteMode::Type depthWriteMode );
+                        DepthWriteMode::Type depthWriteMode,
+                        DepthFunction::Type depthFunction );
 
   /**
    * Constructor.
@@ -101,6 +103,7 @@ public:
    * @param[in] faceCullingMode The face-culling mode.
    * @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied.
    * @param[in] depthWriteMode Depth buffer write mode
+   * @param[in] depthFunction Depth function
    */
   Renderer( SceneGraph::RenderDataProvider* dataProviders,
             Render::Geometry* geometry,
@@ -108,7 +111,8 @@ public:
             const Vector4* blendColor,
             FaceCullingMode::Type faceCullingMode,
             bool preMultipliedAlphaEnabled,
-            DepthWriteMode::Type depthWriteMode );
+            DepthWriteMode::Type depthWriteMode,
+            DepthFunction::Type depthFunction );
 
   /**
    * Change the data providers of the renderer
@@ -173,16 +177,28 @@ public:
   void EnablePreMultipliedAlpha( bool preMultipled );
 
   /**
+   * Sets the depth write mode
+   * @param[in] depthWriteMode The depth write mode
+   */
+  void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
+
+  /**
    * Query the Renderer's depth write mode
    * @return The renderer depth write mode
    */
   DepthWriteMode::Type GetDepthWriteMode() const;
 
   /**
-   * Sets the depth write mode
-   * @param[in] depthWriteMode The depth write mode
+   * Sets the depth function
+   * @param[in] depthFunction The depth function
    */
-  void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
+  void SetDepthFunction( DepthFunction::Type depthFunction );
+
+  /**
+   * Query the Renderer's depth function
+   * @return The renderer depth function
+   */
+  DepthFunction::Type GetDepthFunction() const;
 
   /**
    * Called to render during RenderManager::Render().
@@ -280,6 +296,7 @@ private:
   BlendingOptions       mBlendingOptions; /// Blending options including blend color, blend func and blend equation
   FaceCullingMode::Type mFaceCullingMode; /// Mode of face culling
   DepthWriteMode::Type  mDepthWriteMode;  /// Depth write mode
+  DepthFunction::Type   mDepthFunction;   /// Depth function
 
   size_t mIndexedDrawFirstElement;                  /// Offset of first element to draw
   size_t mIndexedDrawElementsCount;                 /// Number of elements to draw
index d293775..f004cc8 100644 (file)
@@ -98,6 +98,7 @@ enum Flags
   RESEND_INDEXED_DRAW_FIRST_ELEMENT = 1 << 6,
   RESEND_INDEXED_DRAW_ELEMENTS_COUNT = 1 << 7,
   RESEND_DEPTH_WRITE_MODE = 1 << 8,
+  RESEND_DEPTH_FUNCTION = 1 << 9,
 };
 
 }
@@ -125,6 +126,7 @@ Renderer::Renderer()
  mFaceCullingMode( FaceCullingMode::NONE ),
  mBlendMode( BlendMode::AUTO ),
  mDepthWriteMode( DepthWriteMode::AUTO ),
+ mDepthFunction( DepthFunction::LESS ),
  mIndexedDrawFirstElement( 0 ),
  mIndexedDrawElementsCount( 0 ),
  mReferenceCount( 0 ),
@@ -283,6 +285,13 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex )
       new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthWriteMode, mDepthWriteMode );
     }
 
+    if( mResendFlag & RESEND_DEPTH_FUNCTION )
+    {
+      typedef MessageValue1< Render::Renderer, DepthFunction::Type > DerivedType;
+      unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+      new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction );
+    }
+
     mResendFlag = 0;
   }
 }
@@ -333,15 +342,15 @@ void Renderer::SetDepthIndex( int depthIndex )
   mDepthIndex = depthIndex;
 }
 
-void Renderer::SetFaceCullingMode( unsigned int faceCullingMode )
+void Renderer::SetFaceCullingMode( FaceCullingMode::Type faceCullingMode )
 {
-  mFaceCullingMode = static_cast< FaceCullingMode::Type >( faceCullingMode );
+  mFaceCullingMode = faceCullingMode;
   mResendFlag |= RESEND_FACE_CULLING_MODE;
 }
 
-void Renderer::SetBlendMode( unsigned int blendingMode )
+void Renderer::SetBlendMode( BlendMode::Type blendingMode )
 {
-  mBlendMode = static_cast< BlendMode::Type >( blendingMode );
+  mBlendMode = blendingMode;
 }
 
 void Renderer::SetBlendingOptions( unsigned int options )
@@ -385,12 +394,18 @@ void Renderer::EnablePreMultipliedAlpha( bool preMultipled )
   mResendFlag |= RESEND_PREMULTIPLIED_ALPHA;
 }
 
-void Renderer::SetDepthWriteMode( unsigned int depthWriteMode )
+void Renderer::SetDepthWriteMode( DepthWriteMode::Type depthWriteMode )
 {
-  mDepthWriteMode = static_cast< DepthWriteMode::Type >( depthWriteMode );
+  mDepthWriteMode = depthWriteMode;
   mResendFlag |= RESEND_DEPTH_WRITE_MODE;
 }
 
+void Renderer::SetDepthFunction( DepthFunction::Type depthFunction )
+{
+  mDepthFunction = depthFunction;
+  mResendFlag |= RESEND_DEPTH_FUNCTION;
+}
+
 //Called when a node with this renderer is added to the stage
 void Renderer::OnStageConnect()
 {
@@ -403,7 +418,8 @@ void Renderer::OnStageConnect()
                                        mBlendBitmask, mBlendColor,
                                        static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
                                        mPremultipledAlphaEnabled,
-                                       mDepthWriteMode );
+                                       mDepthWriteMode,
+                                       mDepthFunction );
 
     mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
     mResendFlag = 0;
index 705049c..34d3606 100644 (file)
@@ -21,6 +21,7 @@
 #include <dali/devel-api/rendering/geometry.h>
 #include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
 #include <dali/internal/common/blending-options.h>
+#include <dali/internal/common/type-abstraction-enums.h>
 #include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/uniform-map.h>
@@ -127,13 +128,13 @@ public:
    * Set the face culling mode
    * @param[in] faceCullingMode to use
    */
-  void SetFaceCullingMode( unsigned int faceCullingMode );
+  void SetFaceCullingMode( FaceCullingMode::Type faceCullingMode );
 
   /**
    * Set the blending mode
    * @param[in] blendingMode to use
    */
-  void SetBlendMode( unsigned int blendingMode );
+  void SetBlendMode( BlendMode::Type blendingMode );
 
   /**
    * Set the blending options. This should only be called from the update thread.
@@ -170,7 +171,13 @@ public:
    * Sets the depth buffer write mode
    * @param[in] depthWriteMode The depth buffer write mode
    */
-  void SetDepthWriteMode( unsigned int depthWriteMode );
+  void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
+
+  /**
+   * Sets the depth function
+   * @param[in] depthFunction The depth function
+   */
+  void SetDepthFunction( DepthFunction::Type depthFunction );
 
   /**
    * Called when an actor with this renderer is added to the stage
@@ -323,6 +330,7 @@ private:
   FaceCullingMode::Type mFaceCullingMode; ///< The mode of face culling
   BlendMode::Type       mBlendMode;       ///< The mode of blending
   DepthWriteMode::Type  mDepthWriteMode;  ///< The depth write mode
+  DepthFunction::Type   mDepthFunction;   ///< The depth function
 
   CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer
 
@@ -330,7 +338,7 @@ private:
   size_t mIndexedDrawElementsCount;            ///< number of elements to be drawn using indexed draw
   unsigned int mReferenceCount;                ///< Number of nodes currently using this renderer
   unsigned int mRegenerateUniformMap;          ///< 2 if the map should be regenerated, 1 if it should be copied.
-  unsigned char mResendFlag;                   ///< Indicate whether data should be resent to the renderer
+  unsigned short mResendFlag;                  ///< Indicate whether data should be resent to the renderer
   bool         mUniformMapChanged[2];          ///< Records if the uniform map has been altered this frame
   bool         mResourcesReady;                ///< Set during the Update algorithm; true if the renderer has resources ready for the current frame.
   bool         mFinishedResourceAcquisition;   ///< Set during DoPrepareResources; true if ready & all resource acquisition has finished (successfully or otherwise)
@@ -387,9 +395,9 @@ inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, cons
   new (slot) LocalType( &renderer, &Renderer::SetDepthIndex, depthIndex );
 }
 
-inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::FaceCullingMode::Type faceCullingMode )
+inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode )
 {
-  typedef MessageValue1< Renderer, unsigned int > LocalType;
+  typedef MessageValue1< Renderer, FaceCullingMode::Type > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -399,7 +407,7 @@ inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices,
 
 inline void SetBlendModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode )
 {
-  typedef MessageValue1< Renderer, unsigned int > LocalType;
+  typedef MessageValue1< Renderer, BlendMode::Type > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -457,9 +465,9 @@ inline void SetEnablePreMultipliedAlphaMessage( EventThreadServices& eventThread
   new (slot) LocalType( &renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied );
 }
 
-inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::DepthWriteMode::Type depthWriteMode )
+inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode )
 {
-  typedef MessageValue1< Renderer, unsigned int > LocalType;
+  typedef MessageValue1< Renderer, DepthWriteMode::Type > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -467,6 +475,16 @@ inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices,
   new (slot) LocalType( &renderer, &Renderer::SetDepthWriteMode, depthWriteMode );
 }
 
+inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction )
+{
+  typedef MessageValue1< Renderer, DepthFunction::Type > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction );
+}
+
 inline void OnStageConnectMessage( EventThreadServices& eventThreadServices, const Renderer& renderer )
 {
   typedef Message< Renderer > LocalType;