Added logging function to image loader threads 12/161512/4
authorDavid Steele <david.steele@samsung.com>
Thu, 23 Nov 2017 21:49:47 +0000 (21:49 +0000)
committerDavid Steele <david.steele@samsung.com>
Tue, 6 Feb 2018 20:11:57 +0000 (20:11 +0000)
Change-Id: I766605855228ad86fd35e09774e0b82e5f7d1f90

automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
dali-toolkit/internal/image-loader/image-load-thread.cpp
dali-toolkit/internal/image-loader/image-load-thread.h

index 64f876b..8b2160f 100755 (executable)
@@ -32,6 +32,7 @@ SET(TC_SOURCES
 
 # Append list of test harness files (Won't get parsed for test cases)
 LIST(APPEND TC_SOURCES
 
 # Append list of test harness files (Won't get parsed for test cases)
 LIST(APPEND TC_SOURCES
+   ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
index 4b25c5d..3ff177c 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2016 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
 #include <dali/public-api/object/base-object.h>
 
 #include <toolkit-adaptor-impl.h>
 #include <dali/public-api/object/base-object.h>
 
 #include <toolkit-adaptor-impl.h>
+#include <dali/integration-api/debug.h>
+#include <test-application.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -210,6 +212,34 @@ void Adaptor::SetStereoBase(  float stereoBase )
 {
 }
 
 {
 }
 
+
+class LogFactory : public LogFactoryInterface
+{
+public:
+  virtual void InstallLogFunction() const
+  {
+    Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
+    Dali::Integration::Log::InstallLogFunction(logFunction);
+  }
+
+  LogFactory()
+  {
+  }
+  virtual ~LogFactory()
+  {
+  }
+};
+
+LogFactory* gLogFactory = NULL;
+const LogFactoryInterface& Adaptor::GetLogFactory()
+{
+  if( gLogFactory == NULL )
+  {
+    gLogFactory = new LogFactory;
+  }
+  return *gLogFactory;
+}
+
 Adaptor::Adaptor()
 : mImpl( NULL )
 {
 Adaptor::Adaptor()
 : mImpl( NULL )
 {
index 7e0a181..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.
  *
  * 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>
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/integration-api/adaptors/adaptor.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -56,7 +57,8 @@ void LoadingTask::Load()
 
 
 ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger )
 
 
 ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger )
-: mTrigger( trigger )
+: mTrigger( trigger ),
+  mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
 {
 }
 
 {
 }
 
@@ -72,6 +74,8 @@ ImageLoadThread::~ImageLoadThread()
 
 void ImageLoadThread::Run()
 {
 
 void ImageLoadThread::Run()
 {
+  mLogFactory.InstallLogFunction();
+
   while( LoadingTask* task = NextTaskToProcess() )
   {
     task->Load();
   while( LoadingTask* task = NextTaskToProcess() )
   {
     task->Load();
index 3d0ad24..c3f230c 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__
 
 /*
 #define __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__
 
 /*
- * Copyright (c) 2016 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.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 #include <dali/devel-api/threading/thread.h>
 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali/devel-api/threading/thread.h>
 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/adaptors/log-factory-interface.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 #include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
@@ -162,10 +163,11 @@ private:
 
   Vector< LoadingTask* > mLoadQueue;     ///<The task queue with images for loading.
   Vector< LoadingTask* > mCompleteQueue; ///<The task queue with images loaded.
 
   Vector< LoadingTask* > mLoadQueue;     ///<The task queue with images for loading.
   Vector< LoadingTask* > mCompleteQueue; ///<The task queue with images loaded.
+  EventThreadCallback*   mTrigger;
+  const Dali::LogFactoryInterface& mLogFactory; ///< The log factory
 
   ConditionalWait        mConditionalWait;
   Dali::Mutex            mMutex;
 
   ConditionalWait        mConditionalWait;
   Dali::Mutex            mMutex;
-  EventThreadCallback*   mTrigger;
 };
 
 } // namespace Internal
 };
 
 } // namespace Internal