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=213173a425a9766ebb1e0ac368f023bea293d1ef;hp=320911da0c05bc73e6cb3b3ede3ea5a63efac5a7;hb=d9d5db59d3c9b5ec6c34315da1c41b2231547828;hpb=8b474798c4b5a53412ed526f6279d4d27b440fc9 diff --git a/dali-toolkit/internal/image-loader/image-load-thread.cpp b/dali-toolkit/internal/image-loader/image-load-thread.cpp index 320911d..213173a 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,8 @@ // EXTERNAL INCLUDES #include -#include #include +#include namespace Dali { @@ -41,7 +41,28 @@ LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dim fittingMode( fittingMode ), samplingMode( samplingMode ), orientationCorrection( orientationCorrection ), - preMultiplyOnLoad( preMultiplyOnLoad ) + 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 ) { } @@ -55,7 +76,15 @@ void LoadingTask::Load() { pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection ); } +} + +void LoadingTask::ApplyMask() +{ + pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); +} +void LoadingTask::MultiplyAlpha() +{ if( pixelBuffer && Pixel::HasAlpha( pixelBuffer.GetPixelFormat() ) ) { if( preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON ) @@ -65,7 +94,6 @@ void LoadingTask::Load() } } - ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger ) : mTrigger( trigger ), mLogFactory( Dali::Adaptor::Get().GetLogFactory() ) @@ -89,7 +117,16 @@ void ImageLoadThread::Run() while( LoadingTask* task = NextTaskToProcess() ) { - task->Load(); + if( !task->isMaskTask ) + { + task->Load(); + } + else + { + task->ApplyMask(); + } + task->MultiplyAlpha(); + AddCompletedTask( task ); } }