cc9cc8889beefe92d6f99da38f7e01b1bd84a4a6
[platform/core/uifw/dali-adaptor.git] / adaptors / base / fps-tracker.h
1 #ifndef __DALI_INTERNAL_FPS_TRACKER_H__
2 #define __DALI_INTERNAL_FPS_TRACKER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 namespace Dali
22 {
23
24 namespace Internal
25 {
26
27 namespace Adaptor
28 {
29
30 class EnvironmentOptions;
31
32 /**
33  * Tracks the frames per second.
34  *
35  * Can also output the FPS to a file if required.
36  */
37 class FpsTracker
38 {
39 public:
40
41   /**
42    * Create the FPS Tracker.
43    * @param[in] environmentOptions environment options
44    */
45   FpsTracker( const EnvironmentOptions& environmentOptions );
46
47   /**
48    * Non-virtual destructor; UpdateThread is not suitable as a base class.
49    */
50   ~FpsTracker();
51
52   /**
53    * When DALI_FPS_TRACKING is enabled, this method calculates the frame rates for the specified time period
54    *
55    * @param[in] secondsFromLastFrame The time (in seconds) that has elapsed since the last frame.
56    */
57   void Track(float secondsFromLastFrame);
58
59   /**
60    * @return Whether FPS tracking is enabled.
61    */
62   bool Enabled() const;
63
64 private:
65
66   /**
67    * Output the FPS information
68    * when the FSP tracking is enabled,
69    * it is called when the specified tracking period is elapsed or in the destructor when the process finished beforehand
70    */
71   void OutputFPSRecord();
72
73 private: // Data
74
75   float mFpsTrackingSeconds;  ///< fps tracking time length in seconds
76   float mFrameCount;          ///< how many frames occurred during tracking period
77   float mElapsedTime;         ///< time elapsed from previous fps tracking output
78 };
79
80 } // namespace Adaptor
81
82 } // namespace Internal
83
84 } // namespace Dali
85
86 #endif // __DALI_INTERNAL_FPS_TRACKER_H__