• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef ANIMATOR_SCENE_DATA_PROCESSOR_H
16 #define ANIMATOR_SCENE_DATA_PROCESSOR_H
17 
18 #include <string>
19 #include <map>
20 #include <iostream>
21 #include "XperfEvt.h"
22 #include "IAnimatorSceneDataProcessor.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 using AnimatorRecord = IAnimatorSceneDataProcessor::AnimatorRecord;
27 using AnimatorMetrics = IAnimatorSceneDataProcessor::AnimatorMetrics;
28 
29 class AnimatorSceneDataProcessor : public IAnimatorSceneDataProcessor {
30 public:
31     void ProcessSceneData(std::shared_ptr<XperfEvt> evt) override;
32     void SetCb(IAnimatorSceneDataProcessor::MetricReporter* cb);
33 
34 private:
35     IAnimatorSceneDataProcessor::MetricReporter* cb;
36     std::map<int32_t, AnimatorRecord*> db;
37     int32_t focusWindowPid{0};
38     std::string focusBundleName{""};
39 
40     void CreateRecord(std::shared_ptr<XperfEvt> evt, int32_t indexPoint) override;
41     void DeleteRecord(const int32_t uniqueId) override;
42     bool HasStartPoint(std::shared_ptr<XperfEvt> evt);
43     bool AllPointsReceived(std::shared_ptr<XperfEvt> evt);
44     void SaveAnimatorPoint(std::shared_ptr<XperfEvt> evt, int32_t indexPoint);
45     AnimatorMetrics CalcMetrics(const AnimatorRecord& record);
46     void Report(const AnimatorMetrics& metrics);
47     AnimatorRecord* GetRecord(const int32_t uniqueId);
48     void HandleTimeOutPoints();
49     void CacheFocusWindowPid(std::shared_ptr<XperfEvt> evt);
50 };
51 } // HiviewDFX
52 } // OHOS
53 #endif