[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / 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 <dali/internal/system/common/performance-marker.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 namespace
36 {
37
38 struct NamePair
39 {
40   PerformanceInterface::MarkerType type;
41   const char* const name;
42   PerformanceMarker::MarkerFilter group;
43   PerformanceMarker::MarkerEventType eventType;
44 };
45
46 const NamePair MARKER_LOOKUP[] =
47 {
48     // timed event names must be postfixed with with _START and _END
49     // this is to allow tracers to extract the event name by removing the _START, _END strings
50     //
51     { PerformanceInterface::VSYNC       ,         "V_SYNC"               , PerformanceMarker::V_SYNC_EVENTS, PerformanceMarker::SINGLE_EVENT      },
52     { PerformanceInterface::UPDATE_START ,        "UPDATE_START"         , PerformanceMarker::UPDATE,        PerformanceMarker::START_TIMED_EVENT },
53     { PerformanceInterface::UPDATE_END   ,        "UPDATE_END"           , PerformanceMarker::UPDATE,        PerformanceMarker::END_TIMED_EVENT   },
54     { PerformanceInterface::RENDER_START ,        "RENDER_START"         , PerformanceMarker::RENDER,        PerformanceMarker::START_TIMED_EVENT },
55     { PerformanceInterface::RENDER_END   ,        "RENDER_END"           , PerformanceMarker::RENDER,        PerformanceMarker::END_TIMED_EVENT   },
56     { PerformanceInterface::SWAP_START   ,        "SWAP_START"           , PerformanceMarker::SWAP_BUFFERS,  PerformanceMarker::START_TIMED_EVENT },
57     { PerformanceInterface::SWAP_END     ,        "SWAP_END"             , PerformanceMarker::SWAP_BUFFERS,  PerformanceMarker::END_TIMED_EVENT   },
58     { PerformanceInterface::PROCESS_EVENTS_START, "PROCESS_EVENT_START"  , PerformanceMarker::EVENT_PROCESS, PerformanceMarker::START_TIMED_EVENT },
59     { PerformanceInterface::PROCESS_EVENTS_END,   "PROCESS_EVENT_END"    , PerformanceMarker::EVENT_PROCESS, PerformanceMarker::END_TIMED_EVENT   },
60     { PerformanceInterface::PAUSED       ,        "PAUSED"               , PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT  },
61     { PerformanceInterface::RESUME       ,        "RESUMED"              , PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT  },
62     { PerformanceInterface::START        ,        "START"                , PerformanceMarker::CUSTOM_EVENTS, PerformanceMarker::START_TIMED_EVENT  },
63     { PerformanceInterface::END          ,        "END"                  , PerformanceMarker::CUSTOM_EVENTS, PerformanceMarker::END_TIMED_EVENT  }
64 };
65 } // un-named namespace
66
67
68
69 PerformanceMarker::PerformanceMarker( PerformanceInterface::MarkerType type )
70 :mType(type)
71 {
72 }
73
74 PerformanceMarker::PerformanceMarker( PerformanceInterface::MarkerType type, FrameTimeStamp frameInfo )
75 :mType(type),
76  mTimeStamp(frameInfo)
77 {
78 }
79
80 const char* PerformanceMarker::GetName( ) const
81 {
82   return MARKER_LOOKUP[ mType ].name;
83 }
84
85 PerformanceMarker::MarkerEventType PerformanceMarker::GetEventType() const
86 {
87   return MARKER_LOOKUP[ mType ].eventType;
88 }
89
90 PerformanceMarker::MarkerFilter PerformanceMarker::GetFilterType() const
91 {
92   return MARKER_LOOKUP[ mType ].group;
93 }
94
95 unsigned int PerformanceMarker::MicrosecondDiff( const PerformanceMarker& start,const PerformanceMarker& end )
96 {
97   return FrameTimeStamp::MicrosecondDiff( start.mTimeStamp, end.mTimeStamp );
98 }
99
100 bool PerformanceMarker::IsFilterEnabled( MarkerFilter filter ) const
101 {
102   return  (filter & MARKER_LOOKUP[ mType ].group);
103 }
104
105
106 } // namespace Adaptor
107
108 } // namespace Internal
109
110 } // namespace Dali
111