#include <dali/devel-api/common/hash.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
namespace Dali
{
constexpr auto INVALID_CACHE_INDEX = int32_t{-1}; ///< Invalid Cache index
constexpr auto UNINITIALIZED_ID = int32_t{0}; ///< uninitialised id, use to initialize ids
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_IMAGE_PERFORMANCE_MARKER, false);
} // Anonymous namespace
NPatchLoader::NPatchLoader()
NPatchData::NPatchDataId NPatchLoader::Load(TextureManager& textureManager, TextureUploadObserver* textureObserver, const VisualUrl& url, const Rect<int>& border, bool& preMultiplyOnLoad, bool synchronousLoading)
{
- std::shared_ptr<NPatchData> data = GetNPatchData(url, border, preMultiplyOnLoad);
+ NPatchDataPtr data = GetNPatchData(url, border, preMultiplyOnLoad);
- DALI_ASSERT_ALWAYS(data.get() && "NPatchData creation failed!");
+ DALI_ASSERT_ALWAYS(data.Get() && "NPatchData creation failed!");
if(data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
{
auto preMultiplyOnLoading = preMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
: TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
- Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer(url, Dali::ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, synchronousLoading, data.get(), true, preMultiplyOnLoading);
+ Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer(url, Dali::ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, synchronousLoading, data.Get(), true, preMultiplyOnLoading);
if(pixelBuffer)
{
return INVALID_CACHE_INDEX;
}
-bool NPatchLoader::GetNPatchData(const NPatchData::NPatchDataId id, const NPatchData*& data)
+bool NPatchLoader::GetNPatchData(const NPatchData::NPatchDataId id, NPatchDataPtr& data)
{
int32_t cacheIndex = GetCacheIndexFromId(id);
if(cacheIndex != INVALID_CACHE_INDEX)
{
- data = mCache[cacheIndex].mData.get();
+ data = mCache[cacheIndex].mData;
return true;
}
data = nullptr;
void NPatchLoader::Process(bool postProcessor)
{
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_NPATCH_LOADER_PROCESS_REMOVE_QUEUE", [&](std::ostringstream& oss) {
+ oss << "[" << mRemoveQueue.size() << "]";
+ });
+
for(auto& iter : mRemoveQueue)
{
Remove(iter.first, iter.second);
}
+
mRemoveQueue.clear();
if(Adaptor::IsAvailable())
Adaptor::Get().UnregisterProcessor(*this, true);
mRemoveProcessorRegistered = false;
}
+
+ DALI_TRACE_END(gTraceFilter, "DALI_NPATCH_LOADER_PROCESS_REMOVE_QUEUE");
}
-std::shared_ptr<NPatchData> NPatchLoader::GetNPatchData(const VisualUrl& url, const Rect<int>& border, bool& preMultiplyOnLoad)
+NPatchDataPtr NPatchLoader::GetNPatchData(const VisualUrl& url, const Rect<int>& border, bool& preMultiplyOnLoad)
{
std::size_t hash = CalculateHash(url.GetUrl());
std::vector<NPatchInfo>::size_type index = UNINITIALIZED_ID;
// If this is new image loading, make new cache data
if(infoPtr == nullptr)
{
- NPatchInfo info(std::make_shared<NPatchData>());
+ NPatchInfo info(new NPatchData());
info.mData->SetId(GenerateUniqueNPatchDataId());
info.mData->SetHash(hash);
info.mData->SetUrl(url);
// Else if LOAD_COMPLETE, Same url but border is different - use the existing texture
else if(infoPtr->mData->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
{
- NPatchInfo info(std::make_shared<NPatchData>());
+ NPatchInfo info(new NPatchData());
info.mData->SetId(GenerateUniqueNPatchDataId());
info.mData->SetHash(hash);