default_backend: do not allocate frame whenever each frames
[platform/core/uifw/libpui.git] / backends / default_backend.h
1 /*
2  * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial
14  * portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <PUI_backend.h>
29
30 #include <json-c/json.h>
31 #include <dirent.h>
32 #include <errno.h>
33 #include <Eina.h>
34 #include <config.h>
35 #include <Ecore.h>
36 //#include <cmath.h>
37
38 #define ANI_COLLECTION_DIR "/usr/share/pui/"
39 #define MAX_STR 1024
40
41 #define DEFAULT_BACKEND_GEOM_WIDTH 12
42 #define DEFAULT_BACKEND_GEOM_HEIGHT 1
43
44 #ifndef PI
45 #define PI 3.1415926545
46 #endif
47
48 #define LED_MASK_RED   0xFF0000
49 #define LED_MASK_GREEN 0x00FF00
50 #define LED_MASK_BLUE  0x0000FF
51
52 #define ERROR_CHECK(exp, action, fmt, ...) \
53         do { \
54                 if (!(exp)) \
55                 { \
56                         printf(fmt, ##__VA_ARGS__);     \
57                         action; \
58                 } \
59         } while (0)
60
61 typedef enum
62 {
63         None,
64         Linear,
65         EaseInSine,
66         EaseOutSine,
67         EaseInQuart,
68         EaseOutQuart
69 } pui_effect_func;
70
71 typedef struct _default_ani_info default_ani_info;
72 typedef struct _default_frame_info_t default_frame_info_t;
73 typedef struct _default_led_info_t default_led_info_t;
74
75 struct _default_ani_info
76 {
77         pui_id id;
78         pui_ani_status status;
79         pui_ani_control_buffer *buffer;
80         int repeat;
81
82         unsigned int num_key_frames;
83         default_frame_info_t *frames;
84         int interval;
85         unsigned int max_leds;
86         pui_effect_func effect_func;
87
88         unsigned int repeat_cur;
89         unsigned int frame_idx;
90         unsigned int frame_max;
91         unsigned int key_frame_cur;
92 };
93
94 struct _default_frame_info_t
95 {
96         default_led_info_t *leds;
97         int num_led;
98         int frame_duration;
99 };
100
101 struct _default_led_info_t
102 {
103         unsigned int color;
104 };
105
106 default_frame_info_t *backend_util_alloc_frame(default_ani_info *ani_info);
107 void backend_util_cleanup_frame(default_frame_info_t *frame);
108 void backend_util_free_frame(default_frame_info_t *frame);
109
110 void pui_default_backend_ani_listening_func_set(pui_backend_ani_func *func);
111 void pui_default_backend_ani_speaking_func_set(pui_backend_ani_func *func);
112 void pui_default_backend_ani_processing_func_set(pui_backend_ani_func *func);
113 void pui_default_backend_ani_streaming_func_set(pui_backend_ani_func *func);
114 void pui_default_backend_ani_timeout_func_set(pui_backend_ani_func *func);
115 void pui_default_backend_ani_system_processing_func_set(pui_backend_ani_func *func);
116 void pui_default_backend_ani_normal_func_set(pui_backend_ani_func *func);
117 void pui_default_backend_ani_emergency_func_set(pui_backend_ani_func *func);
118 void pui_default_backend_ani_easysetup_func_set(pui_backend_ani_func *func);
119 void pui_default_backend_ani_swupdatedone_func_set(pui_backend_ani_func *func);
120 void pui_default_backend_ani_micoff_func_set(pui_backend_ani_func *func);
121 void pui_default_backend_ani_networkerror_func_set(pui_backend_ani_func *func);
122 void pui_default_backend_ani_error_func_set(pui_backend_ani_func *func);
123 void pui_default_backend_ani_alarm_func_set(pui_backend_ani_func *func);
124 void pui_default_backend_ani_connected_func_set(pui_backend_ani_func *func);
125 void pui_default_backend_ani_pairing_func_set(pui_backend_ani_func *func);