/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
// Child ImageView should be positioned dependinig on Parent ImageView's Padding value
DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
- // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ // Check whether Image Visual transforms on ImageView::OnRelayout()
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
Property::Map resultMap;
DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
- // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ // Check whether Image Visual transforms on ImageView::OnRelayout()
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
Property::Map resultMap;
application.SendNotification();
application.Render();
- // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ // Check whether Image Visual transforms on ImageView::OnRelayout()
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
Property::Map resultMap;
application.SendNotification();
application.Render();
- // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ // Check whether Image Visual transforms on ImageView::OnRelayout()
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
Property::Map resultMap;
application.SendNotification();
application.Render();
- // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ // Check whether Image Visual transforms on ImageView::OnRelayout()
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
Property::Map resultMap;
application.SendNotification();
application.Render();
- // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ // Check whether Image Visual transforms on ImageView::OnRelayout()
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
Property::Map resultMap;
}
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliImageViewAnimatedImageVisualWithReleasePolicy(void)
+{
+ tet_infoline("Use AnimatedImageVisual with ReleasePolicy, and Unparent+Add again. Check ResourceReady comes well");
+ ToolkitTestApplication application;
+
+ gResourceReadySignalFired = false;
+
+ ImageView imageView = ImageView::New();
+
+ Property::Map imageMap;
+ imageMap[Visual::Property::TYPE] = Visual::IMAGE;
+ imageMap[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
+ imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::DESTROYED;
+
+ imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
+ imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
+ imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
+
+ tet_printf("Stop animation immediatly, for the stable test\n");
+ DevelControl::DoAction(imageView, ImageView::Property::IMAGE, DevelAnimatedImageVisual::Action::STOP, Property::Value());
+
+ application.GetScene().Add(imageView);
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread (wait 2 images - batch size)
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
+
+ gResourceReadySignalFired = false;
+
+ tet_printf("Unparent and add scene again\n");
+ imageView.Unparent();
+ application.GetScene().Add(imageView);
+
+ tet_printf("Check whether resource ready signal emitted without Notification or wait\n");
+ DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(16);
+
+ gResourceReadySignalFired = false;
+
+ END_TEST;
+}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
AnimatedImageVisual::~AnimatedImageVisual()
{
- // AnimatedImageVisual destroyed so remove texture unless ReleasePolicy is set to never release
- // If this is animated image, clear cache. Else if this is single frame image, this is affected be release policy.
- if(mFrameCount > SINGLE_IMAGE_COUNT || mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER)
+ if(DALI_LIKELY(mImageCache))
{
- if(DALI_LIKELY(mImageCache))
+ // AnimatedImageVisual destroyed so remove texture unless ReleasePolicy is set to never release
+ // If this is animated image, clear cache always.
+ // Else if this is single frame image, this is affected be release policy.
+ if(mFrameCount > SINGLE_IMAGE_COUNT || mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER)
{
mImageCache->ClearCache();
}
{
mStartFirstFrame = true;
mPlacementActor = actor;
- PrepareTextureSet();
-
actor.InheritedVisibilityChangedSignal().Connect(this, &AnimatedImageVisual::OnControlInheritedVisibilityChanged);
+
+ // We should clear cached informations before mImageCache->FirstFrame();
+ // TODO : Could we remove this cache clearing code?
+ if(mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::DETACHED)
+ {
+ if(DALI_LIKELY(mImageCache))
+ {
+ mImageCache->ClearCache(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
+ }
+ mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+ TextureSet textureSet = TextureSet::New();
+ mImpl->mRenderer.SetTextures(textureSet);
+ }
+
+ PrepareTextureSet();
}
void AnimatedImageVisual::DoSetOffScene(Actor& actor)
}
}
+ mCurrentFrameIndex = FIRST_FRAME_INDEX;
if(mImpl->mResourceStatus != Toolkit::Visual::ResourceStatus::FAILED)
{
if(mFrameCount > SINGLE_IMAGE_COUNT)
DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "ResourceReady(ResourceStatus::READY)\n");
ResourceReady(Toolkit::Visual::ResourceStatus::READY);
}
-
- mCurrentFrameIndex = FIRST_FRAME_INDEX;
}
void AnimatedImageVisual::PrepareTextureSet()
void AnimatedImageVisual::SetImageSize(TextureSet& textureSet)
{
- if(textureSet)
+ if(DALI_LIKELY(textureSet && textureSet.GetTextureCount() > 0u))
{
Texture texture = textureSet.GetTexture(0);
if(texture)
mImpl->mRenderer.SetTextures(textureSet);
CheckMaskTexture();
}
- mFrameDelayTimer.SetInterval(CalculateInterval(mImageCache->GetFrameInterval(frameIndex), mFrameSpeedFactor));
+ if(mFrameDelayTimer)
+ {
+ mFrameDelayTimer.SetInterval(CalculateInterval(mImageCache->GetFrameInterval(frameIndex), mFrameSpeedFactor));
+ }
}
mCurrentFrameIndex = frameIndex;
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
void FixedImageCache::ClearCache()
{
- if(Dali::Adaptor::IsAvailable())
+ if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
{
- for(std::size_t i = 0; i < mImageUrls.size(); ++i)
+ for(std::size_t i = 0u; i < mImageUrls.size(); ++i)
{
mTextureManager.RequestRemove(mImageUrls[i].mTextureId, this);
mImageUrls[i].mTextureId = TextureManager::INVALID_TEXTURE_ID;
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
#if defined(DEBUG_ENABLED)
Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
-#define LOG_CACHE \
- if(gAnimImgLogFilter->IsEnabledFor(Debug::Concise)) \
- { \
- std::ostringstream oss; \
- oss << "Size:" << mQueue.Count() << " [ "; \
- for(std::size_t _i = 0; _i < mQueue.Count(); ++_i) \
- { \
- oss << _i << "={ frm#: " << mQueue[_i].mFrameNumber << " tex: " << mTextureIds[mQueue[_i].mFrameNumber] << "}, "; \
- } \
- oss << " ]" << std::endl; \
- DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "%s", oss.str().c_str()); \
+// clang-format off
+#define LOG_CACHE \
+ if(gAnimImgLogFilter->IsEnabledFor(Debug::Concise)) \
+ { \
+ std::ostringstream oss; \
+ oss << "Size:" << mQueue.Count() << " [ "; \
+ for(std::size_t _i = 0; _i < mQueue.Count(); ++_i) \
+ { \
+ oss << _i << "={ frm#: " << mQueue[_i].mFrameNumber << " tex: "; \
+ oss << (DALI_LIKELY(mQueue[_i].mFrameNumber < mTextureIds.size()) ? \
+ mTextureIds[mQueue[_i].mFrameNumber] : \
+ TextureManager::INVALID_TEXTURE_ID) << "}, "; \
+ } \
+ oss << " ]" << std::endl; \
+ DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "%s", oss.str().c_str()); \
}
-
#else
#define LOG_CACHE
#endif
+// clang-format on
+
} // namespace
namespace Dali
mIsSynchronousLoading(isSynchronousLoading)
{
mTextureIds.resize(mFrameCount);
+ mTextureIds[0] = TextureManager::INVALID_TEXTURE_ID;
mIntervals.assign(mFrameCount, 0);
}
TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId(int index) const
{
- return mTextureIds[mQueue[index].mFrameNumber];
+ return DALI_LIKELY(mQueue[index].mFrameNumber < mTextureIds.size()) ? mTextureIds[mQueue[index].mFrameNumber] : TextureManager::INVALID_TEXTURE_ID;
}
void RollingAnimatedImageCache::PopFrontCache()
void RollingAnimatedImageCache::ClearCache()
{
- while(Dali::Adaptor::IsAvailable() && !mQueue.IsEmpty())
+ if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
{
- PopFrontCache();
+ while(!mQueue.IsEmpty())
+ {
+ PopFrontCache();
+ }
}
mLoadWaitingQueue.clear();
mLoadState = TextureManager::LoadState::NOT_STARTED;
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
void RollingImageCache::ClearCache()
{
- while(Dali::Adaptor::IsAvailable() && !mQueue.IsEmpty())
+ if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
{
- PopFrontCache();
+ while(!mQueue.IsEmpty())
+ {
+ PopFrontCache();
+ }
}
mLoadState = TextureManager::LoadState::NOT_STARTED;
}