From ccbe87b59f6ccd79ad7ee442d3985cf7872cdc66 Mon Sep 17 00:00:00 2001 From: pxd2022 Date: Fri, 19 Apr 2024 14:50:02 +0000 Subject: [PATCH 1/3] update display/composer/cache_manager/cache_manager.h. Signed-off-by: pxd2022 --- display/composer/cache_manager/cache_manager.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/display/composer/cache_manager/cache_manager.h b/display/composer/cache_manager/cache_manager.h index 1532299f..9a893d97 100644 --- a/display/composer/cache_manager/cache_manager.h +++ b/display/composer/cache_manager/cache_manager.h @@ -71,15 +71,15 @@ public: bool InsertCache(IdType id, CacheType* cache) { + std::lock_guard lock(mutex_); if (SearchCache(id) != nullptr) { HDF_LOGI("%{public}s: intend to insert a existing cache, SeqNo=%{public}d", __func__, id); } else { - if (cacheCountMax_ != 0 && Size() >= cacheCountMax_) { + if (cacheCountMax_ != 0 && caches_.size() >= cacheCountMax_) { HDF_LOGE("%{public}s: Caches is full, new seqNo:%{public}d can't be inserted", __func__, id); return false; } } - std::lock_guard lock(mutex_); caches_[id] = std::move(*(new std::unique_ptr(cache))); return true; @@ -87,10 +87,11 @@ public: bool EraseCache(IdType id) { + std::lock_guard lock(mutex_); bool ret = false; - if (SearchCache(id) != nullptr) { - std::lock_guard lock(mutex_); - caches_.erase(id); + auto cacheItem = caches_.find(id); + if (cacheItem != nullptr) { + caches_.erase(cacheItem); ret = true; } else { HDF_LOGE("%{public}s: Cache %{public}d is not existing\n", __func__, id); -- Gitee From 1a52d3351129b76f3a9c25078746c3114c84f8a5 Mon Sep 17 00:00:00 2001 From: pxd2022 Date: Sat, 20 Apr 2024 02:50:24 +0000 Subject: [PATCH 2/3] update display/composer/cache_manager/cache_manager.h. Signed-off-by: pxd2022 --- display/composer/cache_manager/cache_manager.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/display/composer/cache_manager/cache_manager.h b/display/composer/cache_manager/cache_manager.h index 9a893d97..87a27c78 100644 --- a/display/composer/cache_manager/cache_manager.h +++ b/display/composer/cache_manager/cache_manager.h @@ -72,7 +72,8 @@ public: bool InsertCache(IdType id, CacheType* cache) { std::lock_guard lock(mutex_); - if (SearchCache(id) != nullptr) { + auto cacheItem = caches_.find(id); + if (cacheItem != caches_.end()) { HDF_LOGI("%{public}s: intend to insert a existing cache, SeqNo=%{public}d", __func__, id); } else { if (cacheCountMax_ != 0 && caches_.size() >= cacheCountMax_) { @@ -90,7 +91,7 @@ public: std::lock_guard lock(mutex_); bool ret = false; auto cacheItem = caches_.find(id); - if (cacheItem != nullptr) { + if (cacheItem != caches_.end()) { caches_.erase(cacheItem); ret = true; } else { -- Gitee From 6fbfa0e0e6bde0a485f8cc4fadc6c7abb57500dc Mon Sep 17 00:00:00 2001 From: pxd2022 Date: Sat, 20 Apr 2024 17:01:22 +0000 Subject: [PATCH 3/3] update display/composer/v1_0/display_command/display_cmd_utils.h. Signed-off-by: pxd2022 --- .../v1_0/display_command/display_cmd_utils.h | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/display/composer/v1_0/display_command/display_cmd_utils.h b/display/composer/v1_0/display_command/display_cmd_utils.h index f2c33735..73145ae3 100644 --- a/display/composer/v1_0/display_command/display_cmd_utils.h +++ b/display/composer/v1_0/display_command/display_cmd_utils.h @@ -76,22 +76,22 @@ public: } } - static int32_t StartPack(int32_t cmdId, std::shared_ptr packer) + static int32_t StartPack(int32_t cmdId, std::shared_ptr& packer) { return packer->PackBegin(cmdId) ? HDF_SUCCESS : HDF_FAILURE; } - static int32_t EndPack(std::shared_ptr packer) + static int32_t EndPack(std::shared_ptr& packer) { return packer->PackEnd(CONTROL_CMD_REQUEST_END) ? HDF_SUCCESS : HDF_FAILURE; } - static int32_t StartSection(int32_t cmdId, std::shared_ptr packer) + static int32_t StartSection(int32_t cmdId, std::shared_ptr& packer) { return packer->BeginSection(cmdId) ? HDF_SUCCESS : HDF_FAILURE; } - static int32_t SetupDevice(uint32_t devId, uint32_t layerId, std::shared_ptr packer) + static int32_t SetupDevice(uint32_t devId, uint32_t layerId, std::shared_ptr& packer) { DISPLAY_CHK_RETURN(packer->WriteUint32(devId) == false, HDF_FAILURE, HDF_LOGE("%{public}s, write devId error", __func__)); @@ -100,7 +100,7 @@ public: return HDF_SUCCESS; } - static int32_t EndSection(std::shared_ptr packer) + static int32_t EndSection(std::shared_ptr& packer) { return packer->EndSection() ? HDF_SUCCESS : HDF_FAILURE; } @@ -132,7 +132,7 @@ public: return false; } - static int32_t RectPack(const IRect& rect, std::shared_ptr packer) + static int32_t RectPack(const IRect& rect, std::shared_ptr& packer) { DISPLAY_CHK_RETURN(packer->WriteInt32(rect.x) == false, HDF_FAILURE, HDF_LOGE("%{public}s, write rect.x error", __func__)); @@ -145,7 +145,7 @@ public: return HDF_SUCCESS; } - static int32_t LayerColorPack(const LayerColor& layerColor, std::shared_ptr packer) + static int32_t LayerColorPack(const LayerColor& layerColor, std::shared_ptr& packer) { DISPLAY_CHK_RETURN(packer->WriteUint8(layerColor.r) == false, HDF_FAILURE, HDF_LOGE("%{public}s, write layerColor.r error", __func__)); @@ -159,7 +159,7 @@ public: } static int32_t FileDescriptorPack( - const int32_t fd, std::shared_ptr packer, std::vector& hdiFds) + const int32_t fd, std::shared_ptr& packer, std::vector& hdiFds) { HdifdInfo hdifdInfo; hdifdInfo.id = GenerateHdifdSeqid(); @@ -181,7 +181,7 @@ public: return HDF_SUCCESS; } - static int32_t BufferHandlePack(const BufferHandle* buffer, std::shared_ptr packer, + static int32_t BufferHandlePack(const BufferHandle* buffer, std::shared_ptr& packer, std::vector& hdiFds) { if (buffer == nullptr) { @@ -228,7 +228,7 @@ public: return HDF_SUCCESS; } - static int32_t SetupDeviceUnpack(std::shared_ptr unpacker, uint32_t& devId, uint32_t& layerId) + static int32_t SetupDeviceUnpack(std::shared_ptr& unpacker, uint32_t& devId, uint32_t& layerId) { DISPLAY_CHK_RETURN(unpacker->ReadUint32(devId) == false, HDF_FAILURE, HDF_LOGE("%{public}s, read devId failed", __func__)); @@ -237,7 +237,7 @@ public: return HDF_SUCCESS; } - static int32_t RectUnpack(std::shared_ptr unpacker, IRect& rect) + static int32_t RectUnpack(std::shared_ptr& unpacker, IRect& rect) { DISPLAY_CHK_RETURN(unpacker->ReadInt32(rect.x) == false, HDF_FAILURE, HDF_LOGE("%{public}s, read rect.x failed", __func__)); @@ -251,7 +251,7 @@ public: } static int32_t FileDescriptorUnpack( - std::shared_ptr unpacker, const std::vector& hdiFds, int32_t& fd) + std::shared_ptr& unpacker, const std::vector& hdiFds, int32_t& fd) { int32_t fdId = -1; DISPLAY_CHK_RETURN(unpacker->ReadInt32(fdId) == false, HDF_FAILURE, @@ -263,7 +263,7 @@ public: return HDF_SUCCESS; } - static bool UnpackBasicInfo(std::shared_ptr unpacker, const std::vector& hdiFds, + static bool UnpackBasicInfo(std::shared_ptr& unpacker, const std::vector& hdiFds, BufferHandle *handle) { int32_t ret = FileDescriptorUnpack(unpacker, hdiFds, handle->fd); @@ -285,7 +285,7 @@ public: return retVal; } - static bool UnpackExtraInfo(std::shared_ptr unpacker, const std::vector& hdiFds, + static bool UnpackExtraInfo(std::shared_ptr& unpacker, const std::vector& hdiFds, BufferHandle *handle) { bool retVal = true; @@ -308,7 +308,7 @@ public: return retVal; } - static int32_t BufferHandleUnpack(std::shared_ptr unpacker, + static int32_t BufferHandleUnpack(std::shared_ptr& unpacker, const std::vector& hdiFds, BufferHandle*& buffer) { uint32_t fdsNum = 0; @@ -340,7 +340,7 @@ public: return retVal ? HDF_SUCCESS : HDF_FAILURE; } - static int32_t LayerColorUnpack(std::shared_ptr unpacker, LayerColor& layerColor) + static int32_t LayerColorUnpack(std::shared_ptr& unpacker, LayerColor& layerColor) { DISPLAY_CHK_RETURN(unpacker->ReadUint8(layerColor.r) == false, HDF_FAILURE, HDF_LOGE("%{public}s, read layerColor.r failed", __func__)); -- Gitee