Do not change BlendMode by following whether advanced blend equation is appied or not
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-impl.cpp
index c47cfca..aca317e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -20,7 +20,6 @@
 
 // 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>
@@ -441,18 +440,12 @@ void Visual::Base::RegisterMixColor()
   // (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 )
-  {
-    mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
-  }
-
   mImpl->mRenderer.SetProperty( DevelRenderer::Property::OPACITY, mImpl->mMixColor.a );
 
   float preMultipliedAlpha = 0.0f;
@@ -471,10 +464,6 @@ void Visual::Base::SetMixColor( const Vector4& color )
   {
     mImpl->mRenderer.SetProperty( mImpl->mMixColorIndex, Vector3(color) );
     mImpl->mRenderer.SetProperty( DevelRenderer::Property::OPACITY, color.a );
-    if( color.a < 1.f )
-    {
-      mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
-    }
   }
 }
 
@@ -556,13 +545,13 @@ Renderer Visual::Base::GetRenderer()
 
 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
@@ -580,7 +569,7 @@ Property::Index Visual::Base::GetPropertyIndex( Property::Key key )
         // 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;
@@ -668,14 +657,6 @@ void Visual::Base::AnimateOpacityProperty(
   Dali::Animation& transition,
   Internal::TransitionData::Animator& animator )
 {
-  bool isOpaque = mImpl->mMixColor.a >= 1.0f;
-
-  float initialOpacity;
-  if( animator.initialValue.Get( initialOpacity ) )
-  {
-    isOpaque = (initialOpacity >= 1.0f);
-  }
-
   float targetOpacity;
   if( animator.targetValue.Get( targetOpacity ) )
   {
@@ -683,7 +664,6 @@ void Visual::Base::AnimateOpacityProperty(
   }
 
   SetupTransition( transition, animator, DevelRenderer::Property::OPACITY, animator.initialValue, animator.targetValue );
-  SetupBlendMode( transition, isOpaque, animator.animate );
 }
 
 void Visual::Base::AnimateRendererProperty(
@@ -720,7 +700,6 @@ void Visual::Base::AnimateMixColorProperty(
 {
   Property::Index index = mImpl->mMixColorIndex;
   bool animateOpacity = false;
-  bool isOpaque = true;
 
   Property::Value initialOpacity;
   Property::Value targetOpacity;
@@ -735,7 +714,6 @@ void Visual::Base::AnimateMixColorProperty(
       if( animator.initialValue.GetType() == Property::VECTOR4 )
       {
         // if there is an initial color specifying alpha, test it
-        isOpaque = initialColor.a >= 1.0f;
         initialOpacity = initialColor.a;
       }
       initialMixColor = Vector3( initialColor );
@@ -763,47 +741,10 @@ void Visual::Base::AnimateMixColorProperty(
     if( animateOpacity )
     {
       SetupTransition( transition, animator, DevelRenderer::Property::OPACITY, initialOpacity, targetOpacity );
-      SetupBlendMode( transition, isOpaque, animator.animate );
-    }
-  }
-}
-
-void Visual::Base::SetupBlendMode( Animation& transition, bool isInitialOpaque, bool animating )
-{
-  // 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( mImpl->mRenderer )
-    {
-      mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
-
-      if( animating == true && mImpl->mMixColor.a >= 1.0f )
-      {
-        // When it becomes opaque, set the blend mode back to automatically
-        if( ! mImpl->mBlendSlotDelegate )
-        {
-          mImpl->mBlendSlotDelegate = new SlotDelegate<Visual::Base>(this);
-        }
-        transition.FinishedSignal().Connect( *(mImpl->mBlendSlotDelegate),
-                                             &Visual::Base::OnMixColorFinished );
-      }
     }
   }
 }
 
-void Visual::Base::OnMixColorFinished( Animation& animation )
-{
-  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 );
-  }
-  delete mImpl->mBlendSlotDelegate;
-  mImpl->mBlendSlotDelegate = NULL;
-}
-
 } // namespace Internal
 
 } // namespace Toolkit