+LoadingTask::LoadingTask(uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
+: url(""),
+ encodedImageBuffer(),
+ id(id),
+ dimensions(),
+ fittingMode(),
+ samplingMode(),
+ preMultiplyOnLoad(preMultiplyOnLoad),
+ maskPixelBuffer(maskPixelBuffer),
+ contentScale(contentScale),
+ animatedImageLoading(),
+ frameIndex(0u),
+ orientationCorrection(),
+ isMaskTask(true),
+ cropToMask(cropToMask),
+ loadPlanes(false)
+{
+ pixelBuffers.push_back(pixelBuffer);
+}
+
+void LoadingTask::Load()
+{
+ Devel::PixelBuffer pixelBuffer;
+ if(animatedImageLoading)
+ {
+ pixelBuffer = animatedImageLoading.LoadFrame(frameIndex);
+ }
+ else if(encodedImageBuffer)
+ {
+ pixelBuffer = Dali::LoadImageFromBuffer(encodedImageBuffer.GetRawBuffer(), dimensions, fittingMode, samplingMode, orientationCorrection);
+ }
+ else if(url.IsValid() && url.IsLocalResource())
+ {
+ if(loadPlanes)
+ {
+ Dali::LoadImagePlanesFromFile(url.GetUrl(), pixelBuffers, dimensions, fittingMode, samplingMode, orientationCorrection);
+ }
+ else
+ {
+ pixelBuffer = Dali::LoadImageFromFile(url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection);
+ }
+ }
+ else if(url.IsValid())
+ {
+ pixelBuffer = Dali::DownloadImageSynchronously(url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection);
+ }
+
+ if(pixelBuffer)
+ {
+ pixelBuffers.push_back(pixelBuffer);
+ }
+
+ if(pixelBuffers.empty())
+ {
+ DALI_LOG_ERROR("LoadingTask::Load: Loading is failed: %s\n", url.GetUrl().c_str());
+ }
+}
+
+void LoadingTask::ApplyMask()
+{
+ if(!pixelBuffers.empty())
+ {
+ pixelBuffers[0].ApplyMask(maskPixelBuffer, contentScale, cropToMask);
+ }
+}
+
+void LoadingTask::MultiplyAlpha()
+{
+ if(!pixelBuffers.empty() && Pixel::HasAlpha(pixelBuffers[0].GetPixelFormat()))
+ {
+ if(preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON)
+ {
+ pixelBuffers[0].MultiplyColorByAlpha();
+ }
+ }
+}
+
+ImageLoadThread::ImageLoadThread(EventThreadCallback* trigger)
+: mTrigger(trigger),
+ mLogFactory(Dali::Adaptor::Get().GetLogFactory())