/*
- * Copyright (c) 2022 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 HEADER
-#include "loading-task.h"
+#include <dali-toolkit/internal/image-loader/loading-task.h>
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/adaptor-framework/thread-settings.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
+#ifdef TRACE_ENABLED
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+#include <thread>
+#endif
+
namespace Dali
{
namespace Toolkit
{
namespace Internal
{
+namespace
+{
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_IMAGE_PERFORMANCE_MARKER, false);
+
+#ifdef TRACE_ENABLED
+uint64_t GetNanoseconds()
+{
+ // Get the time of a monotonic clock since its epoch.
+ auto epoch = std::chrono::steady_clock::now().time_since_epoch();
+ auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(epoch);
+ return static_cast<uint64_t>(duration.count());
+}
+#endif
+} // namespace
+
LoadingTask::LoadingTask(uint32_t id, Dali::AnimatedImageLoading animatedImageLoading, uint32_t frameIndex, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad, CallbackBase* callback)
: AsyncTask(callback),
url(),
}
LoadingTask::LoadingTask(uint32_t id, const VisualUrl& url, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad, bool loadPlanes, CallbackBase* callback)
-: AsyncTask(callback),
+: AsyncTask(callback, url.GetProtocolType() == VisualUrl::ProtocolType::REMOTE ? AsyncTask::PriorityType::LOW : AsyncTask::PriorityType::HIGH),
url(url),
encodedImageBuffer(),
id(id),
void LoadingTask::Process()
{
+#ifdef TRACE_ENABLED
+ uint64_t mStartTimeNanoSceonds = 0;
+ uint64_t mEndTimeNanoSceonds = 0;
+ if(gTraceFilter && gTraceFilter->IsTraceEnabled())
+ {
+ mStartTimeNanoSceonds = GetNanoseconds();
+ std::ostringstream oss;
+ oss << "[u:" << (!!(animatedImageLoading) ? animatedImageLoading.GetUrl() : url.GetEllipsedUrl()) << "]";
+ // DALI_TRACE_BEGIN(gTraceFilter, "DALI_IMAGE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
+ DALI_LOG_RELEASE_INFO("BEGIN: DALI_IMAGE_LOADING_TASK %s", oss.str().c_str());
+ }
+#endif
+
isReady = false;
if(!isMaskTask)
{
}
MultiplyAlpha();
isReady = true;
+
+#ifdef TRACE_ENABLED
+ if(gTraceFilter && gTraceFilter->IsTraceEnabled())
+ {
+ mEndTimeNanoSceonds = GetNanoseconds();
+ std::ostringstream oss;
+ oss << std::fixed << std::setprecision(3);
+ oss << "[";
+ oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
+ oss << "m:" << isMaskTask << " ";
+ oss << "i:" << frameIndex << " ";
+ oss << "b:" << pixelBuffers.size() << " ";
+ if(!pixelBuffers.empty())
+ {
+ oss << "s:" << pixelBuffers[0].GetWidth() << "x" << pixelBuffers[0].GetHeight() << " ";
+ oss << "p:" << pixelBuffers[0].IsAlphaPreMultiplied() << " ";
+ }
+ oss << "u:" << (!!(animatedImageLoading) ? animatedImageLoading.GetUrl() : url.GetEllipsedUrl()) << "]";
+ // DALI_TRACE_END(gTraceFilter, "DALI_IMAGE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
+ DALI_LOG_RELEASE_INFO("END: DALI_IMAGE_LOADING_TASK %s", oss.str().c_str());
+ }
+#endif
}
bool LoadingTask::IsReady()
else if(encodedImageBuffer)
{
pixelBuffer = Dali::LoadImageFromBuffer(encodedImageBuffer.GetRawBuffer(), dimensions, fittingMode, samplingMode, orientationCorrection);
+
+ // We don't need to hold image buffer anymore.
+ encodedImageBuffer.Reset();
}
else if(url.IsValid() && url.IsLocalResource())
{