• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup UI_Utils
18  * @{
19  *
20  * @brief Defines basic UI utils.
21  *
22  * @since 1.0
23  * @version 1.0
24  */
25 
26 /**
27  * @file mem_api.h
28  *
29  * @brief Defines the functions for memory application and release. You can implement the <b>malloc</b> and <b>free</b>
30  *        functions to manage the memory.
31  *
32  * @since 1.0
33  * @version 1.0
34  */
35 
36 #ifndef GRAPHIC_LITE_MEM_API_H
37 #define GRAPHIC_LITE_MEM_API_H
38 
39 #include "graphic_config.h"
40 #include "gfx_utils/image_info.h"
41 
42 #ifndef IMG_CACHE_MEMORY_CUSTOM
43 #include <cstdlib>
44 #endif
45 
46 namespace OHOS {
47 /**
48  * @brief Applies for the image cache memory. You can customize the memory area when loading image resources.
49  *
50  * @param info Indicates the image information. For details, see {@link ImageInfo}.
51  * @since 1.0
52  * @version 1.0
53  */
54 void* ImageCacheMalloc(ImageInfo& info);
55 
56 /**
57  * @brief Releases the image cache memory.
58  *
59  * @param info Indicates the image information. For details, see {@link ImageInfo}.
60  * @since 1.0
61  * @version 1.0
62  */
63 void ImageCacheFree(ImageInfo& info);
64 
65 /**
66  * @brief Applies for memory for the graphics module. You can implement this function to override the <b>malloc</b> and
67  *        <b>new</b> functions.
68  *
69  * @param size Indicates the size of the memory to apply for.
70  * @since 1.0
71  * @version 1.0
72  */
73 void* UIMalloc(uint32_t size);
74 
75 /**
76  * @brief Releases memory for the graphics module. You can implement this function to override the <b>free</b> and
77  *        <b>delete</b> functions.
78  *
79  * @param buffer Indicates the pointer to the memory to be released.
80  * @since 1.0
81  * @version 1.0
82  */
83 void UIFree(void* buffer);
84 
85 /**
86  * @brief 重新调整之前调用UIMalloc所分配的内存指针所指向的内存块的大小
87  *
88  * @param bbuffer 指向内存区的指针
89  * @param size 分配的内存块大小
90  * @since 3.0
91  * @version 5.0
92  */
93 void* UIRealloc(void* buffer, uint32_t size);
94 } // namespace OHOS
95 #endif
96