Merge branch devel/master (1.0.49) into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / base / performance-logging / frame-time-stamp.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "frame-time-stamp.h"
20
21 namespace
22 {
23 const unsigned int MICROSECONDS_PER_SECOND = 1000000; ///< 1000000 microseconds per second
24 }
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 FrameTimeStamp::FrameTimeStamp()
36 : frame(0),
37   seconds(0),
38   microseconds(0),
39   bufferIndex(0)
40 {
41 }
42
43 FrameTimeStamp::FrameTimeStamp(unsigned int frame,
44                                unsigned int seconds,
45                                unsigned int microseconds,
46                                unsigned int bufferIndex)
47 : frame( frame ),
48   seconds( seconds ),
49   microseconds( microseconds ),
50   bufferIndex( bufferIndex )
51 {
52 }
53
54 FrameTimeStamp::FrameTimeStamp(unsigned int bufferIndex )
55 : frame( 0 ),
56   seconds(  0 ),
57   microseconds( 0 ),
58   bufferIndex( bufferIndex )
59 {
60 }
61
62 unsigned int FrameTimeStamp::MicrosecondDiff( const FrameTimeStamp& start,const FrameTimeStamp& end )
63 {
64   int microDiff = end.microseconds - start.microseconds;
65   unsigned int secDiff = ( end.seconds - start.seconds ) * MICROSECONDS_PER_SECOND;
66   return ( microDiff + secDiff);
67 }
68
69 } // namespace Adaptor
70
71 } // namespace Internal
72
73 } // namespace Dali
74