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=09fd60ef05e07efe65fc4e926ab55ad05dc31e2f;hp=ba5e0c6b37270564a8b99ca3a5d821532a4f47c9;hb=5a936aac073676657d48db5c42e5d2ad3f5cac9f;hpb=3b814735ce65594bfe644190ed83c381edb66c88 diff --git a/dali-toolkit/internal/visuals/color/color-visual.cpp b/dali-toolkit/internal/visuals/color/color-visual.cpp index ba5e0c6..09fd60e 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.cpp +++ b/dali-toolkit/internal/visuals/color/color-visual.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include //INTERNAL INCLUDES #include @@ -41,7 +42,7 @@ namespace Internal { namespace { -const int CUSTOM_PROPERTY_COUNT(6); // Blur Radius + border/corner +const int CUSTOM_PROPERTY_COUNT(0); VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[6] = { @@ -73,7 +74,6 @@ ColorVisualPtr ColorVisual::New(VisualFactoryCache& factoryCache, const Property ColorVisual::ColorVisual(VisualFactoryCache& factoryCache) : Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::COLOR), mBlurRadius(0.0f), - mBlurRadiusIndex(Property::INVALID_INDEX), mAlwaysUsingBlurRadius(false) { } @@ -117,25 +117,26 @@ void ColorVisual::DoSetProperties(const Property::Map& propertyMap) DALI_LOG_ERROR("ColorVisual:DoSetProperties:: BLUR_RADIUS property has incorrect type: %d\n", blurRadiusValue->GetType()); } - if(mBlurRadiusIndex != Property::INVALID_INDEX) - { - mImpl->mRenderer.SetProperty(mBlurRadiusIndex, mBlurRadius); - } - else if(DALI_UNLIKELY(mImpl->mRenderer && (!EqualsZero(mBlurRadius) || mAlwaysUsingBlurRadius))) + if(DALI_UNLIKELY(mImpl->mRenderer)) { // Unusual case. SetProperty called after OnInitialize(). // Assume that DoAction call UPDATE_PROPERTY. - // We must regist properies into renderer, and update shader. - - // BlurRadius added by this action. Regist property to renderer. - mBlurRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); - mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + DownCast(mImpl->mRenderer).RegisterBlurRadiusUniform(); + mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, mBlurRadius); - // Change the shader must not be occured many times. we always have to use blur feature. - mAlwaysUsingBlurRadius = true; - - // Change shader - UpdateShader(); + // Check whether we must update shader. + if(!mAlwaysUsingBlurRadius && IsBlurRequired()) + { + // Change the shader must not be occured many times. we always have to use blur feature. + mAlwaysUsingBlurRadius = true; + + mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + // Change shader + if(!mImpl->mCustomShader) + { + UpdateShader(); + } + } } } } @@ -159,10 +160,10 @@ void ColorVisual::DoCreatePropertyMap(Property::Map& map) const map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR); map.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, mImpl->mMixColor); - if(mImpl->mRenderer && mBlurRadiusIndex != Property::INVALID_INDEX) + if(mImpl->mRenderer) { // Update values from Renderer - float blurRadius = mImpl->mRenderer.GetProperty(mBlurRadiusIndex); + float blurRadius = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS); map.Insert(Toolkit::DevelColorVisual::Property::BLUR_RADIUS, blurRadius); } else @@ -208,14 +209,15 @@ void ColorVisual::OnInitialize() Shader shader = GenerateShader(); - mImpl->mRenderer = VisualRenderer::New(geometry, shader); + mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader); mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(mImpl->mMixColor)); - if(!EqualsZero(mBlurRadius)) + if(mAlwaysUsingBlurRadius || !EqualsZero(mBlurRadius)) { - mBlurRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); + DownCast(mImpl->mRenderer).RegisterBlurRadiusUniform(); + mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, mBlurRadius); mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); } @@ -230,7 +232,7 @@ Shader ColorVisual::GenerateShader() const bool roundedCorner = IsRoundedCornerRequired(); bool borderline = IsBorderlineRequired(); - bool blur = !EqualsZero(mBlurRadius) || mAlwaysUsingBlurRadius; + bool blur = IsBlurRequired(); int shaderTypeFlag = ColorVisualRequireFlag::DEFAULT; if(roundedCorner) @@ -287,23 +289,39 @@ Dali::Property ColorVisual::OnGetPropertyObject(Dali::Property::Key key) if((key.type == Property::Key::INDEX && key.indexKey == DevelColorVisual::Property::BLUR_RADIUS) || (key.type == Property::Key::STRING && key.stringKey == BLUR_RADIUS_NAME)) { - mBlurRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius); + const bool updateShader = !mImpl->mCustomShader && !IsBlurRequired(); // Blur is animated now. we always have to use blur feature. mAlwaysUsingBlurRadius = true; - mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); - - // Change shader - UpdateShader(); + if(updateShader) + { + // Update each values to renderer + DownCast(mImpl->mRenderer).RegisterBlurRadiusUniform(); + mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, mBlurRadius); - return Dali::Property(mImpl->mRenderer, mBlurRadiusIndex); + // Change shader + UpdateShader(); + } + mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + return Dali::Property(mImpl->mRenderer, DecoratedVisualRenderer::Property::BLUR_RADIUS); } Handle handle; return Dali::Property(handle, Property::INVALID_INDEX); } +bool ColorVisual::IsBlurRequired() const +{ + float blurRadius = mBlurRadius; + if(mImpl->mRenderer) + { + // Update values from Renderer + blurRadius = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS); + } + return mAlwaysUsingBlurRadius || !EqualsZero(blurRadius); +} + } // namespace Internal } // namespace Toolkit