From a805d2f33a0c161123dae89b964894527ed6af20 Mon Sep 17 00:00:00 2001 From: huyx Date: Fri, 4 Jul 2025 11:49:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?ReAllocMem=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- display/buffer/v1_2/include/idisplay_buffer.h | 1 + display/buffer/v1_3/BUILD.gn | 86 +++++++++++++++++++ display/buffer/v1_3/IAllocator.idl | 34 ++++++++ .../v1_3/hdi_impl/display_buffer_hdi_impl.cpp | 36 ++++++++ .../v1_3/hdi_impl/display_buffer_hdi_impl.h | 86 +++++++++++++++++++ display/buffer/v1_3/include/idisplay_buffer.h | 49 +++++++++++ display/bundle.json | 36 +++++++- 7 files changed, 327 insertions(+), 1 deletion(-) create mode 100644 display/buffer/v1_3/BUILD.gn create mode 100644 display/buffer/v1_3/IAllocator.idl create mode 100644 display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp create mode 100644 display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h create mode 100644 display/buffer/v1_3/include/idisplay_buffer.h diff --git a/display/buffer/v1_2/include/idisplay_buffer.h b/display/buffer/v1_2/include/idisplay_buffer.h index 0a68609f..1d2d51ae 100644 --- a/display/buffer/v1_2/include/idisplay_buffer.h +++ b/display/buffer/v1_2/include/idisplay_buffer.h @@ -18,6 +18,7 @@ #include "v1_0/include/idisplay_buffer.h" #include "v1_1/include/idisplay_buffer.h" +#include "v1_2/display_buffer_type.h" namespace OHOS { namespace HDI { diff --git a/display/buffer/v1_3/BUILD.gn b/display/buffer/v1_3/BUILD.gn new file mode 100644 index 00000000..17079e5d --- /dev/null +++ b/display/buffer/v1_3/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/components/hdi/hdi.gni") + +hdi("display_buffer") { + module_name = "display_buffer" + + proxy_deps = [ + "//drivers/interface/display/buffer/v1_0:libdisplay_buffer_proxy_1.0", + "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_proxy_1.1", + "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_proxy_1.2" + ] + stub_deps = [ + "//drivers/interface/display/buffer/v1_0:libdisplay_buffer_stub_1.0", + "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_stub_1.1", + "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_stub_1.2" + ] + + sources = [ + "IAllocator.idl", + ] + innerapi_tags = [ + "chipsetsdk_indirect", + "platformsdk_indirect", + ] + + branch_protector_ret = "pac_ret" + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_display" +} + +config("libdisplay_buffer_hdi_impl_config") { + include_dirs = [ "./../" ] +} + +ohos_shared_library("libdisplay_buffer_hdi_impl_v1_3") { + sources = [ + "../v1_0/hdi_impl/display_buffer_hdi_impl.cpp", + "../v1_1/hdi_impl/display_buffer_hdi_impl.cpp", + "../v1_2/hdi_impl/display_buffer_hdi_impl.cpp", + "./hdi_impl/display_buffer_hdi_impl.cpp", + ] + + public_configs = [ ":libdisplay_buffer_hdi_impl_config" ] + + deps = [ + ":libdisplay_buffer_proxy_1.3", + "../v1_0:libdisplay_buffer_proxy_1.0", + "../v1_1:libdisplay_buffer_proxy_1.1", + "../v1_2:libdisplay_buffer_proxy_1.2", + ] + + external_deps = [ + "c_utils:utils", + "graphic_surface:buffer_handle", + "hdf_core:libhdi", + "hdf_core:libpub_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + + install_images = [ "system" ] + subsystem_name = "hdf" + innerapi_tags = [ + "chipsetsdk", + "platformsdk_indirect", + ] + + branch_protector_ret = "pac_ret" + + part_name = "drivers_interface_display" +} diff --git a/display/buffer/v1_3/IAllocator.idl b/display/buffer/v1_3/IAllocator.idl new file mode 100644 index 00000000..1efee8a8 --- /dev/null +++ b/display/buffer/v1_3/IAllocator.idl @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.hdi.display.buffer.v1_3; + +import ohos.hdi.display.buffer.v1_2.DisplayBufferType; +import ohos.hdi.display.buffer.v1_0.IAllocator; + +interface IAllocator extends ohos.hdi.display.buffer.v1_0.IAllocator { + /** + * @brief get iamge position + * + * @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. + * @since 5.0 + * @version 1.2 + */ + ReAllocMem([in] struct AllocInfo info, [in] NativeBuffer inHandle, [out] NativeBuffer outHandle); +} diff --git a/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp new file mode 100644 index 00000000..cc8c3954 --- /dev/null +++ b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "display_buffer_hdi_impl.h" +namespace OHOS { +namespace HDI { +namespace Display { +namespace Buffer { +namespace V1_3 { +using namespace OHOS::HDI::Display::Buffer::V1_3; +IDisplayBuffer *IDisplayBuffer::Get() +{ + IDisplayBuffer *instance = new V1_3::HdiDisplayBufferImpl(); + if (instance == nullptr) { + return nullptr; + } + return instance; +} + +} // namespace V1_3 +} // namespace Buffer +} // namespace Display +} // namespace HDI +} // namespace OHOS 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 new file mode 100644 index 00000000..4671c809 --- /dev/null +++ b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_HDI_DISPLAY_V1_3_DISPLAY_BUFFER_HDI_IMPL_H +#define OHOS_HDI_DISPLAY_V1_3_DISPLAY_BUFFER_HDI_IMPL_H + +#include +#include +#include "hdf_log.h" +#include "hilog/log.h" +#include "v1_0/imapper.h" +#include "v1_3/iallocator.h" +#include "v1_3/include/idisplay_buffer.h" +#include "v1_2/hdi_impl/display_buffer_hdi_impl.h" + +#undef LOG_TAG +#define LOG_TAG "DISP_HDI_BUFF" +#undef LOG_DOMAIN +#define LOG_DOMAIN 0xD002515 + +namespace OHOS { +namespace HDI { +namespace Display { +namespace Buffer { +namespace V1_3 { +template +class DisplayBufferHdiImpl : public V1_2::DisplayBufferHdiImpl { +public: + explicit DisplayBufferHdiImpl(bool isAllocLocal = false) : BaseType3_0(isAllocLocal), allocator_v1_3(nullptr) + { + while ((allocator_v1_3 = IMapper::Get(true)) == nullptr) { + // Waiting for metadata service ready + usleep(WAIT_TIME_INTERVAL); + } + } + virtual ~DisplayBufferHdiImpl() {}; + + virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, + BufferHandle*& outHandle) const override + { + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(allocator_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 = allocator_v1_3->ReAllocMem(info, hdiInBuffer, hdiOutBuffer); + if ((ret == HDF_SUCCESS) && (hdiOutBuffer != nullptr)) { + outHandle = hdiOutBuffer->Move(); + } else { + outHandle = nullptr; + if (ret == HDF_SUCCESS) { + ret = HDF_FAILURE; + } + HDF_LOGE("%{public}s: ReAllocMem error", __func__); + } + return ret; + } + +private: + using BaseType3_0 = V1_2::DisplayBufferHdiImpl; +protected: + using BaseType3_0::WAIT_TIME_INTERVAL; + sptr allocator_v1_3; +}; +using HdiDisplayBufferImpl = DisplayBufferHdiImpl; +} // namespace V1_3 +} // namespace Buffer +} // namespace Display +} // namespace HDI +} // namespace OHOS + +#endif // OHOS_HDI_DISPLAY_V1_3_DISPLAY_BUFFER_HDI_IMPL_H diff --git a/display/buffer/v1_3/include/idisplay_buffer.h b/display/buffer/v1_3/include/idisplay_buffer.h new file mode 100644 index 00000000..18923d01 --- /dev/null +++ b/display/buffer/v1_3/include/idisplay_buffer.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_HDI_DISPLAY_V1_3_IDISPLAY_BUFFER_H +#define OHOS_HDI_DISPLAY_V1_3_IDISPLAY_BUFFER_H + +#include "v1_0/include/idisplay_buffer.h" +#include "v1_1/include/idisplay_buffer.h" +#include "v1_2/include/idisplay_buffer.h" + +namespace OHOS { +namespace HDI { +namespace Display { +namespace Buffer { +namespace V1_3 { +class IDisplayBuffer : public V1_2::IDisplayBuffer { +public: + virtual ~IDisplayBuffer() = default; + + /** + * @brief Obtains all interfaces of IDisplayBuffer. + * + * @return Returns IDisplayBuffer* if the operation is successful; returns an null point otherwise. + * @since 6.0 + * @version 1.3 + */ + static IDisplayBuffer *Get(); + virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, + BufferHandle*& outHandle) const = 0; +}; +} // namespace V1_3 +} // namespace Buffer +} // namespace Display +} // namespace HDI +} // namespace OHOS + +#endif // OHOS_HDI_DISPLAY_V1_3_IDISPLAY_BUFFER_H diff --git a/display/bundle.json b/display/bundle.json index 7643e832..300344cc 100644 --- a/display/bundle.json +++ b/display/bundle.json @@ -46,6 +46,8 @@ "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_hdi_impl_v1_1", "//drivers/interface/display/buffer/v1_2:display_buffer_idl_target", "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_hdi_impl_v1_2", + "//drivers/interface/display/buffer/v1_3:display_buffer_idl_target", + "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_hdi_impl_v1_3", "//drivers/interface/display/composer/cache_manager:libcomposer_buffer_cache", "//drivers/interface/display/composer/v1_0:display_composer_idl_target", "//drivers/interface/display/composer/v1_1:display_composer_idl_target", @@ -131,7 +133,7 @@ "header_base": "//drivers/interface/display/buffer" } }, - { + { "name": "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_proxy_1.2", "header": { "header_files": [ @@ -163,6 +165,38 @@ "header_base": "//drivers/interface/display/buffer" } }, + { + "name": "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_proxy_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, + { + "name": "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_stub_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, + { + "name": "//drivers/interface/display/buffer/v1_3:display_buffer_idl_headers_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, + { + "name": "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_hdi_impl_v1_3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, { "name": "//drivers/interface/display/composer/cache_manager:libcomposer_buffer_cache", "header": { -- Gitee From 279492a60872de9c4f99952d39522dafcc43890b Mon Sep 17 00:00:00 2001 From: huyx Date: Fri, 4 Jul 2025 13:38:57 +0800 Subject: [PATCH 2/4] =?UTF-8?q?ReAllocMem=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h | 4 ++-- display/buffer/v1_3/include/idisplay_buffer.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) 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 4671c809..c4b6bc2a 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 @@ -47,10 +47,10 @@ public: } virtual ~DisplayBufferHdiImpl() {}; - virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, + virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, BufferHandle*& outHandle) const override { - DISPLAY_TRACE; + DISPLAY_TRACE; CHECK_NULLPOINTER_RETURN_VALUE(allocator_v1_3, HDF_FAILURE); sptr hdiInBuffer = new NativeBuffer(); CHECK_NULLPOINTER_RETURN_VALUE(hdiInBuffer, HDF_FAILURE); diff --git a/display/buffer/v1_3/include/idisplay_buffer.h b/display/buffer/v1_3/include/idisplay_buffer.h index 18923d01..9b7120a8 100644 --- a/display/buffer/v1_3/include/idisplay_buffer.h +++ b/display/buffer/v1_3/include/idisplay_buffer.h @@ -37,7 +37,8 @@ public: * @version 1.3 */ static IDisplayBuffer *Get(); - virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, + + virtual int32_t ReAllocMem(const V1_0::AllocInfo& info, const BufferHandle& inHandle, BufferHandle*& outHandle) const = 0; }; } // namespace V1_3 -- Gitee From 1adaf7e2fd10e69bd90f0eb39ee3e8e4c9850f51 Mon Sep 17 00:00:00 2001 From: huyx Date: Fri, 4 Jul 2025 15:51:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?ReAllocMem=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c4b6bc2a..62a6f1e0 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 @@ -40,7 +40,7 @@ class DisplayBufferHdiImpl : public V1_2::DisplayBufferHdiImpl { public: explicit DisplayBufferHdiImpl(bool isAllocLocal = false) : BaseType3_0(isAllocLocal), allocator_v1_3(nullptr) { - while ((allocator_v1_3 = IMapper::Get(true)) == nullptr) { + while ((allocator_v1_3 = OHOS::HDI::Display::Buffer::V1_3::IAllocator::Get(isAllocLocal)) == nullptr) { // Waiting for metadata service ready usleep(WAIT_TIME_INTERVAL); } @@ -74,7 +74,7 @@ private: using BaseType3_0 = V1_2::DisplayBufferHdiImpl; protected: using BaseType3_0::WAIT_TIME_INTERVAL; - sptr allocator_v1_3; + sptr allocator_v1_3; }; using HdiDisplayBufferImpl = DisplayBufferHdiImpl; } // namespace V1_3 -- Gitee From f6616f9ee7eb03d95a3fd70c7c0835410339e93b Mon Sep 17 00:00:00 2001 From: huyx Date: Fri, 4 Jul 2025 18:26:27 +0800 Subject: [PATCH 4/4] =?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/IAllocator.idl | 4 ++-- display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/display/buffer/v1_3/IAllocator.idl b/display/buffer/v1_3/IAllocator.idl index 1efee8a8..cff578bd 100644 --- a/display/buffer/v1_3/IAllocator.idl +++ b/display/buffer/v1_3/IAllocator.idl @@ -27,8 +27,8 @@ interface IAllocator extends ohos.hdi.display.buffer.v1_0.IAllocator { * * @return Returns 0 if the operation is successful; returns an error code defined * in {@link DispErrCode} otherwise. - * @since 5.0 - * @version 1.2 + * @since 6.0 + * @version 1.3 */ ReAllocMem([in] struct AllocInfo info, [in] NativeBuffer inHandle, [out] NativeBuffer outHandle); } 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 62a6f1e0..5d2b7b83 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 @@ -74,7 +74,7 @@ private: using BaseType3_0 = V1_2::DisplayBufferHdiImpl; protected: using BaseType3_0::WAIT_TIME_INTERVAL; - sptr allocator_v1_3; + sptr allocator_v1_3; }; using HdiDisplayBufferImpl = DisplayBufferHdiImpl; } // namespace V1_3 -- Gitee