[dali_1.0.1] Merge branch 'tizen'
[platform/core/uifw/dali-adaptor.git] / adaptors / common / vsync-monitor.h
1 #ifndef __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
2 #define __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
3
4 /*
5  * Copyright (c) 2014 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 // EXTERNAL INCLUDES
22 #include <xf86drm.h>
23
24 // INTERNAL INCLUDES
25 #include <base/interfaces/vsync-monitor-interface.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace Adaptor
34 {
35
36 /**
37  * Tizen interface for monitoring VSync
38  */
39 class VSyncMonitor : public VSyncMonitorInterface
40 {
41 public:
42   /**
43    * Default constructor
44    */
45   VSyncMonitor();
46
47   /**
48    * Destructor
49    */
50   virtual ~VSyncMonitor();
51
52 public:
53
54   /**
55    * Set the use hardware flag
56    * @param[in] useHardware The new state for the use hardware flag.
57    */
58   void SetUseHardware( bool useHardware );
59
60 private: // From Dali::Internal::Adaptor::VSyncMonitorInterface
61
62   /**
63    * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Initialize
64    */
65   virtual void Initialize();
66
67   /**
68    * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Terminate
69    */
70   virtual void Terminate();
71
72   /**
73    * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::UseHardware
74    */
75   virtual bool UseHardware();
76
77   /**
78    * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::DoSync
79    */
80   virtual bool DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds );
81
82 private:
83
84   int       mFileDescriptor;  ///< DRM dev node file descriptor
85   drmVBlank mVBlankInfo;
86   bool      mUseHardware;     ///< Hardware VSyncs available flag
87
88 };
89
90 } // namespace Adaptor
91
92 } // namespace Internal
93
94 } // namespace Dali
95
96 #endif // __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__