Add SetTapMaximumAllowedTime
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / performance-logger-impl.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-logger-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/adaptor/common/adaptor-impl.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 namespace
31 {
32 PerformanceInterface* GetPerformanceInterface()
33 {
34   if(Adaptor::IsAvailable())
35   {
36     return Internal::Adaptor::Adaptor::GetImplementation(Adaptor::Get()).GetPerformanceInterface();
37   }
38
39   return NULL;
40 }
41
42 } // Anonymous namespace
43
44 PerformanceLoggerPtr PerformanceLogger::New(const char* name)
45 {
46   PerformanceLoggerPtr logger = new PerformanceLogger(name);
47   return logger;
48 }
49
50 PerformanceLogger::PerformanceLogger(const char* name)
51 : mContext(0)
52 {
53   PerformanceInterface* performance = GetPerformanceInterface();
54   if(performance)
55   {
56     mContext = performance->AddContext(name);
57   }
58 }
59
60 PerformanceLogger::~PerformanceLogger()
61 {
62   PerformanceInterface* performance = GetPerformanceInterface();
63   if(performance)
64   {
65     performance->RemoveContext(mContext);
66   }
67 }
68
69 void PerformanceLogger::AddMarker(Dali::PerformanceLogger::Marker markerType)
70 {
71   PerformanceInterface* performance = GetPerformanceInterface();
72   if(performance)
73   {
74     PerformanceInterface::MarkerType newMarkerType = PerformanceInterface::START;
75     switch(markerType)
76     {
77       case Dali::PerformanceLogger::START_EVENT:
78       {
79         newMarkerType = PerformanceInterface::START;
80         break;
81       }
82       case Dali::PerformanceLogger::END_EVENT:
83       {
84         newMarkerType = PerformanceInterface::END;
85         break;
86       }
87     }
88
89     performance->AddMarker(newMarkerType, mContext);
90   }
91 }
92
93 void PerformanceLogger::SetLoggingFrequency(unsigned int logFrequency)
94 {
95   PerformanceInterface* performance = GetPerformanceInterface();
96   if(performance)
97   {
98     performance->SetLoggingFrequency(logFrequency, mContext);
99   }
100 }
101
102 void PerformanceLogger::EnableLogging(bool enable)
103 {
104   PerformanceInterface* performance = GetPerformanceInterface();
105   if(performance)
106   {
107     performance->EnableLogging(enable, mContext);
108   }
109 }
110
111 } // namespace Adaptor
112
113 } // namespace Internal
114
115 } // namespace Dali