+ std::string vertexShader = std::string(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_IMAGE_VISUAL_SHADER_VERT.data());
+ std::string fragmentShader = std::string(Dali::Shader::GetFragmentShaderPrefix() + fragmentShaderPrefixList + SHADER_IMAGE_VISUAL_SHADER_FRAG.data());
+
+ if(changeFragmentShader == ImageVisualShaderFeature::ChangeFragmentShader::NEED_CHANGE)
+ {
+ if(DALI_UNLIKELY(mFragmentShaderNeedChange == ImageVisualShaderFeature::ChangeFragmentShader::UNDECIDED))
+ {
+ // NOTE : This routine will run exist one times.
+ //
+ // First, we will run ApplyNativeFragmentShader
+ // - If fragment shader is modified, then current platform allow to change fragment shader.
+ // We cache this result mFragmentShaderNeedChange = ChangeFragmentShader::NEED_CHANGE.
+ // - If fragment shader is not modified, then current platform will always don't change fragment shader.
+ // We cache this result mFragmentShaderNeedChange = ChangeFragmentShader::DONT_CHANGE.
+ // And change current shaderType into normal image range.
+ // After cached the result, shaderType never become NATIVE_IMAGE_SHADER anymore.
+ // Second, save shader result.
+
+ // Try to apply fragmentShader
+ bool modified = DevelTexture::ApplyNativeFragmentShader(featureBuilder.mTexture, fragmentShader);
+ if(modified)
+ {
+ // Now we know that fragment shader need to change.
+ mFragmentShaderNeedChange = ImageVisualShaderFeature::ChangeFragmentShader::NEED_CHANGE;
+ }
+ else
+ {
+ // Now we know that fragment shader even don't need to change.
+ // We can skip ApplyNativeFragmentShader routine after now.
+ mFragmentShaderNeedChange = ImageVisualShaderFeature::ChangeFragmentShader::DONT_CHANGE;
+
+ // Now we need normal shader type
+ // So decrease NATIVE_SHADER_TYPE_OFFSET.
+ shaderType = static_cast<VisualFactoryCache::ShaderType>(static_cast<int>(shaderType) - NATIVE_SHADER_TYPE_OFFSET);
+
+ // If we already compiled this type already, just use that cached shader.
+ // Else, just go forward.
+ shader = factoryCache.GetShader(shaderType);
+ if(shader)
+ {
+ return shader;
+ }
+ }
+ }
+ else if(mFragmentShaderNeedChange == ImageVisualShaderFeature::ChangeFragmentShader::NEED_CHANGE)
+ {
+ // Always need to apply fragmentShader
+ bool modified = DevelTexture::ApplyNativeFragmentShader(featureBuilder.mTexture, fragmentShader);
+ DALI_ASSERT_ALWAYS(modified && "NativeImageTexture need to change fragment shader. But DALI default image shader doesn't changed!");
+ }
+ }
+ shader = Shader::New(vertexShader, fragmentShader);