Added logging function to image loader threads
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / image-load-thread.cpp
index d0b504d..857a55b 100644 (file)
@@ -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.
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/integration-api/adaptors/adaptor.h>
 
 namespace Dali
 {
@@ -30,9 +31,9 @@ namespace Toolkit
 namespace Internal
 {
 
-LoadingTask::LoadingTask( uint32_t id, const std::string& url, ImageDimensions dimensions,
+LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions,
                           FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
-: pixelData(),
+: pixelBuffer(),
   url( url ),
   id( id ),
   dimensions( dimensions ),
@@ -44,12 +45,20 @@ LoadingTask::LoadingTask( uint32_t id, const std::string& url, ImageDimensions d
 
 void LoadingTask::Load()
 {
-  pixelData = Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
+  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() )
 {
 }
 
@@ -65,6 +74,8 @@ ImageLoadThread::~ImageLoadThread()
 
 void ImageLoadThread::Run()
 {
+  mLogFactory.InstallLogFunction();
+
   while( LoadingTask* task = NextTaskToProcess() )
   {
     task->Load();