X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fimage-loader%2Fimage-load-thread.cpp;h=857a55b7d1c1ce7cf1b98799c871199175cadc07;hb=1498b458e65cce375898c232cfa87c831b1f1c6b;hp=a27db1450e458aaa9a83012d37abcaeaa2c9c4c8;hpb=41307f75478fd6c6fb5f9ae7e7de5036647f39b3;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 a27db14..857a55b 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) 2017 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. @@ -18,6 +18,10 @@ // CLASS HEADER #include "image-load-thread.h" +// EXTERNAL INCLUDES +#include +#include + namespace Dali { @@ -27,14 +31,34 @@ namespace Toolkit namespace Internal { -LoadingTask::LoadingTask(uint32_t id, BitmapLoader loader ) -: loader( loader ), - id( id ) +LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions, + FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection ) +: pixelBuffer(), + url( url ), + id( id ), + dimensions( dimensions ), + fittingMode( fittingMode ), + samplingMode( samplingMode ), + orientationCorrection( orientationCorrection ) +{ +} + +void LoadingTask::Load() { + if( url.IsLocalResource() ) + { + pixelBuffer = Dali::LoadImageFromFile( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection ); + } + else + { + pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection ); + } } + ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger ) -: mTrigger( trigger ) +: mTrigger( trigger ), + mLogFactory( Dali::Adaptor::Get().GetLogFactory() ) { } @@ -50,9 +74,11 @@ ImageLoadThread::~ImageLoadThread() void ImageLoadThread::Run() { - while( LoadingTask* task = NextTaskToProcess()) + mLogFactory.InstallLogFunction(); + + while( LoadingTask* task = NextTaskToProcess() ) { - task->loader.Load(); + task->Load(); AddCompletedTask( task ); } } @@ -68,7 +94,7 @@ void ImageLoadThread::AddTask( LoadingTask* task ) mLoadQueue.PushBack( task ); } - if( wasEmpty) + if( wasEmpty ) { // wake up the image loading thread mConditionalWait.Notify(); @@ -97,7 +123,7 @@ bool ImageLoadThread::CancelTask( uint32_t loadingTaskId ) // Lock while remove task from the queue ConditionalWait::ScopedLock lock( mConditionalWait ); - for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); iter++ ) + for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); ++iter ) { if( (*iter)->id == loadingTaskId ) { @@ -116,9 +142,9 @@ void ImageLoadThread::CancelAll() // Lock while remove task from the queue ConditionalWait::ScopedLock lock( mConditionalWait ); - for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); iter++ ) + for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); ++iter ) { - delete (*iter); + delete ( *iter ); } mLoadQueue.Clear(); } @@ -150,8 +176,6 @@ void ImageLoadThread::AddCompletedTask( LoadingTask* task ) mTrigger->Trigger(); } - - } // namespace Internal } // namespace Toolkit