X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frendering%2Frenderer-impl.cpp;h=35431d50caa9ccf0663a47cb8fb54c82fe0fe6e3;hb=5b204db436c567cae602a0f4650edb4117cf7d19;hp=7ee14a0fa3eb27cd414c17f61a5990c814c5b6da;hpb=2c01ff92c5894aa368225bdbf29a29f5220dd832;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index 7ee14a0..35431d5 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include #include // Dali::Internal::ObjectHelper #include // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END @@ -56,15 +57,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 +140,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 ) @@ -190,14 +192,14 @@ Geometry* Renderer::GetGeometry() const void Renderer::SetTextures( TextureSet& textureSet ) { - mTextureSetConnector.Set( textureSet, OnStage() ); + mTextureSet = &textureSet; const SceneGraph::TextureSet* textureSetSceneObject = textureSet.GetTextureSetSceneObject(); SetTexturesMessage( GetEventThreadServices(), *mSceneObject, *textureSetSceneObject ); } TextureSet* Renderer::GetTextures() const { - return mTextureSetConnector.Get().Get(); + return mTextureSet.Get(); } void Renderer::SetShader( Shader& shader ) @@ -288,28 +290,6 @@ void Renderer::GetBlendEquation( BlendEquation::Type& equationRgb, equationAlpha = mBlendingOptions.GetBlendEquationAlpha(); } -void Renderer::SetBlendColor( const Vector4& color ) -{ - if( !mBlendColor ) - { - mBlendColor = new Vector4(); - } - if( *mBlendColor != color ) - { - *mBlendColor = color; - SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, *mBlendColor ); - } -} - -Vector4 Renderer::GetBlendColor() const -{ - if( mBlendColor ) - { - return *mBlendColor; - } - return Color::TRANSPARENT; // GL default -} - void Renderer::SetIndexedDrawFirstElement( size_t firstElement ) { if( firstElement != mIndexedDrawFirstElement ) @@ -335,7 +315,7 @@ void Renderer::EnablePreMultipliedAlpha( bool preMultipled ) { if( preMultipled ) { - SetBlendFunc( BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE ); + SetBlendFunc( BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA ); } mPremultipledAlphaEnabled = preMultipled; SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), *mSceneObject, mPremultipledAlphaEnabled ); @@ -555,13 +535,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 +624,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; - } } } @@ -740,14 +707,7 @@ Property::Value Renderer::GetDefaultProperty( Property::Index index ) const } case Dali::Renderer::Property::BLEND_COLOR: { - if( mBlendColor ) - { - value = *mBlendColor; - } - else - { - value = Color::TRANSPARENT; - } + value = GetBlendColor(); break; } case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA: @@ -800,9 +760,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,15 +780,15 @@ 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; } +Property::Value Renderer::GetDefaultPropertyCurrentValue( Property::Index index ) const +{ + return GetDefaultProperty( index ); // Event-side only properties +} + const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const { return mSceneObject; @@ -844,14 +804,11 @@ const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Prop DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" ); const SceneGraph::PropertyBase* property = NULL; - if( OnStage() ) - { - property = RENDERER_IMPL.GetRegisteredSceneGraphProperty( - this, - &Renderer::FindAnimatableProperty, - &Renderer::FindCustomProperty, - index ); - } + property = RENDERER_IMPL.GetRegisteredSceneGraphProperty( + this, + &Renderer::FindAnimatableProperty, + &Renderer::FindCustomProperty, + index ); return property; } @@ -860,15 +817,12 @@ const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index { const PropertyInputImpl* property = NULL; - if( OnStage() ) - { - const SceneGraph::PropertyBase* baseProperty = - RENDERER_IMPL.GetRegisteredSceneGraphProperty( this, - &Renderer::FindAnimatableProperty, - &Renderer::FindCustomProperty, - index ); - property = static_cast( baseProperty ); - } + const SceneGraph::PropertyBase* baseProperty = + RENDERER_IMPL.GetRegisteredSceneGraphProperty( this, + &Renderer::FindAnimatableProperty, + &Renderer::FindCustomProperty, + index ); + property = static_cast( baseProperty ); return property; } @@ -878,44 +832,18 @@ int Renderer::GetPropertyComponentIndex( Property::Index index ) const return Property::INVALID_COMPONENT_INDEX; } -bool Renderer::OnStage() const -{ - return mOnStageCount > 0; -} - -void Renderer::Connect() -{ - if( mOnStageCount == 0 ) - { - mTextureSetConnector.OnStageConnect(); - } - ++mOnStageCount; -} - -void Renderer::Disconnect() -{ - --mOnStageCount; - if( mOnStageCount == 0 ) - { - mTextureSetConnector.OnStageDisconnect(); - } -} - Renderer::Renderer() -: mSceneObject (NULL ), - mBlendColor( NULL ), +: mSceneObject(NULL ), mDepthIndex( 0 ), - 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 ) { } @@ -926,18 +854,35 @@ void Renderer::Initialize() SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager(); mSceneObject = SceneGraph::Renderer::New(); - AddMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject ); + OwnerPointer< SceneGraph::Renderer > transferOwnership( mSceneObject ); + AddRendererMessage( updateManager, transferOwnership ); eventThreadServices.RegisterObject( this ); } +void Renderer::SetBlendColor( const Vector4& blendColor ) +{ + mBlendingOptions.SetBlendColor( blendColor ); + SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, GetBlendColor() ); +} + +const Vector4& Renderer::GetBlendColor() const +{ + const Vector4* blendColor = mBlendingOptions.GetBlendColor(); + if( blendColor ) + { + return *blendColor; + } + return Color::TRANSPARENT; // GL default +} + Renderer::~Renderer() { if( EventThreadServices::IsCoreRunning() ) { EventThreadServices& eventThreadServices = GetEventThreadServices(); SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager(); - RemoveMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject ); + RemoveRendererMessage( updateManager, *mSceneObject ); eventThreadServices.UnregisterObject( this ); }