/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
// EXTERNAL HEADER
#include <dali-toolkit/public-api/dali-toolkit-common.h>
-#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/integration-api/debug.h>
return mImpl->mDepthIndex;
}
-void Visual::Base::SetOnStage( Actor& actor )
+void Visual::Base::SetOnScene( Actor& actor )
{
- if( !IsOnStage() )
+ if( !IsOnScene() )
{
// To display the actor correctly, renderer should not be added to actor until all required resources are ready.
// Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
- DoSetOnStage( actor );
+ DoSetOnScene( actor );
if( mImpl->mRenderer )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
- mImpl->mFlags |= Impl::IS_ON_STAGE; // Only sets the flag if renderer exists
+ mImpl->mFlags |= Impl::IS_ON_SCENE; // Only sets the flag if renderer exists
}
}
}
-void Visual::Base::SetOffStage( Actor& actor )
+void Visual::Base::SetOffScene( Actor& actor )
{
- if( IsOnStage() )
+ if( IsOnScene() )
{
- DoSetOffStage( actor );
+ DoSetOffScene( actor );
mImpl->mMixColorIndex = Property::INVALID_INDEX;
mImpl->mCornerRadiusIndex = Property::INVALID_INDEX;
- mImpl->mFlags &= ~Impl::IS_ON_STAGE;
+ mImpl->mFlags &= ~Impl::IS_ON_SCENE;
}
}
// which is ok, because they have a different key value range.
map.Insert( Toolkit::Visual::Property::MIX_COLOR, mImpl->mMixColor ); // vec4
map.Insert( Toolkit::Visual::Property::OPACITY, mImpl->mMixColor.a );
- map.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, IsSynchronousLoadingRequired() );
auto fittingModeString = Scripting::GetLinearEnumerationName< FittingMode >(
mImpl->mFittingMode, VISUAL_FITTING_MODE_TABLE, VISUAL_FITTING_MODE_TABLE_COUNT );
return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
}
-void Visual::Base::DoSetOffStage( Actor& actor )
+bool Visual::Base::IsAdvancedBlendEquationApplied() const
+{
+ return IsPreMultipliedAlphaEnabled() && DevelRenderer::IsAdvancedBlendEquationApplied( mImpl->mRenderer );
+}
+
+void Visual::Base::DoSetOffScene( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
}
-bool Visual::Base::IsOnStage() const
+bool Visual::Base::IsOnScene() const
{
- return mImpl->mFlags & Impl::IS_ON_STAGE;
+ return mImpl->mFlags & Impl::IS_ON_SCENE;
}
bool Visual::Base::IsRoundedCornerRequired() const
// (Color and Primitive visuals will register their own and save to this index)
if( mImpl->mMixColorIndex == Property::INVALID_INDEX )
{
- mImpl->mMixColorIndex = DevelHandle::RegisterProperty(
- mImpl->mRenderer,
+ mImpl->mMixColorIndex = mImpl->mRenderer.RegisterProperty(
Toolkit::Visual::Property::MIX_COLOR,
MIX_COLOR,
Vector3(mImpl->mMixColor) );
}
- if( mImpl->mMixColor.a < 1.f )
+ if( mImpl->mMixColor.a < 1.f || IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
{
mImpl->mRenderer.SetProperty( mImpl->mMixColorIndex, Vector3(color) );
mImpl->mRenderer.SetProperty( DevelRenderer::Property::OPACITY, color.a );
- if( color.a < 1.f )
+ if( color.a < 1.f || IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
Property::Index Visual::Base::GetPropertyIndex( Property::Key key )
{
- Property::Index index = DevelHandle::GetPropertyIndex( mImpl->mRenderer, key );
+ Property::Index index = mImpl->mRenderer.GetPropertyIndex( key );
if( index == Property::INVALID_INDEX )
{
// Is it a shader property?
Shader shader = mImpl->mRenderer.GetShader();
- index = DevelHandle::GetPropertyIndex( shader, key );
+ index = shader.GetPropertyIndex( key );
if( index != Property::INVALID_INDEX )
{
// Yes - we should register it in the Renderer so it can be set / animated
// Leave keyIndex as INVALID_KEY - it can still be registered against the string key.
}
Property::Value value = shader.GetProperty( index );
- index = DevelHandle::RegisterProperty( mImpl->mRenderer, keyIndex, keyName, value );
+ index = mImpl->mRenderer.RegisterProperty( keyIndex, keyName, value );
}
}
return index;
{
// Ensure the blend mode is turned on if we are animating opacity, and
// turned off after the animation ends if the final value is opaque
- if( ! isInitialOpaque || mImpl->mMixColor.a < 1.0f )
+ if( ( ! isInitialOpaque || mImpl->mMixColor.a < 1.0f ) ||
+ ( mImpl->mRenderer && IsAdvancedBlendEquationApplied() ) )
{
if( mImpl->mRenderer )
{
if( mImpl->mRenderer )
{
DALI_LOG_INFO( gVisualBaseLogFilter, Debug::General, "Visual::Base::OnMixColorFinished()\n");
- mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE,
- ( mImpl->mMixColor.a < 1.0 ) ? BlendMode::ON : BlendMode::AUTO );
+
+ if( mImpl->mMixColor.a >= 1.f &&
+ !IsAdvancedBlendEquationApplied() )
+ {
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO );
+ }
+ else
+ {
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
+ }
}
delete mImpl->mBlendSlotDelegate;
mImpl->mBlendSlotDelegate = NULL;