1 /* 2 * Copyright (c) 2021 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 FRAME_FILTER_H 17 #define FRAME_FILTER_H 18 #include <vector> 19 #include "double_map.h" 20 #include "filter_base.h" 21 #include "trace_data_cache.h" 22 #include "trace_streamer_filters.h" 23 namespace SysTuning { 24 namespace TraceStreamer { 25 class FrameFilter : private FilterBase { 26 public: 27 FrameFilter(TraceDataCache* dataCache, const TraceStreamerFilters* filter); 28 ~FrameFilter() override; 29 void BeginVsyncEvent(uint64_t ts, 30 uint32_t ipid, 31 uint32_t itid, 32 uint64_t expectStart, 33 uint64_t expectEnd, 34 uint32_t vsyncId, 35 uint32_t callStackSliceId); 36 bool MarkRSOnDoCompositionEvent(uint64_t ts, uint32_t itid); 37 bool BeginRSTransactionData(uint64_t ts, uint32_t itid, uint32_t franeNum); 38 typedef struct { 39 uint32_t sourceItid; 40 uint32_t frameNum; 41 } FrameMap; 42 bool BeginProcessCommandUni(uint64_t ts, uint32_t itid, const std::vector<FrameMap>& frame, uint32_t sliceIndex); 43 bool EndVsyncEvent(uint64_t ts, uint32_t itid); 44 bool StartFrameQueue(uint64_t ts, uint32_t itid); 45 bool EndFrameQueue(uint64_t ts, uint32_t itid); 46 void Clear(); 47 48 private: 49 class FrameSlice { 50 public: FrameSlice()51 FrameSlice() {} 52 uint64_t startTs_ = INVALID_UINT64; 53 // @deprecated it will be deleted later 54 uint64_t expectedStartTs_ = INVALID_UINT64; 55 // if a frame experience video lag, is depend on if the real end ts is later then the expected ts, rather then 56 // the dur. noted at 2023/4/6 57 uint64_t expectedEndTs_ = INVALID_UINT64; 58 // @deprecated it will be deleted later 59 uint64_t expectedDur_ = INVALID_UINT64; 60 uint64_t endTs_ = INVALID_UINT64; 61 bool gpuEnd_ = true; 62 TraceStdtype::FrameSlice::FrameSliceType frameType_ = TraceStdtype::FrameSlice::ACTURAL_SLICE; 63 uint32_t vsyncId_ = INVALID_UINT32; 64 uint64_t frameQueueStartTs_ = INVALID_UINT64; 65 bool vsyncEnd_ = false; 66 bool isRsMainThread_ = false; 67 uint32_t frameNum_ = INVALID_UINT32; 68 uint64_t callStackSliceId_ = INVALID_UINT64; 69 uint64_t frameSliceRow_ = INVALID_UINT64; 70 uint64_t frameExpectedSliceRow_ = INVALID_UINT64; 71 std::vector<uint64_t> sourceSlice_ = {}; 72 std::vector<uint64_t> sourceExpectedSlice_ = {}; 73 uint64_t dstFrameSliceId_ = INVALID_UINT64; 74 uint64_t dstExpectedFrameSliceId_ = INVALID_UINT64; 75 }; 76 std::unordered_map<uint32_t /* tid */, std::vector<std::shared_ptr<FrameSlice>>> vsyncRenderSlice_ = {}; 77 std::unordered_map<uint32_t /* tid */, std::unordered_map<uint32_t /* frameNum */, std::shared_ptr<FrameSlice>>> 78 dstRenderSlice_ = {}; 79 }; 80 } // namespace TraceStreamer 81 } // namespace SysTuning 82 #endif 83