Revert "[3.0] Combine StencilMode and WriteToColorBuffer to RenderMode" 03/97603/1
authordongsug.song <dongsug.song@samsung.com>
Mon, 14 Nov 2016 13:51:46 +0000 (22:51 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 14 Nov 2016 13:51:50 +0000 (22:51 +0900)
This reverts commit be285a5aa0ba77ea635e8d8c2692d585ca30630e.

Change-Id: If490aa4b8ebd81142180c93efecc6d3be356466c

automated-tests/src/dali/utc-Dali-Renderer.cpp
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/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
dali/public-api/rendering/renderer.h

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;
+}
index a788e60..b1d44ad 100644 (file)
@@ -33,7 +33,7 @@ template <> struct ParameterType< Dali::BlendMode::Type >        : public BasicT
 template <> struct ParameterType< Dali::DepthWriteMode::Type >   : public BasicType< Dali::DepthWriteMode::Type > {};
 template <> struct ParameterType< Dali::DepthTestMode::Type >    : public BasicType< Dali::DepthTestMode::Type > {};
 template <> struct ParameterType< Dali::DepthFunction::Type >    : public BasicType< Dali::DepthFunction::Type > {};
-template <> struct ParameterType< Dali::RenderMode::Type >       : public BasicType< Dali::RenderMode::Type > {};
+template <> struct ParameterType< Dali::StencilMode::Type >      : public BasicType< Dali::StencilMode::Type > {};
 template <> struct ParameterType< Dali::StencilFunction::Type >  : public BasicType< Dali::StencilFunction::Type > {};
 template <> struct ParameterType< Dali::StencilOperation::Type > : public BasicType< Dali::StencilOperation::Type > {};
 
index b2f07e6..7ee14a0 100644 (file)
@@ -56,14 +56,15 @@ DALI_PROPERTY( "indexRangeCount",                 INTEGER,   true, false,  false
 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( "depthTestMode",                   INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_TEST_MODE )
-DALI_PROPERTY( "renderMode",                      INTEGER,   true, false,  false, Dali::Renderer::Property::RENDER_MODE )
 DALI_PROPERTY( "stencilFunction",                 INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_FUNCTION )
 DALI_PROPERTY( "stencilFunctionMask",             INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
 DALI_PROPERTY( "stencilFunctionReference",        INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
 DALI_PROPERTY( "stencilMask",                     INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_MASK )
+DALI_PROPERTY( "stencilMode",                     INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_MODE )
 DALI_PROPERTY( "stencilOperationOnFail",          INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
 DALI_PROPERTY( "stencilOperationOnZFail",         INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
 DALI_PROPERTY( "stencilOperationOnZPass",         INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
+DALI_PROPERTY( "writeToColorBuffer",              BOOLEAN,   true, false,  false, Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER )
 DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX )
 
 // Property string to enumeration tables:
@@ -139,13 +140,11 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, GREATER_EQUAL )
 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, ALWAYS )
 DALI_ENUM_TO_STRING_TABLE_END( STENCIL_FUNCTION )
 
-DALI_ENUM_TO_STRING_TABLE_BEGIN( RENDER_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, NONE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, AUTO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, STENCIL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR_STENCIL )
-DALI_ENUM_TO_STRING_TABLE_END( RENDER_MODE )
+DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( StencilMode, OFF )
+DALI_ENUM_TO_STRING_WITH_SCOPE( StencilMode, AUTO )
+DALI_ENUM_TO_STRING_WITH_SCOPE( StencilMode, ON )
+DALI_ENUM_TO_STRING_TABLE_END( STENCIL_MODE )
 
 DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_OPERATION )
 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, ZERO )
@@ -556,13 +555,13 @@ void Renderer::SetDefaultProperty( Property::Index index,
       }
       break;
     }
-    case Dali::Renderer::Property::RENDER_MODE:
+    case Dali::Renderer::Property::STENCIL_MODE:
     {
-      RenderMode::Type convertedValue = mStencilParameters.renderMode;
-      if( Scripting::GetEnumerationProperty< RenderMode::Type >( propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue ) )
+      StencilMode::Type convertedValue = mStencilParameters.stencilMode;
+      if( Scripting::GetEnumerationProperty< StencilMode::Type >( propertyValue, STENCIL_MODE_TABLE, STENCIL_MODE_TABLE_COUNT, convertedValue ) )
       {
-        mStencilParameters.renderMode = convertedValue;
-        SetRenderModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+        mStencilParameters.stencilMode = convertedValue;
+        SetStencilModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
       }
       break;
     }
@@ -645,6 +644,19 @@ void Renderer::SetDefaultProperty( Property::Index index,
       }
       break;
     }
+    case Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER:
+    {
+      bool writeToColorBuffer;
+      if( propertyValue.Get( writeToColorBuffer ) )
+      {
+        if( mWriteToColorBuffer != writeToColorBuffer )
+        {
+          mWriteToColorBuffer = writeToColorBuffer;
+          SetWriteToColorBufferMessage( GetEventThreadServices(), *mSceneObject, writeToColorBuffer );
+        }
+      }
+      break;
+    }
   }
 }
 
@@ -788,9 +800,9 @@ Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
       value = mStencilParameters.stencilMask;
       break;
     }
-    case Dali::Renderer::Property::RENDER_MODE:
+    case Dali::Renderer::Property::STENCIL_MODE:
     {
-      value = mStencilParameters.renderMode;
+      value = mStencilParameters.stencilMode;
       break;
     }
     case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
@@ -808,6 +820,11 @@ Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
       value = mStencilParameters.stencilOperationOnZPass;
       break;
     }
+    case Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER:
+    {
+      value = mWriteToColorBuffer;
+      break;
+    }
   }
   return value;
 }
@@ -891,13 +908,14 @@ Renderer::Renderer()
   mOnStageCount( 0 ),
   mIndexedDrawFirstElement( 0 ),
   mIndexedDrawElementCount( 0 ),
-  mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
+  mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
   mBlendingOptions(),
   mDepthFunction( DepthFunction::LESS ),
   mFaceCullingMode( FaceCullingMode::NONE ),
   mBlendMode( BlendMode::AUTO ),
   mDepthWriteMode( DepthWriteMode::AUTO ),
   mDepthTestMode( DepthTestMode::AUTO ),
+  mWriteToColorBuffer( true ),
   mPremultipledAlphaEnabled( false )
 {
 }
index cb4ba5e..745159b 100644 (file)
@@ -312,6 +312,7 @@ private: // data
   BlendMode::Type              mBlendMode:2;                  ///< Local copy of the mode of blending
   DepthWriteMode::Type         mDepthWriteMode:2;             ///< Local copy of the depth write mode
   DepthTestMode::Type          mDepthTestMode:2;              ///< Local copy of the depth test mode
+  bool                         mWriteToColorBuffer:1;         ///< Local copy of the write to color buffer flag
   bool                         mPremultipledAlphaEnabled:1;   ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
 };
 
index ce56324..9410358 100644 (file)
@@ -144,12 +144,10 @@ inline void SetupPerRendererFlags( const RenderItem& item, Context& context, boo
 
   // Setup the color buffer based on the renderers properties.
   Renderer *renderer = item.mRenderer;
-  RenderMode::Type renderMode = renderer->GetRenderMode();
-  const bool writeToColorBuffer = ( renderMode == RenderMode::AUTO ) || ( renderMode == RenderMode::COLOR ) || ( renderMode == RenderMode::COLOR_STENCIL );
-  context.ColorMask( writeToColorBuffer );
+  context.ColorMask( renderer->GetWriteToColorBuffer() );
 
   // If the stencil buffer is disabled for this renderer, exit now to save unnecessary value setting.
-  if( ( renderMode != RenderMode::STENCIL ) && ( renderMode != RenderMode::COLOR_STENCIL ) )
+  if( renderer->GetStencilMode() != StencilMode::ON )
   {
     // No per-renderer stencil setup, exit.
     context.EnableStencilBuffer( false );
index 4dfb27a..82e4a69 100644 (file)
@@ -117,11 +117,12 @@ Renderer* Renderer::New( SceneGraph::RenderDataProvider* dataProvider,
                          DepthWriteMode::Type depthWriteMode,
                          DepthTestMode::Type depthTestMode,
                          DepthFunction::Type depthFunction,
-                         StencilParameters& stencilParameters )
+                         StencilParameters& stencilParameters,
+                         bool writeToColorBuffer )
 {
   return new Renderer( dataProvider, geometry, blendingBitmask, blendColor,
                        faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode,
-                       depthFunction, stencilParameters );
+                       depthFunction, stencilParameters, writeToColorBuffer );
 }
 
 Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
@@ -133,7 +134,8 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
                     DepthWriteMode::Type depthWriteMode,
                     DepthTestMode::Type depthTestMode,
                     DepthFunction::Type depthFunction,
-                    StencilParameters& stencilParameters )
+                    StencilParameters& stencilParameters,
+                    bool writeToColorBuffer )
 : mRenderDataProvider( dataProvider ),
   mContext( NULL),
   mTextureCache( NULL ),
@@ -148,6 +150,7 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
   mFaceCullingMode( faceCullingMode ),
   mDepthWriteMode( depthWriteMode ),
   mDepthTestMode( depthTestMode ),
+  mWriteToColorBuffer( writeToColorBuffer ),
   mUpdateAttributesLocation( true ),
   mPremultipledAlphaEnabled( preMultipliedAlphaEnabled )
 {
@@ -476,14 +479,14 @@ DepthFunction::Type Renderer::GetDepthFunction() const
   return mDepthFunction;
 }
 
-void Renderer::SetRenderMode( RenderMode::Type renderMode )
+void Renderer::SetStencilMode( StencilMode::Type stencilMode )
 {
-  mStencilParameters.renderMode = renderMode;
+  mStencilParameters.stencilMode = stencilMode;
 }
 
-RenderMode::Type Renderer::GetRenderMode() const
+StencilMode::Type Renderer::GetStencilMode() const
 {
-  return mStencilParameters.renderMode;
+  return mStencilParameters.stencilMode;
 }
 
 void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction )
@@ -556,6 +559,16 @@ StencilOperation::Type Renderer::GetStencilOperationOnZPass() const
   return mStencilParameters.stencilOperationOnZPass;
 }
 
+void Renderer::SetWriteToColorBuffer( bool writeToColorBuffer )
+{
+  mWriteToColorBuffer = writeToColorBuffer;
+}
+
+bool Renderer::GetWriteToColorBuffer() const
+{
+  return mWriteToColorBuffer;
+}
+
 void Renderer::Render( Context& context,
                        SceneGraph::TextureCache& textureCache,
                        BufferIndex bufferIndex,
index 0f17f26..628b078 100644 (file)
@@ -68,28 +68,28 @@ public:
    */
   struct StencilParameters
   {
-    StencilParameters( RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask,
+    StencilParameters( StencilMode::Type stencilMode, StencilFunction::Type stencilFunction, int stencilFunctionMask,
                        int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail,
                        StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass )
     : stencilFunctionMask      ( stencilFunctionMask      ),
       stencilFunctionReference ( stencilFunctionReference ),
       stencilMask              ( stencilMask              ),
-      renderMode               ( renderMode               ),
       stencilFunction          ( stencilFunction          ),
       stencilOperationOnFail   ( stencilOperationOnFail   ),
       stencilOperationOnZFail  ( stencilOperationOnZFail  ),
-      stencilOperationOnZPass  ( stencilOperationOnZPass  )
+      stencilOperationOnZPass  ( stencilOperationOnZPass  ),
+      stencilMode              ( stencilMode              )
     {
     }
 
     int stencilFunctionMask;                          ///< The stencil function mask
     int stencilFunctionReference;                     ///< The stencil function reference
     int stencilMask;                                  ///< The stencil mask
-    RenderMode::Type       renderMode:3;              ///< The render mode
-    StencilFunction::Type  stencilFunction:3;         ///< The stencil function
+    StencilFunction::Type stencilFunction:3;          ///< The stencil function
     StencilOperation::Type stencilOperationOnFail:3;  ///< The stencil operation for stencil test fail
     StencilOperation::Type stencilOperationOnZFail:3; ///< The stencil operation for depth test fail
     StencilOperation::Type stencilOperationOnZPass:3; ///< The stencil operation for depth test pass
+    StencilMode::Type stencilMode:2;                  ///< The stencil mode
   };
 
   /**
@@ -114,6 +114,7 @@ public:
    * @param[in] depthTestMode Depth buffer test mode
    * @param[in] depthFunction Depth function
    * @param[in] stencilParameters Struct containing all stencil related options
+   * @param[in] writeToColorBuffer Set to True to write to the color buffer
    */
   static Renderer* New( SceneGraph::RenderDataProvider* dataProviders,
                         Render::Geometry* geometry,
@@ -124,7 +125,8 @@ public:
                         DepthWriteMode::Type depthWriteMode,
                         DepthTestMode::Type depthTestMode,
                         DepthFunction::Type depthFunction,
-                        StencilParameters& stencilParameters );
+                        StencilParameters& stencilParameters,
+                        bool writeToColorBuffer );
 
   /**
    * Constructor.
@@ -138,6 +140,7 @@ public:
    * @param[in] depthTestMode Depth buffer test mode
    * @param[in] depthFunction Depth function
    * @param[in] stencilParameters Struct containing all stencil related options
+   * @param[in] writeToColorBuffer Set to True to write to the color buffer
    */
   Renderer( SceneGraph::RenderDataProvider* dataProviders,
             Render::Geometry* geometry,
@@ -148,7 +151,8 @@ public:
             DepthWriteMode::Type depthWriteMode,
             DepthTestMode::Type depthTestMode,
             DepthFunction::Type depthFunction,
-            StencilParameters& stencilParameters );
+            StencilParameters& stencilParameters,
+            bool writeToColorBuffer );
 
   /**
    * Change the data providers of the renderer
@@ -248,16 +252,16 @@ public:
   DepthFunction::Type GetDepthFunction() const;
 
   /**
-   * Sets the render mode
-   * @param[in] renderMode The render mode
+   * Sets the stencil mode
+   * @param[in] stencilMode The stencil function
    */
-  void SetRenderMode( RenderMode::Type mode );
+  void SetStencilMode( StencilMode::Type stencilMode );
 
   /**
-   * Gets the render mode
-   * @return The render mode
+   * Gets the stencil mode
+   * @return The stencil function
    */
-  RenderMode::Type GetRenderMode() const;
+  StencilMode::Type GetStencilMode() const;
 
   /**
    * Sets the stencil function
@@ -344,6 +348,18 @@ public:
   StencilOperation::Type GetStencilOperationOnZPass() const;
 
   /**
+   * Sets whether or not to write to the color buffer
+   * @param[in] writeToColorBuffer True to write to the color buffer
+   */
+  void SetWriteToColorBuffer( bool writeToColorBuffer );
+
+  /**
+   * Gets whether or not to write to the color buffer
+   * @return True to write to the color buffer
+   */
+  bool GetWriteToColorBuffer() const;
+
+  /**
    * Called to render during RenderManager::Render().
    * @param[in] context The context used for rendering
    * @param[in] textureCache The texture cache used to get textures
@@ -446,6 +462,7 @@ private:
   BlendMode::Type              mBlendMode:2;                ///< The mode of blending
   DepthWriteMode::Type         mDepthWriteMode:2;           ///< The depth write mode
   DepthTestMode::Type          mDepthTestMode:2;            ///< The depth test mode
+  bool                         mWriteToColorBuffer:1;       ///< True if we are writing to the color buffer
   bool                         mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed
   bool                         mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
 };
index b1926ba..17b402f 100644 (file)
@@ -99,14 +99,15 @@ enum Flags
   RESEND_DEPTH_WRITE_MODE            = 1 << 8,
   RESEND_DEPTH_TEST_MODE             = 1 << 9,
   RESEND_DEPTH_FUNCTION              = 1 << 10,
-  RESEND_RENDER_MODE                 = 1 << 11,
+  RESEND_STENCIL_MODE                = 1 << 11,
   RESEND_STENCIL_FUNCTION            = 1 << 12,
   RESEND_STENCIL_FUNCTION_MASK       = 1 << 13,
   RESEND_STENCIL_FUNCTION_REFERENCE  = 1 << 14,
   RESEND_STENCIL_MASK                = 1 << 15,
   RESEND_STENCIL_OPERATION_ON_FAIL   = 1 << 16,
   RESEND_STENCIL_OPERATION_ON_Z_FAIL = 1 << 17,
-  RESEND_STENCIL_OPERATION_ON_Z_PASS = 1 << 18
+  RESEND_STENCIL_OPERATION_ON_Z_PASS = 1 << 18,
+  RESEND_WRITE_TO_COLOR_BUFFER       = 1 << 19
 };
 
 } // Anonymous namespace
@@ -130,7 +131,7 @@ Renderer::Renderer()
   mGeometry( NULL ),
   mShader( NULL ),
   mBlendColor( NULL ),
-  mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
+  mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
   mIndexedDrawFirstElement( 0u ),
   mIndexedDrawElementsCount( 0u ),
   mBlendBitmask( 0u ),
@@ -141,6 +142,7 @@ Renderer::Renderer()
   mBlendMode( BlendMode::AUTO ),
   mDepthWriteMode( DepthWriteMode::AUTO ),
   mDepthTestMode( DepthTestMode::AUTO ),
+  mWriteToColorBuffer( true ),
   mResourcesReady( false ),
   mFinishedResourceAcquisition( false ),
   mPremultipledAlphaEnabled( false ),
@@ -311,11 +313,11 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex )
       new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction );
     }
 
-    if( mResendFlag & RESEND_RENDER_MODE )
+    if( mResendFlag & RESEND_STENCIL_MODE )
     {
-      typedef MessageValue1< Render::Renderer, RenderMode::Type > DerivedType;
+      typedef MessageValue1< Render::Renderer, StencilMode::Type > DerivedType;
       unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-      new (slot) DerivedType( mRenderer, &Render::Renderer::SetRenderMode, mStencilParameters.renderMode );
+      new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilMode, mStencilParameters.stencilMode );
     }
 
     if( mResendFlag & RESEND_STENCIL_FUNCTION )
@@ -367,6 +369,13 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex )
       new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnZPass, mStencilParameters.stencilOperationOnZPass );
     }
 
+    if( mResendFlag & RESEND_WRITE_TO_COLOR_BUFFER )
+    {
+      typedef MessageValue1< Render::Renderer, bool > DerivedType;
+      unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+      new (slot) DerivedType( mRenderer, &Render::Renderer::SetWriteToColorBuffer, mWriteToColorBuffer );
+    }
+
     mResendFlag = 0;
   }
 }
@@ -487,10 +496,10 @@ void Renderer::SetDepthFunction( DepthFunction::Type depthFunction )
   mResendFlag |= RESEND_DEPTH_FUNCTION;
 }
 
-void Renderer::SetRenderMode( RenderMode::Type mode )
+void Renderer::SetStencilMode( StencilMode::Type mode )
 {
-  mStencilParameters.renderMode = mode;
-  mResendFlag |= RESEND_RENDER_MODE;
+  mStencilParameters.stencilMode = mode;
+  mResendFlag |= RESEND_STENCIL_MODE;
 }
 
 void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction )
@@ -535,6 +544,12 @@ void Renderer::SetStencilOperationOnZPass( StencilOperation::Type stencilOperati
   mResendFlag |= RESEND_STENCIL_OPERATION_ON_Z_PASS;
 }
 
+void Renderer::SetWriteToColorBuffer( bool writeToColorBuffer )
+{
+  mWriteToColorBuffer = writeToColorBuffer;
+  mResendFlag |= RESEND_WRITE_TO_COLOR_BUFFER;
+}
+
 //Called when SceneGraph::Renderer is added to update manager ( that happens when an "event-thread renderer" is created )
 void Renderer::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
 {
@@ -543,7 +558,7 @@ void Renderer::ConnectToSceneGraph( SceneController& sceneController, BufferInde
   RenderDataProvider* dataProvider = NewRenderDataProvider();
 
   mRenderer = Render::Renderer::New( dataProvider, mGeometry, mBlendBitmask, mBlendColor, static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
-                                         mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters );
+                                         mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters, mWriteToColorBuffer );
 
   mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
 }
index 61605b6..4249b0f 100644 (file)
@@ -185,10 +185,10 @@ public:
   void SetDepthFunction( DepthFunction::Type depthFunction );
 
   /**
-   * Sets the render mode
-   * @param[in] mode The render mode
+   * Sets the stencil mode
+   * @param[in] mode The stencil function
    */
-  void SetRenderMode( RenderMode::Type mode );
+  void SetStencilMode( StencilMode::Type mode );
 
   /**
    * Sets the stencil function
@@ -233,6 +233,12 @@ public:
   void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass );
 
   /**
+   * Sets whether or not to write to the color buffer
+   * @param[in] writeToColorBuffer True to write to the color buffer
+   */
+  void SetWriteToColorBuffer( bool writeToColorBuffer );
+
+  /**
    * Prepare the object for rendering.
    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
    * @param[in] updateBufferIndex The current update buffer index.
@@ -375,6 +381,7 @@ private:
   BlendMode::Type              mBlendMode:2;                      ///< Local copy of the mode of blending
   DepthWriteMode::Type         mDepthWriteMode:2;                 ///< Local copy of the depth write mode
   DepthTestMode::Type          mDepthTestMode:2;                  ///< Local copy of the depth test mode
+  bool                         mWriteToColorBuffer:1;             ///< Local copy of the write to color buffer flag
 
   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.
@@ -532,14 +539,14 @@ inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, c
   new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction );
 }
 
-inline void SetRenderModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode )
+inline void SetStencilModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilMode::Type mode )
 {
-  typedef MessageValue1< Renderer, RenderMode::Type > LocalType;
+  typedef MessageValue1< Renderer, StencilMode::Type > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
-  new (slot) LocalType( &renderer, &Renderer::SetRenderMode, mode );
+  new (slot) LocalType( &renderer, &Renderer::SetStencilMode, mode );
 }
 
 inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction )
@@ -612,6 +619,15 @@ inline void SetStencilOperationOnZPassMessage( EventThreadServices& eventThreadS
   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation );
 }
 
+inline void SetWriteToColorBufferMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool writeToColorBuffer )
+{
+  typedef MessageValue1< Renderer, bool > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  new (slot) LocalType( &renderer, &Renderer::SetWriteToColorBuffer, writeToColorBuffer );
+}
 
 } // namespace SceneGraph
 } // namespace Internal
index 2d0d02f..9c06ea3 100644 (file)
@@ -162,24 +162,6 @@ enum Type
 
 } // namespace DepthFunction
 
-namespace RenderMode
-{
-
-/**
- * @brief Controls how this renderer uses its stencil properties and writes to the color buffer.
- * @SINCE_1_2.5
- */
-enum Type
-{
-  NONE,         ///< Don’t write to either color or stencil buffer (But will potentially render to depth buffer). @SINCE_1_2.5
-  AUTO,         ///< Managed by the Actor Clipping API. This is the default.                                      @SINCE_1_2.5
-  COLOR,        ///< Ingore stencil properties.  Write to the color buffer.                                       @SINCE_1_2.5
-  STENCIL,      ///< Use the stencil properties. Do not write to the color buffer.                                @SINCE_1_2.5
-  COLOR_STENCIL ///< Use the stencil properties AND Write to the color buffer.                                    @SINCE_1_2.5
-};
-
-} // namespace RenderMode
-
 namespace StencilFunction
 {
 
@@ -201,6 +183,22 @@ enum Type
 
 } // namespace StencilFunction
 
+namespace StencilMode
+{
+
+/**
+ * @brief How the stencil buffer will be managed.
+ * @SINCE_1_1.43
+ */
+enum Type
+{
+  OFF,       ///< Off for this renderer                                  @SINCE_1_1.43
+  AUTO,      ///< Managed by the Actor clipping API. This is the default @SINCE_1_1.43
+  ON         ///< On for this renderer. Select this to use the Renderer stencil properties to manage behavior. Note that Actor clipping management is bypassed for this renderer @SINCE_1_1.43
+};
+
+} // namespace StencilMode
+
 namespace StencilOperation
 {
 
@@ -355,14 +353,6 @@ public:
       DEPTH_TEST_MODE,
 
       /**
-       * @brief name "renderMode", type INTEGER
-       * @see RenderMode
-       * @note The default value is RenderMode::AUTO
-       * @SINCE_1_2.5
-       */
-      RENDER_MODE,
-
-      /**
        * @brief name "stencilFunction", type INTEGER
        * @see StencilFunction
        * @note The default value is StencilFunction::ALWAYS
@@ -392,6 +382,14 @@ public:
       STENCIL_MASK,
 
       /**
+       * @brief name "stencilMode", type INTEGER
+       * @see StencilMode
+       * @note The default value is StencilMode::AUTO
+       * @SINCE_1_1.43
+       */
+      STENCIL_MODE,
+
+      /**
        * @brief name "stencilOperationOnFail", type INTEGER
        * @see StencilOperation
        * @note The default value is StencilOperation::KEEP
@@ -414,6 +412,15 @@ public:
        * @SINCE_1_1.43
        */
       STENCIL_OPERATION_ON_Z_PASS,
+
+      /**
+       * @brief name "writeToColorBuffer", type BOOLEAN
+       * This allows per-renderer control of writing to the color buffer.
+       * For example: This can be turned off to write to the stencil or depth buffers only.
+       * @note The default value is True
+       * @SINCE_1_1.43
+       */
+      WRITE_TO_COLOR_BUFFER
     };
   };