• 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 #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 GetLayer(std::string pkgSurface);
44     FpsInfo mFpsInfo;
GetInstance()45     static FPS &GetInstance()
46     {
47         static FPS instance;
48         return instance;
49     }
50     std::map<std::string, std::string> ItemData() override;
51 
52 private:
FPS()53     FPS() {};
54     FPS(const FPS &);
55     FPS &operator = (const FPS &);
56 
57     std::string pkgName;
58     std::string curLayerName;
59     int isCatchTrace = 0;
60     int isCapture = 0;
61     FpsInfo GetSurfaceFrame(std::string name);
62 };
63 
64 struct DumpEntity {
65     const std::string windowName;
66     const std::string displayId;
67     const std::string pid;
68     const std::string windId;
69     const std::string zOrd;
70 };
71 
72 }
73 }
74 #endif
75