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=179734a10671b19aaf3a5eba27d4f51381ff04cc;hp=74d3e3972f186f3a1b73c84a601c6858eac762f7;hb=690684ccea076f90c10464c89e110951f11bf6f5;hpb=2dd55c62173e94588e4bb45e263a32b3d77af65a diff --git a/dali-toolkit/internal/image-loader/image-load-thread.cpp b/dali-toolkit/internal/image-loader/image-load-thread.cpp index 74d3e39..179734a 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) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -20,8 +20,9 @@ // EXTERNAL INCLUDES #include -#include #include +#include +#include namespace Dali { @@ -33,14 +34,36 @@ namespace Internal { LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions, - FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection ) + FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ) : pixelBuffer(), url( url ), id( id ), dimensions( dimensions ), fittingMode( fittingMode ), samplingMode( samplingMode ), - orientationCorrection( orientationCorrection ) + orientationCorrection( orientationCorrection ), + preMultiplyOnLoad( preMultiplyOnLoad ), + isMaskTask( false ), + maskPixelBuffer(), + contentScale( 1.0f ), + cropToMask( false ) +{ +} + +LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ) +: pixelBuffer( pixelBuffer ), + url( "" ), + id( id ), + dimensions(), + fittingMode(), + samplingMode(), + orientationCorrection(), + preMultiplyOnLoad( preMultiplyOnLoad ), + isMaskTask( true ), + maskPixelBuffer( maskPixelBuffer ), + contentScale( contentScale ), + cropToMask( cropToMask ) { } @@ -54,8 +77,28 @@ void LoadingTask::Load() { pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection ); } + + if( !pixelBuffer ) + { + DALI_LOG_ERROR( "LoadingTask::Load: Loading is failed: %s\n", url.GetUrl().c_str() ); + } } +void LoadingTask::ApplyMask() +{ + pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); +} + +void LoadingTask::MultiplyAlpha() +{ + if( pixelBuffer && Pixel::HasAlpha( pixelBuffer.GetPixelFormat() ) ) + { + if( preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON ) + { + pixelBuffer.MultiplyColorByAlpha(); + } + } +} ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger ) : mTrigger( trigger ), @@ -80,7 +123,16 @@ void ImageLoadThread::Run() while( LoadingTask* task = NextTaskToProcess() ) { - task->Load(); + if( !task->isMaskTask ) + { + task->Load(); + } + else + { + task->ApplyMask(); + } + task->MultiplyAlpha(); + AddCompletedTask( task ); } }