Apply to update shaders when CornerRadius/Borderline Animate
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-vector-image / animated-vector-image-visual.cpp
index edd7b1b..35d7456 100644 (file)
@@ -283,26 +283,7 @@ void AnimatedVectorImageVisual::DoSetProperty(Property::Index index, const Prope
 
 void AnimatedVectorImageVisual::OnInitialize(void)
 {
-  Shader shader;
-
-  if(mImpl->mCustomShader)
-  {
-    shader = Shader::New(mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
-                         mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
-                         mImpl->mCustomShader->mHints);
-
-    shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
-  }
-  else
-  {
-    shader = mImageVisualShaderFactory.GetShader(
-      mFactoryCache,
-      TextureAtlas::DISABLED,
-      DefaultTextureWrapMode::APPLY,
-      IsRoundedCornerRequired() ? RoundedCorner::ENABLED : RoundedCorner::DISABLED,
-      IsBorderlineRequired() ? Borderline::ENABLED : Borderline::DISABLED
-    );
-  }
+  Shader shader = GenerateShader();
 
   Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
 
@@ -411,6 +392,15 @@ void AnimatedVectorImageVisual::OnSetTransform()
   }
 }
 
+void AnimatedVectorImageVisual::UpdateShader()
+{
+  if(mImpl->mRenderer)
+  {
+    Shader shader = GenerateShader();
+    mImpl->mRenderer.SetShader(shader);
+  }
+}
+
 void AnimatedVectorImageVisual::OnDoAction(const Property::Index actionId, const Property::Value& attributes)
 {
   // Check if action is valid for this visual type and perform action if possible
@@ -633,6 +623,31 @@ void AnimatedVectorImageVisual::OnProcessEvents()
   mEventCallback = nullptr; // The callback will be deleted in the VectorAnimationManager
 }
 
+Shader AnimatedVectorImageVisual::GenerateShader() const
+{
+  Shader shader;
+  if(mImpl->mCustomShader)
+  {
+    shader = Shader::New(mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
+                         mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
+                         mImpl->mCustomShader->mHints);
+
+    shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+  }
+  else
+  {
+    shader = mImageVisualShaderFactory.GetShader(
+      mFactoryCache,
+      TextureAtlas::DISABLED,
+      DefaultTextureWrapMode::APPLY,
+      IsRoundedCornerRequired() ? RoundedCorner::ENABLED : RoundedCorner::DISABLED,
+      IsBorderlineRequired() ? Borderline::ENABLED : Borderline::DISABLED
+    );
+  }
+  return shader;
+}
+
+
 } // namespace Internal
 
 } // namespace Toolkit