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