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 using AnimatorRecord = IAnimatorSceneDataProcessor::AnimatorRecord; 25 using AnimatorMetrics = IAnimatorSceneDataProcessor::AnimatorMetrics; 26 27 class AnimatorSceneDataProcessor : public IAnimatorSceneDataProcessor { 28 public: 29 void ProcessSceneData(std::shared_ptr<XperfEvt> evt) override; 30 void SetCb(IAnimatorSceneDataProcessor::MetricReporter* cb); 31 32 private: 33 IAnimatorSceneDataProcessor::MetricReporter* cb; 34 std::map<int32_t, AnimatorRecord*> db; 35 int32_t focusWindowPid{0}; 36 std::string focusBundleName{""}; 37 38 void CreateRecord(std::shared_ptr<XperfEvt> evt, int32_t indexPoint) override; 39 void DeleteRecord(const int32_t uniqueId) override; 40 bool HasStartPoint(std::shared_ptr<XperfEvt> evt); 41 bool AllPointsReceived(std::shared_ptr<XperfEvt> evt); 42 void SaveAnimatorPoint(std::shared_ptr<XperfEvt> evt, int32_t indexPoint); 43 AnimatorMetrics CalcMetrics(const AnimatorRecord& record); 44 void Report(const AnimatorMetrics& metrics); 45 AnimatorRecord* GetRecord(const int32_t uniqueId); 46 void HandleTimeOutPoints(); 47 void CacheFocusWindowPid(std::shared_ptr<XperfEvt> evt); 48 }; 49 #endif