[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-adaptor.git] / adaptors / base / vsync-notifier.h
1 #ifndef __DALI_INTERNAL_VSYNC_NOTIFIER_H__
2 #define __DALI_INTERNAL_VSYNC_NOTIFIER_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 namespace boost
21 {
22
23 class thread;
24
25 } // namespace boost
26
27 namespace Dali
28 {
29
30 namespace Integration
31 {
32
33 class Core;
34 class PlatformAbstraction;
35
36 } // namespace Integration
37
38 namespace Internal
39 {
40
41 namespace Adaptor
42 {
43
44 class VSyncMonitorInterface;
45 class UpdateRenderSynchronization;
46 class LogOptions;
47 class AdaptorInternalServices;
48
49 /**
50  * Implements a simple class that monitors vertical blanks from libdrm
51  * and sends a notification to Core.
52  */
53 class VSyncNotifier
54 {
55 public:
56
57   /**
58    * Create the vsync notification thread; this will not start to monitor vsync and
59    * send notifications until Start() is called.
60    * @param[in] sync         An object used to synchronize update, render and vsync threads.
61    * @param[in] adaptorInterfaces base adaptor interface
62    * @param[in] logOption    Log options
63    */
64   VSyncNotifier( UpdateRenderSynchronization& sync,
65                  AdaptorInternalServices& adaptorInterfaces,
66                  const LogOptions& logOptions);
67
68   /**
69    * Non-virtual destructor; VSyncNotifier is not suitable as a base class.
70    */
71   ~VSyncNotifier();
72
73   /**
74    * Starts the thread
75    */
76   void Start();
77
78   /**
79    * Stops the thread
80    */
81   void Stop();
82
83 private:
84
85   /**
86    * The main thread loop. The system thread will be destroyed on
87    * exit from this function.
88    */
89   void Run();
90
91 private:
92
93   UpdateRenderSynchronization&        mUpdateRenderSync;    ///< Used to synchronize the update, render & vsync threads
94   Dali::Integration::Core&            mCore;                ///< Dali core reference
95   Integration::PlatformAbstraction&   mPlatformAbstraction; ///< The platform abstraction for retrieving the current time etc.
96   VSyncMonitorInterface*              mVSyncMonitor;        ///< VSyncMonitor interface
97   boost::thread*                      mThread;              ///< The actual thread.
98   const LogOptions&                   mLogOptions;          ///< Log options
99
100 }; // class VSyncNotifier
101
102 } // namespace Adaptor
103
104 } // namespace Internal
105
106 } // namespace Dali
107
108 #endif // __DALI_INTERNAL_VSYNC_NOTIFIER_H__