License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-adaptor.git] / adaptors / base / performance-logging / performance-marker.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 "performance-marker.h"
20
21 namespace Dali
22 {
23
24 namespace Internal
25 {
26
27 namespace Adaptor
28 {
29
30 namespace
31 {
32
33 struct NamePair
34 {
35   PerformanceMarker::MarkerType type;
36   const char* name;
37 };
38
39 const NamePair MarkerLookup[] =
40 {
41     { PerformanceMarker::V_SYNC       ,        "V_SYNC"                },
42     { PerformanceMarker::UPDATE_START ,        "UPDATE_START"          },
43     { PerformanceMarker::UPDATE_END   ,        "UPDATE_END"            },
44     { PerformanceMarker::RENDER_START ,        "RENDER_START"          },
45     { PerformanceMarker::RENDER_END   ,        "RENDER_END"            },
46     { PerformanceMarker::SWAP_START   ,        "SWAP_START"            },
47     { PerformanceMarker::SWAP_END     ,        "SWAP_END"              },
48     { PerformanceMarker::PROCESS_EVENTS_START, "PROCESS_EVENT_START"   },
49     { PerformanceMarker::PROCESS_EVENTS_END,   "PROCESS_EVENT_END"     },
50     { PerformanceMarker::PAUSED       ,        "PAUSED"                },
51     { PerformanceMarker::RESUME       ,        "RESUMED"               }
52 };
53 }
54 PerformanceMarker::PerformanceMarker( MarkerType type )
55 :mType(type)
56 {
57 }
58
59 PerformanceMarker::PerformanceMarker( MarkerType type, FrameTimeStamp frameInfo )
60 :mType(type),
61  mTimeStamp(frameInfo)
62 {
63 }
64
65 const char* PerformanceMarker::GetName( ) const
66 {
67   return MarkerLookup[ mType ].name;
68 }
69
70 unsigned int PerformanceMarker::MicrosecondDiff( const PerformanceMarker& start,const PerformanceMarker& end )
71 {
72   return FrameTimeStamp::MicrosecondDiff( start.mTimeStamp, end.mTimeStamp );
73 }
74
75 } // namespace Adaptor
76
77 } // namespace Internal
78
79 } // namespace Dali
80