• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef RENDER_PERF_CPU_PERF_SCOPE_H
16 #define RENDER_PERF_CPU_PERF_SCOPE_H
17 
18 #include <core/perf/cpu_perf_scope.h>
19 
20 #if defined(CORE_PERF_ENABLED) && (CORE_PERF_ENABLED == 1)
21 CORE_BEGIN_NAMESPACE()
22 template<>
23 struct CORE_NS::PerformanceTraceSubsystem<2> {
24     static constexpr bool IsEnabled()
25     {
26 #if (RENDER_PERF_ENABLED == 1)
27         return true;
28 #else
29         return false;
30 #endif
31     }
32 };
33 CORE_END_NAMESPACE()
34 
35 RENDER_BEGIN_NAMESPACE()
36 using PROFILER_SUBSYSTEM_RENDERER = CORE_NS::PerformanceTraceSubsystem<2>;
37 RENDER_END_NAMESPACE()
38 #endif
39 
40 constexpr uint32_t RENDER_PROFILER_DEFAULT_COLOR { 0xff5c00 };
41 #define RENDER_CPU_PERF_BEGIN(timerName, subCategory, name, ...)                                    \
42     CORE_PROFILER_PERF_BEGIN(timerName, "RENDER", subCategory, name, RENDER_PROFILER_DEFAULT_COLOR, \
43         RENDER_NS::PROFILER_SUBSYSTEM_RENDERER, ##__VA_ARGS__)
44 #define RENDER_CPU_PERF_END(timerName) CORE_PROFILER_PERF_END(timerName)
45 #define RENDER_CPU_PERF_SCOPE(subCategory, name, ...)                                    \
46     CORE_PROFILER_PERF_SCOPE("RENDER", subCategory, name, RENDER_PROFILER_DEFAULT_COLOR, \
47         RENDER_NS::PROFILER_SUBSYSTEM_RENDERER, ##__VA_ARGS__)
48 
49 #endif