X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fimage-loader%2Fimage-load-thread.cpp;h=deb01781ed5cab893d3546ab88b1500f9a2eeb10;hp=c0959f687301036373a151bc0af7c2141df3dd49;hb=11e1ee5bb1a33525dd3016a0fd145a6a3ee2c133;hpb=0d81c2ea24d4e6f1e20d387a3e6c17c04c861a81 diff --git a/dali-toolkit/internal/image-loader/image-load-thread.cpp b/dali-toolkit/internal/image-loader/image-load-thread.cpp index c0959f6..deb0178 100644 --- a/dali-toolkit/internal/image-loader/image-load-thread.cpp +++ b/dali-toolkit/internal/image-loader/image-load-thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -19,11 +19,11 @@ #include "image-load-thread.h" // EXTERNAL INCLUDES -#include #include #include #include #include +#include namespace Dali { @@ -32,83 +32,85 @@ namespace Toolkit namespace Internal { LoadingTask::LoadingTask(uint32_t id, Dali::AnimatedImageLoading animatedImageLoading, uint32_t frameIndex, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) -: pixelBuffer(), - url(), +: url(), encodedImageBuffer(), id(id), dimensions(), fittingMode(), samplingMode(), - orientationCorrection(), preMultiplyOnLoad(preMultiplyOnLoad), - isMaskTask(false), maskPixelBuffer(), contentScale(1.0f), - cropToMask(false), animatedImageLoading(animatedImageLoading), - frameIndex(frameIndex) + frameIndex(frameIndex), + orientationCorrection(), + isMaskTask(false), + cropToMask(false), + loadPlanes(false) { } -LoadingTask::LoadingTask(uint32_t id, const VisualUrl& url, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) -: pixelBuffer(), - url(url), +LoadingTask::LoadingTask(uint32_t id, const VisualUrl& url, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad, bool loadPlanes) +: url(url), encodedImageBuffer(), id(id), dimensions(dimensions), fittingMode(fittingMode), samplingMode(samplingMode), - orientationCorrection(orientationCorrection), preMultiplyOnLoad(preMultiplyOnLoad), - isMaskTask(false), maskPixelBuffer(), contentScale(1.0f), - cropToMask(false), animatedImageLoading(), - frameIndex(0u) + frameIndex(0u), + orientationCorrection(orientationCorrection), + isMaskTask(false), + cropToMask(false), + loadPlanes(loadPlanes) { } LoadingTask::LoadingTask(uint32_t id, const EncodedImageBuffer& encodedImageBuffer, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) -: pixelBuffer(), - url(), +: url(), encodedImageBuffer(encodedImageBuffer), id(id), dimensions(dimensions), fittingMode(fittingMode), samplingMode(samplingMode), - orientationCorrection(orientationCorrection), preMultiplyOnLoad(preMultiplyOnLoad), - isMaskTask(false), maskPixelBuffer(), contentScale(1.0f), - cropToMask(false), animatedImageLoading(), - frameIndex(0u) + frameIndex(0u), + orientationCorrection(orientationCorrection), + isMaskTask(false), + cropToMask(false), + loadPlanes(false) { } LoadingTask::LoadingTask(uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) -: pixelBuffer(pixelBuffer), - url(""), +: url(""), encodedImageBuffer(), id(id), dimensions(), fittingMode(), samplingMode(), - orientationCorrection(), preMultiplyOnLoad(preMultiplyOnLoad), - isMaskTask(true), maskPixelBuffer(maskPixelBuffer), contentScale(contentScale), - cropToMask(cropToMask), animatedImageLoading(), - frameIndex(0u) + 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); @@ -119,14 +121,26 @@ void LoadingTask::Load() } else if(url.IsValid() && url.IsLocalResource()) { - pixelBuffer = Dali::LoadImageFromFile(url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection); + 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) + if(pixelBuffer) + { + pixelBuffers.push_back(pixelBuffer); + } + + if(pixelBuffers.empty()) { DALI_LOG_ERROR("LoadingTask::Load: Loading is failed: %s\n", url.GetUrl().c_str()); } @@ -134,16 +148,19 @@ void LoadingTask::Load() void LoadingTask::ApplyMask() { - pixelBuffer.ApplyMask(maskPixelBuffer, contentScale, cropToMask); + if(!pixelBuffers.empty()) + { + pixelBuffers[0].ApplyMask(maskPixelBuffer, contentScale, cropToMask); + } } void LoadingTask::MultiplyAlpha() { - if(pixelBuffer && Pixel::HasAlpha(pixelBuffer.GetPixelFormat())) + if(!pixelBuffers.empty() && Pixel::HasAlpha(pixelBuffers[0].GetPixelFormat())) { if(preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON) { - pixelBuffer.MultiplyColorByAlpha(); + pixelBuffers[0].MultiplyColorByAlpha(); } } }