diff --git a/display/buffer/v1_3/IMapper.idl b/display/buffer/v1_3/IMapper.idl index 318ce3049e3bfb377da2b30fc735237b14732ad0..70bea65d4c55eb9d761ff4c9a197f16e628bd118 100644 --- a/display/buffer/v1_3/IMapper.idl +++ b/display/buffer/v1_3/IMapper.idl @@ -19,6 +19,18 @@ import ohos.hdi.display.buffer.v1_2.DisplayBufferType; import ohos.hdi.display.buffer.v1_2.IMapper; interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { + /** + * @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 + */ + AllocMem([in] struct AllocInfo info, [out] NativeBuffer handle); /** * @brief get iamge position * @@ -30,6 +42,6 @@ interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { * @since 6.0 * @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 bba4ccb8f36f39f2dc96e36bcbb1db4ee2c0a14c..6b03879e86f7ce620da31fb37696a57ba5a51e82 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 881ddf9379ff441da928c5a8642d1120c857d834..aabf1fd252df5b314e4a0bc47000e0db75e614e7 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