/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
TextureManager::TextureManager(bool loadYuvPlanes)
: mTextureCacheManager(),
mAsyncLoader(std::unique_ptr<TextureAsyncLoadingHelper>(new TextureAsyncLoadingHelper(*this))),
- mLifecycleObservers(),
mLoadQueue(),
mLoadingQueueTextureId(INVALID_TEXTURE_ID),
mRemoveQueue(),
Adaptor::Get().UnregisterProcessor(*this, true);
mRemoveProcessorRegistered = false;
}
-
- for(auto iter = mLifecycleObservers.Begin(), endIter = mLifecycleObservers.End(); iter != endIter; ++iter)
- {
- (*iter)->TextureManagerDestroyed();
- }
}
TextureSet TextureManager::LoadAnimatedImageTexture(
}
}
-void TextureManager::AddObserver(TextureManager::LifecycleObserver& observer)
-{
- // make sure an observer doesn't observe the same object twice
- // otherwise it will get multiple calls to ObjectDestroyed()
- DALI_ASSERT_DEBUG(mLifecycleObservers.End() == std::find(mLifecycleObservers.Begin(), mLifecycleObservers.End(), &observer));
- mLifecycleObservers.PushBack(&observer);
-}
-
-void TextureManager::RemoveObserver(TextureManager::LifecycleObserver& observer)
-{
- // Find the observer...
- auto endIter = mLifecycleObservers.End();
- for(auto iter = mLifecycleObservers.Begin(); iter != endIter; ++iter)
- {
- if((*iter) == &observer)
- {
- mLifecycleObservers.Erase(iter);
- break;
- }
- }
- DALI_ASSERT_DEBUG(endIter != mLifecycleObservers.End());
-}
-
void TextureManager::LoadOrQueueTexture(TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer)
{
switch(textureInfo.loadState)
#define DALI_TOOLKIT_TEXTURE_MANAGER_IMPL_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
};
using MaskingDataPointer = std::unique_ptr<MaskingData>;
- /**
- * Class to provide lifecycle event on destruction of texture manager.
- */
- struct LifecycleObserver
- {
- /**
- * Called shortly before the texture manager is destroyed.
- */
- virtual void TextureManagerDestroyed() = 0;
- };
-
/**
* Constructor.
*
const TextureManager::ReloadPolicy reloadPolicy,
TextureManager::MultiplyOnLoad& preMultiplyOnLoad);
- /**
- * Add an observer to the object.
- * @param[in] observer The observer to add.
- */
- void AddObserver(TextureManager::LifecycleObserver& observer);
-
- /**
- * Remove an observer from the object
- * @pre The observer has already been added.
- * @param[in] observer The observer to remove.
- */
- void RemoveObserver(TextureManager::LifecycleObserver& observer);
-
/**
* @brief Returns the geometry associated with texture.
* @param[in] textureId Id of the texture
private: // Member Variables:
TextureCacheManager mTextureCacheManager; ///< Manager the life-cycle and caching of Textures
- std::unique_ptr<TextureAsyncLoadingHelper> mAsyncLoader; ///< The Asynchronous image loader used to provide all local async loads
- Dali::Vector<LifecycleObserver*> mLifecycleObservers; ///< Lifecycle observers of texture manager
+ std::unique_ptr<TextureAsyncLoadingHelper> mAsyncLoader; ///< The Asynchronous image loader used to provide all local async loads
Dali::Vector<QueueElement> mLoadQueue; ///< Queue of textures to load after NotifyObservers
TextureManager::TextureId mLoadingQueueTextureId; ///< TextureId when it is loading. it causes Load Textures to be queued.
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
#include <dali-toolkit/internal/visuals/image-atlas-manager.h> // For ImageAtlasManagerPtr
// EXTERNAL HEADERS
+#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
namespace Dali
void FixedImageCache::ClearCache()
{
- if(mTextureManagerAlive)
+ if(Dali::Adaptor::IsAvailable())
{
for(std::size_t i = 0; i < mImageUrls.size(); ++i)
{
{
if(loadSuccess)
{
- mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+ mLoadState = TextureManager::LoadState::LOAD_FINISHED;
bool isCurrentFrameReady = IsFrameReady(mCurrentFrameIndex);
if(!mRequestingLoad)
{
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
mInterval(interval),
mLoadState(TextureManager::LoadState::NOT_STARTED),
mRequestingLoad(false),
- mPreMultiplyOnLoad(preMultiplyOnLoad),
- mTextureManagerAlive(true)
+ mPreMultiplyOnLoad(preMultiplyOnLoad)
{
- mTextureManager.AddObserver(*this);
}
ImageCache::~ImageCache()
{
- if(mTextureManagerAlive)
- {
- mTextureManager.RemoveObserver(*this);
- }
-}
-
-void ImageCache::TextureManagerDestroyed()
-{
- mTextureManagerAlive = false;
}
void ImageCache::SetInterval(uint32_t interval)
#define DALI_TOOLKIT_INTERNAL_IMAGE_CACHE_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
{
namespace Internal
{
-class ImageCache : public TextureManager::LifecycleObserver
+class ImageCache
{
public:
/**
virtual void SetInterval(uint32_t interval);
private:
- /**
- * @brief Called before the texture manager is destroyed.
- */
- void TextureManagerDestroyed() final;
-
void AllocateMaskData();
protected:
TextureManager::LoadState mLoadState;
bool mRequestingLoad : 1;
bool mPreMultiplyOnLoad : 1;
- bool mTextureManagerAlive : 1;
};
} // namespace Internal
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL HEADERS
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
#include <dali-toolkit/internal/visuals/image-atlas-manager.h> // For ImageAtlasManagerPtr
+#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
namespace
void RollingAnimatedImageCache::ClearCache()
{
- while(mTextureManagerAlive && !mQueue.IsEmpty())
+ while(Dali::Adaptor::IsAvailable() && !mQueue.IsEmpty())
{
PopFrontCache();
}
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL HEADERS
#include <dali-toolkit/internal/visuals/image-atlas-manager.h> // For ImageAtlasManagerPtr
-#include <dali/integration-api/debug.h>
// EXTERNAL HEADERS
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/debug.h>
namespace
{
void RollingImageCache::ClearCache()
{
- while(mTextureManagerAlive && !mQueue.IsEmpty())
+ while(Dali::Adaptor::IsAvailable() && !mQueue.IsEmpty())
{
PopFrontCache();
}
mLastSentPlayStateId(0u),
mLoadFailed(false),
mRendererAdded(false),
- mCoreShutdown(false),
mRedrawInScalingDown(true),
mEnableFrameCache(false),
mUseNativeImage(false),
AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
{
- if(!mCoreShutdown)
+ if(Dali::Adaptor::IsAvailable())
{
if(mImageUrl.IsBufferResource())
{
textureManager.RemoveEncodedImageBuffer(mImageUrl.GetUrl());
}
- auto& vectorAnimationManager = mFactoryCache.GetVectorAnimationManager();
- vectorAnimationManager.RemoveObserver(*this);
-
if(mEventCallback)
{
mFactoryCache.GetVectorAnimationManager().UnregisterEventCallback(mEventCallback);
}
}
-void AnimatedVectorImageVisual::VectorAnimationManagerDestroyed()
-{
- // Core is shutting down. Don't talk to the plugin any more.
- mCoreShutdown = true;
-}
-
void AnimatedVectorImageVisual::GetNaturalSize(Vector2& naturalSize)
{
if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
mVectorAnimationTask->KeepRasterizedBuffer(mEnableFrameCache);
mVectorAnimationTask->RequestLoad(mImageUrl, encodedImageBuffer, IsSynchronousLoadingRequired());
- auto& vectorAnimationManager = mFactoryCache.GetVectorAnimationManager();
- vectorAnimationManager.AddObserver(*this);
-
Shader shader = GenerateShader();
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
}
case DevelAnimatedVectorImageVisual::Action::FLUSH:
{
- if(DALI_LIKELY(!mCoreShutdown))
+ if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
{
SendAnimationData();
}
void AnimatedVectorImageVisual::TriggerVectorRasterization()
{
- if(!mEventCallback && !mCoreShutdown)
+ if(!mEventCallback && Dali::Adaptor::IsAvailable())
{
mEventCallback = MakeCallback(this, &AnimatedVectorImageVisual::OnProcessEvents);
auto& vectorAnimationManager = mFactoryCache.GetVectorAnimationManager();
* | url | STRING |
*
*/
-class AnimatedVectorImageVisual : public Visual::Base, public ConnectionTracker, public VectorAnimationManager::LifecycleObserver
+class AnimatedVectorImageVisual : public Visual::Base, public ConnectionTracker
{
public:
/**
*/
void EnablePreMultipliedAlpha(bool preMultiplied) override;
-protected: // From VectorAnimationManager::LifecycleObserver:
- /**
- * @copydoc VectorAnimationManager::LifecycleObserver::VectorAnimationManagerDestroyed()
- */
- void VectorAnimationManagerDestroyed() override;
-
protected:
/**
* @brief Constructor.
bool mLoadFailed : 1;
bool mRendererAdded : 1;
- bool mCoreShutdown : 1;
bool mRedrawInScalingDown : 1;
bool mEnableFrameCache : 1;
bool mUseNativeImage : 1;
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
VectorAnimationManager::VectorAnimationManager()
: mEventCallbacks(),
- mLifecycleObservers(),
mVectorAnimationThread(nullptr),
mProcessorRegistered(false)
{
{
Adaptor::Get().UnregisterProcessor(*this, true);
}
-
- for(auto observer : mLifecycleObservers)
- {
- observer->VectorAnimationManagerDestroyed();
- }
-}
-
-void VectorAnimationManager::AddObserver(VectorAnimationManager::LifecycleObserver& observer)
-{
- DALI_ASSERT_DEBUG(mLifecycleObservers.end() == std::find(mLifecycleObservers.begin(), mLifecycleObservers.end(), &observer));
- mLifecycleObservers.push_back(&observer);
-}
-
-void VectorAnimationManager::RemoveObserver(VectorAnimationManager::LifecycleObserver& observer)
-{
- auto iterator = std::find(mLifecycleObservers.begin(), mLifecycleObservers.end(), &observer);
- if(iterator != mLifecycleObservers.end())
- {
- mLifecycleObservers.erase(iterator);
- }
}
VectorAnimationThread& VectorAnimationManager::GetVectorAnimationThread()
#define DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
class VectorAnimationManager : public Integration::Processor
{
public:
- struct LifecycleObserver
- {
- virtual void VectorAnimationManagerDestroyed() = 0;
- };
-
/**
* @brief Constructor.
*/
*/
~VectorAnimationManager() override;
- /**
- * Add a lifecycle observer
- * @param[in] observer The object watching this one
- */
- void AddObserver(LifecycleObserver& observer);
-
- /**
- * Remove a lifecycle observer
- * @param[in] observer The object watching this one
- */
- void RemoveObserver(LifecycleObserver& observer);
-
/**
* Get the vector animation thread.
* @return A raw pointer pointing to the vector animation thread.
private:
std::vector<std::unique_ptr<CallbackBase>> mEventCallbacks;
- std::vector<LifecycleObserver*> mLifecycleObservers;
std::unique_ptr<VectorAnimationThread> mVectorAnimationThread;
bool mProcessorRegistered;
};