From 6bde520f7341682eacab317cf6bf72357f762365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=91=E5=B1=91=E5=B1=91?= Date: Thu, 4 Sep 2025 20:40:54 +0800 Subject: [PATCH] reopen display only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 屑屑屑 --- .../innerkitsimpl/common/src/pixel_astc.cpp | 4 +-- .../innerkitsimpl/common/src/pixel_map.cpp | 31 +++++++++++++++++-- .../pixel_map_test/pixel_map_test.cpp | 2 ++ interfaces/innerkits/include/pixel_map.h | 12 +++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/frameworks/innerkitsimpl/common/src/pixel_astc.cpp b/frameworks/innerkitsimpl/common/src/pixel_astc.cpp index 3a752cc18..73a451905 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_astc.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_astc.cpp @@ -209,13 +209,13 @@ bool PixelAstc::IsSameImage(const PixelMap &other) uint32_t PixelAstc::ReadPixels(const uint64_t &bufferSize, const uint32_t &offset, const uint32_t &stride, const Rect ®ion, uint8_t *dst) { - IMAGE_LOGE("ReadPixels is not support on pixelastc"); + IMAGE_LOGE("%{public}d:ReadPixels is not support on pixelastc", uniqueId_); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t PixelAstc::ReadPixels(const uint64_t &bufferSize, uint8_t *dst) { - IMAGE_LOGE("ReadPixels is not support on pixelastc"); + IMAGE_LOGE("%{public}d:ReadPixels is not support on pixelastc", uniqueId_); return ERR_IMAGE_INVALID_PARAMETER; } diff --git a/frameworks/innerkitsimpl/common/src/pixel_map.cpp b/frameworks/innerkitsimpl/common/src/pixel_map.cpp index 08a71722b..fe66140a1 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_map.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_map.cpp @@ -236,6 +236,33 @@ void PixelMap::SetPixelsAddr(void *addr, void *context, uint32_t size, Allocator ImageUtils::FlushSurfaceBuffer(this); } +void PixelMap::SetPixelsAddr(void *addr, void *context, uint32_t size, AllocatorType type, bool displayOnly) +{ + if (type < AllocatorType::DEFAULT || type > AllocatorType::DMA_ALLOC) { + IMAGE_LOGE("Unmarshalling setPixelsAddr error invalid allocatorType"); + return; + } + if (data_ != nullptr) { + IMAGE_LOGD("Unmarshalling setPixelsAddr release the existed data first"); + FreePixelMap(); + } + if (type == AllocatorType::SHARE_MEM_ALLOC && context == nullptr) { + IMAGE_LOGE("Unmarshalling setPixelsAddr error type %{public}d ", type); + } + data_ = static_cast(addr); + isUnMap_ = false; + context_ = context; + pixelsSize_ = size; + allocatorType_ = type; + custFreePixelMap_ = nullptr; + if (type == AllocatorType::DMA_ALLOC && rowDataSize_ != 0) { + UpdateImageInfo(); + } + if (!displayOnly) { + ImageUtils::FlushSurfaceBuffer(this); + } +} + bool CheckPixelmap(std::unique_ptr &pixelMap, ImageInfo &imageInfo) { if (pixelMap == nullptr) { @@ -1886,7 +1913,7 @@ uint32_t PixelMap::ReadPixel(const Position &pos, uint32_t &dst) return ERR_IMAGE_INVALID_PARAMETER; } if (isUnMap_ || data_ == nullptr) { - IMAGE_LOGE("read pixel by pos source data is null, isUnMap %{public}d.", isUnMap_); + IMAGE_LOGE("%{public}d:read pixel by pos source data is null, isUnMap %{public}d.", uniqueId_, isUnMap_); return ERR_IMAGE_READ_PIXELMAP_FAILED; } ImageInfo dstImageInfo = @@ -3008,7 +3035,7 @@ bool PixelMap::UpdatePixelMapMemInfo(PixelMap *pixelMap, ImageInfo &imgInfo, Pix return false; } pixelMap->SetPixelsAddr(pixelMemInfo.base, pixelMemInfo.context, - pixelMemInfo.bufferSize, pixelMemInfo.allocatorType, nullptr); + pixelMemInfo.bufferSize, pixelMemInfo.allocatorType, pixelMap->IsDisplayOnly()); return true; } diff --git a/frameworks/innerkitsimpl/test/unittest/pixel_map_test/pixel_map_test.cpp b/frameworks/innerkitsimpl/test/unittest/pixel_map_test/pixel_map_test.cpp index 8b24c760d..59bb34fd8 100644 --- a/frameworks/innerkitsimpl/test/unittest/pixel_map_test/pixel_map_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/pixel_map_test/pixel_map_test.cpp @@ -1024,6 +1024,8 @@ HWTEST_F(PixelMapTest, PixelMapTest006, TestSize.Level3) void *fdBuffer = nullptr; uint32_t bufferSize = pixelMap1->GetByteCount(); pixelMap1->SetPixelsAddr(dstPixels, fdBuffer, bufferSize, AllocatorType::HEAP_ALLOC, nullptr); + pixelMap1->SetPixelsAddr(dstPixels, fdBuffer, bufferSize, AllocatorType::HEAP_ALLOC, false); + pixelMap1->SetPixelsAddr(dstPixels, fdBuffer, bufferSize, AllocatorType::HEAP_ALLOC, true); ImageInfo info1; info1.size.width = INT32_MAX; // 300 means height diff --git a/interfaces/innerkits/include/pixel_map.h b/interfaces/innerkits/include/pixel_map.h index 42e5a3b11..93c147a36 100644 --- a/interfaces/innerkits/include/pixel_map.h +++ b/interfaces/innerkits/include/pixel_map.h @@ -319,6 +319,18 @@ public: NATIVEEXPORT virtual void SetPixelsAddr(void *addr, void *context, uint32_t size, AllocatorType type, CustomFreePixelMap func); + /** + * Set pixel buffer information. + * + * @param addr Pixel address. + * @param context Buffer descriptor. + * @param size Pixel size. + * @param type Memory type. + * @param displayOnly Whether to flush buffer. + */ + NATIVEEXPORT virtual void SetPixelsAddr(void *addr, void *context, uint32_t size, AllocatorType type, + bool displayOnly); + /** * Get pixel step size. */ -- Gitee