• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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     // for calculate the frame rate
50     const std::string frameRateCmd_ = "H:GenerateVsyncCount";
51     // if the realFrameRate present, no calculation is required
52     const std::string realFrameRateCmd_ = "H:RSJankStats::RecordAnimationDynamicFrameRate";
53     const std::string frameBeginCmd_ = "H:RSUniRender::Process:[WindowScene_";
54     const std::string frameCountCmd_ = "H:Repaint";
55     const std::string frameBeginPrefix_ = "H:RSUniRender::Process:[";
56     const std::string screenSizeCmd_ = "H:RSUniRender::Process:[SCBDesktop";
57     const DataIndex frameEndTimeCmd_ = traceDataCache_->GetDataIndex("H:RSMainThread::DoComposition");
58     std::unordered_set<DataIndex> onAnimationStartEvents_ = {};
59     // for update dynamicFrameInfo at the end, first is callStackRow, second is dynamicFramRow
60     std::map<uint64_t, uint64_t> callStackRowMap_ = {};
61     // for update animationInfo, first is callStackRow, second is animationRow
62     std::unordered_map<uint64_t, uint64_t> animationCallIds_ = {};
63     // for count number of frames
64     std::unordered_set<uint64_t> frameCountRows_ = {};
65     std::deque<uint64_t> frameCountEndTimes_ = {};
66     // for realFrameRate, first is realFrameRateFlag, second is animationRow
67     std::unordered_map<DataIndex, uint64_t> realFrameRateFlagsDict_ = {};
68     uint64_t generateFirstTime_ = INVALID_UINT64;
69     uint8_t generateVsyncCnt_ = 0;
70     DynamicFrame* dynamicFrame_ = nullptr;
71     CallStack* callStackSlice_ = nullptr;
72     const uint8_t inputTimeIndex_ = 3;
73 };
74 } // namespace TraceStreamer
75 } // namespace SysTuning
76 #endif // ANIMATION_FILTER_H
77