1 /* 2 * Copyright (c) 2022-2023 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 16 #ifndef RENDER_SERVICE_BASE_COMMON_OPTIONAL_TRACE 17 #define RENDER_SERVICE_BASE_COMMON_OPTIONAL_TRACE 18 19 #include "rs_trace.h" 20 #include "platform/common/rs_system_properties.h" 21 22 #define RS_OPTIONAL_TRACE_BEGIN(name) \ 23 do { \ 24 if (Rosen::RSSystemProperties::GetDebugTraceEnabled()) { \ 25 RS_TRACE_BEGIN(name); \ 26 } \ 27 } while (0) 28 29 #define RS_OPTIONAL_TRACE_END() \ 30 do { \ 31 if (Rosen::RSSystemProperties::GetDebugTraceEnabled()) { \ 32 RS_TRACE_END(); \ 33 } \ 34 } while (0) 35 36 #define RS_OPTIONAL_TRACE_FUNC_BEGIN() \ 37 do { \ 38 if (Rosen::RSSystemProperties::GetDebugTraceEnabled()) { \ 39 RS_TRACE_BEGIN(__func__); \ 40 } \ 41 } while (0) 42 43 #define RS_OPTIONAL_TRACE_FUNC_END() RS_OPTIONAL_TRACE_END() 44 45 #define RS_OPTIONAL_TRACE_NAME(name) \ 46 do { \ 47 if (Rosen::RSSystemProperties::GetDebugTraceEnabled()) { \ 48 RS_TRACE_NAME(name); \ 49 } \ 50 } while (0) 51 52 #define RS_OPTIONAL_TRACE_NAME_FMT(fmt, ...) \ 53 do { \ 54 if (Rosen::RSSystemProperties::GetDebugTraceEnabled()) { \ 55 HITRACE_METER_FMT(HITRACE_TAG_GRAPHIC_AGP, fmt, ##__VA_ARGS__); \ 56 } \ 57 } while (0) 58 59 #endif // RENDER_SERVICE_BASE_COMMON_OPTIONAL_TRACE