Revert "[3.0] Combine StencilMode and WriteToColorBuffer to RenderMode"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Renderer.cpp
index 0d93f91..78b4795 100644 (file)
@@ -2090,7 +2090,7 @@ int UtcDaliRendererEnumProperties(void)
   CheckEnumerationProperty< DepthFunction::Type >( renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
   CheckEnumerationProperty< DepthTestMode::Type >( renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
   CheckEnumerationProperty< StencilFunction::Type >( renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
-  CheckEnumerationProperty< RenderMode::Type >( renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
+  CheckEnumerationProperty< StencilMode::Type >( renderer, Renderer::Property::STENCIL_MODE, StencilMode::AUTO, StencilMode::OFF, StencilMode::ON, "ON" );
   CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
   CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
   CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
@@ -2251,10 +2251,10 @@ int UtcDaliRendererCheckStencilDefaults(void)
   END_TEST;
 }
 
-int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
+int UtcDaliRendererSetStencilMode(void)
 {
   TestApplication application;
-  tet_infoline("Test setting the RenderMode to use the stencil buffer");
+  tet_infoline("Test setting the StencilMode");
 
   Renderer renderer = RendererTestFixture( application );
   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
@@ -2263,36 +2263,19 @@ int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
   TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
   TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
 
-  // Set the StencilFunction to something other than the default, to confirm it is set as a property,
-  // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
   ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
 
+  // Set the StencilFunction to something other than the default, to confirm it is set as a property,
+  // but NO GL call has been made while the StencilMode is set to OFF.
   renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
   DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
-
-  ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
-  std::string methodString( "StencilFunc" );
-  DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
-
-  // Test the other RenderModes that will not enable the stencil buffer.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
   ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
-  DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
 
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
-  ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+  std::string methodString( "StencilFunc" );
   DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
 
-  // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
-  ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
-
-  DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
-  DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
-
-  // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
+  // Now set the StencilMode to ON and check the StencilFunction has changed.
+  renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
   ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
 
   DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
@@ -2301,42 +2284,6 @@ int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
   END_TEST;
 }
 
-// Helper function for the SetRenderModeToUseColorBuffer test.
-void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
-{
-  // Set the RenderMode property to a value that should not allow color buffer writes.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
-  application.SendNotification();
-  application.Render();
-
-  // Check if ColorMask has been called, and that the values are correct.
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
-
-  DALI_TEST_EQUALS<bool>( colorMaskParams.red,   expectedValue, TEST_LOCATION );
-  DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
-  DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  expectedValue, TEST_LOCATION );
-  DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
-}
-
-int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
-{
-  TestApplication application;
-  tet_infoline("Test setting the RenderMode to use the color buffer");
-
-  Renderer renderer = RendererTestFixture( application );
-
-  // Set the RenderMode property to a value that should not allow color buffer writes.
-  // Then check if ColorMask has been called, and that the values are correct.
-  CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
-  CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
-  CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
-  CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
-  CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
-
-  END_TEST;
-}
-
 int UtcDaliRendererSetStencilFunction(void)
 {
   TestApplication application;
@@ -2349,8 +2296,8 @@ int UtcDaliRendererSetStencilFunction(void)
   TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
   TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
 
-  // RenderMode must use the stencil for StencilFunction to operate.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+  // StencilMode must be ON for StencilFunction to operate.
+  renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
   ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
 
   /*
@@ -2439,8 +2386,8 @@ int UtcDaliRendererSetStencilOperation(void)
   TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
   TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
 
-  // RenderMode must use the stencil for StencilOperation to operate.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+  // StencilMode must be ON for StencilOperation to operate.
+  renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
 
   /*
    * Lookup table for testing StencilOperation.
@@ -2526,8 +2473,8 @@ int UtcDaliRendererSetStencilMask(void)
   TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
   TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
 
-  // RenderMode must use the stencil for StencilMask to operate.
-  renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+  // StencilMode must be ON for StencilMask to operate.
+  renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
 
   // Set the StencilMask property to a value.
   renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
@@ -2558,3 +2505,48 @@ int UtcDaliRendererSetStencilMask(void)
 
   END_TEST;
 }
+
+int UtcDaliRendererSetWriteToColorBuffer(void)
+{
+  TestApplication application;
+  tet_infoline("Test setting the WriteToColorBuffer flag");
+
+  Renderer renderer = RendererTestFixture( application );
+  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+
+  // Set the StencilMask property to a value.
+  renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, false );
+
+  // Check GetProperty returns the same value.
+  DALI_TEST_CHECK( !renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
+
+  application.SendNotification();
+  application.Render();
+
+  // Check if ColorMask has been called, and that the values are correct.
+  const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
+
+  DALI_TEST_EQUALS<bool>( colorMaskParams.red,   false, TEST_LOCATION );
+  DALI_TEST_EQUALS<bool>( colorMaskParams.green, false, TEST_LOCATION );
+  DALI_TEST_EQUALS<bool>( colorMaskParams.blue,  false, TEST_LOCATION );
+  DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, false, TEST_LOCATION );
+
+  // Set the StencilMask property to true.
+  renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
+
+  // Check GetProperty returns the same value.
+  DALI_TEST_CHECK( renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
+
+  application.SendNotification();
+  application.Render();
+
+  // Check if ColorMask has been called, and that the values are correct.
+  const TestGlAbstraction::ColorMaskParams& colorMaskParamsChanged( glAbstraction.GetColorMaskParams() );
+
+  DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.red,   true, TEST_LOCATION );
+  DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.green, true, TEST_LOCATION );
+  DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.blue,  true, TEST_LOCATION );
+  DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.alpha, true, TEST_LOCATION );
+
+  END_TEST;
+}