Move shader list instead of copy + Use RawShaderData full string 35/318235/6
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 26 Sep 2024 01:41:26 +0000 (10:41 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 30 Sep 2024 02:48:23 +0000 (11:48 +0900)
Let we allow to move operation for save precompiled shader list

Change-Id: I5d3d3356af907fa9b32f746900ec554cabe364ae
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
16 files changed:
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/visuals/color/color-visual-shader-factory.cpp
dali-toolkit/internal/visuals/color/color-visual-shader-factory.h
dali-toolkit/internal/visuals/custom-shader-factory.cpp
dali-toolkit/internal/visuals/custom-shader-factory.h
dali-toolkit/internal/visuals/image/image-visual-shader-factory.cpp
dali-toolkit/internal/visuals/image/image-visual-shader-factory.h
dali-toolkit/internal/visuals/npatch-shader-factory.cpp [deleted file]
dali-toolkit/internal/visuals/npatch-shader-factory.h [deleted file]
dali-toolkit/internal/visuals/npatch/npatch-shader-factory.cpp [new file with mode: 0644]
dali-toolkit/internal/visuals/npatch/npatch-shader-factory.h [new file with mode: 0644]
dali-toolkit/internal/visuals/text/text-visual-shader-factory.cpp
dali-toolkit/internal/visuals/text/text-visual-shader-factory.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/internal/visuals/visual-shader-factory-interface.h

index 46c42f7b886cd6b4a325d9d2ab19bc6f2f2db11a..d22f9f0888fe48f537dc99350fc8e762f9e72f58 100644 (file)
@@ -2884,7 +2884,7 @@ int UtcDaliVisualFactoryUsePreCompiledShader(void)
   ToolkitTestApplication application;
   tet_infoline("UtcDaliVisualFactoryUsePreCompiledShader: Test a UsePreCompiledShader fucntion");
 
-  std::vector<RawShaderData> precompiledShaderList;
+  ShaderPreCompiler::RawShaderDataList precompiledShaderList;
   DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // before Get Shader
   ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
   DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // after Get Shader
@@ -3001,7 +3001,7 @@ int UtcDaliVisualFactoryUsePreCompiledShaderN(void)
   ToolkitTestApplication application;
   tet_infoline("UtcDaliVisualFactoryUsePreCompiledShader: Test a UsePreCompiledShader fucntion with invalid options");
 
-  std::vector<RawShaderData> precompiledShaderList;
+  ShaderPreCompiler::RawShaderDataList precompiledShaderList;
   DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // before Get Shader
   ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
   DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // after Get Shader
index 59d49557264c3b239f3dce26a8d27cfaaf0879f8..0753d01aae363a1e73c780118fb961d74a9d7f28 100644 (file)
@@ -38,7 +38,6 @@ SET( toolkit_src_files
    ${toolkit_src_dir}/visuals/color/color-visual-shader-factory.cpp
    ${toolkit_src_dir}/visuals/color/color-visual.cpp
    ${toolkit_src_dir}/visuals/custom-shader-factory.cpp
-   ${toolkit_src_dir}/visuals/npatch-shader-factory.cpp
    ${toolkit_src_dir}/visuals/gradient/gradient-visual.cpp
    ${toolkit_src_dir}/visuals/gradient/gradient.cpp
    ${toolkit_src_dir}/visuals/gradient/linear-gradient.cpp
@@ -52,6 +51,7 @@ SET( toolkit_src_files
    ${toolkit_src_dir}/visuals/mesh/mesh-visual.cpp
    ${toolkit_src_dir}/visuals/npatch/npatch-data.cpp
    ${toolkit_src_dir}/visuals/npatch/npatch-loader.cpp
+   ${toolkit_src_dir}/visuals/npatch/npatch-shader-factory.cpp
    ${toolkit_src_dir}/visuals/npatch/npatch-visual.cpp
    ${toolkit_src_dir}/visuals/primitive/primitive-visual.cpp
    ${toolkit_src_dir}/visuals/svg/svg-loader-observer.cpp
index bbc37fa16cf469a30c3ea22bd41125d6edaebf66..54dd9f62a2f07bb69c4561786ae1fcd367656e48 100644 (file)
@@ -219,31 +219,36 @@ bool ColorVisualShaderFactory::AddPrecompiledShader(PrecompileShaderOption& opti
   VisualFactoryCache::ShaderType type = featureBuilder.GetShaderType();
   featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
   featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
-  return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList);
+  return SavePrecompileShader(type, std::move(vertexPrefixList), std::move(fragmentPrefixList));
 }
 
-void ColorVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
+void ColorVisualShaderFactory::GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders)
 {
-  std::vector<std::string_view> vertexPrefix;
-  std::vector<std::string_view> fragmentPrefix;
-  std::vector<std::string_view> shaderName;
-  int                           shaderCount = 0;
-  shaders.shaderCount                       = 0;
+  std::vector<std::string> vertexPrefix;
+  std::vector<std::string> fragmentPrefix;
+  std::vector<std::string> shaderName;
+
+  uint32_t shaderCount = 0;
+
+  shaders.shaderCount = 0;
 
   // precompile requested shader first
   for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++)
   {
-    vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
-    fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
-    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+    vertexPrefix.push_back(std::move(mRequestedPrecompileShader[i].vertexPrefix));
+    fragmentPrefix.push_back(std::move(mRequestedPrecompileShader[i].fragmentPrefix));
+    shaderName.push_back(std::string(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT)));
     shaderCount++;
   }
 
+  // Clean up requested precompile shader list
+  mRequestedPrecompileShader.clear();
+
   for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; ++i)
   {
-    vertexPrefix.push_back(VertexPredefines[i]);
-    fragmentPrefix.push_back(FragmentPredefines[i]);
-    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+    vertexPrefix.push_back(std::string(VertexPredefines[i]));
+    fragmentPrefix.push_back(std::string(FragmentPredefines[i]));
+    shaderName.push_back(std::string(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT)));
     shaderCount++;
   }
 
@@ -291,7 +296,7 @@ void ColorVisualShaderFactory::CreatePrecompileShader(ColorVisualShaderFeature::
   }
 }
 
-bool ColorVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix)
+bool ColorVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix)
 {
   for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; i++)
   {
@@ -313,9 +318,9 @@ bool ColorVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderTy
 
   RequestShaderInfo info;
   info.type           = shader;
-  info.vertexPrefix   = vertexPrefix;
-  info.fragmentPrefix = fragmentPrefix;
-  mRequestedPrecompileShader.push_back(info);
+  info.vertexPrefix   = std::move(vertexPrefix);
+  info.fragmentPrefix = std::move(fragmentPrefix);
+  mRequestedPrecompileShader.emplace_back(std::move(info));
   DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(shader, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
   return true;
 }
index 7ef6f5658f307c44a02be89872cc27219b1cf61f..f3964bcc4d28ef111607c7f29d42e76e4c70fd57 100644 (file)
@@ -31,7 +31,6 @@ namespace Toolkit
 {
 namespace Internal
 {
-
 namespace ColorVisualShaderFeature
 {
 namespace RoundedCorner
@@ -92,8 +91,8 @@ public:
   FeatureBuilder& EnableCutout(bool enableCutout);
 
   VisualFactoryCache::ShaderType GetShaderType() const;
-  void GetVertexShaderPrefixList(std::string& vertexShaderPrefixList) const;
-  void GetFragmentShaderPrefixList(std::string& fragmentShaderPrefixList) const;
+  void                           GetVertexShaderPrefixList(std::string& vertexShaderPrefixList) const;
+  void                           GetFragmentShaderPrefixList(std::string& fragmentShaderPrefixList) const;
 
   bool IsEnabledRoundCorner() const
   {
@@ -154,7 +153,7 @@ public: // Implementation of VisualShaderFactoryInterface
   /**
    * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::GetPreCompiledShader
    */
-  void GetPreCompiledShader(RawShaderData& shaders) override;
+  void GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders) override;
 
 private:
   /**
@@ -164,7 +163,7 @@ private:
   /**
    * @brief Check if cached hash value is valid or not.
    */
-  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix);
+  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix);
 
 protected:
   /**
index eb05b7bbfe9face7d9938949afc3a64bb7f2c798..791da47847a946d567d10f915e97c7ce5d396a3d 100644 (file)
@@ -41,44 +41,50 @@ bool CustomShaderFactory::AddPrecompiledShader(PrecompileShaderOption& option)
   auto shaderName     = option.GetShaderName();
   auto vertexShader   = option.GetVertexShader();
   auto fragmentShader = option.GetFragmentShader();
-  return SavePrecompileShader(shaderName, vertexShader, fragmentShader);
+  return SavePrecompileShader(std::move(shaderName), std::move(vertexShader), std::move(fragmentShader));
 }
 
-void CustomShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
+void CustomShaderFactory::GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders)
 {
-  std::vector<std::string_view> vertexPrefix;
-  std::vector<std::string_view> fragmentPrefix;
-  std::vector<std::string_view> shaderName;
-  int                           shaderCount = 0;
-  shaders.shaderCount                       = 0;
+  std::vector<std::string> vertexPrefix;
+  std::vector<std::string> fragmentPrefix;
+  std::vector<std::string> shaderName;
+
+  uint32_t shaderCount = 0;
+
+  shaders.shaderCount = 0;
 
   // precompile requested shader first
   for(uint32_t i = 0; i < mRequestedPrecompileShader.size(); i++)
   {
-    vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
-    fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
-    shaderName.push_back(mRequestedPrecompileShader[i].name);
+    vertexPrefix.push_back(std::move(mRequestedPrecompileShader[i].vertexPrefix));
+    fragmentPrefix.push_back(std::move(mRequestedPrecompileShader[i].fragmentPrefix));
+    shaderName.push_back(std::move(mRequestedPrecompileShader[i].name));
     shaderCount++;
   }
 
+  // Clean up requested precompile shader list
+  mRequestedPrecompileShader.clear();
+
   shaders.vertexPrefix   = std::move(vertexPrefix);
   shaders.fragmentPrefix = std::move(fragmentPrefix);
   shaders.shaderName     = std::move(shaderName);
   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.shaderCount    = shaderCount;
   shaders.custom         = true;
 }
 
-bool CustomShaderFactory::SavePrecompileShader(std::string& shaderName, std::string& vertexShader, std::string& fragmentShader)
+bool CustomShaderFactory::SavePrecompileShader(std::string&& shaderName, std::string&& vertexShader, std::string&& fragmentShader)
 {
+  DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)", shaderName.c_str());
+
   RequestShaderInfo info;
   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());
+  info.name           = std::move(shaderName);
+  info.vertexPrefix   = std::move(vertexShader);
+  info.fragmentPrefix = std::move(fragmentShader);
+  mRequestedPrecompileShader.emplace_back(std::move(info));
   return true;
 }
 
index 5401c731e305eca13a2baebe48efe152e041e147..fb39a9b1e3fc0f87d404171d658fc8febdd7e17c 100644 (file)
@@ -31,7 +31,6 @@ namespace Toolkit
 {
 namespace Internal
 {
-
 /**
  * CustomShaderFactory is an object that provides custom shader
  */
@@ -57,13 +56,13 @@ public: // Implementation of VisualShaderFactoryInterface
   /**
    * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::GetPreCompiledShader
    */
-  void GetPreCompiledShader(RawShaderData& shaders) override;
+  void GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders) override;
 
 private:
   /**
    * @brief Save the custom shader
    */
-  bool SavePrecompileShader(std::string& shaderName, std::string& vertexPrefix, std::string& fragmentPrefix);
+  bool SavePrecompileShader(std::string&& shaderName, std::string&& vertexPrefix, std::string&& fragmentPrefix);
 
 protected:
   /**
index 7e2c59d75a0a30a90a0fbdf6908f030321d27082..23ceddf15c5662dd7c774680ea3360f6d9c61833 100644 (file)
@@ -199,30 +199,36 @@ bool ImageVisualShaderFactory::AddPrecompiledShader(PrecompileShaderOption& opti
   VisualFactoryCache::ShaderType type = featureBuilder.GetShaderType();
   featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
   featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
-  return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList);
+  return SavePrecompileShader(type, std::move(vertexPrefixList), std::move(fragmentPrefixList));
 }
 
-void ImageVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
+void ImageVisualShaderFactory::GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders)
 {
-  std::vector<std::string_view> vertexPrefix;
-  std::vector<std::string_view> fragmentPrefix;
-  std::vector<std::string_view> shaderName;
+  std::vector<std::string> vertexPrefix;
+  std::vector<std::string> fragmentPrefix;
+  std::vector<std::string> shaderName;
+
+  uint32_t shaderCount = 0;
+
   shaders.shaderCount = 0;
-  int shaderCount     = 0;
 
-  for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++)
+  // precompile requested shader first
+  for(uint32_t i = 0; i < mRequestedPrecompileShader.size(); i++)
   {
-    vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
-    fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
-    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+    vertexPrefix.push_back(std::move(mRequestedPrecompileShader[i].vertexPrefix));
+    fragmentPrefix.push_back(std::move(mRequestedPrecompileShader[i].fragmentPrefix));
+    shaderName.push_back(std::string(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT)));
     shaderCount++;
   }
 
+  // Clean up requested precompile shader list
+  mRequestedPrecompileShader.clear();
+
   for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; ++i)
   {
-    vertexPrefix.push_back(VertexPredefines[i]);
-    fragmentPrefix.push_back(FragmentPredefines[i]);
-    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+    vertexPrefix.push_back(std::string(VertexPredefines[i]));
+    fragmentPrefix.push_back(std::string(FragmentPredefines[i]));
+    shaderName.push_back(std::string(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT)));
     shaderCount++;
   }
 
@@ -287,7 +293,7 @@ void ImageVisualShaderFactory::CreatePrecompileShader(ImageVisualShaderFeature::
   }
 }
 
-bool ImageVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix)
+bool ImageVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix)
 {
   for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; i++)
   {
@@ -309,9 +315,9 @@ bool ImageVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderTy
 
   RequestShaderInfo info;
   info.type           = shader;
-  info.vertexPrefix   = vertexPrefix;
-  info.fragmentPrefix = fragmentPrefix;
-  mRequestedPrecompileShader.push_back(info);
+  info.vertexPrefix   = std::move(vertexPrefix);
+  info.fragmentPrefix = std::move(fragmentPrefix);
+  mRequestedPrecompileShader.emplace_back(std::move(info));
   DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(shader, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
   return true;
 }
index e7af94a2a3d694374a28e0fa6fd482ba09591f3d..408695d153d05488af0dc80a1c4960021744574c 100644 (file)
@@ -32,7 +32,6 @@ namespace Toolkit
 {
 namespace Internal
 {
-
 /**
  * ImageVisualShaderFactory is an object that provides and shares shaders between image visuals
  */
@@ -77,7 +76,7 @@ public: // Implementation of VisualShaderFactoryInterface
   /**
    * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::GetPreCompiledShader
    */
-  void GetPreCompiledShader(RawShaderData& shaders) override;
+  void GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders) override;
 
 private:
   /**
@@ -87,7 +86,7 @@ private:
   /**
    * @brief Check if cached hash value is valid or not.
    */
-  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix);
+  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix);
 
 protected:
   /**
diff --git a/dali-toolkit/internal/visuals/npatch-shader-factory.cpp b/dali-toolkit/internal/visuals/npatch-shader-factory.cpp
deleted file mode 100644 (file)
index 26fa64c..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/visuals/npatch-shader-factory.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
-#include <dali-toolkit/internal/visuals/visual-string-constants.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-
-NpatchShaderFactory::NpatchShaderFactory()
-: mNpatchXStretchCount(0),
-  mNpatchYStretchCount(0),
-  mNpatchMaskingEnable(false)
-{
-}
-
-NpatchShaderFactory::~NpatchShaderFactory()
-{
-}
-
-bool NpatchShaderFactory::AddPrecompiledShader(PrecompileShaderOption& option)
-{
-  ShaderFlagList shaderOption = option.GetShaderOptions();
-
-  // Find Masking flag
-  for(uint32_t i = 0; i < shaderOption.size(); ++i)
-  {
-    if(shaderOption[i] == PrecompileShaderOption::Flag::MASKING)
-    {
-      mNpatchMaskingEnable = true;
-    }
-  }
-
-  mNpatchXStretchCount = option.GetNpatchXStretchCount();
-  mNpatchYStretchCount = option.GetNpatchYStretchCount();
-
-  std::string vertexShader;
-  std::string fragmentShader;
-  GetVertexShader(vertexShader);
-  GetFragmentShader(fragmentShader);
-
-  VisualFactoryCache::ShaderType shaderType =  mNpatchMaskingEnable? VisualFactoryCache::ShaderType::NINE_PATCH_MASK_SHADER : VisualFactoryCache::ShaderType::NINE_PATCH_SHADER;
-  return SavePrecompileShader(shaderType, vertexShader, fragmentShader);
-}
-
-void NpatchShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
-{
-  std::vector<std::string_view> vertexPrefix;
-  std::vector<std::string_view> fragmentPrefix;
-  std::vector<std::string_view> shaderName;
-  int                           shaderCount = 0;
-  shaders.shaderCount                       = 0;
-
-  // precompile requested shader first
-  for(uint32_t i = 0; i < mRequestedPrecompileShader.size(); i++ )
-  {
-    vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
-    fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
-    shaderName.push_back(mRequestedPrecompileShader[i].name);
-    shaderCount++;
-  }
-
-  shaders.vertexPrefix   = std::move(vertexPrefix);
-  shaders.fragmentPrefix = std::move(fragmentPrefix);
-  shaders.shaderName     = std::move(shaderName);
-  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;
-}
-
-void NpatchShaderFactory::GetVertexShader(std::string& vertexShader) const
-{
-  if(DALI_LIKELY((mNpatchXStretchCount == 1 && mNpatchYStretchCount == 1) ||
-                  (mNpatchXStretchCount == 0 && mNpatchYStretchCount == 0)))
-  {
-    vertexShader += SHADER_NPATCH_VISUAL_3X3_SHADER_VERT;
-  }
-  else if(mNpatchXStretchCount > 0 || mNpatchYStretchCount > 0)
-  {
-    std::stringstream vertextShaderStream;
-    vertextShaderStream << "#define FACTOR_SIZE_X " << mNpatchXStretchCount + 2 << "\n"
-                        << "#define FACTOR_SIZE_Y " << mNpatchYStretchCount + 2 << "\n"
-                        << SHADER_NPATCH_VISUAL_SHADER_VERT;
-    vertexShader += vertextShaderStream.str();
-  }
-}
-
-void NpatchShaderFactory::GetFragmentShader(std::string& fragmentShader) const
-{
-  fragmentShader += (mNpatchMaskingEnable ? SHADER_NPATCH_VISUAL_MASK_SHADER_FRAG : SHADER_NPATCH_VISUAL_SHADER_FRAG);
-}
-
-bool NpatchShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexShader, std::string& fragmentShader)
-{
-  for(uint32_t i = 0u; i< mRequestedPrecompileShader.size(); i++)
-  {
-    if(mRequestedPrecompileShader[i].type == shader)
-    {
-      DALI_LOG_WARNING("This shader already requsted(%s).", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
-      return false;
-    }
-  }
-
-  std::string shaderName = Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(shader, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT);
-  if(!((mNpatchXStretchCount == 1 && mNpatchYStretchCount == 1) || (mNpatchXStretchCount == 0 && mNpatchYStretchCount == 0)))
-  {
-    if(mNpatchXStretchCount > 0 || mNpatchYStretchCount > 0)
-    {
-      std::stringstream shaderNameStream;
-      shaderNameStream << "NINE_PATCH_SHADER_" << mNpatchXStretchCount << "x" << mNpatchYStretchCount;
-      shaderName = shaderNameStream.str();
-    }
-  }
-
-  RequestShaderInfo info;
-  info.type = shader;
-  info.name = shaderName;
-  info.vertexPrefix = vertexShader;
-  info.fragmentPrefix = fragmentShader;
-  mRequestedPrecompileShader.push_back(info);
-  DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)",Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(shader, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
-  return true;
-}
-
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/dali-toolkit/internal/visuals/npatch-shader-factory.h b/dali-toolkit/internal/visuals/npatch-shader-factory.h
deleted file mode 100644 (file)
index c3c42f4..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef DALI_TOOLKIT_NPATCH_SHADER_FACTORY_H
-#define DALI_TOOLKIT_NPATCH_SHADER_FACTORY_H
-
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/adaptor-framework/shader-precompiler.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
-#include <dali-toolkit/internal/visuals/visual-shader-factory-interface.h>
-#include <string_view>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-
-/**
- * NpatchShaderFactory is an object that provides custom shader
- */
-class NpatchShaderFactory : public VisualShaderFactoryInterface
-{
-public:
-  /**
-   * @brief Constructor
-   */
-  NpatchShaderFactory();
-
-  /**
-   * @brief Destructor
-   */
-  ~NpatchShaderFactory() override;
-
-public: // Implementation of VisualShaderFactoryInterface
-  /**
-   * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::AddPrecompiledShader
-   */
-  bool AddPrecompiledShader(PrecompileShaderOption& option) override;
-
-  /**
-   * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::GetPreCompiledShader
-   */
-  void GetPreCompiledShader(RawShaderData& shaders) override;
-
-private:
-  /**
-   * @brief Get the NPatch vertex shader. this is used for generating pre-compiled shader.
-   */
-  void GetVertexShader(std::string& vertexShader) const;
-
-  /**
-   * @brief Get the NPatch fragment shader. this is used for generating pre-compiled shader
-   */
-  void GetFragmentShader(std::string& fragmentShader) const;
-
-  /**
-   * @brief Save the npatch shader
-   */
-  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix);
-
-protected:
-  /**
-   * Undefined copy constructor.
-   */
-  NpatchShaderFactory(const NpatchShaderFactory&) = delete;
-
-  /**
-   * Undefined assignment operator.
-   */
-  NpatchShaderFactory& operator=(const NpatchShaderFactory& rhs) = delete;
-
-private:
-  // For Npatch
-  uint32_t mNpatchXStretchCount;
-  uint32_t mNpatchYStretchCount;
-  bool     mNpatchMaskingEnable;
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_NPATCH_SHADER_FACTORY_H
diff --git a/dali-toolkit/internal/visuals/npatch/npatch-shader-factory.cpp b/dali-toolkit/internal/visuals/npatch/npatch-shader-factory.cpp
new file mode 100644 (file)
index 0000000..ddbc49a
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/visuals/npatch/npatch-shader-factory.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+NpatchShaderFactory::NpatchShaderFactory()
+: mNpatchXStretchCount(0),
+  mNpatchYStretchCount(0),
+  mNpatchMaskingEnable(false)
+{
+}
+
+NpatchShaderFactory::~NpatchShaderFactory()
+{
+}
+
+bool NpatchShaderFactory::AddPrecompiledShader(PrecompileShaderOption& option)
+{
+  ShaderFlagList shaderOption = option.GetShaderOptions();
+
+  // Find Masking flag
+  for(uint32_t i = 0; i < shaderOption.size(); ++i)
+  {
+    if(shaderOption[i] == PrecompileShaderOption::Flag::MASKING)
+    {
+      mNpatchMaskingEnable = true;
+    }
+  }
+
+  mNpatchXStretchCount = option.GetNpatchXStretchCount();
+  mNpatchYStretchCount = option.GetNpatchYStretchCount();
+
+  std::string vertexShader;
+  std::string fragmentShader;
+  GetVertexShader(vertexShader);
+  GetFragmentShader(fragmentShader);
+
+  VisualFactoryCache::ShaderType shaderType = mNpatchMaskingEnable ? VisualFactoryCache::ShaderType::NINE_PATCH_MASK_SHADER : VisualFactoryCache::ShaderType::NINE_PATCH_SHADER;
+  return SavePrecompileShader(shaderType, std::move(vertexShader), std::move(fragmentShader));
+}
+
+void NpatchShaderFactory::GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders)
+{
+  std::vector<std::string> vertexPrefix;
+  std::vector<std::string> fragmentPrefix;
+  std::vector<std::string> shaderName;
+
+  uint32_t shaderCount = 0;
+
+  shaders.shaderCount = 0;
+
+  // precompile requested shader first
+  for(uint32_t i = 0; i < mRequestedPrecompileShader.size(); i++)
+  {
+    vertexPrefix.push_back(std::move(mRequestedPrecompileShader[i].vertexPrefix));
+    fragmentPrefix.push_back(std::move(mRequestedPrecompileShader[i].fragmentPrefix));
+    shaderName.push_back(std::move(mRequestedPrecompileShader[i].name));
+    shaderCount++;
+  }
+
+  // Clean up requested precompile shader list
+  mRequestedPrecompileShader.clear();
+
+  shaders.vertexPrefix   = std::move(vertexPrefix);
+  shaders.fragmentPrefix = std::move(fragmentPrefix);
+  shaders.shaderName     = std::move(shaderName);
+  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    = shaderCount;
+  shaders.custom         = true; ///< Note that npatch shader is kind of custom shader.
+}
+
+void NpatchShaderFactory::GetVertexShader(std::string& vertexShader) const
+{
+  if(DALI_LIKELY((mNpatchXStretchCount == 1 && mNpatchYStretchCount == 1) ||
+                 (mNpatchXStretchCount == 0 && mNpatchYStretchCount == 0)))
+  {
+    vertexShader += SHADER_NPATCH_VISUAL_3X3_SHADER_VERT;
+  }
+  else if(mNpatchXStretchCount > 0 || mNpatchYStretchCount > 0)
+  {
+    std::stringstream vertextShaderStream;
+    vertextShaderStream << "#define FACTOR_SIZE_X " << mNpatchXStretchCount + 2 << "\n"
+                        << "#define FACTOR_SIZE_Y " << mNpatchYStretchCount + 2 << "\n"
+                        << SHADER_NPATCH_VISUAL_SHADER_VERT;
+    vertexShader += vertextShaderStream.str();
+  }
+}
+
+void NpatchShaderFactory::GetFragmentShader(std::string& fragmentShader) const
+{
+  fragmentShader += (mNpatchMaskingEnable ? SHADER_NPATCH_VISUAL_MASK_SHADER_FRAG : SHADER_NPATCH_VISUAL_SHADER_FRAG);
+}
+
+bool NpatchShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexShader, std::string&& fragmentShader)
+{
+  for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++)
+  {
+    if(mRequestedPrecompileShader[i].type == shader)
+    {
+      DALI_LOG_WARNING("This shader already requsted(%s).", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+      return false;
+    }
+  }
+
+  std::string shaderName = Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(shader, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT);
+  if(!((mNpatchXStretchCount == 1 && mNpatchYStretchCount == 1) || (mNpatchXStretchCount == 0 && mNpatchYStretchCount == 0)))
+  {
+    if(mNpatchXStretchCount > 0 || mNpatchYStretchCount > 0)
+    {
+      std::stringstream shaderNameStream;
+      shaderNameStream << "NINE_PATCH_SHADER_" << mNpatchXStretchCount << "x" << mNpatchYStretchCount;
+      shaderName = shaderNameStream.str();
+    }
+  }
+
+  DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)", shaderName.c_str());
+
+  RequestShaderInfo info;
+  info.type           = shader;
+  info.name           = std::move(shaderName);
+  info.vertexPrefix   = std::move(vertexShader);
+  info.fragmentPrefix = std::move(fragmentShader);
+  mRequestedPrecompileShader.emplace_back(std::move(info));
+  return true;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/visuals/npatch/npatch-shader-factory.h b/dali-toolkit/internal/visuals/npatch/npatch-shader-factory.h
new file mode 100644 (file)
index 0000000..975ea9d
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef DALI_TOOLKIT_NPATCH_SHADER_FACTORY_H
+#define DALI_TOOLKIT_NPATCH_SHADER_FACTORY_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/shader-precompiler.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-shader-factory-interface.h>
+#include <string_view>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+/**
+ * NpatchShaderFactory is an object that provides custom shader
+ */
+class NpatchShaderFactory : public VisualShaderFactoryInterface
+{
+public:
+  /**
+   * @brief Constructor
+   */
+  NpatchShaderFactory();
+
+  /**
+   * @brief Destructor
+   */
+  ~NpatchShaderFactory() override;
+
+public: // Implementation of VisualShaderFactoryInterface
+  /**
+   * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::AddPrecompiledShader
+   */
+  bool AddPrecompiledShader(PrecompileShaderOption& option) override;
+
+  /**
+   * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::GetPreCompiledShader
+   */
+  void GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders) override;
+
+private:
+  /**
+   * @brief Get the NPatch vertex shader. this is used for generating pre-compiled shader.
+   */
+  void GetVertexShader(std::string& vertexShader) const;
+
+  /**
+   * @brief Get the NPatch fragment shader. this is used for generating pre-compiled shader
+   */
+  void GetFragmentShader(std::string& fragmentShader) const;
+
+  /**
+   * @brief Save the npatch shader
+   */
+  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix);
+
+protected:
+  /**
+   * Undefined copy constructor.
+   */
+  NpatchShaderFactory(const NpatchShaderFactory&) = delete;
+
+  /**
+   * Undefined assignment operator.
+   */
+  NpatchShaderFactory& operator=(const NpatchShaderFactory& rhs) = delete;
+
+private:
+  // For Npatch
+  uint32_t mNpatchXStretchCount;
+  uint32_t mNpatchYStretchCount;
+  bool     mNpatchMaskingEnable;
+};
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_NPATCH_SHADER_FACTORY_H
index 6e1b7df3d0810cc18996c129416d198ad2a5a583..d08c41154cf022b6438e4e502ea4d4f47f94baec 100644 (file)
@@ -196,30 +196,34 @@ bool TextVisualShaderFactory::AddPrecompiledShader(PrecompileShaderOption& optio
   VisualFactoryCache::ShaderType type = featureBuilder.GetShaderType();
   featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
   featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
-  return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList);
+  return SavePrecompileShader(type, std::move(vertexPrefixList), std::move(fragmentPrefixList));
 }
 
-void TextVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
+void TextVisualShaderFactory::GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders)
 {
-  std::vector<std::string_view> vertexPrefix;
-  std::vector<std::string_view> fragmentPrefix;
-  std::vector<std::string_view> shaderName;
-  int                           shaderCount = 0;
+  std::vector<std::string> vertexPrefix;
+  std::vector<std::string> fragmentPrefix;
+  std::vector<std::string> shaderName;
+
+  uint32_t shaderCount = 0;
 
   // precompile requested shader first
   for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++)
   {
-    vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
-    fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
-    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+    vertexPrefix.push_back(std::move(mRequestedPrecompileShader[i].vertexPrefix));
+    fragmentPrefix.push_back(std::move(mRequestedPrecompileShader[i].fragmentPrefix));
+    shaderName.push_back(std::string(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT)));
     shaderCount++;
   }
 
+  // Clean up requested precompile shader list
+  mRequestedPrecompileShader.clear();
+
   for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; ++i)
   {
-    vertexPrefix.push_back(VertexPredefines[i]);
-    fragmentPrefix.push_back(FragmentPredefines[i]);
-    shaderName.push_back(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+    vertexPrefix.push_back(std::string(VertexPredefines[i]));
+    fragmentPrefix.push_back(std::string(FragmentPredefines[i]));
+    shaderName.push_back(std::string(Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT)));
     shaderCount++;
   }
 
@@ -267,7 +271,7 @@ void TextVisualShaderFactory::CreatePrecompileShader(TextVisualShaderFeature::Fe
   }
 }
 
-bool TextVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix)
+bool TextVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix)
 {
   for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; i++)
   {
@@ -289,9 +293,9 @@ bool TextVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderTyp
 
   RequestShaderInfo info;
   info.type           = shader;
-  info.vertexPrefix   = vertexPrefix;
-  info.fragmentPrefix = fragmentPrefix;
-  mRequestedPrecompileShader.push_back(info);
+  info.vertexPrefix   = std::move(vertexPrefix);
+  info.fragmentPrefix = std::move(fragmentPrefix);
+  mRequestedPrecompileShader.emplace_back(std::move(info));
   DALI_LOG_RELEASE_INFO("Add precompile shader success!!(%s)\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(shader, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
   return true;
 }
index 183f1499388dc77e34b350fbc0ab57d98b149701..14d496218386581273714ebdcfd5411ff6156575 100644 (file)
@@ -97,8 +97,8 @@ public:
   FeatureBuilder& EnableOverlay(bool enableOverlay);
 
   VisualFactoryCache::ShaderType GetShaderType() const;
-  void GetVertexShaderPrefixList(std::string& vertexShaderPrefixList) const;
-  void GetFragmentShaderPrefixList(std::string& fragmentShaderPrefixList) const;
+  void                           GetVertexShaderPrefixList(std::string& vertexShaderPrefixList) const;
+  void                           GetFragmentShaderPrefixList(std::string& fragmentShaderPrefixList) const;
 
   bool IsEnabledMultiColor() const
   {
@@ -159,7 +159,7 @@ public: // Implementation of VisualShaderFactoryInterface
   /**
    * @copydoc Dali::Toolkit::VisualShaderFactoryInterface::GetPreCompiledShader
    */
-  void GetPreCompiledShader(RawShaderData& shaders) override;
+  void GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders) override;
 
 private:
   /**
@@ -170,7 +170,7 @@ private:
   /**
    * @brief Check if cached hash value is valid or not.
    */
-  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix);
+  bool SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string&& vertexPrefix, std::string&& fragmentPrefix);
 
 protected:
   /**
index 26aae4fe314175d7d3984d1780819a4125e36abe..803c5d65920481cdd5668e97c2488dc9e41a9f58 100644 (file)
@@ -43,7 +43,7 @@
 #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-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>
@@ -440,36 +440,39 @@ void VisualFactory::UsePreCompiledShader()
   }
   mPrecompiledShaderRequested = true;
 
-  ShaderPreCompiler::Get().Enable();
+  ShaderPreCompiler::Get().Enable(true);
 
   // Get image shader
-  std::vector<RawShaderData> rawShaderList;
-  RawShaderData              imageShaderData;
+  ShaderPreCompiler::RawShaderDataList rawShaderList;
+  ShaderPreCompiler::RawShaderData     imageShaderData;
   GetImageVisualShaderFactory().GetPreCompiledShader(imageShaderData);
-  rawShaderList.push_back(imageShaderData);
+  rawShaderList.emplace_back(std::move(imageShaderData));
 
   // Get text shader
-  RawShaderData textShaderData;
+  ShaderPreCompiler::RawShaderData textShaderData;
   GetTextVisualShaderFactory().GetPreCompiledShader(textShaderData);
-  rawShaderList.push_back(textShaderData);
+  rawShaderList.emplace_back(std::move(textShaderData));
 
   // Get color shader
-  RawShaderData colorShaderData;
+  ShaderPreCompiler::RawShaderData colorShaderData;
   GetColorVisualShaderFactory().GetPreCompiledShader(colorShaderData);
-  rawShaderList.push_back(colorShaderData);
+  rawShaderList.emplace_back(std::move(colorShaderData));
 
-  RawShaderData npatchShaderData;
+  // Get npatch shader
+  ShaderPreCompiler::RawShaderData npatchShaderData;
   GetNpatchShaderFactory().GetPreCompiledShader(npatchShaderData);
-  rawShaderList.push_back(npatchShaderData);
+  rawShaderList.emplace_back(std::move(npatchShaderData));
 
   // Get 3D shader
+  // TODO
+
   // Get Custom shader
-  RawShaderData customShaderData;
+  ShaderPreCompiler::RawShaderData customShaderData;
   GetCustomShaderFactory().GetPreCompiledShader(customShaderData);
-  rawShaderList.push_back(customShaderData);
+  rawShaderList.emplace_back(std::move(customShaderData));
 
   // Save all shader
-  ShaderPreCompiler::Get().SavePreCompileShaderList(rawShaderList);
+  ShaderPreCompiler::Get().SavePreCompileShaderList(std::move(rawShaderList));
 }
 
 Internal::TextureManager& VisualFactory::GetTextureManager()
index 704be912b907058a14f8cc211463fda6a0a411d4..cfc4df1720dec276b3e7dbf51875ebaf0301daac 100644 (file)
 #include <dali/integration-api/adaptor-framework/shader-precompiler.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/dali-toolkit-common.h>
 #include <dali-toolkit/devel-api/visual-factory/precompile-shader-option.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
 namespace Toolkit
 {
-
-using HashType = uint64_t;
+using HashType       = uint64_t;
 using ShaderFlagList = std::vector<PrecompileShaderOption::Flag>;
 
 namespace Internal
@@ -42,19 +41,18 @@ namespace Internal
 class VisualShaderFactoryInterface
 {
 public:
-
   /**
    * @brief Structure to request shader info from visual shader factory.
    */
   struct RequestShaderInfo
   {
-    VisualFactoryCache::ShaderType type;
-    std::string name;
-    std::string vertexPrefix;
-    std::string fragmentPrefix;
+    VisualFactoryCache::ShaderType type{VisualFactoryCache::ShaderType::SHADER_TYPE_MAX};
+    std::string                    name{};
+    std::string                    vertexPrefix{};
+    std::string                    fragmentPrefix{};
   };
 
-  VisualShaderFactoryInterface() = default;
+  VisualShaderFactoryInterface()          = default;
   virtual ~VisualShaderFactoryInterface() = default;
 
   /**
@@ -67,7 +65,7 @@ public:
    * @brief Get precompiled shader for precompile
    * @param[out] shaders shaderList for precompile
    */
-  virtual void GetPreCompiledShader(RawShaderData& shaders) = 0;
+  virtual void GetPreCompiledShader(ShaderPreCompiler::RawShaderData& shaders) = 0;
 
 protected:
   std::vector<RequestShaderInfo> mRequestedPrecompileShader;