开机动画使用Imageinfo创建和释放,解决动画内存泄漏 848/3 848/head
authorluozheng <1732036298@qq.com>
Sat, 31 Aug 2024 09:06:44 +0000 (17:06 +0800)
committerluozheng <1732036298@qq.com>
Sat, 31 Aug 2024 09:06:44 +0000 (17:06 +0800)
code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp

index 0aec8fa..133454f 100755 (executable)
@@ -28,6 +28,7 @@
 #include "custom_utils.h"
 #include "components/ui_image_animator.h"
 #include "wearable_log.h"
+#include "uicomponents/UIComponents.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -67,7 +68,7 @@ static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_X = 0;
 static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_Y = 0;
 static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_W = 466;
 static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_H = 466;
-const char **ReBootPathsArray{nullptr};                                     // 开机图片路径数组
+const  OHOS::ImageInfo **ReBootPathsArray{nullptr};                                     // 开机图片路径数组
 static OHOS::UIImageAnimatorView::AnimatorStopListener *bootStoplistener{nullptr};
 static bool boot_animation_flag = false;
 static app_task_definition_t taskcfg={0};
@@ -115,7 +116,8 @@ static void ClearAll(void)
             bootStoplistener = nullptr;
         }
 
-        FreeImagePathsArray(ReBootPathsArray, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+        // FreeImagePathsArray(ReBootPathsArray, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+        OHOS::FreeImageInfoArray(ReBootPathsArray, ReBootPaths, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
 
         delete group;
         group = nullptr;
@@ -163,7 +165,7 @@ static const char ** CreateImagePathsArray(const char *basePath, const char *fil
 
 bool ShowReBootAnimatorView()
 {
-    ReBootPathsArray = CreateImagePathsArray(ReBootPaths, "bin", REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+    ReBootPathsArray = OHOS::CreateImageInfoArray(ReBootPaths, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
 
     if (ReBootImageAnimatorView == nullptr)
     {
@@ -175,8 +177,8 @@ bool ShowReBootAnimatorView()
         }
         for (uint8_t i = 0; i < REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
         {
-            ReBootImageInfo[i].imagePath = (ReBootPathsArray[i]);
-            ReBootImageInfo[i].imageType = OHOS::IMG_SRC_FILE_PATH;
+            ReBootImageInfo[i].imageInfo = (ReBootPathsArray[i]);
+            ReBootImageInfo[i].imageType = OHOS::IMG_SRC_IMAGE_INFO;
             ReBootImageInfo[i].pos.x = REBOOT_IMAGE_ANIMATOR_VIEW_X;
             ReBootImageInfo[i].pos.y = REBOOT_IMAGE_ANIMATOR_VIEW_Y;
             ReBootImageInfo[i].width = REBOOT_IMAGE_ANIMATOR_VIEW_W;