From b492c038af27b92f3abd1082752c316d3e5330c9 Mon Sep 17 00:00:00 2001 From: songzhigang Date: Wed, 7 Aug 2024 09:57:41 +0800 Subject: [PATCH] =?UTF-8?q?support=20dump=20textureExport=20buffer=20?= =?UTF-8?q?=EF=BC=88cherry=20picked=20commit=20from=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- surface/include/buffer_utils.h | 2 +- surface/src/buffer_queue.cpp | 4 ++-- surface/src/buffer_utils.cpp | 17 ++++++++++++----- surface/test/unittest/buffer_utils_test.cpp | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/surface/include/buffer_utils.h b/surface/include/buffer_utils.h index 4c32739..0fe1e07 100644 --- a/surface/include/buffer_utils.h +++ b/surface/include/buffer_utils.h @@ -48,7 +48,7 @@ void WriteHDRMetaDataSet(MessageParcel &parcel, const std::vector &meta void ReadExtDataHandle(MessageParcel &parcel, sptr &handle); void WriteExtDataHandle(MessageParcel &parcel, const GraphicExtDataHandle *handle); -GSError DumpToFileAsync(pid_t pid, std::string name, sptr &buffer); +GSError DumpToFileAsync(bool isLocalRender, pid_t pid, std::string name, sptr &buffer); } // namespace OHOS #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_UTILS_H diff --git a/surface/src/buffer_queue.cpp b/surface/src/buffer_queue.cpp index 4b3084a..71f5bde 100644 --- a/surface/src/buffer_queue.cpp +++ b/surface/src/buffer_queue.cpp @@ -740,8 +740,8 @@ GSError BufferQueue::DoFlushBuffer(uint32_t sequence, sptr beda if (dumpBufferEnabled) { // Wait for the status of the fence to change to SIGNALED. int32_t ret = fence->Wait(-1); - if (ret == 0 && access("/data/bq_dump", F_OK) == 0) { - DumpToFileAsync(GetRealPid(), name_, bufferQueueCache_[sequence].buffer); + if (ret == 0 && (access("/data/bq_dump", F_OK) == 0 || access("/data/storage/el1/base/bq_dump", F_OK) == 0)) { + DumpToFileAsync(isLocalRender_, GetRealPid(), name_, bufferQueueCache_[sequence].buffer); } } diff --git a/surface/src/buffer_utils.cpp b/surface/src/buffer_utils.cpp index 4d7ac56..ebcac79 100644 --- a/surface/src/buffer_utils.cpp +++ b/surface/src/buffer_utils.cpp @@ -329,8 +329,8 @@ void CloneBuffer(uint8_t* dest, const uint8_t* src, size_t totalSize) } } -void WriteToFile(std::string pid, void* dest, size_t size, int32_t format, int32_t width, int32_t height, - const std::string name) +void WriteToFile(std::string prefixPath, std::string pid, void* dest, size_t size, int32_t format, int32_t width, + int32_t height, const std::string name) { struct timeval now; gettimeofday(&now, nullptr); @@ -338,7 +338,7 @@ void WriteToFile(std::string pid, void* dest, size_t size, int32_t format, int32 int64_t nowVal = (int64_t)now.tv_sec * secToUsec + (int64_t)now.tv_usec; std::stringstream ss; - ss << "/data/bq_" << pid << "_" << name << "_" << nowVal << "_" << format << "_" + ss << prefixPath << pid << "_" << name << "_" << nowVal << "_" << format << "_" << width << "x" << height << ".raw"; // Open the file for writing in binary mode @@ -358,7 +358,7 @@ void WriteToFile(std::string pid, void* dest, size_t size, int32_t format, int32 free(dest); } -GSError DumpToFileAsync(pid_t pid, std::string name, sptr &buffer) +GSError DumpToFileAsync(bool isLocalRender, pid_t pid, std::string name, sptr &buffer) { if (buffer == nullptr) { BLOGE("buffer is a nullptr."); @@ -378,8 +378,15 @@ GSError DumpToFileAsync(pid_t pid, std::string name, sptr &buffer if (dest != nullptr) { // Copy through multithreading CloneBuffer(dest, src, size); + + // Is texture export + std::string prefixPath = "/data/bq_"; + if (!isLocalRender) { + prefixPath = "/data/storage/el1/base/bq_"; + } + // create dump thread,async export file - std::thread file_writer(WriteToFile, std::to_string(pid), dest, size, buffer->GetFormat(), + std::thread file_writer(WriteToFile, prefixPath, std::to_string(pid), dest, size, buffer->GetFormat(), buffer->GetWidth(), buffer->GetHeight(), name); file_writer.detach(); } else { diff --git a/surface/test/unittest/buffer_utils_test.cpp b/surface/test/unittest/buffer_utils_test.cpp index 8cfb147..7dd6c4d 100644 --- a/surface/test/unittest/buffer_utils_test.cpp +++ b/surface/test/unittest/buffer_utils_test.cpp @@ -86,7 +86,7 @@ HWTEST_F(BufferUtilsTest, DumpToFileAsyncTest001, Function | MediumTest | Level2 buffer->Alloc(requestConfig); // Call DumpToFileAsync - GSError ret = DumpToFileAsync(pid, name_, buffer); + GSError ret = DumpToFileAsync(true, pid, name_, buffer); ASSERT_EQ(ret, OHOS::GSERROR_OK); // Expect Buffer Dump to be completed within 20ms. -- Gitee