X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fcolor%2Fcolor-visual.cpp;h=8dfc168f0a7e391d82ddc553c1f9ebd716f919a2;hp=31e0c55257e8f7c7ca4dba11022c26924349283f;hb=38f0ea9fcdf1dc5037144fa19c8a52316c8af763;hpb=478e477e07fde916953748d2cd4befc0326bfc34 diff --git a/dali-toolkit/internal/visuals/color/color-visual.cpp b/dali-toolkit/internal/visuals/color/color-visual.cpp index 31e0c55..8dfc168 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.cpp +++ b/dali-toolkit/internal/visuals/color/color-visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -23,8 +23,8 @@ #include //INTERNAL INCLUDES -#include #include +#include #include #include #include @@ -41,14 +41,16 @@ namespace Internal { namespace { +const int CUSTOM_PROPERTY_COUNT(6); // Blur Radius + border/corner + VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[6] = -{ - VisualFactoryCache::COLOR_SHADER, - VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER, - VisualFactoryCache::COLOR_SHADER_BORDERLINE, - VisualFactoryCache::COLOR_SHADER_ROUNDED_BORDERLINE, - VisualFactoryCache::COLOR_SHADER_BLUR_EDGE, - VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER_BLUR_EDGE, + { + VisualFactoryCache::COLOR_SHADER, + VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER, + VisualFactoryCache::COLOR_SHADER_BORDERLINE, + VisualFactoryCache::COLOR_SHADER_ROUNDED_BORDERLINE, + VisualFactoryCache::COLOR_SHADER_BLUR_EDGE, + VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER_BLUR_EDGE, }; // enum of required list when we select shader @@ -126,7 +128,7 @@ void ColorVisual::DoSetProperties(const Property::Map& propertyMap) // We must regist properies into renderer, and update shader. // BlurRadius added by this action. Regist property to renderer. - mBlurRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); + mBlurRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); // Change the shader must not be occured many times. we always have to use blur feature. @@ -174,11 +176,20 @@ void ColorVisual::DoCreateInstancePropertyMap(Property::Map& map) const // Do nothing } +void ColorVisual::EnablePreMultipliedAlpha(bool preMultiplied) +{ + // Make always disable pre multiplied alpha whether preMultiplied value is true. + if(preMultiplied) + { + DALI_LOG_WARNING("Note : ColorVisual cannot enable PreMultipliedAlpha\n"); + } +} + void ColorVisual::OnSetTransform() { if(mImpl->mRenderer) { - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } } @@ -197,32 +208,30 @@ void ColorVisual::OnInitialize() Shader shader = GenerateShader(); - mImpl->mRenderer = Renderer::New(geometry, shader); + mImpl->mRenderer = VisualRenderer::New(geometry, shader); + mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); - // ColorVisual has it's own index key for mix color - use this instead - // of using the new base index to avoid changing existing applications - // String keys will get to this property. - mImpl->mMixColorIndex = mImpl->mRenderer.RegisterProperty(Toolkit::ColorVisual::Property::MIX_COLOR, MIX_COLOR, Vector3(mImpl->mMixColor)); + mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(mImpl->mMixColor)); if(!EqualsZero(mBlurRadius)) { - mBlurRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); + mBlurRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); } // Register transform properties - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } Shader ColorVisual::GenerateShader() const { - Shader shader; + Shader shader; VisualFactoryCache::ShaderType shaderType; - bool roundedCorner = IsRoundedCornerRequired(); - bool borderline = IsBorderlineRequired(); - bool blur = !EqualsZero(mBlurRadius) || mAlwaysUsingBlurRadius; - int shaderTypeFlag = ColorVisualRequireFlag::DEFAULT; + bool roundedCorner = IsRoundedCornerRequired(); + bool borderline = IsBorderlineRequired(); + bool blur = !EqualsZero(mBlurRadius) || mAlwaysUsingBlurRadius; + int shaderTypeFlag = ColorVisualRequireFlag::DEFAULT; if(roundedCorner) { @@ -240,27 +249,27 @@ Shader ColorVisual::GenerateShader() const } shaderType = SHADER_TYPE_TABLE[shaderTypeFlag]; - shader = mFactoryCache.GetShader(shaderType); + shader = mFactoryCache.GetShader(shaderType); if(!shader) { std::string vertexShaderPrefixList; std::string fragmentShaderPrefixList; if(roundedCorner) { - vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n"; + vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n"; fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n"; } if(blur) { - vertexShaderPrefixList += "#define IS_REQUIRED_BLUR 1\n"; + vertexShaderPrefixList += "#define IS_REQUIRED_BLUR 1\n"; fragmentShaderPrefixList += "#define IS_REQUIRED_BLUR 1\n"; } if(borderline) { - vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n"; + vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n"; fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n"; } - shader = Shader::New(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_VERT.data(), + 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); }