Use original PixelBufferLoadedSignalType signal parameter.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / async-image-loader-impl.cpp
index 8454992..de0ee3f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 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.
@@ -53,15 +53,30 @@ 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;
   }
+  mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad ) );
 
-  mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection ) );
+  return mLoadTaskId;
+}
+
+uint32_t AsyncImageLoader::ApplyMask( Devel::PixelBuffer pixelBuffer,
+                                      Devel::PixelBuffer maskPixelBuffer,
+                                      float contentScale,
+                                      bool cropToMask )
+{
+  if( !mIsLoadThreadStarted )
+  {
+    mLoadThread.Start();
+    mIsLoadThreadStarted = true;
+  }
+  mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, pixelBuffer, maskPixelBuffer, contentScale, cropToMask ) );
 
   return mLoadTaskId;
 }
@@ -71,6 +86,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 );
@@ -85,7 +105,20 @@ void AsyncImageLoader::ProcessLoadedImage()
 {
   while( LoadingTask *next = mLoadThread.NextCompletedTask() )
   {
-    mLoadedSignal.Emit( next->id, next->pixelData );
+    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;
   }
 }