From 2df64d208113875f612dd592dc71e9387aae026e Mon Sep 17 00:00:00 2001 From: huyx Date: Mon, 7 Jul 2025 11:44:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ReAllocMem=E9=87=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- display/buffer/v1_3/IMapper.idl | 7 ++++--- .../v1_3/hdi_impl/display_buffer_hdi_impl.h | 20 +++++++++++++++++++ display/buffer/v1_3/include/idisplay_buffer.h | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/display/buffer/v1_3/IMapper.idl b/display/buffer/v1_3/IMapper.idl index 318ce304..67fbd9de 100644 --- a/display/buffer/v1_3/IMapper.idl +++ b/display/buffer/v1_3/IMapper.idl @@ -20,10 +20,10 @@ import ohos.hdi.display.buffer.v1_2.IMapper; interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { /** - * @brief get iamge position + * @brief the function to alloc memory * - * @param handle The input buffer handle - * @param layout the iamge position data + * @param info describs the buffer to be alloced + * @param handle the allocated buffer handle * * @return Returns 0 if the operation is successful; returns an error code defined * in {@link DispErrCode} otherwise. @@ -31,5 +31,6 @@ interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { * @version 1.3 */ AllocMem([in] struct AllocInfo info, [out] NativeBuffer handle); + ReAllocMem([in] struct AllocInfo info, [in] NativeBuffer inHandle, [out] NativeBuffer outHandle); IsSupportAllocPassthrough([in] struct AllocInfo info); } diff --git a/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h index bba4ccb8..6b03879e 100644 --- a/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h +++ b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h @@ -107,6 +107,26 @@ public: } } + virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, + BufferHandle*& outHandle)const override + { + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(mapper_v1_3_, HDF_FAILURE); + + sptr hdiInBuffer = new NativeBuffer(); + CHECK_NULLPOINTER_RETURN_VALUE(hdiInBuffer, HDF_FAILURE); + sptr hdiOutBuffer; + + hdiInBuffer->SetBufferHandle(const_cast(&inHandle)); + int32_t ret = mapper_v1_3_->ReAllocMem(info, hdiInBuffer, hdiOutBuffer); + if ((ret == HDF_SUCCESS) && (hdiOutBuffer != nullptr)) { + outHandle = hdiOutBuffer->Move(); + } else { + return AllocMemIpc(info, outHandle); + } + return ret; + } + private: using BaseType3_0 = V1_2::DisplayBufferHdiImpl; protected: diff --git a/display/buffer/v1_3/include/idisplay_buffer.h b/display/buffer/v1_3/include/idisplay_buffer.h index 881ddf93..aabf1fd2 100644 --- a/display/buffer/v1_3/include/idisplay_buffer.h +++ b/display/buffer/v1_3/include/idisplay_buffer.h @@ -38,6 +38,8 @@ public: */ static IDisplayBuffer *Get(); virtual int32_t AllocMem(const V1_0::AllocInfo& info, BufferHandle*& handle) const = 0; + virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, + BufferHandle*& outHandle) const = 0; }; } // namespace V1_3 } // namespace Buffer -- Gitee From b585a3180a786ced919f969cbb6c47f6ebfad0ed Mon Sep 17 00:00:00 2001 From: huyx Date: Tue, 8 Jul 2025 10:35:18 +0800 Subject: [PATCH 2/3] ReAllocMem Signed-off-by: huyx --- display/buffer/v1_3/IMapper.idl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/display/buffer/v1_3/IMapper.idl b/display/buffer/v1_3/IMapper.idl index 67fbd9de..085af899 100644 --- a/display/buffer/v1_3/IMapper.idl +++ b/display/buffer/v1_3/IMapper.idl @@ -31,6 +31,17 @@ interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { * @version 1.3 */ AllocMem([in] struct AllocInfo info, [out] NativeBuffer handle); + /** + * @brief the function to alloc memory + * + * @param info describs the buffer to be alloced + * @param handle the allocated buffer handle + * + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link DispErrCode} otherwise. + * @since 6.0 + * @version 1.3 + */ ReAllocMem([in] struct AllocInfo info, [in] NativeBuffer inHandle, [out] NativeBuffer outHandle); IsSupportAllocPassthrough([in] struct AllocInfo info); } -- Gitee From 02e4983e7711d1891337c9a7a036cd0d3c732f1c Mon Sep 17 00:00:00 2001 From: huyx Date: Tue, 8 Jul 2025 11:30:27 +0800 Subject: [PATCH 3/3] ReAllocMem Signed-off-by: huyx --- display/buffer/v1_3/IMapper.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/display/buffer/v1_3/IMapper.idl b/display/buffer/v1_3/IMapper.idl index 085af899..70bea65d 100644 --- a/display/buffer/v1_3/IMapper.idl +++ b/display/buffer/v1_3/IMapper.idl @@ -32,10 +32,10 @@ interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { */ AllocMem([in] struct AllocInfo info, [out] NativeBuffer handle); /** - * @brief the function to alloc memory + * @brief get iamge position * - * @param info describs the buffer to be alloced - * @param handle the allocated buffer handle + * @param handle The input buffer handle + * @param layout the iamge position data * * @return Returns 0 if the operation is successful; returns an error code defined * in {@link DispErrCode} otherwise. -- Gitee