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 29 namespace SysTuning { 30 namespace TraceStreamer { 31 using namespace SysTuning::base; 32 class AnimationFilter : private FilterBase { 33 public: 34 AnimationFilter(TraceDataCache *dataCache, const TraceStreamerFilters *filter); 35 ~AnimationFilter() override; 36 bool UpdateDeviceInfoEvent(const TracePoint &point, const BytraceLine &line); 37 bool BeginDynamicFrameEvent(const TracePoint &point, size_t callStackRow); 38 bool EndDynamicFrameEvent(uint64_t ts, size_t callStackRow); 39 bool StartAnimationEvent(const BytraceLine &line, const TracePoint &point, size_t callStackRow); 40 bool FinishAnimationEvent(const BytraceLine &line, size_t callStackRow); 41 void UpdateDynamicFrameInfo(); 42 void UpdateFrameInfo(); 43 void Clear(); 44 45 private: 46 bool UpdateDeviceFps(const BytraceLine &line); 47 bool UpdateDeviceScreenSize(const TracePoint &point); 48 bool UpdateDynamicEndTime(const uint64_t curFrameRow, uint64_t curStackRow); 49 const std::regex framePixPattern_ = 50 std::regex(R"(\[(.*?)\]\s*\(\s*-?(\d+),\s*-?(\d+),\s*(\d+),\s*(\d+)\)\s*Alpha:\s+-*(\d+\.\d+))"); 51 // for calculate the frame rate 52 const std::string frameRateCmd_ = "H:GenerateVsyncCount"; 53 // if the realFrameRate present, no calculation is required 54 const std::string realFrameRateCmd_ = "H:RSJankStats::RecordAnimationDynamicFrameRate"; // 动效过程帧率 55 const std::string frameCountCmd_ = "H:Repaint"; 56 const std::string frameBeginCmd_ = "H:RSUniRender::Process:[WindowScene_"; 57 const std::string newFrameBeginCmd_ = "H:RSSurfaceRenderNodeDrawable::OnDraw:[WindowScene_"; // 动效帧数据 58 const std::string frameBeginPrefix_ = "H:RSUniRender::Process:["; 59 const std::string screenSizeCmd_ = "H:RSUniRender::Process:[SCBDesktop"; 60 const std::string newScreenSizeCmd_ = "H:RSSurfaceRenderNodeDrawable::OnDraw:[SCBDesktop"; // 设备分辨率 61 const std::string frameEndTimeCmd_ = "H:RSMainThread::DoComposition"; 62 const std::string paralleCmd_ = "H:PostAndWait, parallel type"; // 并行化标志 63 const std::string renderFrameCmd_ = "H:RenderFrame"; // 并行化后动效帧结束时间相关trace点 64 std::unordered_set<DataIndex> onAnimationStartEvents_ = {}; 65 // for update dynamicFrameInfo at the end, first is callStackRow, second is dynamicFramRow 66 std::deque<uint64_t> callstackWithDynamicFrameRows_ = {}; 67 // for update animationInfo, first is callStackRow, second is animationRow 68 std::unordered_map<uint64_t, uint64_t> animationCallIds_ = {}; 69 // for count number of frames 70 std::unordered_set<uint64_t> frameCountRows_ = {}; 71 std::deque<uint64_t> frameCountEndTimes_ = {}; 72 // for realFrameRate, first is realFrameRateFlag, second is animationRow 73 std::unordered_map<DataIndex, uint64_t> realFrameRateFlagsDict_ = {}; 74 uint64_t generateFirstTime_ = INVALID_UINT64; 75 uint8_t generateVsyncCnt_ = 0; 76 std::deque<uint64_t> parallelRows_ = {}; 77 bool isNewAnimation_ = false; 78 DynamicFrame *dynamicFrame_ = nullptr; 79 CallStack *callStackSlice_ = nullptr; 80 const uint8_t inputTimeIndex_ = 3; 81 }; 82 } // namespace TraceStreamer 83 } // namespace SysTuning 84 #endif // ANIMATION_FILTER_H 85