diff --git a/display/buffer/v1_2/include/idisplay_buffer.h b/display/buffer/v1_2/include/idisplay_buffer.h index 0a68609f39cb9f1bd925f0d8452f58a7fc0edfde..1d2d51ae843fc14838fdd85efa31dd0fd0d66aeb 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 0000000000000000000000000000000000000000..17079e5d562035e989f733c472a04a36cda87539 --- /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 0000000000000000000000000000000000000000..cff578bd6b05d73a246cad506a19805cd1f37ceb --- /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 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.cpp b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cc8c3954f07a1bfc9d65c491dd1f67f8b5343b1a --- /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 0000000000000000000000000000000000000000..5d2b7b83bd65052557422e7dbf414ecef702c1a6 --- /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 = OHOS::HDI::Display::Buffer::V1_3::IAllocator::Get(isAllocLocal)) == 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 0000000000000000000000000000000000000000..9b7120a887b5d4aacf843423a0d30ce90e600f10 --- /dev/null +++ b/display/buffer/v1_3/include/idisplay_buffer.h @@ -0,0 +1,50 @@ +/* + * 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 7643e8326e8a80a61ae71b4b4c3d8bd3fa5e4416..300344cc98792f115fad1df3b2b348cd04748b33 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": {