/*
- * Copyright (c) 2022 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.
BORDERLINE = 1 << 1,
BLUR = 1 << 2,
};
+
+constexpr uint32_t MINIMUM_SHADER_VERSION_SUPPORT_ROUNDED_BLUR = 300;
} // unnamed namespace
ColorVisualPtr ColorVisual::New(VisualFactoryCache& factoryCache, const Property::Map& properties)
{
}
ColorVisual::ColorVisual(VisualFactoryCache& factoryCache)
-: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::COLOR),
+: Visual::Base(factoryCache, Visual::FittingMode::DONT_CARE, Toolkit::Visual::COLOR),
mBlurRadius(0.0f),
mAlwaysUsingBlurRadius(false)
{
bool blur = IsBlurRequired();
int shaderTypeFlag = ColorVisualRequireFlag::DEFAULT;
- if(roundedCorner)
- {
- shaderTypeFlag |= ColorVisualRequireFlag::ROUNDED_CORNER;
- }
if(blur)
{
// If we use blur, just ignore borderline
borderline = false;
shaderTypeFlag |= ColorVisualRequireFlag::BLUR;
}
+ if(roundedCorner)
+ {
+ shaderTypeFlag |= ColorVisualRequireFlag::ROUNDED_CORNER;
+ }
if(borderline)
{
shaderTypeFlag |= ColorVisualRequireFlag::BORDERLINE;
{
vertexShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
fragmentShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
+
+ // If shader version doesn't support latest blur with corner radius, Let we use legacy code.
+ if(DALI_UNLIKELY(Dali::Shader::GetShaderLanguageVersion() < MINIMUM_SHADER_VERSION_SUPPORT_ROUNDED_BLUR))
+ {
+ fragmentShaderPrefixList += "#define SL_VERSION_LOW\n";
+ }
}
if(borderline)
{
vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
}
- shader = Shader::New(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_VERT.data(),
- Dali::Shader::GetFragmentShaderPrefix() + fragmentShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_FRAG.data());
- mFactoryCache.SaveShader(shaderType, shader);
+
+ shader = mFactoryCache.GenerateAndSaveShader(shaderType,
+ Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_VERT.data(),
+ Dali::Shader::GetFragmentShaderPrefix() + fragmentShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_FRAG.data());
}
return shader;