Move MultiplyColorByAlpha() from main thread to resource thread
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / async-image-loader-impl.cpp
index 06065b7..1b764cb 100644 (file)
@@ -19,7 +19,6 @@
 #include "async-image-loader-impl.h"
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
 #include <dali/integration-api/adaptors/adaptor.h>
 
 namespace Dali
@@ -50,21 +49,19 @@ IntrusivePtr<AsyncImageLoader> AsyncImageLoader::New()
   return internal;
 }
 
-uint32_t AsyncImageLoader::Load( const std::string& url,
+uint32_t AsyncImageLoader::Load( const VisualUrl& url,
                                  ImageDimensions dimensions,
                                  FittingMode::Type fittingMode,
                                  SamplingMode::Type samplingMode,
-                                 bool orientationCorrection )
+                                 bool orientationCorrection,
+                                 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
 {
   if( !mIsLoadThreadStarted )
   {
     mLoadThread.Start();
     mIsLoadThreadStarted = true;
   }
-
-  BitmapLoader loader = BitmapLoader::New( url, dimensions, fittingMode, samplingMode, orientationCorrection );
-
-  mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, loader ) );
+  mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad ) );
 
   return mLoadTaskId;
 }
@@ -74,6 +71,11 @@ Toolkit::AsyncImageLoader::ImageLoadedSignalType& AsyncImageLoader::ImageLoadedS
   return mLoadedSignal;
 }
 
+Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& AsyncImageLoader::PixelBufferLoadedSignal()
+{
+  return mPixelBufferLoadedSignal;
+}
+
 bool AsyncImageLoader::Cancel( uint32_t loadingTaskId )
 {
   return mLoadThread.CancelTask( loadingTaskId );
@@ -86,9 +88,22 @@ void AsyncImageLoader::CancelAll()
 
 void AsyncImageLoader::ProcessLoadedImage()
 {
-  while( LoadingTask *next =  mLoadThread.NextCompletedTask() )
+  while( LoadingTask *next = mLoadThread.NextCompletedTask() )
   {
-    mLoadedSignal.Emit( next->id, next->loader.GetPixelData() );
+    if( mPixelBufferLoadedSignal.GetConnectionCount() > 0 )
+    {
+      mPixelBufferLoadedSignal.Emit( next->id, next->pixelBuffer );
+    }
+    else if( mLoadedSignal.GetConnectionCount() > 0 )
+    {
+      PixelData pixelData;
+      if( next->pixelBuffer )
+      {
+        pixelData = Devel::PixelBuffer::Convert( next->pixelBuffer );
+      }
+      mLoadedSignal.Emit( next->id, pixelData );
+    }
+
     delete next;
   }
 }