Extract out FPS Tracker & Update Status Logger from UpdateThread class
[platform/core/uifw/dali-adaptor.git] / adaptors / base / update-thread.h
index 37c3831..0f861a9 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_UPDATE_THREAD_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
  *
  */
 
-// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-
-namespace boost
-{
+// EXTERNAL INCLUDES
+#include <pthread.h>
 
-class thread;
-
-} // namespace boost
+// INTERNAL INCLUDES
+#include <base/fps-tracker.h>
+#include <base/update-status-logger.h>
 
 namespace Dali
 {
@@ -42,7 +39,7 @@ namespace Internal
 namespace Adaptor
 {
 
-class UpdateRenderSynchronization;
+class ThreadSynchronization;
 class AdaptorInternalServices;
 class EnvironmentOptions;
 
@@ -60,7 +57,7 @@ public:
    * @param[in] adaptorInterfaces base adaptor interface
    * @param[in] environmentOptions environment options
    */
-  UpdateThread(UpdateRenderSynchronization& sync,
+  UpdateThread(ThreadSynchronization& sync,
                AdaptorInternalServices& adaptorInterfaces,
                const EnvironmentOptions& environmentOptions );
 
@@ -88,39 +85,25 @@ private:
   bool Run();
 
   /**
-   * When DALI_FPS_TRACKING is enabled, this method calculates the frame rates for the specified time period
-   */
-  void FPSTracking(float secondsFromLastFrame);
-
-  /**
-   * Output the FPS information
-   * when the FSP tracking is enabled,
-   * it is called when the specified tracking period is elapsed or in the destructor when the process finished beforehand
-   */
-  void OutputFPSRecord();
-
-  /**
-   * Optionally output the update thread status.
-   * @param[in] keepUpdatingStatus Whether the update-thread requested further updates.
-   * @param[in] renderNeedsUpdate Whether the render-thread requested another update.
+   * Helper for the thread calling the entry function
+   * @param[in] This A pointer to the current UpdateThread object
    */
-  void UpdateStatusLogging( unsigned int keepUpdatingStatus, bool renderNeedsUpdate );
+  static inline void* InternalThreadEntryFunc( void* This )
+  {
+    ( static_cast<UpdateThread*>( This ) )->Run();
+    return NULL;
+  }
 
 private: // Data
 
-  UpdateRenderSynchronization&        mUpdateRenderSync;    ///< Used to synchronize the update & render threads
+  ThreadSynchronization&              mThreadSynchronization; ///< Used to synchronize all the threads
 
   Dali::Integration::Core&            mCore;                ///< Dali core reference
 
-  unsigned int                        mFpsTrackingSeconds;  ///< fps tracking time length in seconds
-  std::vector<float>                  mFpsRecord;           ///< Record of frame rate
-  float                               mElapsedTime;         ///< time elapsed within current second
-  unsigned int                        mElapsedSeconds;      ///< seconds elapsed since the fps tracking started
-
-  unsigned int                        mStatusLogInterval;   ///< Interval in frames between status debug prints
-  unsigned int                        mStatusLogCount;      ///< Used to count frames between status debug prints
+  FpsTracker                          mFpsTracker;          ///< Object that tracks the FPS
+  UpdateStatusLogger                  mUpdateStatusLogger;  ///< Object that logs the update-status as required.
 
-  boost::thread*                      mThread;              ///< The actual update-thread.
+  pthread_t*                          mThread;              ///< The actual update-thread.
   const EnvironmentOptions&           mEnvironmentOptions;  ///< environment options
 }; // class UpdateThread