Fix Svace/Coverity issue after merge precompile shader refactorize 41/317741/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 13 Sep 2024 09:58:28 +0000 (18:58 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 13 Sep 2024 09:58:44 +0000 (18:58 +0900)
Change-Id: Ic137fae18ab49da19473e870145c0f9387e17300
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/custom-shader-factory.cpp
dali-toolkit/internal/visuals/visual-factory-cache.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp

index e0b345cf0d3e1bf9f24d356d4d964d9864627835..eb05b7bbfe9face7d9938949afc3a64bb7f2c798 100644 (file)
@@ -28,7 +28,6 @@ namespace Toolkit
 {
 namespace Internal
 {
-
 CustomShaderFactory::CustomShaderFactory()
 {
 }
@@ -39,8 +38,8 @@ CustomShaderFactory::~CustomShaderFactory()
 
 bool CustomShaderFactory::AddPrecompiledShader(PrecompileShaderOption& option)
 {
-  auto shaderName = option.GetShaderName();
-  auto vertexShader = option.GetVertexShader();
+  auto shaderName     = option.GetShaderName();
+  auto vertexShader   = option.GetVertexShader();
   auto fragmentShader = option.GetFragmentShader();
   return SavePrecompileShader(shaderName, vertexShader, fragmentShader);
 }
@@ -54,7 +53,7 @@ void CustomShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
   shaders.shaderCount                       = 0;
 
   // precompile requested shader first
-  for(uint32_t i = 0; i < mRequestedPrecompileShader.size(); i++ )
+  for(uint32_t i = 0; i < mRequestedPrecompileShader.size(); i++)
   {
     vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
     fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
@@ -68,17 +67,18 @@ void CustomShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
   shaders.vertexShader   = ""; // Custom shader use prefix shader only. No need to set vertexShader and fragmentShader.
   shaders.fragmentShader = ""; // Custom shader use prefix shader only. No need to set vertexShader and fragmentShader.
   shaders.shaderCount    = std::move(shaderCount);
-  shaders.custom = true;
+  shaders.custom         = true;
 }
 
 bool CustomShaderFactory::SavePrecompileShader(std::string& shaderName, std::string& vertexShader, std::string& fragmentShader)
 {
   RequestShaderInfo info;
-  info.name = shaderName;
-  info.vertexPrefix = vertexShader;
+  info.type           = VisualFactoryCache::SHADER_TYPE_MAX; ///< Not be used
+  info.name           = shaderName;
+  info.vertexPrefix   = vertexShader;
   info.fragmentPrefix = fragmentShader;
   mRequestedPrecompileShader.push_back(info);
-  DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)",shaderName.c_str());
+  DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)", shaderName.c_str());
   return true;
 }
 
index 7270b349b64dae43fc6dc2a95fea54b44525aa80..cc59ea708185c32c06cd4e7adede710d10675660 100644 (file)
@@ -143,7 +143,7 @@ public:
     WIREFRAME_SHADER,
     ARC_BUTT_CAP_SHADER,
     ARC_ROUND_CAP_SHADER,
-    SHADER_TYPE_MAX = ARC_ROUND_CAP_SHADER
+    SHADER_TYPE_MAX
   };
 
   /**
@@ -156,7 +156,7 @@ public:
     NINE_PATCH_GEOMETRY,
     NINE_PATCH_BORDER_GEOMETRY,
     WIREFRAME_GEOMETRY,
-    GEOMETRY_TYPE_MAX = WIREFRAME_GEOMETRY
+    GEOMETRY_TYPE_MAX
   };
 
 public:
@@ -368,8 +368,8 @@ private:
     uint32_t                 height;
   };
 
-  Geometry mGeometry[GEOMETRY_TYPE_MAX + 1];
-  Shader   mShader[SHADER_TYPE_MAX + 1];
+  Geometry mGeometry[GEOMETRY_TYPE_MAX];
+  Shader   mShader[SHADER_TYPE_MAX];
 
   bool mLoadYuvPlanes; ///< A global flag to specify if the image should be loaded as yuv planes
 
index 8242f75054393b312891aca282108ad8f269f906..92b2fa87ee00519f12d65766b926924a1cd785b2 100644 (file)
 #include <dali-toolkit/internal/visuals/color/color-visual-shader-factory.h>
 #include <dali-toolkit/internal/visuals/color/color-visual.h>
 #include <dali-toolkit/internal/visuals/custom-shader-factory.h>
-#include <dali-toolkit/internal/visuals/npatch-shader-factory.h>
 #include <dali-toolkit/internal/visuals/gradient/gradient-visual.h>
 #include <dali-toolkit/internal/visuals/image/image-visual-shader-factory.h>
 #include <dali-toolkit/internal/visuals/image/image-visual.h>
 #include <dali-toolkit/internal/visuals/mesh/mesh-visual.h>
+#include <dali-toolkit/internal/visuals/npatch-shader-factory.h>
 #include <dali-toolkit/internal/visuals/npatch/npatch-visual.h>
 #include <dali-toolkit/internal/visuals/primitive/primitive-visual.h>
 #include <dali-toolkit/internal/visuals/svg/svg-visual.h>
@@ -422,7 +422,7 @@ void VisualFactory::DiscardVisual(Toolkit::Visual::Base visual)
 bool VisualFactory::AddPrecompileShader(const Property::Map& map)
 {
   PrecompileShaderOption shaderOption(map);
-  auto type = shaderOption.GetShaderType();
+  auto                   type = shaderOption.GetShaderType();
   if(type == PrecompileShaderOption::ShaderType::UNKNOWN)
   {
     DALI_LOG_ERROR("AddPrecompileShader is failed. we can't find shader type");
@@ -567,7 +567,7 @@ CustomShaderFactory& VisualFactory::GetCustomShaderFactory()
 bool VisualFactory::AddPrecompileShader(PrecompileShaderOption& option)
 {
   auto type = option.GetShaderType();
-  bool ret = false;
+  bool ret  = false;
   switch(type)
   {
     case PrecompileShaderOption::ShaderType::COLOR:
@@ -588,6 +588,7 @@ bool VisualFactory::AddPrecompileShader(PrecompileShaderOption& option)
     case PrecompileShaderOption::ShaderType::NPATCH:
     {
       ret = GetNpatchShaderFactory().AddPrecompiledShader(option);
+      break;
     }
     case PrecompileShaderOption::ShaderType::MODEL_3D:
     {
@@ -601,7 +602,7 @@ bool VisualFactory::AddPrecompileShader(PrecompileShaderOption& option)
     }
     default:
     {
-      DALI_LOG_ERROR("AddPrecompileShader is failed. we can't find shader factory type:%d",type);
+      DALI_LOG_ERROR("AddPrecompileShader is failed. we can't find shader factory type:%d", type);
       break;
     }
   }