X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=a2e90968cb8d703f9d0b325995cc3cc274a84401;hb=dd5c89d78423e23ca27708cabfd0d88ce798b294;hp=b798e57db7c98dab46d915148bd97b714d583c5b;hpb=908a404d710bddfa2337e82a4f7515c97fa09232;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index b798e57..a2e9096 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/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. @@ -31,9 +31,9 @@ // INTERNAL HEADERS #include +#include #include #include -#include #include #include #include @@ -51,6 +51,8 @@ namespace Internal { namespace { +const int CUSTOM_PROPERTY_COUNT(9); // wrap, pixel area, atlas, pixalign, + border/corner + // fitting modes DALI_ENUM_TO_STRING_TABLE_BEGIN(FITTING_MODE) DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::FittingMode, SHRINK_TO_FIT) @@ -200,7 +202,7 @@ ImageVisual::~ImageVisual() else if(mImageUrl.IsBufferResource()) { TextureManager& textureManager = mFactoryCache.GetTextureManager(); - textureManager.RemoveExternalEncodedImageBuffer(mImageUrl.GetUrl()); + textureManager.RemoveEncodedImageBuffer(mImageUrl.GetUrl()); } } @@ -513,7 +515,7 @@ void ImageVisual::GetNaturalSize(Vector2& naturalSize) } else { - Actor actor = mPlacementActor.GetHandle(); + Actor actor = mPlacementActor.GetHandle(); Vector2 imageSize = Vector2::ZERO; if(actor) { @@ -521,8 +523,8 @@ void ImageVisual::GetNaturalSize(Vector2& naturalSize) } mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); Texture brokenImage = mImpl->mRenderer.GetTextures().GetTexture(0); - naturalSize.x = brokenImage.GetWidth(); - naturalSize.y = brokenImage.GetWidth(); + naturalSize.x = brokenImage.GetWidth(); + naturalSize.y = brokenImage.GetWidth(); } return; } @@ -565,10 +567,11 @@ void ImageVisual::OnInitialize() Shader shader = GenerateShader(); // Create the renderer - mImpl->mRenderer = Renderer::New(geometry, shader); + mImpl->mRenderer = VisualRenderer::New(geometry, shader); + mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); //Register transform properties - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); EnablePreMultipliedAlpha(IsPreMultipliedAlphaEnabled()); } @@ -755,7 +758,7 @@ void ImageVisual::DoCreatePropertyMap(Property::Map& map) const map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE); bool sync = IsSynchronousLoadingRequired(); - map.Insert(SYNCHRONOUS_LOADING, sync); + map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, sync); if(mImageUrl.IsValid()) { map.Insert(Toolkit::ImageVisual::Property::URL, mImageUrl.GetUrl()); @@ -795,11 +798,11 @@ void ImageVisual::DoCreateInstancePropertyMap(Property::Map& map) const } } -void ImageVisual::OnDoAction(const Dali::Property::Index actionName, const Dali::Property::Value& attributes) +void ImageVisual::OnDoAction(const Dali::Property::Index actionId, const Dali::Property::Value& attributes) { // Check if action is valid for this visual type and perform action if possible - switch(actionName) + switch(actionId) { case DevelImageVisual::Action::RELOAD: { @@ -814,16 +817,10 @@ void ImageVisual::OnSetTransform() { if(mImpl->mRenderer) { - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } } -bool ImageVisual::IsResourceReady() const -{ - return (mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::READY || - mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::FAILED); -} - void ImageVisual::UpdateShader() { if(mImpl->mRenderer) @@ -853,17 +850,17 @@ void ImageVisual::UploadCompleted() } // From Texture Manager -void ImageVisual::UploadComplete(bool loadingSuccess, int32_t textureId, TextureSet textureSet, bool usingAtlas, const Vector4& atlasRectangle, bool preMultiplied) +void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureInformation) { Toolkit::Visual::ResourceStatus resourceStatus; if(mImpl->mRenderer) { - if(usingAtlas) + if(textureInformation.useAtlasing) { mImpl->mRenderer.RegisterProperty(ATLAS_RECT_UNIFORM_NAME, mAtlasRect); } - EnablePreMultipliedAlpha(preMultiplied); + EnablePreMultipliedAlpha(textureInformation.preMultiplied); Actor actor = mPlacementActor.GetHandle(); if(!loadingSuccess) @@ -874,14 +871,14 @@ void ImageVisual::UploadComplete(bool loadingSuccess, int32_t textureId, Texture imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); } mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); - textureSet = mImpl->mRenderer.GetTextures(); + textureInformation.textureSet = mImpl->mRenderer.GetTextures(); } else { Sampler sampler = Sampler::New(); sampler.SetWrapMode(mWrapModeU, mWrapModeV); - textureSet.SetSampler(0u, sampler); - mImpl->mRenderer.SetTextures(textureSet); + textureInformation.textureSet.SetSampler(0u, sampler); + mImpl->mRenderer.SetTextures(textureInformation.textureSet); } if(actor) @@ -895,7 +892,7 @@ void ImageVisual::UploadComplete(bool loadingSuccess, int32_t textureId, Texture // Storing TextureSet needed when renderer staged. if(!mImpl->mRenderer) { - mTextures = textureSet; + mTextures = textureInformation.textureSet; } // Image loaded, set status regardless of staged status. @@ -974,9 +971,9 @@ Shader ImageVisual::GenerateShader() const { Shader shader; - bool usesWholeTexture = true; - const bool useStandardShader = !mImpl->mCustomShader; - const bool useNativeImage = (mTextures && DevelTexture::IsNative(mTextures.GetTexture(0))); + bool usesWholeTexture = true; + const bool useStandardShader = !mImpl->mCustomShader; + const bool useNativeImage = (mTextures && DevelTexture::IsNative(mTextures.GetTexture(0))); if(useStandardShader) { @@ -984,12 +981,11 @@ Shader ImageVisual::GenerateShader() const shader = mImageVisualShaderFactory.GetShader( mFactoryCache, ImageVisualShaderFeature::FeatureBuilder() - .EnableTextureAtlas(mImpl->mFlags & Impl::IS_ATLASING_APPLIED && !useNativeImage) - .ApplyDefaultTextureWrapMode(mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE) - .EnableRoundedCorner(IsRoundedCornerRequired()) - .EnableBorderline(IsBorderlineRequired()) - .SetTextureForFragmentShaderCheck(useNativeImage ? mTextures.GetTexture(0) : Dali::Texture()) - ); + .EnableTextureAtlas(mImpl->mFlags & Impl::IS_ATLASING_APPLIED && !useNativeImage) + .ApplyDefaultTextureWrapMode(mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE) + .EnableRoundedCorner(IsRoundedCornerRequired()) + .EnableBorderline(IsBorderlineRequired()) + .SetTextureForFragmentShaderCheck(useNativeImage ? mTextures.GetTexture(0) : Dali::Texture())); } else {