• 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 ROSEN_MODULE_FRAME_ANALYZER_EXPORT_FRAME_PAINTER_H
17 #define ROSEN_MODULE_FRAME_ANALYZER_EXPORT_FRAME_PAINTER_H
18 
19 #include "frame_collector.h"
20 
21 #include <vector>
22 
23 #ifdef USE_ROSEN_DRAWING
24 #include "draw/canvas.h"
25 #include "draw/color.h"
26 #endif
27 
28 #ifndef USE_ROSEN_DRAWING
29 class SkCanvas;
30 #endif
31 
32 namespace OHOS {
33 namespace Rosen {
34 class FramePainter {
35 public:
36     FramePainter(FrameCollector &collector);
37 
38 #ifndef USE_ROSEN_DRAWING
39     void Draw(SkCanvas &canvas);
40 #else
41     void Draw(Drawing::Canvas &canvas);
42 #endif
43 
44 private:
45     struct TimeBar {
46         bool isHeavy = false;
47         uint32_t color = 0;
48         double posX = 0;
49         double posY = 0;
50         double width = 0;
51         double height = 0;
52     };
53 
54 #ifndef USE_ROSEN_DRAWING
55     void DrawFPSLine(SkCanvas &canvas, uint32_t fps, double thickness, uint32_t color);
56 #else
57     void DrawFPSLine(Drawing::Canvas &canvas, uint32_t fps, double thickness, uint32_t color);
58 #endif
59     std::vector<struct TimeBar> GenerateTimeBars(uint32_t width, uint32_t height, uint32_t fps);
60     double SumTimesInMs(const struct FrameInfo &info);
61 
62     FrameCollector &collector_;
63 };
64 } // namespace Rosen
65 } // namespace OHOS
66 
67 #endif // ROSEN_MODULE_FRAME_ANALYZER_EXPORT_FRAME_PAINTER_H
68