X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fimage-loader%2Fimage-load-thread.cpp;h=f687af6cb7236eb7756b51bd0ab57f51ab8a63bb;hb=c554768b59fa4b5becd9b809a583e9b3e9c56237;hp=7e0a181dd36fdcc6dec3a8541bcd8841cbd76b15;hpb=58ae307297125b55c93c38a631a8745c6a7c51f1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/image-loader/image-load-thread.cpp b/dali-toolkit/internal/image-loader/image-load-thread.cpp index 7e0a181..f687af6 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) 2015 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,6 +20,8 @@ // EXTERNAL INCLUDES #include +#include +#include namespace Dali { @@ -31,14 +33,35 @@ 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 ) +: pixelBuffer( pixelBuffer ), + url( "" ), + id( id ), + dimensions(), + fittingMode(), + samplingMode(), + orientationCorrection(), + preMultiplyOnLoad(), + isMaskTask( true ), + maskPixelBuffer( maskPixelBuffer ), + contentScale( contentScale ), + cropToMask( cropToMask ) { } @@ -52,11 +75,24 @@ void LoadingTask::Load() { pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection ); } + + if( pixelBuffer && Pixel::HasAlpha( pixelBuffer.GetPixelFormat() ) ) + { + if( preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON ) + { + pixelBuffer.MultiplyColorByAlpha(); + } + } } +void LoadingTask::ApplyMask() +{ + pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); +} ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger ) -: mTrigger( trigger ) +: mTrigger( trigger ), + mLogFactory( Dali::Adaptor::Get().GetLogFactory() ) { } @@ -72,9 +108,20 @@ ImageLoadThread::~ImageLoadThread() void ImageLoadThread::Run() { + SetThreadName( "ImageLoadThread" ); + mLogFactory.InstallLogFunction(); + while( LoadingTask* task = NextTaskToProcess() ) { - task->Load(); + if( !task->isMaskTask ) + { + task->Load(); + } + else + { + task->ApplyMask(); + } + AddCompletedTask( task ); } }