From: Tom Robinson Date: Wed, 7 Sep 2016 18:17:38 +0000 (+0100) Subject: [3.0] Combine StencilMode and WriteToColorBuffer to RenderMode X-Git-Tag: accepted/tizen/3.0/ivi/20161011.043719~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be285a5aa0ba77ea635e8d8c2692d585ca30630e;hp=45628564543dd3f9229710ac0661259147353637;p=platform%2Fcore%2Fuifw%2Fdali-core.git [3.0] Combine StencilMode and WriteToColorBuffer to RenderMode Change-Id: Ib22783d9036ab1e53b8b45e25f2af1e65a408b77 --- diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index 78b4795..0d93f91 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -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< StencilMode::Type >( renderer, Renderer::Property::STENCIL_MODE, StencilMode::AUTO, StencilMode::OFF, StencilMode::ON, "ON" ); + CheckEnumerationProperty< RenderMode::Type >( renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" ); 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 UtcDaliRendererSetStencilMode(void) +int UtcDaliRendererSetRenderModeToUseStencilBuffer(void) { TestApplication application; - tet_infoline("Test setting the StencilMode"); + tet_infoline("Test setting the RenderMode to use the stencil buffer"); Renderer renderer = RendererTestFixture( application ); TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); @@ -2263,19 +2263,36 @@ int UtcDaliRendererSetStencilMode(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( static_cast( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get() ), static_cast( StencilFunction::NEVER ), TEST_LOCATION ); - ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); std::string methodString( "StencilFunc" ); DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) ); - // Now set the StencilMode to ON and check the StencilFunction has changed. - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON ); + // 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 ); + 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 ); ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) ); @@ -2284,6 +2301,42 @@ int UtcDaliRendererSetStencilMode(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( colorMaskParams.red, expectedValue, TEST_LOCATION ); + DALI_TEST_EQUALS( colorMaskParams.green, expectedValue, TEST_LOCATION ); + DALI_TEST_EQUALS( colorMaskParams.blue, expectedValue, TEST_LOCATION ); + DALI_TEST_EQUALS( 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; @@ -2296,8 +2349,8 @@ int UtcDaliRendererSetStencilFunction(void) TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); - // StencilMode must be ON for StencilFunction to operate. - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON ); + // RenderMode must use the stencil for StencilFunction to operate. + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); /* @@ -2386,8 +2439,8 @@ int UtcDaliRendererSetStencilOperation(void) TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); - // StencilMode must be ON for StencilOperation to operate. - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON ); + // RenderMode must use the stencil for StencilOperation to operate. + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); /* * Lookup table for testing StencilOperation. @@ -2473,8 +2526,8 @@ int UtcDaliRendererSetStencilMask(void) TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace(); TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace(); - // StencilMode must be ON for StencilMask to operate. - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON ); + // RenderMode must use the stencil for StencilMask to operate. + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL ); // Set the StencilMask property to a value. renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 ); @@ -2505,48 +2558,3 @@ 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() ); - - 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( colorMaskParams.red, false, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParams.green, false, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParams.blue, false, TEST_LOCATION ); - DALI_TEST_EQUALS( 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() ); - - 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( colorMaskParamsChanged.red, true, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParamsChanged.green, true, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParamsChanged.blue, true, TEST_LOCATION ); - DALI_TEST_EQUALS( colorMaskParamsChanged.alpha, true, TEST_LOCATION ); - - END_TEST; -} diff --git a/dali/internal/common/type-abstraction-enums.h b/dali/internal/common/type-abstraction-enums.h index b1d44ad..a788e60 100644 --- a/dali/internal/common/type-abstraction-enums.h +++ b/dali/internal/common/type-abstraction-enums.h @@ -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::StencilMode::Type > : public BasicType< Dali::StencilMode::Type > {}; +template <> struct ParameterType< Dali::RenderMode::Type > : public BasicType< Dali::RenderMode::Type > {}; template <> struct ParameterType< Dali::StencilFunction::Type > : public BasicType< Dali::StencilFunction::Type > {}; template <> struct ParameterType< Dali::StencilOperation::Type > : public BasicType< Dali::StencilOperation::Type > {}; diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index 7ee14a0..b2f07e6 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -56,15 +56,14 @@ 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: @@ -140,11 +139,13 @@ 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( 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( 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_OPERATION ) DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, ZERO ) @@ -555,13 +556,13 @@ void Renderer::SetDefaultProperty( Property::Index index, } break; } - case Dali::Renderer::Property::STENCIL_MODE: + case Dali::Renderer::Property::RENDER_MODE: { - StencilMode::Type convertedValue = mStencilParameters.stencilMode; - if( Scripting::GetEnumerationProperty< StencilMode::Type >( propertyValue, STENCIL_MODE_TABLE, STENCIL_MODE_TABLE_COUNT, convertedValue ) ) + RenderMode::Type convertedValue = mStencilParameters.renderMode; + if( Scripting::GetEnumerationProperty< RenderMode::Type >( propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue ) ) { - mStencilParameters.stencilMode = convertedValue; - SetStencilModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue ); + mStencilParameters.renderMode = convertedValue; + SetRenderModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue ); } break; } @@ -644,19 +645,6 @@ 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; - } } } @@ -800,9 +788,9 @@ Property::Value Renderer::GetDefaultProperty( Property::Index index ) const value = mStencilParameters.stencilMask; break; } - case Dali::Renderer::Property::STENCIL_MODE: + case Dali::Renderer::Property::RENDER_MODE: { - value = mStencilParameters.stencilMode; + value = mStencilParameters.renderMode; break; } case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL: @@ -820,11 +808,6 @@ 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; } @@ -908,14 +891,13 @@ Renderer::Renderer() mOnStageCount( 0 ), mIndexedDrawFirstElement( 0 ), mIndexedDrawElementCount( 0 ), - mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ), + mStencilParameters( RenderMode::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 ) { } diff --git a/dali/internal/event/rendering/renderer-impl.h b/dali/internal/event/rendering/renderer-impl.h index 745159b..cb4ba5e 100644 --- a/dali/internal/event/rendering/renderer-impl.h +++ b/dali/internal/event/rendering/renderer-impl.h @@ -312,7 +312,6 @@ 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 }; diff --git a/dali/internal/render/common/render-algorithms.cpp b/dali/internal/render/common/render-algorithms.cpp index 9410358..ce56324 100644 --- a/dali/internal/render/common/render-algorithms.cpp +++ b/dali/internal/render/common/render-algorithms.cpp @@ -144,10 +144,12 @@ inline void SetupPerRendererFlags( const RenderItem& item, Context& context, boo // Setup the color buffer based on the renderers properties. Renderer *renderer = item.mRenderer; - context.ColorMask( renderer->GetWriteToColorBuffer() ); + RenderMode::Type renderMode = renderer->GetRenderMode(); + const bool writeToColorBuffer = ( renderMode == RenderMode::AUTO ) || ( renderMode == RenderMode::COLOR ) || ( renderMode == RenderMode::COLOR_STENCIL ); + context.ColorMask( writeToColorBuffer ); // If the stencil buffer is disabled for this renderer, exit now to save unnecessary value setting. - if( renderer->GetStencilMode() != StencilMode::ON ) + if( ( renderMode != RenderMode::STENCIL ) && ( renderMode != RenderMode::COLOR_STENCIL ) ) { // No per-renderer stencil setup, exit. context.EnableStencilBuffer( false ); diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 82e4a69..4dfb27a 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -117,12 +117,11 @@ Renderer* Renderer::New( SceneGraph::RenderDataProvider* dataProvider, DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, DepthFunction::Type depthFunction, - StencilParameters& stencilParameters, - bool writeToColorBuffer ) + StencilParameters& stencilParameters ) { return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode, - depthFunction, stencilParameters, writeToColorBuffer ); + depthFunction, stencilParameters ); } Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, @@ -134,8 +133,7 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, DepthFunction::Type depthFunction, - StencilParameters& stencilParameters, - bool writeToColorBuffer ) + StencilParameters& stencilParameters ) : mRenderDataProvider( dataProvider ), mContext( NULL), mTextureCache( NULL ), @@ -150,7 +148,6 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, mFaceCullingMode( faceCullingMode ), mDepthWriteMode( depthWriteMode ), mDepthTestMode( depthTestMode ), - mWriteToColorBuffer( writeToColorBuffer ), mUpdateAttributesLocation( true ), mPremultipledAlphaEnabled( preMultipliedAlphaEnabled ) { @@ -479,14 +476,14 @@ DepthFunction::Type Renderer::GetDepthFunction() const return mDepthFunction; } -void Renderer::SetStencilMode( StencilMode::Type stencilMode ) +void Renderer::SetRenderMode( RenderMode::Type renderMode ) { - mStencilParameters.stencilMode = stencilMode; + mStencilParameters.renderMode = renderMode; } -StencilMode::Type Renderer::GetStencilMode() const +RenderMode::Type Renderer::GetRenderMode() const { - return mStencilParameters.stencilMode; + return mStencilParameters.renderMode; } void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction ) @@ -559,16 +556,6 @@ 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, diff --git a/dali/internal/render/renderers/render-renderer.h b/dali/internal/render/renderers/render-renderer.h index 628b078..0f17f26 100644 --- a/dali/internal/render/renderers/render-renderer.h +++ b/dali/internal/render/renderers/render-renderer.h @@ -68,28 +68,28 @@ public: */ struct StencilParameters { - StencilParameters( StencilMode::Type stencilMode, StencilFunction::Type stencilFunction, int stencilFunctionMask, + StencilParameters( RenderMode::Type renderMode, 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 ), - stencilMode ( stencilMode ) + stencilOperationOnZPass ( stencilOperationOnZPass ) { } int stencilFunctionMask; ///< The stencil function mask int stencilFunctionReference; ///< The stencil function reference int stencilMask; ///< The stencil mask - StencilFunction::Type stencilFunction:3; ///< The stencil function + RenderMode::Type renderMode:3; ///< The render mode + 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,7 +114,6 @@ 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, @@ -125,8 +124,7 @@ public: DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, DepthFunction::Type depthFunction, - StencilParameters& stencilParameters, - bool writeToColorBuffer ); + StencilParameters& stencilParameters ); /** * Constructor. @@ -140,7 +138,6 @@ 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, @@ -151,8 +148,7 @@ public: DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, DepthFunction::Type depthFunction, - StencilParameters& stencilParameters, - bool writeToColorBuffer ); + StencilParameters& stencilParameters ); /** * Change the data providers of the renderer @@ -252,16 +248,16 @@ public: DepthFunction::Type GetDepthFunction() const; /** - * Sets the stencil mode - * @param[in] stencilMode The stencil function + * Sets the render mode + * @param[in] renderMode The render mode */ - void SetStencilMode( StencilMode::Type stencilMode ); + void SetRenderMode( RenderMode::Type mode ); /** - * Gets the stencil mode - * @return The stencil function + * Gets the render mode + * @return The render mode */ - StencilMode::Type GetStencilMode() const; + RenderMode::Type GetRenderMode() const; /** * Sets the stencil function @@ -348,18 +344,6 @@ 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 @@ -462,7 +446,6 @@ 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 }; diff --git a/dali/internal/update/rendering/scene-graph-renderer.cpp b/dali/internal/update/rendering/scene-graph-renderer.cpp index 17b402f..b1926ba 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-renderer.cpp @@ -99,15 +99,14 @@ enum Flags RESEND_DEPTH_WRITE_MODE = 1 << 8, RESEND_DEPTH_TEST_MODE = 1 << 9, RESEND_DEPTH_FUNCTION = 1 << 10, - RESEND_STENCIL_MODE = 1 << 11, + RESEND_RENDER_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_WRITE_TO_COLOR_BUFFER = 1 << 19 + RESEND_STENCIL_OPERATION_ON_Z_PASS = 1 << 18 }; } // Anonymous namespace @@ -131,7 +130,7 @@ Renderer::Renderer() mGeometry( NULL ), mShader( NULL ), mBlendColor( NULL ), - mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ), + mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ), mIndexedDrawFirstElement( 0u ), mIndexedDrawElementsCount( 0u ), mBlendBitmask( 0u ), @@ -142,7 +141,6 @@ Renderer::Renderer() mBlendMode( BlendMode::AUTO ), mDepthWriteMode( DepthWriteMode::AUTO ), mDepthTestMode( DepthTestMode::AUTO ), - mWriteToColorBuffer( true ), mResourcesReady( false ), mFinishedResourceAcquisition( false ), mPremultipledAlphaEnabled( false ), @@ -313,11 +311,11 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex ) new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction ); } - if( mResendFlag & RESEND_STENCIL_MODE ) + if( mResendFlag & RESEND_RENDER_MODE ) { - typedef MessageValue1< Render::Renderer, StencilMode::Type > DerivedType; + typedef MessageValue1< Render::Renderer, RenderMode::Type > DerivedType; unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilMode, mStencilParameters.stencilMode ); + new (slot) DerivedType( mRenderer, &Render::Renderer::SetRenderMode, mStencilParameters.renderMode ); } if( mResendFlag & RESEND_STENCIL_FUNCTION ) @@ -369,13 +367,6 @@ 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; } } @@ -496,10 +487,10 @@ void Renderer::SetDepthFunction( DepthFunction::Type depthFunction ) mResendFlag |= RESEND_DEPTH_FUNCTION; } -void Renderer::SetStencilMode( StencilMode::Type mode ) +void Renderer::SetRenderMode( RenderMode::Type mode ) { - mStencilParameters.stencilMode = mode; - mResendFlag |= RESEND_STENCIL_MODE; + mStencilParameters.renderMode = mode; + mResendFlag |= RESEND_RENDER_MODE; } void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction ) @@ -544,12 +535,6 @@ 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 ) { @@ -558,7 +543,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, mWriteToColorBuffer ); + mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters ); mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer ); } diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index 4249b0f..61605b6 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -185,10 +185,10 @@ public: void SetDepthFunction( DepthFunction::Type depthFunction ); /** - * Sets the stencil mode - * @param[in] mode The stencil function + * Sets the render mode + * @param[in] mode The render mode */ - void SetStencilMode( StencilMode::Type mode ); + void SetRenderMode( RenderMode::Type mode ); /** * Sets the stencil function @@ -233,12 +233,6 @@ 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. @@ -381,7 +375,6 @@ 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. @@ -539,14 +532,14 @@ inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, c new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction ); } -inline void SetStencilModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilMode::Type mode ) +inline void SetRenderModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode ) { - typedef MessageValue1< Renderer, StencilMode::Type > LocalType; + typedef MessageValue1< Renderer, RenderMode::Type > LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - new (slot) LocalType( &renderer, &Renderer::SetStencilMode, mode ); + new (slot) LocalType( &renderer, &Renderer::SetRenderMode, mode ); } inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction ) @@ -619,15 +612,6 @@ 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 diff --git a/dali/public-api/rendering/renderer.h b/dali/public-api/rendering/renderer.h index 9c06ea3..2d0d02f 100644 --- a/dali/public-api/rendering/renderer.h +++ b/dali/public-api/rendering/renderer.h @@ -162,6 +162,24 @@ 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 { @@ -183,22 +201,6 @@ 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 { @@ -353,6 +355,14 @@ 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 @@ -382,14 +392,6 @@ 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 @@ -412,15 +414,6 @@ 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 }; };