{
typedef Toolkit::NPatchUtility::StretchRanges StretchRanges;
+constexpr uint32_t PLATFORM_DEFAULT_PRECOMPILED_SHADER_COUNT = 5u;
+
const char* TEST_9_PATCH_FILE_NAME = TEST_RESOURCE_DIR "/demo-tile-texture-focused.9.png";
const char* TEST_NPATCH_FILE_NAME = TEST_RESOURCE_DIR "/heartsframe.9.png";
const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
npatchShader2["xStretchCount"] = 4;
npatchShader2["yStretchCount"] = 3;
- Property::Map customSHader;
- customSHader["shaderType"] = "custom";
- customSHader["shaderName"] = "myShader";
- customSHader["vertexShader"] = VertexSource;
- customSHader["fragmentShader"] = FragmentSource;
+ Property::Map customShader;
+ customShader["shaderType"] = "custom";
+ customShader["shaderName"] = "myShader";
+ customShader["vertexShader"] = VertexSource;
+ customShader["fragmentShader"] = FragmentSource;
factory.AddPrecompileShader(imageShader);
factory.AddPrecompileShader(imageShader); // use same shader, because check line coverage
factory.AddPrecompileShader(imageShader2);
factory.AddPrecompileShader(imageShader3);
factory.AddPrecompileShader(imageShader4);
+ factory.AddPrecompileShader(imageShader4); // use same shader, because check line coverage
factory.AddPrecompileShader(imageShader5);
factory.AddPrecompileShader(textShader);
+ factory.AddPrecompileShader(textShader); // use same shader, because check line coverage
factory.AddPrecompileShader(textShader2);
factory.AddPrecompileShader(colorShader);
+ factory.AddPrecompileShader(colorShader); // use same shader, because check line coverage
factory.AddPrecompileShader(colorShader2);
factory.AddPrecompileShader(npatchShader);
factory.AddPrecompileShader(npatchShader2);
- factory.AddPrecompileShader(customSHader);
+ factory.AddPrecompileShader(customShader);
factory.UsePreCompiledShader();
ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
- DALI_TEST_CHECK(precompiledShaderList.size() != 0u); // after Get Shader
+
+ DALI_TEST_EQUALS(precompiledShaderList.size(), PLATFORM_DEFAULT_PRECOMPILED_SHADER_COUNT, TEST_LOCATION);
Property::Map propertyMap;
propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
END_TEST;
}
+
+int UtcDaliVisualFactoryUsePreCompiledShaderN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryUsePreCompiledShader: Test a UsePreCompiledShader fucntion with invalid options");
+
+ std::vector<RawShaderData> precompiledShaderList;
+ DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // before Get Shader
+ ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
+ DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // after Get Shader
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map invalidShaderType;
+ invalidShaderType["shaderType"] = "invalid";
+
+ Property::Map invalidShaderFlag;
+ invalidShaderFlag["shaderType"] = "image";
+ invalidShaderFlag["shaderOption"] = Property::Map().Add("INVALID", true);
+
+ Property::Map invalidShaderFlag2;
+ invalidShaderFlag2["shaderType"] = "image";
+ invalidShaderFlag2["shaderOption"] = Property::Map().Add("ROUNDED_CORNER", false).Add("INVALID", false);
+
+ Property::Map unmatchedShaderOption;
+ unmatchedShaderOption["shaderType"] = "image";
+ unmatchedShaderOption["shaderOption"] = Property::Map().Add("CUTOUT", true);
+
+ Property::Map unmatchedShaderOption2;
+ unmatchedShaderOption2["shaderType"] = "text";
+ unmatchedShaderOption2["shaderOption"] = Property::Map().Add("ROUNDED_CORNER", true);
+
+ Property::Map unmatchedShaderOption3;
+ unmatchedShaderOption3["shaderType"] = "color";
+ unmatchedShaderOption3["shaderOption"] = Property::Map().Add("EMOJI", true);
+
+ factory.AddPrecompileShader(invalidShaderType);
+ factory.AddPrecompileShader(invalidShaderFlag);
+ factory.AddPrecompileShader(invalidShaderFlag2);
+ factory.AddPrecompileShader(unmatchedShaderOption);
+ factory.AddPrecompileShader(unmatchedShaderOption2);
+ factory.AddPrecompileShader(unmatchedShaderOption3);
+
+ factory.UsePreCompiledShader();
+
+ ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
+
+ DALI_TEST_EQUALS(precompiledShaderList.size(), PLATFORM_DEFAULT_PRECOMPILED_SHADER_COUNT, TEST_LOCATION);
+
+ END_TEST;
+}
#include <dali-toolkit/devel-api/visual-factory/precompile-shader-option.h>
// EXTERNAL INCLUDES
+#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/integration-api/debug.h>
namespace
{
- // TYPE
- const char* TOKEN_TYPE("shaderType");
- const char* TOKEN_TYPE_IMAGE("image");
- const char* TOKEN_TYPE_TEXT("text");
- const char* TOKEN_TYPE_COLOR("color");
- const char* TOKEN_TYPE_MODEL_3D("3d");
- const char* TOKEN_TYPE_NPATCH("npatch");
- const char* TOKEN_TYPE_CUSTOM("custom");
-
- // OPTION
- const char* TOKEN_OPTION("shaderOption");
- const char* TOKEN_OPTION_ROUNDED_CORNER("ROUNDED_CORNER");
- const char* TOKEN_OPTION_BORDERLINE("BORDERLINE");
- const char* TOKEN_OPTION_BLUR_EDGE("BLUR_EDGE");
- const char* TOKEN_OPTION_CUTOUT("CUTOUT");
- const char* TOKEN_OPTION_ATLAS_DEFAULT("ATLAS_DEFAULT");
- const char* TOKEN_OPTION_ATLAS_CUSTOM("ATLAS_CUSTOM");
- const char* TOKEN_OPTION_MASKING("MASKING");
- const char* TOKEN_OPTION_YUV_TO_RGB("YUV_TO_RGB");
- const char* TOKEN_OPTION_YUV_AND_RGB("YUV_AND_RGB");
- const char* TOKEN_OPTION_MULTI_COLOR("MULTI_COLOR");
- const char* TOKEN_OPTION_STYLES("STYLES");
- const char* TOKEN_OPTION_OVERLAY("OVERLAY");
- const char* TOKEN_OPTION_EMOJI("EMOJI");
- const char* TOKEN_OPTION_STRETCH_X("xStretchCount");
- const char* TOKEN_OPTION_STRETCH_Y("yStretchCount");
-
-
- // CUSTOM
- const char* TOKEN_CUSTOM_VERTEX("vertexShader");
- const char* TOKEN_CUSTOM_FRAMENT("fragmentShader");
- const char* TOKEN_CUSTOM_NAME("shaderName");
-}
+// TYPE
+const char* TOKEN_TYPE("shaderType");
+const char* TOKEN_TYPE_IMAGE("image");
+const char* TOKEN_TYPE_TEXT("text");
+const char* TOKEN_TYPE_COLOR("color");
+const char* TOKEN_TYPE_MODEL_3D("3d");
+const char* TOKEN_TYPE_NPATCH("npatch");
+const char* TOKEN_TYPE_CUSTOM("custom");
+
+// OPTION
+const char* TOKEN_OPTION("shaderOption");
+const char* TOKEN_OPTION_ROUNDED_CORNER("ROUNDED_CORNER");
+const char* TOKEN_OPTION_BORDERLINE("BORDERLINE");
+const char* TOKEN_OPTION_BLUR_EDGE("BLUR_EDGE");
+const char* TOKEN_OPTION_CUTOUT("CUTOUT");
+const char* TOKEN_OPTION_ATLAS_DEFAULT("ATLAS_DEFAULT");
+const char* TOKEN_OPTION_ATLAS_CUSTOM("ATLAS_CUSTOM");
+const char* TOKEN_OPTION_MASKING("MASKING");
+const char* TOKEN_OPTION_YUV_TO_RGB("YUV_TO_RGB");
+const char* TOKEN_OPTION_YUV_AND_RGB("YUV_AND_RGB");
+const char* TOKEN_OPTION_MULTI_COLOR("MULTI_COLOR");
+const char* TOKEN_OPTION_STYLES("STYLES");
+const char* TOKEN_OPTION_OVERLAY("OVERLAY");
+const char* TOKEN_OPTION_EMOJI("EMOJI");
+const char* TOKEN_OPTION_STRETCH_X("xStretchCount");
+const char* TOKEN_OPTION_STRETCH_Y("yStretchCount");
+
+// CUSTOM
+const char* TOKEN_CUSTOM_VERTEX("vertexShader");
+const char* TOKEN_CUSTOM_FRAMENT("fragmentShader");
+const char* TOKEN_CUSTOM_NAME("shaderName");
+
+// String to enum table
+// clang-format off
+DALI_ENUM_TO_STRING_TABLE_BEGIN(SHADER_TYPE)
+ {TOKEN_TYPE_IMAGE, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::ShaderType::IMAGE)},
+ {TOKEN_TYPE_TEXT, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::ShaderType::TEXT)},
+ {TOKEN_TYPE_COLOR, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::ShaderType::COLOR)},
+ {TOKEN_TYPE_MODEL_3D, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::ShaderType::MODEL_3D)},
+ {TOKEN_TYPE_NPATCH, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::ShaderType::NPATCH)},
+ {TOKEN_TYPE_CUSTOM, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::ShaderType::CUSTOM)},
+DALI_ENUM_TO_STRING_TABLE_END(SHADER_TYPE);
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(SHADER_OPTION_FLAG)
+ {TOKEN_OPTION_ROUNDED_CORNER, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::ROUNDED_CORNER)},
+ {TOKEN_OPTION_BORDERLINE, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::BORDERLINE)},
+ {TOKEN_OPTION_BLUR_EDGE, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::BLUR_EDGE)},
+ {TOKEN_OPTION_CUTOUT, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::CUTOUT)},
+ {TOKEN_OPTION_ATLAS_DEFAULT, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::ATLAS_DEFAULT)},
+ {TOKEN_OPTION_ATLAS_CUSTOM, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::ATLAS_CUSTOM)},
+ {TOKEN_OPTION_MASKING, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::MASKING)},
+ {TOKEN_OPTION_YUV_TO_RGB, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::YUV_TO_RGB)},
+ {TOKEN_OPTION_YUV_AND_RGB, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::YUV_AND_RGB)},
+ {TOKEN_OPTION_MULTI_COLOR, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::MULTI_COLOR)},
+ {TOKEN_OPTION_STYLES, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::STYLES)},
+ {TOKEN_OPTION_OVERLAY, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::OVERLAY)},
+ {TOKEN_OPTION_EMOJI, static_cast<int32_t>(Dali::Toolkit::PrecompileShaderOption::Flag::EMOJI)},
+DALI_ENUM_TO_STRING_TABLE_END(SHADER_OPTION_FLAG);
+// clang-format on
+} // namespace
namespace Dali
{
-
namespace Toolkit
{
-
PrecompileShaderOption::PrecompileShaderOption(const Property::Map& shaderOption)
: mShaderType(ShaderType::UNKNOWN),
mShaderOptions(),
const KeyValuePair pair(shaderOption.GetKeyValue(shaderIdx));
if(pair.first.type == Property::Key::INDEX)
{
- continue; // We don't consider index keys.
+ continue; // We don't consider index keys.
}
const std::string& key(pair.first.stringKey);
if(key == TOKEN_TYPE)
{
- if(value.GetType() == Property::STRING)
+ if(!GetEnumerationProperty(value, SHADER_TYPE_TABLE, SHADER_TYPE_TABLE_COUNT, mShaderType) || mShaderType == ShaderType::UNKNOWN)
{
- auto shaderType = value.Get<std::string>();
- if(shaderType == TOKEN_TYPE_IMAGE)
- {
- mShaderType = ShaderType::IMAGE;
- }
- else if(shaderType == TOKEN_TYPE_TEXT)
- {
- mShaderType = ShaderType::TEXT;
- }
- else if(shaderType == TOKEN_TYPE_COLOR)
- {
- mShaderType = ShaderType::COLOR;
- }
- else if(shaderType == TOKEN_TYPE_MODEL_3D)
- {
- mShaderType = ShaderType::MODEL_3D;
- }
- else if(shaderType == TOKEN_TYPE_NPATCH)
- {
- mShaderType = ShaderType::NPATCH;
- }
- else if(shaderType == TOKEN_TYPE_CUSTOM)
- {
- mShaderType = ShaderType::CUSTOM;
- }
- else
- {
- mShaderType = ShaderType::UNKNOWN;
- }
- }
-
- if(mShaderType == ShaderType::UNKNOWN)
- {
- DALI_LOG_ERROR("Can't find proper type.");
- break;
+ DALI_LOG_ERROR("Can't find proper type[%s]\n", value.Get<std::string>().c_str());
+ continue;
}
}
else if(key == TOKEN_OPTION)
continue; // We don't consider index keys.
}
- const std::string& optionKey(optionPair.first.stringKey);
-
- if(optionKey == TOKEN_OPTION_ROUNDED_CORNER)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::ROUNDED_CORNER);
- }
- }
- else if(optionKey == TOKEN_OPTION_BORDERLINE)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::BORDERLINE);
- }
- }
- else if(optionKey == TOKEN_OPTION_CUTOUT)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::CUTOUT);
- }
- }
- else if(optionKey == TOKEN_OPTION_ATLAS_DEFAULT)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::ATLAS_DEFAULT);
- }
- }
- else if(optionKey == TOKEN_OPTION_ATLAS_CUSTOM)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::ATLAS_CUSTOM);
- }
- }
- else if(optionKey == TOKEN_OPTION_BLUR_EDGE)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::BLUR_EDGE);
- }
- }
- else if(optionKey == TOKEN_OPTION_MASKING)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::MASKING);
- }
- }
- else if(optionKey == TOKEN_OPTION_YUV_TO_RGB)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::YUV_TO_RGB);
- }
- }
- else if(optionKey == TOKEN_OPTION_YUV_AND_RGB)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::YUV_AND_RGB);
- }
- }
- else if(optionKey == TOKEN_OPTION_MULTI_COLOR)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::MULTI_COLOR);
- }
- }
- else if(optionKey == TOKEN_OPTION_STYLES)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::STYLES);
- }
- }
- else if(optionKey == TOKEN_OPTION_OVERLAY)
- {
- if(optionPair.second.Get<bool>())
- {
- mShaderOptions.push_back(Flag::OVERLAY);
- }
- }
- else if(optionKey == TOKEN_OPTION_EMOJI)
+ Flag flag = Flag::UNKNOWN;
+ const std::string& optionKey(optionPair.first.stringKey);
+ if(GetEnumeration(optionKey.c_str(), SHADER_OPTION_FLAG_TABLE, SHADER_OPTION_FLAG_TABLE_COUNT, flag) && flag != Flag::UNKNOWN)
{
if(optionPair.second.Get<bool>())
{
- mShaderOptions.push_back(Flag::EMOJI);
+ mShaderOptions.push_back(flag);
}
}
else
{
- DALI_LOG_WARNING("Can't find this flag[%s] \n",optionKey.c_str());
+ DALI_LOG_WARNING("Can't find this flag[%s]\n", optionKey.c_str());
+ continue;
}
}
}
return mNpatchXStretchCount;
}
-uint32_t PrecompileShaderOption::GetNpatchYStretchCount() const
+uint32_t PrecompileShaderOption::GetNpatchYStretchCount() const
{
return mNpatchYStretchCount;
}
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/object/property-map.h>
-#include <dali/public-api/common/vector-wrapper.h>
#include <memory>
#include <string>
#include <string_view>
{
namespace Toolkit
{
-
/**
* @brief PrecompiledShaderOption is a class for precompiled shader option.
*
enum class Flag
{
- ROUNDED_CORNER = 0,
+ UNKNOWN = 0,
+ ROUNDED_CORNER,
BORDERLINE,
BLUR_EDGE,
CUTOUT,
PrecompileShaderOption(const PrecompileShaderOption& rhs);
PrecompileShaderOption& operator=(const PrecompileShaderOption& rhs);
- using ShaderOptions= std::vector<Flag>;
+ using ShaderOptions = std::vector<Flag>;
public:
/**
*/
uint32_t GetNpatchXStretchCount() const;
- /**
+ /**
* @brief Get the YStretchCount for npatch
*
* @return The NpatchYStretchCount
uint32_t GetNpatchYStretchCount() const;
private:
- ShaderType mShaderType;
- std::vector<Flag> mShaderOptions;
- std::string mShaderName;
- std::string mVertexShader;
- std::string mFragmentShader;
- uint32_t mNpatchXStretchCount;
- uint32_t mNpatchYStretchCount;
+ ShaderType mShaderType;
+ ShaderOptions mShaderOptions;
+ std::string mShaderName;
+ std::string mVertexShader;
+ std::string mFragmentShader;
+ uint32_t mNpatchXStretchCount;
+ uint32_t mNpatchYStretchCount;
};
} // namespace Toolkit
{
namespace Internal
{
-
namespace
{
-
constexpr VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[] = {
VisualFactoryCache::COLOR_SHADER,
VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER,
VisualFactoryCache::ShaderType::COLOR_SHADER,
VisualFactoryCache::ShaderType::COLOR_SHADER_ROUNDED_CORNER,
};
-}
+} // namespace
namespace ColorVisualShaderFeature
{
-
FeatureBuilder::FeatureBuilder()
: mColorRoundCorner(RoundedCorner::DISABLED),
mColorBorderline(Borderline::DISABLED),
VisualFactoryCache::ShaderType FeatureBuilder::GetShaderType() const
{
- VisualFactoryCache::ShaderType shaderType = VisualFactoryCache::COLOR_SHADER;
- uint32_t shaderTypeFlag = ColorVisualRequireFlag::DEFAULT;
+ VisualFactoryCache::ShaderType shaderType = VisualFactoryCache::COLOR_SHADER;
+ uint32_t shaderTypeFlag = ColorVisualRequireFlag::DEFAULT;
if(mColorBlur)
{
shaderTypeFlag |= ColorVisualRequireFlag::BLUR;
{
vertexShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
}
- if(mColorBorderline == Borderline::ENABLED && mColorBlur == RoundedCorner::DISABLED)
+ if(mColorBorderline == Borderline::ENABLED && mColorBlur == Blur::DISABLED)
{
vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
}
fragmentShaderPrefixList += "#define SL_VERSION_LOW\n";
}
}
- if(mColorBorderline == Borderline::ENABLED && mColorBlur == RoundedCorner::DISABLED)
+ if(mColorBorderline == Borderline::ENABLED && mColorBlur == Blur::DISABLED)
{
fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
}
Shader ColorVisualShaderFactory::GetShader(VisualFactoryCache& factoryCache, const ColorVisualShaderFeature::FeatureBuilder& featureBuilder)
{
Shader shader;
- VisualFactoryCache::ShaderType shaderType = featureBuilder.GetShaderType();
- shader = factoryCache.GetShader(shaderType);
+ VisualFactoryCache::ShaderType shaderType = featureBuilder.GetShaderType();
+ shader = factoryCache.GetShader(shaderType);
if(!shader)
{
shader = factoryCache.GenerateAndSaveShader(shaderType, vertexShader, fragmentShader);
}
return shader;
-
}
bool ColorVisualShaderFactory::AddPrecompiledShader(PrecompileShaderOption& option)
{
ShaderFlagList shaderOption = option.GetShaderOptions();
- auto featureBuilder = ColorVisualShaderFeature::FeatureBuilder();
+ auto featureBuilder = ColorVisualShaderFeature::FeatureBuilder();
std::string vertexPrefixList;
std::string fragmentPrefixList;
CreatePrecompileShader(featureBuilder, shaderOption);
VisualFactoryCache::ShaderType type = featureBuilder.GetShaderType();
featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
- return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList );
+ return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList);
}
void ColorVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
shaders.shaderCount = 0;
// precompile requested shader first
- for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++ )
+ for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++)
{
vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
shaders.vertexShader = SHADER_COLOR_VISUAL_SHADER_VERT;
shaders.fragmentShader = SHADER_COLOR_VISUAL_SHADER_FRAG;
shaders.shaderCount = shaderCount;
- shaders.custom = false;
+ shaders.custom = false;
}
void ColorVisualShaderFactory::CreatePrecompileShader(ColorVisualShaderFeature::FeatureBuilder& builder, const ShaderFlagList& option)
{
for(uint32_t i = 0; i < option.size(); ++i)
{
- if(option[i] == PrecompileShaderOption::Flag::ROUNDED_CORNER)
- {
- builder.EnableRoundCorner(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::BORDERLINE)
- {
- builder.EnableBorderLine(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::BLUR_EDGE)
- {
- builder.EnableBlur(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::CUTOUT)
+ switch(option[i])
{
- builder.EnableCutout(true);
+ case PrecompileShaderOption::Flag::ROUNDED_CORNER:
+ {
+ builder.EnableRoundCorner(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::BORDERLINE:
+ {
+ builder.EnableBorderLine(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::BLUR_EDGE:
+ {
+ builder.EnableBlur(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::CUTOUT:
+ {
+ builder.EnableCutout(true);
+ break;
+ }
+ default:
+ {
+ DALI_LOG_WARNING("Unknown option[%d]. maybe this type can't use this flag\n", static_cast<int>(option[i]));
+ break;
+ }
}
}
}
bool ColorVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix)
{
- for(uint32_t i = 0u; i< PREDEFINED_SHADER_TYPE_COUNT; i++)
+ for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; i++)
{
if(ShaderTypePredefines[i] == shader)
{
- DALI_LOG_WARNING("This shader already added list(%s).", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+ DALI_LOG_WARNING("This shader already added list(%s).\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
return false;
}
}
- for(uint32_t i = 0u; i< mRequestedPrecompileShader.size(); i++)
+ 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));
+ DALI_LOG_WARNING("This shader already requsted(%s).\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
return false;
}
}
RequestShaderInfo info;
- info.type = shader;
- info.vertexPrefix = vertexPrefix;
+ info.type = shader;
+ info.vertexPrefix = vertexPrefix;
info.fragmentPrefix = fragmentPrefix;
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));
+ 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;
}
{
for(uint32_t i = 0; i < option.size(); ++i)
{
- if(option[i] == PrecompileShaderOption::Flag::ATLAS_DEFAULT)
+ switch(option[i])
{
- builder.EnableTextureAtlas(true);
- builder.ApplyDefaultTextureWrapMode(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::ATLAS_CUSTOM)
- {
- builder.EnableTextureAtlas(true);
- builder.ApplyDefaultTextureWrapMode(false);
- }
- else if(option[i] == PrecompileShaderOption::Flag::ROUNDED_CORNER)
- {
- builder.EnableRoundedCorner(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::BORDERLINE)
- {
- builder.EnableBorderline(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::MASKING)
- {
- builder.EnableAlphaMaskingOnRendering(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::YUV_TO_RGB)
- {
- builder.EnableYuvToRgb(true, false);
- }
- else if(option[i] == PrecompileShaderOption::Flag::YUV_AND_RGB)
- {
- builder.EnableYuvToRgb(false, true);
+ case PrecompileShaderOption::Flag::ATLAS_DEFAULT:
+ {
+ builder.EnableTextureAtlas(true);
+ builder.ApplyDefaultTextureWrapMode(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::ATLAS_CUSTOM:
+ {
+ builder.EnableTextureAtlas(true);
+ builder.ApplyDefaultTextureWrapMode(false);
+ break;
+ }
+ case PrecompileShaderOption::Flag::ROUNDED_CORNER:
+ {
+ builder.EnableRoundedCorner(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::BORDERLINE:
+ {
+ builder.EnableBorderline(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::MASKING:
+ {
+ builder.EnableAlphaMaskingOnRendering(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::YUV_TO_RGB:
+ {
+ builder.EnableYuvToRgb(true, false);
+ break;
+ }
+ case PrecompileShaderOption::Flag::YUV_AND_RGB:
+ {
+ builder.EnableYuvToRgb(false, true);
+ break;
+ }
+ default:
+ {
+ DALI_LOG_WARNING("Unknown option[%d]. maybe this type can't use this flag\n", static_cast<int>(option[i]));
+ break;
+ }
}
}
}
{
if(ShaderTypePredefines[i] == shader)
{
- DALI_LOG_WARNING("This shader already added list(%s).", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+ DALI_LOG_WARNING("This shader already added list(%s).\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
return false;
}
}
{
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));
+ DALI_LOG_WARNING("This shader already requsted(%s).\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
return false;
}
}
info.vertexPrefix = vertexPrefix;
info.fragmentPrefix = fragmentPrefix;
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));
+ 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;
}
Shader TextVisualShaderFactory::GetShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder)
{
Shader shader;
- VisualFactoryCache::ShaderType shaderType = featureBuilder.GetShaderType();
- shader = factoryCache.GetShader(shaderType);
+ VisualFactoryCache::ShaderType shaderType = featureBuilder.GetShaderType();
+ shader = factoryCache.GetShader(shaderType);
if(!shader)
{
{
ShaderFlagList shaderOption = option.GetShaderOptions();
- auto featureBuilder = TextVisualShaderFeature::FeatureBuilder();
+ auto featureBuilder = TextVisualShaderFeature::FeatureBuilder();
std::string vertexPrefixList;
std::string fragmentPrefixList;
CreatePrecompileShader(featureBuilder, shaderOption);
VisualFactoryCache::ShaderType type = featureBuilder.GetShaderType();
featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
- return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList );
+ return SavePrecompileShader(type, vertexPrefixList, fragmentPrefixList);
}
-
void TextVisualShaderFactory::GetPreCompiledShader(RawShaderData& shaders)
{
std::vector<std::string_view> vertexPrefix;
int shaderCount = 0;
// precompile requested shader first
- for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++ )
+ for(uint32_t i = 0u; i < mRequestedPrecompileShader.size(); i++)
{
vertexPrefix.push_back(mRequestedPrecompileShader[i].vertexPrefix);
fragmentPrefix.push_back(mRequestedPrecompileShader[i].fragmentPrefix);
shaders.vertexShader = SHADER_TEXT_VISUAL_SHADER_VERT;
shaders.fragmentShader = SHADER_TEXT_VISUAL_SHADER_FRAG;
shaders.shaderCount = shaderCount;
- shaders.custom = false;
+ shaders.custom = false;
}
void TextVisualShaderFactory::CreatePrecompileShader(TextVisualShaderFeature::FeatureBuilder& builder, const ShaderFlagList& option)
{
for(uint32_t i = 0; i < option.size(); ++i)
{
- if(option[i] == PrecompileShaderOption::Flag::STYLES)
- {
- builder.EnableStyle(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::OVERLAY)
- {
- builder.EnableOverlay(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::EMOJI)
- {
- builder.EnableEmoji(true);
- }
- else if(option[i] == PrecompileShaderOption::Flag::MULTI_COLOR)
- {
- builder.EnableMultiColor(true);
- }
- else
+ switch(option[i])
{
- DALI_LOG_WARNING("Unknown option[%d]. maybe this type can't use this flag \n", option[i]);
+ case PrecompileShaderOption::Flag::STYLES:
+ {
+ builder.EnableStyle(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::OVERLAY:
+ {
+ builder.EnableOverlay(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::EMOJI:
+ {
+ builder.EnableEmoji(true);
+ break;
+ }
+ case PrecompileShaderOption::Flag::MULTI_COLOR:
+ {
+ builder.EnableMultiColor(true);
+ break;
+ }
+ default:
+ {
+ DALI_LOG_WARNING("Unknown option[%d]. maybe this type can't use this flag\n", static_cast<int>(option[i]));
+ break;
+ }
}
}
}
bool TextVisualShaderFactory::SavePrecompileShader(VisualFactoryCache::ShaderType shader, std::string& vertexPrefix, std::string& fragmentPrefix)
{
- for(uint32_t i = 0u; i< PREDEFINED_SHADER_TYPE_COUNT; i++)
+ for(uint32_t i = 0u; i < PREDEFINED_SHADER_TYPE_COUNT; i++)
{
if(ShaderTypePredefines[i] == shader)
{
- DALI_LOG_WARNING("This shader already added list(%s).", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
+ DALI_LOG_WARNING("This shader already added list(%s).\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(ShaderTypePredefines[i], VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
return false;
}
}
- for(uint32_t i = 0u; i< mRequestedPrecompileShader.size(); i++)
+ 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));
+ DALI_LOG_WARNING("This shader already requsted(%s).\n", Scripting::GetLinearEnumerationName<VisualFactoryCache::ShaderType>(mRequestedPrecompileShader[i].type, VISUAL_SHADER_TYPE_TABLE, VISUAL_SHADER_TYPE_TABLE_COUNT));
return false;
}
}
RequestShaderInfo info;
- info.type = shader;
- info.vertexPrefix = vertexPrefix;
+ info.type = shader;
+ info.vertexPrefix = vertexPrefix;
info.fragmentPrefix = fragmentPrefix;
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));
+ 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;
}
} // namespace Internal
auto type = shaderOption.GetShaderType();
if(type == PrecompileShaderOption::ShaderType::UNKNOWN)
{
- DALI_LOG_ERROR("AddPrecompileShader is failed. we can't find shader type");
+ DALI_LOG_ERROR("AddPrecompileShader is failed. we can't find shader type\n");
return false;
}
}
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\n", type);
break;
}
}