1 #ifndef __DALI_INTERNAL_UPDATE_THREAD_H__
2 #define __DALI_INTERNAL_UPDATE_THREAD_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
38 class ThreadSynchronization;
39 class AdaptorInternalServices;
40 class EnvironmentOptions;
43 * The update-thread is responsible for calling Core::Update(), and
44 * for triggering the render-thread after each update.
51 * Create the update-thread; this will not do anything until Start() is called.
52 * @param[in] sync An object used to synchronize update & render threads.
53 * @param[in] adaptorInterfaces base adaptor interface
54 * @param[in] environmentOptions environment options
56 UpdateThread(ThreadSynchronization& sync,
57 AdaptorInternalServices& adaptorInterfaces,
58 const EnvironmentOptions& environmentOptions );
61 * Non-virtual destructor; UpdateThread is not suitable as a base class.
66 * Starts the update-thread
71 * Stops the update-thread
78 * This method is used by the update-thread for calling Core::Update().
79 * @return true, if the thread finishes properly.
84 * When DALI_FPS_TRACKING is enabled, this method calculates the frame rates for the specified time period
86 void FPSTracking(float secondsFromLastFrame);
89 * Output the FPS information
90 * when the FSP tracking is enabled,
91 * it is called when the specified tracking period is elapsed or in the destructor when the process finished beforehand
93 void OutputFPSRecord();
96 * Optionally output the update thread status.
97 * @param[in] keepUpdatingStatus Whether the update-thread requested further updates.
99 void UpdateStatusLogging( unsigned int keepUpdatingStatus );
102 * Helper for the thread calling the entry function
103 * @param[in] This A pointer to the current UpdateThread object
105 static inline void* InternalThreadEntryFunc( void* This )
107 ( static_cast<UpdateThread*>( This ) )->Run();
113 ThreadSynchronization& mThreadSynchronization; ///< Used to synchronize all the threads
115 Dali::Integration::Core& mCore; ///< Dali core reference
117 float mFpsTrackingSeconds; ///< fps tracking time length in seconds
118 float mFrameCount; ///< how many frames occurred during tracking period
119 float mElapsedTime; ///< time elapsed from previous fps tracking output
121 unsigned int mStatusLogInterval; ///< Interval in frames between status debug prints
122 unsigned int mStatusLogCount; ///< Used to count frames between status debug prints
124 pthread_t* mThread; ///< The actual update-thread.
125 const EnvironmentOptions& mEnvironmentOptions; ///< environment options
126 }; // class UpdateThread
128 } // namespace Adaptor
130 } // namespace Internal
134 #endif // __DALI_INTERNAL_UPDATE_THREAD_H__