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 #ifndef FPS_H 16 #define FPS_H 17 #include <vector> 18 #include <queue> 19 #include "sp_profiler.h" 20 namespace OHOS { 21 namespace SmartPerf { 22 struct FpsInfo { 23 int fps; 24 int preFps; 25 std::vector<long long> jitters; 26 std::queue<long long> timeStampQ; 27 long long lastFrameReadyTime; 28 long long currentFpsTime; FpsInfoFpsInfo29 FpsInfo() 30 { 31 fps = 0; 32 preFps = 0; 33 lastFrameReadyTime = 0; 34 currentFpsTime = 0; 35 } 36 }; 37 class FPS : public SpProfiler { 38 public: 39 void SetPackageName(std::string pName); 40 void SetCaptureOn(); 41 void SetTraceCatch(); 42 FpsInfo GetFpsInfo(); 43 std::string GetSurface(); 44 std::string GetLayer(std::string pkgSurface); 45 FpsInfo mFpsInfo; GetInstance()46 static FPS &GetInstance() 47 { 48 static FPS instance; 49 return instance; 50 } 51 std::map<std::string, std::string> ItemData() override; 52 53 private: FPS()54 FPS() {}; 55 FPS(const FPS &); 56 FPS &operator = (const FPS &); 57 58 std::string pkgName; 59 std::string curLayerName; 60 int isCatchTrace = 0; 61 int isCapture = 0; 62 FpsInfo GetSurfaceFrame(std::string name); 63 }; 64 65 struct DumpEntity { 66 const std::string windowName; 67 const std::string displayId; 68 const std::string pid; 69 const std::string windId; 70 const std::string zOrd; 71 }; 72 73 } 74 } 75 #endif 76