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 #include "draw/canvas.h" 24 #include "draw/color.h" 25 26 27 namespace OHOS { 28 namespace Rosen { 29 class FramePainter { 30 public: 31 FramePainter(FrameCollector &collector); 32 33 void Draw(Drawing::Canvas &canvas); 34 35 private: 36 struct TimeBar { 37 bool isHeavy = false; 38 uint32_t color = 0; 39 double posX = 0; 40 double posY = 0; 41 double width = 0; 42 double height = 0; 43 }; 44 45 void DrawFPSLine(Drawing::Canvas &canvas, uint32_t fps, double thickness, uint32_t color); 46 std::vector<struct TimeBar> GenerateTimeBars(uint32_t width, uint32_t height, uint32_t fps); 47 double SumTimesInMs(const struct FrameInfo &info); 48 49 FrameCollector &collector_; 50 }; 51 } // namespace Rosen 52 } // namespace OHOS 53 54 #endif // ROSEN_MODULE_FRAME_ANALYZER_EXPORT_FRAME_PAINTER_H 55