Switch Sync- and AsynchImageLoaders to use new (object less) image loading adaptor API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / image-load-thread.cpp
index a27db14..d0b504d 100644 (file)
@@ -18,6 +18,9 @@
 // CLASS HEADER
 #include "image-load-thread.h"
 
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/image-loading.h>
+
 namespace Dali
 {
 
@@ -27,12 +30,24 @@ namespace Toolkit
 namespace Internal
 {
 
-LoadingTask::LoadingTask(uint32_t id, BitmapLoader loader )
-: loader( loader ),
-  id( id )
+LoadingTask::LoadingTask( uint32_t id, const std::string& url, ImageDimensions dimensions,
+                          FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
+: pixelData(),
+  url( url ),
+  id( id ),
+  dimensions( dimensions ),
+  fittingMode( fittingMode ),
+  samplingMode( samplingMode ),
+  orientationCorrection( orientationCorrection )
+{
+}
+
+void LoadingTask::Load()
 {
+  pixelData = Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
 }
 
+
 ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger )
 : mTrigger( trigger )
 {
@@ -50,9 +65,9 @@ ImageLoadThread::~ImageLoadThread()
 
 void ImageLoadThread::Run()
 {
-  while( LoadingTask* task =  NextTaskToProcess())
+  while( LoadingTask* task = NextTaskToProcess() )
   {
-    task->loader.Load();
+    task->Load();
     AddCompletedTask( task );
   }
 }
@@ -68,7 +83,7 @@ void ImageLoadThread::AddTask( LoadingTask* task )
     mLoadQueue.PushBack( task );
   }
 
-  if( wasEmpty)
+  if( wasEmpty )
   {
     // wake up the image loading thread
     mConditionalWait.Notify();
@@ -97,7 +112,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 +131,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 +165,6 @@ void ImageLoadThread::AddCompletedTask( LoadingTask* task )
   mTrigger->Trigger();
 }
 
-
-
 } // namespace Internal
 
 } // namespace Toolkit