1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 ANIMATION_FILTER_H 17 #define ANIMATION_FILTER_H 18 19 #include <unordered_map> 20 #include <unordered_set> 21 22 #include "clock_filter_ex.h" 23 #include "common_types.h" 24 #include "filter_base.h" 25 #include "string_help.h" 26 #include "string_to_numerical.h" 27 #include "trace_streamer_filters.h" 28 #include "config_filter.h" 29 30 namespace SysTuning { 31 namespace TraceStreamer { 32 using namespace SysTuning::base; 33 class AnimationFilter : private FilterBase { 34 public: 35 AnimationFilter(TraceDataCache *dataCache, const TraceStreamerFilters *filter); 36 ~AnimationFilter() override; 37 bool UpdateDeviceInfoEvent(const TracePoint &point, const BytraceLine &line); 38 bool BeginDynamicFrameEvent(const TracePoint &point, size_t callStackRow); 39 bool EndDynamicFrameEvent(uint64_t ts, size_t callStackRow); 40 bool StartAnimationEvent(const BytraceLine &line, const TracePoint &point, size_t callStackRow); 41 bool FinishAnimationEvent(const BytraceLine &line, size_t callStackRow); 42 void UpdateDynamicFrameInfo(); 43 void UpdateFrameInfo(); 44 void InitAnimationStartEvents(); 45 void Clear(); 46 47 private: 48 bool UpdateDeviceFps(const BytraceLine &line); 49 bool UpdateDeviceScreenSize(const TracePoint &point); 50 bool UpdateDynamicEndTime(const uint64_t curFrameRow, uint64_t curStackRow); 51 const std::regex framePixPattern_ = 52 std::regex(R"(\[(.*?)\]\s*\(\s*-?(\d+),\s*-?(\d+),\s*(\d+),\s*(\d+)\)\s*Alpha:\s+-*(\d+\.\d+))"); 53 // for calculate the frame rate 54 const std::string frameEndTimeCmd_ = "H:RSMainThread::DoComposition"; 55 std::unordered_set<DataIndex> onAnimationStartEvents_ = {}; 56 // for update dynamicFrameInfo at the end, first is callStackRow, second is dynamicFramRow 57 std::deque<uint64_t> callstackWithDynamicFrameRows_ = {}; 58 // for update animationInfo, first is callStackRow, second is animationRow 59 std::unordered_map<uint64_t, uint64_t> animationCallIds_ = {}; 60 // for count number of frames 61 std::unordered_set<uint64_t> frameCountRows_ = {}; 62 std::deque<uint64_t> frameCountEndTimes_ = {}; 63 // for realFrameRate, first is realFrameRateFlag, second is animationRow 64 std::unordered_map<DataIndex, uint64_t> realFrameRateFlagsDict_ = {}; 65 uint64_t generateFirstTime_ = INVALID_UINT64; 66 uint8_t generateVsyncCnt_ = 0; 67 std::deque<uint64_t> parallelRows_ = {}; 68 bool isNewAnimation_ = false; 69 DynamicFrame *dynamicFrame_ = nullptr; 70 CallStack *callStackSlice_ = nullptr; 71 const uint8_t inputTimeIndex_ = 3; 72 }; 73 } // namespace TraceStreamer 74 } // namespace SysTuning 75 #endif // ANIMATION_FILTER_H 76