• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 #ifndef HI_GV_RESM_H
17 #define HI_GV_RESM_H
18 
19 /* add include here */
20 #include "hi_type.h"
21 #include "hi_go.h"
22 #include "hi_gv_conf.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define UNLIMITED_REPEATE_COUNT (-1)
29 /* Invalid resource ID */
30 #define INVALID_RESID 0
31 /* The max length of resource file name */
32 #define HIGV_RESM_MAX_FILENAME_LEN 256
33 
34 /* The max alpha value */
35 #define HIGV_RESM_MAX_ALPHA 255
36 
37 /* Resource ID */
38 typedef HI_PARAM HI_RESID;
39 
40 /* Resource type */
41 typedef enum hiHIGV_RESTYPE_E {
42     HIGV_RESTYPE_IMG,
43     /* Picture resource */
44 
45     HIGV_RESTYPE_FONT,
46     /* Font resource */
47 
48     HIGV_RESTYPE_BUTT
49 } HIGV_RESTYPE_E;
50 
51 /* Skin type */
52 typedef enum hiHIGV_STYLE_TYPE_E {
53     HIGV_STYLETYPE_COLOR = 0,
54     /* Color type */
55     HIGV_STYLETYPE_PIC /* Picture type */
56 } HIGV_STYLE_TYPE_E;
57 
58 /*  Style union */
59 typedef union hiHIGV_STYLE_MEMBER_U {
60     HI_COLOR Color; /* Color value  */
61     HI_RESID ResId; /* Resource ID */
62 } HIGV_STYLE_MEMBER_U;
63 
64 /*  The style structure */
65 typedef struct hiHIGV_STYLE_S {
66     HIGV_STYLE_TYPE_E StyleType; /* Style type */
67     HIGV_STYLE_MEMBER_U
68     Top;     /* Top side (color or picture resource) */
69     HIGV_STYLE_MEMBER_U Bottom;
70     /* Bottom side (color or picture resource) */
71     HIGV_STYLE_MEMBER_U Left; /* Left side (color or picture resource */
72     HIGV_STYLE_MEMBER_U Right;    /* Right side (color or picture resource) */
73 
74     HIGV_STYLE_MEMBER_U LeftTop;    /* Top left co (color or picture resource) */
75 
76     HIGV_STYLE_MEMBER_U LeftBottom;    /* Top side (color or picture resource) */
77 
78     HIGV_STYLE_MEMBER_U RightTop;    /* Right top side (color or picture resource) */
79 
80     HIGV_STYLE_MEMBER_U RightBottom;    /* Right bottom side (color or picture resource) */
81 
82     HIGV_STYLE_MEMBER_U BackGround;    /* Background (color or picture resource) */
83 
84     HI_COLOR FontColor; /* Font color */
85     HI_U32 bNoDrawBg;   /* Is not draw background */
86     HI_U32 LineWidth;   /* Line width */
87     HI_U32 isRoundRect;
88     HI_U32 roundRadius;
89 } HIGV_STYLE_S;
90 
91 typedef struct hiHIGV_FONT_S {
92     HI_RESID SbFontID;
93     HI_RESID MbFontID;
94     HI_U32 Size;
95     HI_BOOL bBold;
96     HI_BOOL bItalic;
97     HI_U32 lineSpace;
98 } HIGV_FONT_S;
99 
100 typedef struct hiHIGV_DEC_SUFINFO_S {
101     HIGO_PF_E PixFormat;
102     HIGO_MEMTYPE_E MemType;
103     HI_BOOL IsPubPalette;
104 } HIGV_DEC_SUFINFO_S;
105 
106 typedef struct {
107     HI_CHAR *pTopName;         /* Resource file name of top side */
108     HI_CHAR *pBottomName;      /* Resource file name of bottom side */
109     HI_CHAR *pLeftName;        /* Resource file name of left side */
110     HI_CHAR *pRightName;       /* Resource file name of right side */
111     HI_CHAR *pLeftTopName;     /* Resource file name of top and left side */
112     HI_CHAR *pLeftBottomName;  /* Resource file name of bottom and left side */
113     HI_CHAR *pRightTopName;    /* Resource file name of right and up side */
114     HI_CHAR *pRightBottomName; /* Resource file name of right and bottom  side */
115     HI_CHAR *pBackGroundName;  /* Resource file name of background */
116 } HIGV_STYLEFILENAME_S;
117 
118 /*  The Anim structure */
119 typedef enum hiHIGV_ANIM_TYPE_E {
120     /* Translate type */
121     HIGV_ANIMTYPE_TRANSLATE = 0,
122     /* Alpha type */
123     HIGV_ANIMTYPE_ALPHA,
124     /* Roll type */
125     HIGV_ANIMTYPE_ROLL,
126     /* Any type */
127     HIGV_ANIMTYPE_ANY,
128     HIGV_ANIMTYPE_INVALIDATE
129 } HIGV_ANIM_TYPE_E;
130 
131 /* Animation repeat type */
132 typedef enum hiHIGV_ANIM_REPEAT_TYPE_E {
133     /* Repeate type restart */
134     HIGV_REPEATE_TYPE_RESTART = 0,
135     /* Repeate type reverse */
136     HIGV_REPEATE_TYPE_REVERSE
137 } HIGV_ANIM_REPEAT_TYPE_E;
138 
139 /* Animation roll type */
140 typedef enum {
141     HIGV_ANIM_ROLL_UP = 0, /* Up */
142     HIGV_ANIM_ROLL_DOWN,   /* Down */
143     HIGV_ANIM_ROLL_LEFT,   /* Letf */
144     HIGV_ANIM_ROLL_RIGHT   /* Right */
145 } HIGV_ANIM_ROLL_DIRECTION_E;
146 
147 /* Translate info */
148 typedef struct hiHIGV_ANIM_TRANSLATE_INFO_S {
149     HI_S32 FromX; /* ʼX */
150     HI_S32 FromY; /* ʼY */
151     HI_S32 ToX;   /* X */
152     HI_S32 ToY;   /* Y */
153 } HIGV_ANIM_TRANSLATE_INFO_S;
154 
155 /* Alpha info */
156 typedef struct hiHIGV_ANIM_ALPHA_INFO_S {
157     HI_U32 FromApha; /*  ʼAlpha */
158     HI_U32 ToAlpha;  /*  Alpha */
159 } HIGV_ANIM_ALPHA_INFO_S;
160 
161 /* Any info */
162 
163 typedef struct hiHIGV_ANIM_ANY_INFO_S {
164     HI_S32 FromValue; /*  ʼ Value */
165     HI_S32 ToValue;   /*   Value */
166 } HIGV_ANIM_ANY_INFO_S;
167 
168 /* Roll info */
169 
170 typedef struct hiHIGV_ANIM_ROLL_INFO_S {
171     HIGV_ANIM_ROLL_DIRECTION_E DirectionType; /*  */
172     HI_S32 FromLoc;                           /* ʼλ */
173     HI_S32 ToLoc;                             /* λ */
174 } HIGV_ANIM_ROLL_INFO_S;
175 
176 /* Animation info */
177 
178 typedef struct hiHIGV_ANIM_INFO_S {
179     HI_U32 AnimHandle;                  /* Anim ID */
180     HI_U32 DurationMs;                  /* Duration Times */
181     HI_S32 RepeatCount;                 /* Repeat Times */
182     HIGV_ANIM_REPEAT_TYPE_E RepeatMode;
183     HI_U32 DelayStart;
184     HIGV_ANIM_TYPE_E AnimType;
185     union {
186         HIGV_ANIM_TRANSLATE_INFO_S Translate;
187         HIGV_ANIM_ALPHA_INFO_S Alpha;
188         HIGV_ANIM_ROLL_INFO_S Roll;
189         HIGV_ANIM_ANY_INFO_S Any;
190     } AnimParam;
191 } HIGV_ANIM_INFO_S;
192 
193  /*
194 * brief Create resource ID.
195 * attention \n
196 * 1. The picture use ID in the system.
197 * 2. This function is effected by resource environment var
198 * param[in]  fileName    Picture file name.
199 * param[in]  resType Resource type.
200 * param[out] resId   Resource ID.
201 * retval ::HI_SUCCESS Success.
202 * retval ::HI_ERR_COMM_LOST Invalid handle.
203 * retval ::HI_ERR_COMM_NORES No memory.
204 * see ::HI_GV_Res_DestroyID
205 */
206 HI_S32 HI_GV_Res_CreateID(const HI_CHAR *fileName, HIGV_RESTYPE_E resType, HI_RESID *resID);
207 
208 /*
209 * brief Create resource ID no res prefix path.
210 * attention:
211 * The picture use ID in the system.
212 *
213 * param[in]  fileName    Picture file name.
214 * param[in]  resType Resource type.
215 * param[out] resId   Resource ID.
216 * retval ::HI_SUCCESS Success.
217 * retval ::HI_ERR_COMM_LOST Invalid handle.
218 * retval ::HI_ERR_COMM_NORES No memory.
219 * see ::HI_GV_Res_DestroyID
220 */
221 HI_S32 HI_GV_Res_CreateID_NoPrefixPath(const HI_CHAR *fileName, HIGV_RESTYPE_E resType, HI_RESID *resID);
222 
223 /*
224 * brief Disable application use resource environment variables.
225 * If you set the reource environment variable, and don't want usnet the env variable,
226 * you can call this function disable.
227 * [HIGV_RES_FONT_PATH, HIGV_RES_IMAGE_PATH] \attention \n N/A.
228 * retval ::HI_SUCCESS Success.
229 * see :: HI_GV_Res_CreateID_NoPrefixPath
230 */
231 HI_S32 HI_GV_Res_DisablePrefixPath(const HI_BOOL disable);
232 
233 /*
234 * brief Destroy resource id.
235 * param[in] resID Rouce ID.
236 * retval ::HI_SUCCESS Success.
237 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id .
238 * retval ::HI_ERR_RES_USED The resource is used.
239 * see :: HI_GV_Res_CreateID
240 */
241 HI_S32 HI_GV_Res_DestroyID(HI_RESID resID);
242 
243 /*
244 * brief Generate style.
245 * param[in]  style   Generate the information of the skin.
246 * param[out] styleHandle  Skin handle.
247 * retval ::HI_SUCCESS Success.
248 * retval ::HI_ERR_COMM_LOST Invalid handle.
249 * retval ::HI_ERR_COMM_NORES No memory.
250 * retval ::HI_ERR_COMM_INVAL Invalid parameter.
251 \* see :: HI_GV_Res_DestroyStyle
252 */
253 HI_S32 HI_GV_Res_CreateStyle(const HIGV_STYLE_S *style, HIGV_HANDLE *styleHandle);
254 
255 /*
256 * brief Generate Style by the resource ID.
257 * param[in] style Style pointer.
258 * param[in] styleHandle  Style handle.
259 * retval ::HI_SUCCESS Success.
260 * retval ::HI_ERR_COMM_NORES No memory.
261 * retval ::HI_ERR_COMM_INVAL Invalid parater.
262 */
263 HI_S32 HI_GV_Res_CreateStyleByHandle(const HIGV_STYLE_S *style, HIGV_HANDLE styleHandle);
264 
265 /*
266 * brief Destroy style.
267 * param[in] styleHandle  Style handle.
268 * retval ::HI_SUCCESS Success.
269 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id.
270 * see ::HI_GV_Res_CreateStyle
271 */
272 HI_S32 HI_GV_Res_DestroyStyle(HIGV_HANDLE styleHandle);
273 
274 /*
275 * brief Set the resource to persistent memory.
276 * param[in] resID Resource handle.
277 * retval ::HI_SUCCESS Success.
278 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id.
279 */
280 HI_S32 HI_GV_Res_SetResident(HI_RESID resID);
281 
282 /*
283 * brief Create font.
284 * param[in]  fontInfo the point of Font information.
285 * param[out] fontHandle     Font handle.
286 * retval ::HI_SUCCESS Success.
287 * retval ::HI_ERR_COMM_LOST Invalid handle.
288 * retval ::HI_ERR_COMM_NORES No memory.
289 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id.
290 * see ::HI_GV_Font_Destroy
291 */
292 HI_S32 HI_GV_Font_Create(const HIGV_FONT_S *fontInfo, HIGV_HANDLE *fontHandle);
293 
294 /*
295 * brief Create font by the handle.
296 * param[in] fontInfo
297 * param[in] fontHandle
298 * retval ::HI_SUCCESS Success.
299 * retval ::HI_ERR_COMM_LOST Invalid handle.
300 * retval ::HI_ERR_COMM_NORES No memory.
301 * retval ::HI_ERR_RES_UNKNOWRES
302 */
303 HI_S32 HI_GV_Font_CreateByHandle(const HIGV_FONT_S *fontInfo, HIGV_HANDLE fontHandle);
304 
305 /*
306 * brief Destroy font.
307 * param[in] fontHandle  Font handle.
308 * retval ::HI_SUCCESS Success.
309 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the font.
310 * see ::HI_GV_Font_Create
311 */
312 HI_S32 HI_GV_Font_Destroy(HIGV_HANDLE fontHandle);
313 
314 /*
315 * brief Set system default font.
316 * param[in] fontHandle Font handle.
317 * retval ::HI_SUCCESS
318 * see ::HI_GV_Font_GetSystemDefault
319 */
320 HI_S32 HI_GV_Font_SetSystemDefault(HIGV_HANDLE fontHandle);
321 
322 /*
323 * brief Get system default font.
324 * param[out] fontHandle Font handle.
325 * retval ::HI_SUCCESS Success.
326 * retval ::HI_ERR_COMM_INVAL Invalid handle.
327 * see ::HI_GV_Font_SetSystemDefault
328 */
329 HI_S32 HI_GV_Font_GetSystemDefault(HIGV_HANDLE *fontHandle);
330 
331 /*
332 * brief Get String width and height.
333 * param[in] fontHandle Font handle.
334 * param[in] strHandle String handle.
335 * param[out] width String width.
336 * param[out] height String height.
337 * retval ::HI_SUCCESS Success.
338 * retval ::HI_ERR_COMM_INVAL Invalid handle.
339 */
340 HI_S32 HI_GV_Font_GetTextExtent(HIGV_HANDLE fontHandle, HI_RESID strHandle, HI_S32 *width, HI_S32 *height);
341 
342 /*
343 * brief Destroy all style.
344 * attention \n
345 * Release the resource of style and don't rlease the picture resource.
346 *
347 * param N/A.
348 * retval ::HI_SUCCESS
349 * retval ::HI_ERR_RES_USED
350 */
351 HI_S32 HI_GV_Resm_DestroyAllStyle(HI_VOID);
352 
353 /*
354 * brief Destroy all resource.
355 * param N/A.
356 * retval ::HI_SUCCESS   Success.
357 */
358 HI_S32 HI_GV_Resm_DestroyAllRes(HI_VOID);
359 
360 /*
361 * brief Force to releaee all resource.
362 * param N/A.
363 * retval ::HI_SUCCESS   Success.
364 */
365 HI_S32 HI_GV_Resm_ForceUnloadAllRes(HI_VOID);
366 
367 /*
368 * brief Set the information of decode surface.
369 * param[in] DecSufinfo The information of decode surface.
370 * retval ::HI_SUCCESS Success.
371 * retval ::HI_ERR_COMM_INVAL Invalid parameter.
372 */
373 HI_S32 HI_GV_Resm_SetDecSurfInfo(const HIGV_DEC_SUFINFO_S *decSufInfo);
374 
375 /*
376 * brief Get the information of decode surface.
377 * param[out] decSufinfo The surface information of decode surface.
378 * retval ::HI_SUCCESS Success.
379 * retval ::HI_ERR_COMM_INVAL Invalid parameter.
380 */
381 HI_S32 HI_GV_Resm_GetDecSurfInfo(HIGV_DEC_SUFINFO_S *decSufInfo);
382 
383 /*
384 * brief Get the information of the surface which is for picture reource ID.
385 * param[in]  resID Resource ID.
386 * param[out] resHandle  the handle of resource surface.
387 * retval ::HI_SUCCESS  Success.
388 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id.
389 * retval ::HI_ERR_RES_LOAD   Load failed.
390 */
391 HI_S32 HI_GV_Res_GetResInfo(HI_RESID resID, HIGV_HANDLE *resHandle);
392 
393 /*
394 * brief Free the information of the surface which is for picture reource ID.
395 * param[in]  resID Resource ID.
396 * retval ::HI_SUCCESS  Success.
397 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id.
398 * retval ::HI_ERR_RES_NOLOAD   No Load.
399 */
400 HI_S32 HI_GV_Res_ReleaseResInfo(HI_RESID resID);
401 
402 /*
403 * brief Create font set.
404 * attention
405 *
406 * param[out] fontHandle
407 * retval ::HI_SUCCESS Success.
408 * retval ::HI_ERR_COMM_LOST Invalid handle.
409 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the font.
410 * see::HI_GV_FontSet_Destroy
411 */
412 HI_S32 HI_GV_FontSet_Create(HIGV_HANDLE *fontSet);
413 
414 /*
415 * brief Add font to font set.
416 * attention
417 * supportLan
418 * param[in] fontHandle Font handle.
419 * param[in]  supportLan The language which font support.
420 * Դ?뽨ʹISO-639 ׼ \param[in]  fontSetHandle  The handle of font set.
421 * retval ::HI_SUCCESS Success.
422 * retval ::HI_ERR_COMM_LOST Invalid handle.
423 * retval ::HI_ERR_COMM_NORES No memory.
424 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the reouce id.
425 * see ::HI_GV_FontSet_Destroy
426 */
427 HI_S32 HI_GV_FontSet_AddFont(HIGV_HANDLE fontHandle, const HI_CHAR *supportLan, HIGV_HANDLE fontSetHandle);
428 
429 /*
430 * brief  Query the font style which is the same as fontHandle from font set.
431 * param[in]  lan
432 * param[in] fontHandle     Font handle.
433 * param[out]  supprotFontHandle
434 * retval ::HI_SUCCESS Success.
435 * retval ::HI_ERR_COMM_LOST Invalid handle.
436 * retval ::HI_ERR_COMM_NORES No memory.
437 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the resource id.
438 * see ::HI_GV_FontSet_Destroy
439 */
440 HI_S32 HI_GV_FontSet_Query(const HI_CHAR *lan, HIGV_HANDLE fontHandle, HIGV_HANDLE *supprotFontHandle);
441 
442 /*
443 * brief Destroy font set.
444 * retval ::HI_SUCCESS Success.
445 * see :: HI_GV_Font_Create
446 */
447 HI_S32 HI_GV_FontSet_Destroy(HI_VOID);
448 
449 /*
450 * brief Get style file name.
451 * param[in]  styleHandle     Style handle.
452 * param[out] styleFileNameInfo  the file names of resource.
453 * retval ::HI_SUCCESS
454 */
455 HI_S32 HI_GV_Res_GetStyleFileName(HI_RESID styleHandle, HIGV_STYLEFILENAME_S *styleFileNameInfo);
456 
457 /*
458 * brief print resource information.
459 * param N/A.
460 * retval ::HI_SUCCESS
461 */
462 HI_S32 HI_GV_Res_PrintCurLoadResInfo(HI_VOID);
463 
464 /*
465 * brief Create animtion information.
466 * param[in]  animInfo the point of animtion information.
467 * param[out] animHandle  animtion information handle.
468 * retval ::HI_SUCCESS Success.
469 * retval ::HI_ERR_COMM_NORES No memory.
470 * see ::HI_GV_AnimInfo_Destroy
471 */
472 HI_S32 HI_GV_AnimInfo_Create(const HIGV_ANIM_INFO_S *animInfo, HIGV_HANDLE *animHandle);
473 
474 /*
475 * brief Create animtion information by the handle.
476 * param[in]  animInfo the point of animation information.
477 * param[in]  animHandle  Anim handle.
478 * retval ::HI_SUCCESS Success.
479 * retval ::HI_ERR_COMM_LOST Invalid handle.
480 * reval ::HI_ERR_COMM_NORES No memory.
481 */
482 HI_S32 HI_GV_AnimInfo_CreateByHandle(const HIGV_ANIM_INFO_S *animInfo, HIGV_HANDLE animHandle);
483 
484 /*
485 * brief Destroy font.
486 * param[in]  animHandle  Anim handle.
487 * retval ::HI_SUCCESS Success.
488 * retval ::HI_ERR_RES_UNKNOWRES Coun't find the anim.
489 * see ::HI_GV_AnimInfo_Create
490 */
491 HI_S32 HI_GV_AnimInfo_Destroy(HIGV_HANDLE animHandle);
492 
493 /*
494 * brief Get system default font.
495 * param[in]  animHandle  Anim handle.
496 * param[out] animInfo   Anim info.
497 * retval ::HI_SUCCESS Success.
498 * retval ::HI_ERR_COMM_INVAL Invalid handle.
499 * see ::HI_GV_AnimInfo_Create
500 */
501 HI_S32 HI_GV_AnimInfo_Get(HIGV_HANDLE animHandle, HIGV_ANIM_INFO_S *animInfo);
502 
503 #ifdef __cplusplus
504 }
505 #endif
506 #endif /* HI_GV_RESM_H */
507