1 /*
2 * Copyright (c) 2025 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 #include "rs_graphic_test_profiler.h"
17
18 #include "rs_graphic_test_director.h"
19 #include "rs_graphic_test_utils.h"
20 #include "rs_parameter_parse.h"
21 #include "rs_trace.h"
22 #include "transaction/rs_interfaces.h"
23 #include "ui/rs_root_node.h"
24 #include "ui/rs_surface_node.h"
25
26 #include <charconv>
27 #include <chrono>
28 #include <fstream>
29 #include <filesystem>
30 #include <iostream>
31 #include <sstream>
32 #include <thread>
33
34 using namespace std;
35 namespace OHOS {
36 namespace Rosen {
37 constexpr uint32_t SURFACE_COLOR = 0xffffffff;
38 constexpr int FLUSH_RS_WAIT_TIME = 500;
39 constexpr int LOAD_STATIC_WAIT_TIME = 3000;
40 constexpr int NORMAL_WAIT_TIME = 1000;
41 constexpr int PLAYBACK_PREPARE_OUT_TIME = 10000;
42 constexpr int PLAYBACK_PAUSE_OUT_TIME = 5000;
43 constexpr int PLAYBACK_OPERATE_INTERVAL_TIME = 100;
44 constexpr int SCREEN_WIDTH = 1316;
45 constexpr int SCREEN_HEIGHT = 2832;
46 constexpr int FRAME_WIDTH_NUM = 6;
47 const std::string SAVE_IMAGE_PATH_NAME = "ScreenShot";
48 const std::string OHR_CONFIG_FILE_NAME = "ohr_config.json";
49 //json config
50 const std::string OHR_LIST = "ohr_list";
51 const std::string OHR_NAME = "fileName";
52 const std::string OHR_START_TIME = "startTime";
53 const std::string OHR_END_TIME = "endTime";
54 const std::string OHR_TIME_INTERVAL = "timeInterval";
55 constexpr int OHR_INFO_NUM = 4;
56 //dump buffer
57 constexpr uint32_t CROP_X = 0;
58 constexpr uint32_t CROP_Y = 0;
59 constexpr uint32_t ALIGNMENT = 256;
60 constexpr uint32_t RGBA8888_FORMAT = 12;
61
SafeSystem(const std::string & cmd,const std::string & errorMsg)62 void SafeSystem(const std::string& cmd, const std::string& errorMsg)
63 {
64 int result = std::system(cmd.c_str());
65 if (result != 0) {
66 std::cout << "SafeSystem Error:" << errorMsg << "(code:" << result << ")"<< std::endl;
67 }
68 }
69
SetUseBufferDump(bool useBufferDump)70 void RSGraphicTestProfiler::SetUseBufferDump(bool useBufferDump)
71 {
72 useBufferDump_ = useBufferDump;
73 }
74
RunNodeTreeTest(const std::string & path)75 int RSGraphicTestProfiler::RunNodeTreeTest(const std::string& path)
76 {
77 if (!std::filesystem::exists(path)) {
78 std::cout << "root path is not exist :" << path << std::endl;
79 return 0;
80 }
81 NodeTreeTestSetUp();
82
83 runTestCaseNum_ = 0;
84 rootPath_ = path;
85 std::filesystem::path imagePath = GetImageSavePath();
86 for (const auto& entry : std::filesystem::directory_iterator(rootPath_)) {
87 const std::string fileName = entry.path().filename();
88 if (fileName == SAVE_IMAGE_PATH_NAME) {
89 continue;
90 }
91 std::filesystem::path target = imagePath / fileName;
92 if (entry.is_directory()) {
93 std::filesystem::create_directories(target);
94 CopyDirectoryAndLoadNodeTreeFile(entry.path(), target);
95 } else {
96 LoadNodeTreeProfilerFile(entry.path(), target);
97 }
98 }
99 TearDown();
100 // NOT MODIFY THE COMMENTS
101 cout << "[ PASSED ] " << runTestCaseNum_ << " test." << std::endl;
102 return 1;
103 }
104
MakePlaybackSaveDirectories(const std::string & path)105 std::string MakePlaybackSaveDirectories(const std::string& path)
106 {
107 size_t lastSlashPos = path.find_last_of('/');
108 std::string fileNameExt = path.substr(lastSlashPos + 1);
109
110 size_t dotPos = fileNameExt.find('.');
111 std::string fileName = fileNameExt.substr(0, dotPos);
112
113 return path.substr(0, lastSlashPos + 1) + fileName + "/" + fileNameExt;
114 }
115
AnalysePlaybackInfo(const std::filesystem::path & rootPath,const std::filesystem::path & imagePath,const cJSON * root)116 void RSGraphicTestProfiler::AnalysePlaybackInfo(
117 const std::filesystem::path& rootPath, const std::filesystem::path& imagePath, const cJSON* root)
118 {
119 cJSON* item = root->child;
120 PlaybackInfo info;
121 int checkNum = 0;
122 while (item != nullptr) {
123 if (strcmp(item->string, OHR_NAME.c_str()) == 0 && cJSON_IsString(item)) {
124 info.fileName = item->valuestring;
125 checkNum++;
126 } else if (strcmp(item->string, OHR_START_TIME.c_str()) == 0 && cJSON_IsNumber(item)) {
127 info.startTime = item->valueint;
128 checkNum++;
129 } else if (strcmp(item->string, OHR_END_TIME.c_str()) == 0 && cJSON_IsNumber(item)) {
130 info.endTime = item->valueint;
131 checkNum++;
132 } else if (strcmp(item->string, OHR_TIME_INTERVAL.c_str()) == 0 && cJSON_IsNumber(item)) {
133 info.timeInterval = item->valueint;
134 checkNum++;
135 }
136 item = item->next;
137 }
138 if (checkNum != OHR_INFO_NUM) {
139 std::cout << "playback info param num error!" << std::endl;
140 return;
141 }
142 std::filesystem::path filePath = rootPath / info.fileName;
143 std::filesystem::path savePath = imagePath / MakePlaybackSaveDirectories(info.fileName);
144 if (!std::filesystem::exists(filePath)) {
145 std::cout << "playback file is not exist:" << filePath << std::endl;
146 return;
147 }
148 if (savePath.has_parent_path()) {
149 std::filesystem::create_directories(savePath.parent_path());
150 }
151 LoadPlaybackProfilerFile(filePath, savePath, info);
152 }
153
ParseFileConfig(const std::string & path)154 cJSON* ParseFileConfig(const std::string& path)
155 {
156 std::ifstream configFile;
157 configFile.open(path);
158 std::stringstream configStream;
159 configStream << configFile.rdbuf();
160 configFile.close();
161 std::string configString = configStream.str();
162
163 cJSON* rootData = cJSON_Parse(configString.c_str());
164 return rootData;
165 }
166
RunPlaybackTest(const std::string & filePath)167 int RSGraphicTestProfiler::RunPlaybackTest(const std::string& filePath)
168 {
169 if (!std::filesystem::exists(filePath)) {
170 std::cout << "filePath is not exist :" << filePath << std::endl;
171 return 0;
172 }
173
174 PlaybackTestSetUp();
175 runTestCaseNum_ = 0;
176 rootPath_ = filePath;
177 std::filesystem::path rootPath = rootPath_;
178 std::filesystem::path imagePath = GetImageSavePath();
179
180 std::filesystem::path configPath = rootPath / OHR_CONFIG_FILE_NAME;
181 if (!std::filesystem::exists(configPath)) {
182 std::cout << "ohr config is not exist :" << configPath << std::endl;
183 return 0;
184 }
185
186 cJSON* rootData = ParseFileConfig(configPath);
187 if (rootData == nullptr) {
188 cJSON_Delete(rootData);
189 std::cout << "parse config file failed, check it path is:" << configPath << std::endl;
190 return 0;
191 }
192 auto playbackConfig = cJSON_GetObjectItem(rootData, OHR_LIST.c_str());
193 if (cJSON_IsArray(playbackConfig)) {
194 int listSize = cJSON_GetArraySize(playbackConfig);
195 for (int i = 0; i < listSize; i++) {
196 cJSON* item = cJSON_GetArrayItem(playbackConfig, i);
197 if (cJSON_IsObject(item)) {
198 AnalysePlaybackInfo(rootPath, imagePath, item);
199 }
200 }
201 }
202 cJSON_Delete(rootData);
203 TearDown();
204 // NOT MODIFY THE COMMENTS
205 cout << "[ PASSED ] " << runTestCaseNum_ << " test." << std::endl;
206 return 1;
207 }
208
CopyDirectoryAndLoadNodeTreeFile(const std::filesystem::path & src,const std::filesystem::path & dest)209 void RSGraphicTestProfiler::CopyDirectoryAndLoadNodeTreeFile(
210 const std::filesystem::path& src, const std::filesystem::path& dest)
211 {
212 for (const auto& entry : std::filesystem::directory_iterator(src)) {
213 std::filesystem::path target = dest / entry.path().filename();
214 if (entry.is_directory()) {
215 std::filesystem::create_directories(target);
216 CopyDirectoryAndLoadNodeTreeFile(entry.path(), target);
217 } else {
218 LoadNodeTreeProfilerFile(entry.path(), target);
219 }
220 }
221 }
222
GetRootNode() const223 std::shared_ptr<RSGraphicRootNode> RSGraphicTestProfiler::GetRootNode() const
224 {
225 return RSGraphicTestDirector::Instance().GetRootNode();
226 }
227
GetScreenSize() const228 Vector2f RSGraphicTestProfiler::GetScreenSize() const
229 {
230 return RSGraphicTestDirector::Instance().GetScreenSize();
231 }
232
NodeTreeTestSetUp()233 void RSGraphicTestProfiler::NodeTreeTestSetUp()
234 {
235 system("setenforce 0");
236 RSSurfaceNodeConfig config;
237 config.SurfaceNodeName = "TestSurface";
238 auto testSurface = RSSurfaceNode::Create(config, false);
239
240 testSurface->SetBounds({0, 0, SCREEN_WIDTH, SCREEN_HEIGHT});
241 testSurface->SetFrame({0, 0, SCREEN_WIDTH, SCREEN_HEIGHT});
242 testSurface->SetBackgroundColor(SURFACE_COLOR);
243 GetRootNode()->SetTestSurface(testSurface);
244
245 RSGraphicTestDirector::Instance().SetScreenSize(SCREEN_WIDTH, SCREEN_HEIGHT);
246 RSGraphicTestDirector::Instance().SetScreenSurfaceBounds({0, 0, SCREEN_WIDTH, SCREEN_HEIGHT});
247 if (useBufferDump_) {
248 DumpBufferSetUp();
249 }
250 }
251
PlaybackTestSetUp()252 void RSGraphicTestProfiler::PlaybackTestSetUp()
253 {
254 system("setenforce 0");
255 if (useBufferDump_) {
256 DumpBufferSetUp();
257 }
258 }
259
TearDown()260 void RSGraphicTestProfiler::TearDown()
261 {
262 if (useBufferDump_) {
263 DumpBufferTearDown();
264 }
265 }
266
LoadNodeTreeProfilerFile(const std::string & filePath,const std::string & savePath)267 void RSGraphicTestProfiler::LoadNodeTreeProfilerFile(const std::string& filePath, const std::string& savePath)
268 {
269 runTestCaseNum_++;
270 // NOT MODIFY THE COMMENTS
271 cout << "[ RUN ] " << filePath << std::endl;
272 // 1.add load client node to add file
273 auto loadNode = RSCanvasNode::Create();
274 loadNode->SetBounds({ 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT });
275 GetRootNode()->AddChild(loadNode);
276 // need flush client node to rs firstly
277 RSGraphicTestDirector::Instance().FlushMessage();
278 WaitTimeout(FLUSH_RS_WAIT_TIME);
279
280 // 2.send load command
281 std::cout << "load subbtree to node file path is " << filePath << std::endl;
282 std::string command = "rssubtree_load " + std::to_string(loadNode->GetId()) + " " + filePath;
283 RSGraphicTestDirector::Instance().SendProfilerCommand(command);
284 WaitTimeout(LOAD_STATIC_WAIT_TIME);
285
286 // 3.testcase capture
287 WaitTimeout(NORMAL_WAIT_TIME);
288 if (useBufferDump_) {
289 TestCaseBufferDump(true, savePath);
290 } else {
291 TestCaseCapture(false, savePath);
292 }
293
294 // 4.clear
295 GetRootNode()->RemoveChild(loadNode);
296 RSGraphicTestDirector::Instance().SendProfilerCommand("rssubtree_clear");
297 RSGraphicTestDirector::Instance().FlushMessage();
298 WaitTimeout(NORMAL_WAIT_TIME);
299 }
300
LoadPlaybackProfilerFile(const std::string & filePath,const std::string & savePath,PlaybackInfo info)301 void RSGraphicTestProfiler::LoadPlaybackProfilerFile(
302 const std::string& filePath, const std::string& savePath, PlaybackInfo info)
303 {
304 runTestCaseNum_++;
305 // NOT MODIFY THE COMMENTS
306 cout << "[ RUN ] " << filePath << std::endl;
307
308 // playback prepare
309 int64_t pid = 0;
310 float startTime = static_cast<float>(info.startTime) / static_cast<float>(UNIT_SEC_TO_MS);
311 std::string command =
312 "rsrecord_replay_prepare " + std::to_string(pid) + " " + std::to_string(startTime) + " " + filePath;
313 std::cout << "Playback Prepare: " << command << std::endl;
314 RSGraphicTestDirector::Instance().SendProfilerCommand(command, PLAYBACK_PREPARE_OUT_TIME);
315 WaitTimeout(PLAYBACK_OPERATE_INTERVAL_TIME);
316
317 // playback start
318 command = "rsrecord_replay";
319 std::cout << "Playback Start: " << command << std::endl;
320 RSGraphicTestDirector::Instance().SendProfilerCommand(command);
321 WaitTimeout(info.startTime + NORMAL_WAIT_TIME);
322
323 int frame = 1;
324 for (int time = info.startTime; time <= info.endTime; time += info.timeInterval) {
325 if (frame != 1) {
326 float pauseTime = static_cast<float>(time) / static_cast<float>(UNIT_SEC_TO_MS);
327 command = "rsrecord_pause_at " + std::to_string(pauseTime);
328 std::cout << "Playback Pause At: " << command << std::endl;
329 RSGraphicTestDirector::Instance().SendProfilerCommand(command, PLAYBACK_PAUSE_OUT_TIME);
330 }
331
332 WaitTimeout(NORMAL_WAIT_TIME);
333 std::string filename;
334 size_t lastDotPos = savePath.find_last_of(".");
335 if (lastDotPos == std::string::npos || lastDotPos == 0) {
336 filename = savePath;
337 } else {
338 filename = savePath.substr(0, lastDotPos);
339 }
340 std::ostringstream frameStr;
341 frameStr << std::setw(FRAME_WIDTH_NUM) << setfill('0') << frame;
342 filename = filename + "_frame_" + frameStr.str() + "_" + std::to_string(time);
343 if (useBufferDump_) {
344 TestCaseBufferDump(true, filename);
345 } else {
346 TestCaseCapture(true, filename);
347 }
348 frame++;
349 }
350 // playback stop
351 command = "rsrecord_replay_stop";
352 std::cout << "Playback Stop: " << command << std::endl;
353 RSGraphicTestDirector::Instance().SendProfilerCommand(command);
354 command = "rssubtree_clear";
355 RSGraphicTestDirector::Instance().SendProfilerCommand(command);
356 WaitTimeout(NORMAL_WAIT_TIME);
357 }
358
TestCaseCapture(bool isScreenshot,const std::string & savePath)359 void RSGraphicTestProfiler::TestCaseCapture(bool isScreenshot, const std::string& savePath)
360 {
361 auto pixelMap = RSGraphicTestDirector::Instance().TakeScreenCaptureAndWait(
362 RSParameterParse::Instance().surfaceCaptureWaitTime, isScreenshot);
363 if (pixelMap) {
364 std::string filename;
365 size_t lastDotPos = savePath.find_last_of(".");
366 if (lastDotPos == std::string::npos || lastDotPos == 0) {
367 filename = savePath;
368 } else {
369 filename = savePath.substr(0, lastDotPos);
370 }
371 filename += std::string(".png");
372 if (std::filesystem::exists(filename)) {
373 cout << "image has already exist " << filename << std::endl;
374 }
375 if (!WriteToPngWithPixelMap(filename, *pixelMap)) {
376 // NOT MODIFY THE COMMENTS
377 cout << "[ FAILED ] " << filename << std::endl;
378 return;
379 }
380 std::cout << "png write to " << filename << std::endl;
381 // NOT MODIFY THE COMMENTS
382 cout << "[ OK ] " << filename << std::endl;
383 } else {
384 // NOT MODIFY THE COMMENTS
385 cout << "[ FAILED ] " << savePath << std::endl;
386 }
387 }
388
FindDigitStart(const std::string & str,size_t pos)389 size_t FindDigitStart(const std::string& str, size_t pos)
390 {
391 while (pos > 0 && std::isdigit(str[pos - 1])) {
392 --pos;
393 }
394 return pos;
395 }
396
FindDigitEnd(const std::string & str,size_t pos)397 size_t FindDigitEnd(const std::string& str, size_t pos)
398 {
399 while (pos < str.size() && std::isdigit(str[pos])) {
400 ++pos;
401 }
402 return pos;
403 }
404
AlignValue(size_t value)405 constexpr size_t AlignValue(size_t value)
406 {
407 return (value + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
408 }
409
GetDumpBufferSizeFromPath(const std::string & srcFileName,Size & dumpBufferSize)410 bool GetDumpBufferSizeFromPath(const std::string& srcFileName, Size& dumpBufferSize)
411 {
412 size_t posX = srcFileName.find_last_of('x');
413 if (posX == std::string::npos || posX == 0) {
414 std::cout << "Invaild filename format:missing 'x'" << std::endl;
415 return false;
416 }
417
418 size_t widthStart = FindDigitStart(srcFileName, posX);
419 size_t heightEnd = FindDigitEnd(srcFileName, posX + 1);
420
421 std::string_view widthStr(&srcFileName[widthStart], posX - widthStart);
422 std::string_view heightStr(&srcFileName[posX + 1], heightEnd - (posX + 1));
423
424 if (auto [ptr, ec] = std::from_chars(widthStr.begin(), widthStr.end(), dumpBufferSize.width);
425 ec != std::errc()) {
426 std::cout << "Invaild width format" << std::endl;
427 return false;
428 }
429
430 if (auto [ptr, ec] = std::from_chars(heightStr.begin(), heightStr.end(), dumpBufferSize.height);
431 ec != std::errc()) {
432 std::cout << "Invaild height format" << std::endl;
433 return false;
434 }
435 return true;
436 }
437
CheckCropIsValid(Size dumpBufferSize,Vector2f screenSize)438 bool CheckCropIsValid(Size dumpBufferSize, Vector2f screenSize)
439 {
440 if (CROP_X < 0 || CROP_Y < 0 ||
441 CROP_X + screenSize[0] > dumpBufferSize.width ||
442 CROP_Y + screenSize[1] > dumpBufferSize.height) {
443 std::cout << "Invalid crop size, trun to get the screen buffer" << std::endl;
444 return false;
445 }
446 return true;
447 }
448
TestCaseBufferDump(bool isScreenshot,const std::string & savePath)449 void RSGraphicTestProfiler::TestCaseBufferDump(bool isScreenshot, const std::string& savePath)
450 {
451 SafeSystem("hidumper -s 10 -a buffer > null", "Hidumper command failed");
452
453 std::string filename;
454 size_t lastDotPos = savePath.find_last_of(".");
455 if (lastDotPos == std::string::npos || lastDotPos == 0) {
456 filename = savePath;
457 } else {
458 filename = savePath.substr(0, lastDotPos);
459 }
460
461 std::filesystem::path dstFileName = filename;
462 for (const auto& entry : std::filesystem::directory_iterator("/data")) {
463 if (entry.path().filename().string().find("bq_") == 0 &&
464 entry.path().filename().string().find("_RCD") != std::string::npos) {
465 std::filesystem::remove(entry.path());
466 }
467 }
468
469 bool hasDumpFile = false;
470 std::filesystem::create_directories(dstFileName.parent_path());
471 for (const auto& entry : std::filesystem::directory_iterator("/data")) {
472 if (entry.path().filename().string().find("bq_") == 0 &&
473 entry.path().filename().string() != "bq_dump") {
474 hasDumpFile = true;
475 Size dumpBufferSize;
476 GetDumpBufferSizeFromPath(entry.path(), dumpBufferSize);
477 if (isScreenshot || !CheckCropIsValid(dumpBufferSize, GetScreenSize())) {
478 dstFileName += "_" + std::to_string(RGBA8888_FORMAT) + "_" + std::to_string(dumpBufferSize.width) +
479 "x" + std::to_string(dumpBufferSize.height) + ".raw";
480 std::filesystem::rename(entry.path(), dstFileName);
481 break;
482 }
483 dstFileName += "_" + std::to_string(RGBA8888_FORMAT) + "_" +
484 std::to_string(static_cast<int>(GetScreenSize()[0])) +
485 "x" + std::to_string(static_cast<int>(GetScreenSize()[1])) + ".raw";
486 if (!CropRawFile(entry.path().filename().string(), dstFileName, dumpBufferSize)) {
487 std::cout << "CropRawFile fail" << std::endl;
488 break;
489 }
490 std::filesystem::remove(entry.path());
491 break;
492 }
493 }
494 if (hasDumpFile) {
495 std::cout << "dumpbuffer write to " << dstFileName << std::endl;
496 // NOT MODIFY THE COMMENTS
497 cout << "[ OK ] " << dstFileName << std::endl;
498 } else {
499 // NOT MODIFY THE COMMENTS
500 cout << "[ FAILED ] " << dstFileName << std::endl;
501 }
502 }
503
CropRawFile(const std::string & srcFileName,const std::string & dstFileName,Size dumpBufferSize)504 bool RSGraphicTestProfiler::CropRawFile(
505 const std::string& srcFileName, const std::string& dstFileName, Size dumpBufferSize)
506 {
507 char srcFilePath[PATH_MAX] = {0};
508 if (srcFileName.length() <= 0 || srcFileName.length() > PATH_MAX || !realpath(srcFileName.c_str(), srcFilePath)) {
509 std::cout << "Raw src file path is invalid :" << srcFileName << std::endl;
510 return false;
511 }
512 std::ifstream input(srcFilePath, std::ios::binary);
513 if (!input) {
514 std::cout << "Failed to open input file" << std::endl;
515 return false;
516 }
517 std::filesystem::path dstFilePath = dstFileName;
518 char srcFileParentPath[PATH_MAX] = {0};
519 if (!realpath(dstFilePath.parent_path().c_str(), srcFileParentPath)) {
520 std::cout << "Raw dst file path is invalid :" << dstFilePath << std::endl;
521 return false;
522 }
523 std::ofstream output(dstFilePath, std::ios::binary);
524 const int bytesPerPixel = 4; //RGBA
525 size_t stride = AlignValue(dumpBufferSize.width * bytesPerPixel);
526 size_t cropRowSize = GetScreenSize()[0] * bytesPerPixel;
527 size_t startOffset = CROP_Y * stride + CROP_X * bytesPerPixel;
528 input.seekg(startOffset, std::ios::beg);
529 for (int row = 0; row < GetScreenSize()[1]; ++row) {
530 std::vector<char> buffer(cropRowSize);
531 input.read(buffer.data(), cropRowSize);
532 output.write(buffer.data(), cropRowSize);
533 //Skip the rest of the line in the original image
534 input.seekg(stride - (CROP_X + GetScreenSize()[0]) * bytesPerPixel, std::ios::cur);
535 }
536 return true;
537 }
538
DumpBufferSetUp()539 void RSGraphicTestProfiler::DumpBufferSetUp()
540 {
541 const std::string initCommands =
542 "setenforce 0; "
543 "param set debug.dumpstaticframe.enabled 1; "
544 "param set rosen.afbc.enabled 0; "
545 "param set rosen.hebc.enabled 0; "
546 "touch /data/bq_dump";
547 SafeSystem(initCommands, "Initialization commands failed");
548 }
549
DumpBufferTearDown()550 void RSGraphicTestProfiler::DumpBufferTearDown()
551 {
552 std::filesystem::remove("/data/bq_dump");
553 const std::string cleanupCommands =
554 "setenforce 1; "
555 "param set debug.dumpstaticframe.enabled 0; "
556 "param set rosen.afbc.enabled 1; "
557 "param set rosen.hebc.enabled 1;";
558 SafeSystem(cleanupCommands, "cleanup commands failed");
559 }
560
GetImageSavePath()561 std::string RSGraphicTestProfiler::GetImageSavePath()
562 {
563 std::filesystem::path rootPath(rootPath_);
564 std::filesystem::path savePath = rootPath / SAVE_IMAGE_PATH_NAME;
565 if (!std::filesystem::exists(savePath)) {
566 if (!std::filesystem::create_directories(savePath)) {
567 std::cout << "create image directories failed: " << savePath << std::endl;
568 }
569 } else {
570 if (!std::filesystem::is_directory(savePath)) {
571 std::cout << "image directories failed is not directory: " << savePath << std::endl;
572 }
573 }
574 return savePath.string();
575 }
576 } // namespace Rosen
577 } // namespace OHOS