Merge "atspi: remove undefined method" into devel/master
[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 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 namespace
31 {
32 struct NamePair
33 {
34   PerformanceInterface::MarkerType   type;
35   const char* const                  name;
36   PerformanceMarker::MarkerFilter    group;
37   PerformanceMarker::MarkerEventType eventType;
38 };
39
40 // clang-format off
41 const NamePair MARKER_LOOKUP[] =
42 {
43     // timed event names must be postfixed with with _START and _END
44     // this is to allow tracers to extract the event name by removing the _START, _END strings
45     //
46     {PerformanceInterface::VSYNC,                "V_SYNC",              PerformanceMarker::V_SYNC_EVENTS,     PerformanceMarker::SINGLE_EVENT     },
47     {PerformanceInterface::UPDATE_START,         "UPDATE_START",        PerformanceMarker::UPDATE,            PerformanceMarker::START_TIMED_EVENT},
48     {PerformanceInterface::UPDATE_END,           "UPDATE_END",          PerformanceMarker::UPDATE,            PerformanceMarker::END_TIMED_EVENT  },
49     {PerformanceInterface::RENDER_START,         "RENDER_START",        PerformanceMarker::RENDER,            PerformanceMarker::START_TIMED_EVENT},
50     {PerformanceInterface::RENDER_END,           "RENDER_END",          PerformanceMarker::RENDER,            PerformanceMarker::END_TIMED_EVENT  },
51     {PerformanceInterface::SWAP_START,           "SWAP_START",          PerformanceMarker::SWAP_BUFFERS,      PerformanceMarker::START_TIMED_EVENT},
52     {PerformanceInterface::SWAP_END,             "SWAP_END",            PerformanceMarker::SWAP_BUFFERS,      PerformanceMarker::END_TIMED_EVENT  },
53     {PerformanceInterface::PROCESS_EVENTS_START, "PROCESS_EVENT_START", PerformanceMarker::EVENT_PROCESS,     PerformanceMarker::START_TIMED_EVENT},
54     {PerformanceInterface::PROCESS_EVENTS_END,   "PROCESS_EVENT_END",   PerformanceMarker::EVENT_PROCESS,     PerformanceMarker::END_TIMED_EVENT  },
55     {PerformanceInterface::PAUSED,               "PAUSED",              PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT     },
56     {PerformanceInterface::RESUME,               "RESUMED",             PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT     },
57     {PerformanceInterface::START,                "START",               PerformanceMarker::CUSTOM_EVENTS,     PerformanceMarker::START_TIMED_EVENT},
58     {PerformanceInterface::END,                  "END",                 PerformanceMarker::CUSTOM_EVENTS,     PerformanceMarker::END_TIMED_EVENT  }
59 };
60 // clang-format on
61 } // namespace
62
63 PerformanceMarker::PerformanceMarker(PerformanceInterface::MarkerType type)
64 : mType(type)
65 {
66 }
67
68 PerformanceMarker::PerformanceMarker(PerformanceInterface::MarkerType type, FrameTimeStamp frameInfo)
69 : mType(type),
70   mTimeStamp(frameInfo)
71 {
72 }
73
74 const char* PerformanceMarker::GetName() const
75 {
76   return MARKER_LOOKUP[mType].name;
77 }
78
79 PerformanceMarker::MarkerEventType PerformanceMarker::GetEventType() const
80 {
81   return MARKER_LOOKUP[mType].eventType;
82 }
83
84 PerformanceMarker::MarkerFilter PerformanceMarker::GetFilterType() const
85 {
86   return MARKER_LOOKUP[mType].group;
87 }
88
89 unsigned int PerformanceMarker::MicrosecondDiff(const PerformanceMarker& start, const PerformanceMarker& end)
90 {
91   return FrameTimeStamp::MicrosecondDiff(start.mTimeStamp, end.mTimeStamp);
92 }
93
94 bool PerformanceMarker::IsFilterEnabled(MarkerFilter filter) const
95 {
96   return (filter & MARKER_LOOKUP[mType].group);
97 }
98
99 } // namespace Adaptor
100
101 } // namespace Internal
102
103 } // namespace Dali