1 /* 2 * Copyright (c) 2023 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 DRAWING_PLAYBACK_H 17 #define DRAWING_PLAYBACK_H 18 19 #include <chrono> 20 #include <unistd.h> 21 #include <sys/stat.h> 22 #include <sys/mman.h> 23 24 #include <message_parcel.h> 25 #include "pipeline/rs_draw_cmd_list.h" 26 27 #include "benchmark.h" 28 #include "drawing_command.h" 29 #include "skia_recording.h" 30 31 namespace OHOS { 32 namespace Rosen { 33 class DrawingDCL : public BenchMark { 34 public: DrawingDCL()35 DrawingDCL() { std::cout << "DrawingDCL" << std::endl; } 36 DrawingDCL(int32_t argc, char* argv[]); 37 ~DrawingDCL(); 38 bool GetDirectionAndStep(std::string command, bool &isMoreOps); 39 bool IterateFrame(int &curLoop, int &frame); 40 bool PlayBackByFrame(SkCanvas *skiaCanvas, bool isDumpPictures = false); 41 bool PlayBackByOpItem(SkCanvas *skiaCanvas, bool isMoreOps = true); 42 void UpdateParameters(bool notNeeded); 43 void UpdateParametersFromDCLCommand(const DCLCommand& dclCommand); 44 void PrintDurationTime(const std::string &description, std::chrono::time_point<std::chrono::system_clock> start); Start()45 void Start() override {}; Stop()46 void Stop() override {}; 47 void Test(SkCanvas *canvas, int width, int height) override; 48 void Output() override; 49 int LoadDrawCmdList(const std::string& dclFile); 50 std::string GetRealPathStr(const std::string& filePath); 51 bool IsValidFile(const std::string& realPathStr); 52 53 private: 54 friend class DCLCommand; 55 const static size_t recordingParcelMaxCapcity_ = 234 * 1000 * 1024; 56 inline const static std::string dclFileDir_ = "/data/"; 57 DrawCmdList* dcl_ = nullptr; 58 IterateType iterateType = IterateType::ITERATE_FRAME; 59 int beginFrame_ = 0; 60 int endFrame_ = 100; 61 int loop_ = 1; 62 double opItemStep_ = 1; 63 std::string inputFilePath_ = "/data/lkx/"; 64 std::string outputFilePath_ = "/data/lkx/"; 65 SkiaRecording skiaRecording; 66 }; 67 } 68 } 69 70 #endif