1 /* 2 * Copyright (c) 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 #include "window_frame_trace.h" 17 #include <unistd.h> 18 #ifdef FRAME_TRACE_ENABLE 19 #include "frame_trace.h" 20 #endif 21 22 namespace FRAME_TRACE { 23 GetInstance()24WindowFrameTraceImpl* WindowFrameTraceImpl::GetInstance() 25 { 26 static WindowFrameTraceImpl ftWindow; 27 return &ftWindow; 28 } 29 #ifdef FRAME_TRACE_ENABLE AccessFrameTrace()30bool WindowFrameTraceImpl::AccessFrameTrace() 31 { 32 return true; 33 } 34 VsyncStartFrameTrace()35void WindowFrameTraceImpl::VsyncStartFrameTrace() 36 { 37 if (!AccessFrameTrace()) { 38 return; 39 } 40 if (FrameAwareTraceEnable(intervalName_)) { 41 if (handleUI_ == nullptr) { 42 handleUI_ = CreateTraceTag(intervalName_); 43 } 44 if (handleUI_ != nullptr) { 45 EnableTraceForThread(handleUI_); 46 StartFrameTrace(handleUI_); 47 } 48 } 49 } 50 VsyncStopFrameTrace()51void WindowFrameTraceImpl::VsyncStopFrameTrace() 52 { 53 if (!AccessFrameTrace()) { 54 return; 55 } 56 if (FrameAwareTraceEnable(intervalName_)) { 57 if (handleUI_ != nullptr) { 58 StopFrameTrace(handleUI_); 59 } 60 } 61 } 62 #endif 63 } // namespace FRAME_TRACE 64