From bddfa699b8629141390d05af880c2c6ba4367282 Mon Sep 17 00:00:00 2001 From: y00656910 Date: Tue, 29 Jul 2025 23:15:15 +0800 Subject: [PATCH] add setPixelMapName Signed-off-by: y00656910 Change-Id: I54cc781b15e2a303b35ff9fdf0f313448c51d97e Signed-off-by: y00656910 --- .../innerkitsimpl/codec/src/image_source.cpp | 16 ++++++++++++++++ .../image_source_test/image_source_test.cpp | 2 ++ interfaces/innerkits/include/image_source.h | 1 + 3 files changed, 19 insertions(+) diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 4c88fe492..e21ec2704 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -1062,6 +1062,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, const D CHECK_ERROR_PRINT_LOG(convertRes != SUCCESS, "convert rgb to yuv failed, return origin rgb!"); } ImageUtils::FlushSurfaceBuffer(pixelMap.get()); + pixelMap->SetMemoryName(GetPixelMapName(pixelMap.get())); return pixelMap; } @@ -1465,6 +1466,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt // not ext decode, dump pixelMap while decoding svg here ImageUtils::DumpPixelMapIfDumpEnabled(pixelMap, imageId_); + pixelMap->SetMemoryName(GetPixelMapName(pixelMap.get())); return pixelMap; } @@ -5300,5 +5302,19 @@ void ImageSource::RefreshImageSourceByPathName() } } +std::string ImageSource::GetPixelMapName(PixelMap* pixelMap) +{ + if (pixelMap == nullptr) { + IMAGE_LOGE("%{public}s error, pixelMap is null", __func__); + return "undefined_"; + } + std::string pixelMapStr = "w" + std::to_string(pixelMap->GetWidth()) + + "_h" + std::to_string(pixelMap->GetHeight()) + + "_streamSize" + std::to_string(sourceStreamPtr_->GetStreamSize()) + + "_mimeType" + sourceInfo_.encodedFormat; + IMAGE_LOGD("pixelMapStr is %{public}s", pixelMapStr.c_str()); + return pixelMapStr; +} + } // namespace Media } // namespace OHOS diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp index cfe0b6bac..526c9528c 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp @@ -1727,6 +1727,8 @@ HWTEST_F(ImageSourceTest, End2EndTest001, TestSize.Level3) ASSERT_NE(pixelMap.get(), nullptr); ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + ASSERT_EQ("undefined_", imageSource->GetPixelMapName(nullptr)); + ASSERT_EQ("w400_h200_streamSize27897_mimeTypeimage/jpeg", imageSource->GetPixelMapName(pixelMap.get())); } /** diff --git a/interfaces/innerkits/include/image_source.h b/interfaces/innerkits/include/image_source.h index 43a7094e2..bcf81be0f 100644 --- a/interfaces/innerkits/include/image_source.h +++ b/interfaces/innerkits/include/image_source.h @@ -380,6 +380,7 @@ private: bool CheckCropRectValid(const DecodeOptions &opts); void InitDecoderForJpeg(); void RefreshImageSourceByPathName(); + std::string GetPixelMapName(PixelMap* pixelMap); #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM) void SpecialSetComposeBuffer(ImagePlugin::DecodeContext &baseCtx, sptr& baseSptr, -- Gitee