X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fanimated-vector-image-visual.cpp;h=a7d1f76777332b64143b9d0b201b9552c6ffc7a7;hb=38f0ea9fcdf1dc5037144fa19c8a52316c8af763;hp=edd7b1bbe22e4907cf0e79a2e3ba707b9622432a;hpb=6ae6f36998b3be4efa1114e2df856e51628bf812;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp index edd7b1b..a7d1f76 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-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. @@ -27,6 +27,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -43,6 +44,8 @@ namespace Internal { namespace { +const int CUSTOM_PROPERTY_COUNT(6); // 5 transform properties + pixel area, + const Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f); // stop behavior @@ -187,6 +190,15 @@ void AnimatedVectorImageVisual::DoCreateInstancePropertyMap(Property::Map& map) // Do nothing } +void AnimatedVectorImageVisual::EnablePreMultipliedAlpha(bool preMultiplied) +{ + // Make always enable pre multiplied alpha whether preMultiplied value is false. + if(!preMultiplied) + { + DALI_LOG_WARNING("Note : AnimatedVectorVisual cannot disable PreMultipliedAlpha\n"); + } +} + void AnimatedVectorImageVisual::DoSetProperties(const Property::Map& propertyMap) { // url already passed in from constructor @@ -283,36 +295,18 @@ void AnimatedVectorImageVisual::DoSetProperty(Property::Index index, const Prope void AnimatedVectorImageVisual::OnInitialize(void) { - Shader shader; - - if(mImpl->mCustomShader) - { - shader = Shader::New(mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader, - mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader, - mImpl->mCustomShader->mHints); - - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - } - else - { - shader = mImageVisualShaderFactory.GetShader( - mFactoryCache, - TextureAtlas::DISABLED, - DefaultTextureWrapMode::APPLY, - IsRoundedCornerRequired() ? RoundedCorner::ENABLED : RoundedCorner::DISABLED, - IsBorderlineRequired() ? Borderline::ENABLED : Borderline::DISABLED - ); - } + Shader shader = GenerateShader(); Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY); - mImpl->mRenderer = Renderer::New(geometry, shader); + mImpl->mRenderer = VisualRenderer::New(geometry, shader); + mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); TextureSet textureSet = TextureSet::New(); mImpl->mRenderer.SetTextures(textureSet); // Register transform properties - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor) @@ -324,14 +318,10 @@ void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor) if(mLoadFailed) { - TextureSet textureSet = TextureSet::New(); - mImpl->mRenderer.SetTextures(textureSet); - - Texture brokenImage = mFactoryCache.GetBrokenVisualImage(); - textureSet.SetTexture(0u, brokenImage); - + Vector2 imageSize = Vector2::ZERO; + imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); + mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); actor.AddRenderer(mImpl->mRenderer); - ResourceReady(Toolkit::Visual::ResourceStatus::FAILED); } else @@ -411,6 +401,15 @@ void AnimatedVectorImageVisual::OnSetTransform() } } +void AnimatedVectorImageVisual::UpdateShader() +{ + if(mImpl->mRenderer) + { + Shader shader = GenerateShader(); + mImpl->mRenderer.SetShader(shader); + } +} + void AnimatedVectorImageVisual::OnDoAction(const Property::Index actionId, const Property::Value& attributes) { // Check if action is valid for this visual type and perform action if possible @@ -459,15 +458,6 @@ void AnimatedVectorImageVisual::OnDoAction(const Property::Index actionId, const } break; } - case DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY: - { - const Property::Map* map = attributes.GetMap(); - if(map) - { - DoSetProperties(*map); - } - break; - } } TriggerVectorRasterization(); @@ -633,6 +623,28 @@ void AnimatedVectorImageVisual::OnProcessEvents() mEventCallback = nullptr; // The callback will be deleted in the VectorAnimationManager } +Shader AnimatedVectorImageVisual::GenerateShader() const +{ + Shader shader; + if(mImpl->mCustomShader) + { + shader = Shader::New(mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader, + mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader, + mImpl->mCustomShader->mHints); + + shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); + } + else + { + shader = mImageVisualShaderFactory.GetShader( + mFactoryCache, + ImageVisualShaderFeature::FeatureBuilder() + .EnableRoundedCorner(IsRoundedCornerRequired()) + .EnableBorderline(IsBorderlineRequired())); + } + return shader; +} + } // namespace Internal } // namespace Toolkit