1 /*
2  * Copyright (C) 2024 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 CODE_EFFECT_TRACE_H
17 #define CODE_EFFECT_TRACE_H
18 
19 #include "hitrace_meter.h"
20 
21 #define PASTE(x, y) x##y
22 #define EFFECT_TRACE_NAME(name) ::OHOS::Media::Effect::EffectTrace \
23     PASTE(__tracer, __LINE__)(HITRACE_TAG_ZIMAGE, name)
24 
25 #define EFFECT_TRACE_CALL() EFFECT_TRACE_NAME(__FUNCTION__)
26 
27 #define EFFECT_TRACE_BEGIN(name) StartTrace(HITRACE_TAG_ZIMAGE, name)
28 #define EFFECT_TRACE_END() FinishTrace(HITRACE_TAG_ZIMAGE)
29 
30 namespace OHOS {
31 namespace Media {
32 namespace Effect {
33 class EffectTrace {
34 public:
EffectTrace(std::uint64_t tag,const std::string & title)35     inline EffectTrace(std::uint64_t tag, const std::string &title) : mTag(tag)
36     {
37         StartTrace(mTag, title);
38     }
39 
~EffectTrace()40     inline ~EffectTrace()
41     {
42         FinishTrace(mTag);
43     }
44 
45 private:
46     std::uint64_t mTag;
47 };
48 } // namespace Effect
49 } // namespace Media
50 } // namespace OHOS
51 
52 
53 #endif // CODE_EFFECT_TRACE_H
54