[dali_2.3.28] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-gradient / animated-gradient-visual.cpp
index 61f1b4d..905c9d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -133,7 +133,7 @@ AnimatedGradientVisualPtr AnimatedGradientVisual::New(VisualFactoryCache& factor
 }
 
 AnimatedGradientVisual::AnimatedGradientVisual(VisualFactoryCache& factoryCache)
 }
 
 AnimatedGradientVisual::AnimatedGradientVisual(VisualFactoryCache& factoryCache)
-: Visual::Base(factoryCache, Visual::FittingMode::FILL, static_cast<Toolkit::Visual::Type>(Toolkit::DevelVisual::ANIMATED_GRADIENT))
+: Visual::Base(factoryCache, Visual::FittingMode::DONT_CARE, static_cast<Toolkit::Visual::Type>(Toolkit::DevelVisual::ANIMATED_GRADIENT))
 {
   SetupDefaultValue();
 }
 {
   SetupDefaultValue();
 }
@@ -591,10 +591,12 @@ void AnimatedGradientVisual::DoCreateInstancePropertyMap(Property::Map& map) con
 {
 }
 
 {
 }
 
-Shader AnimatedGradientVisual::CreateShader()
+Shader AnimatedGradientVisual::GetOrCreateShader()
 {
   Shader shader;
 
 {
   Shader shader;
 
+  VisualFactoryCache::ShaderType shaderType = GetShaderType(mGradientType, mUnitType, mSpreadType);
+
   std::string tagUnit;
   std::string tagGrad;
   std::string tagSpread;
   std::string tagUnit;
   std::string tagGrad;
   std::string tagSpread;
@@ -649,20 +651,14 @@ Shader AnimatedGradientVisual::CreateShader()
   vert = "#define " + tagUnit + "\n" + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_VERT.data();
   frag = "#define " + tagGrad + "\n" + "#define " + tagSpread + "\n" + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_FRAG.data();
 
   vert = "#define " + tagUnit + "\n" + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_VERT.data();
   frag = "#define " + tagGrad + "\n" + "#define " + tagSpread + "\n" + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_FRAG.data();
 
-  shader = Shader::New(vert, frag);
+  shader = mFactoryCache.GenerateAndSaveShader(shaderType, vert, frag);
   return shader;
 }
 
 void AnimatedGradientVisual::OnInitialize()
 {
   return shader;
 }
 
 void AnimatedGradientVisual::OnInitialize()
 {
-  Geometry                       geometry   = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
-  VisualFactoryCache::ShaderType shaderType = GetShaderType(mGradientType, mUnitType, mSpreadType);
-  Shader                         shader     = mFactoryCache.GetShader(shaderType);
-  if(!shader)
-  {
-    shader = CreateShader();
-    mFactoryCache.SaveShader(shaderType, shader);
-  }
+  Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
+  Shader   shader   = GetOrCreateShader();
 
   mImpl->mRenderer = VisualRenderer::New(geometry, shader);
   mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
 
   mImpl->mRenderer = VisualRenderer::New(geometry, shader);
   mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);