backend: add default clear animations
[platform/core/uifw/libpui.git] / src / PUI_backend.c
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 "PUI_internal.h"
27 #include "PUI_backend.h"
28
29 pui_ani_control_buffer *
30 pui_backend_ani_get_last_buffer(pui_ani_t *ani)
31 {
32         pui_ani_control_buffer *buffer = NULL;
33
34         if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
35         {
36                 PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
37                 return NULL;
38         }
39
40         buffer = pui_ani_get_last_buffer(ani->ani_h);
41
42         if (!buffer)
43                 return NULL;
44
45         return buffer;
46 }
47
48 pui_ani_control_buffer *
49 pui_backend_ani_get_buffer(pui_ani_t *ani)
50 {
51         pui_ani_control_buffer *buffer = NULL;
52
53         if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
54         {
55                 PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
56                 return NULL;
57         }
58
59         buffer = pui_ani_get_buffer(ani->ani_h);
60
61         if (!buffer)
62                 return NULL;
63
64         return buffer;
65 }
66
67 pui_int_error
68 pui_backend_ani_set_buffer(pui_ani_t *ani, pui_ani_control_buffer *buffer)
69 {
70         pui_int_error err = PUI_INT_ERROR_NONE;
71
72         if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
73         {
74                 PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
75                 return PUI_INT_ERROR_INVALID_BUFFER;
76         }
77
78         if (!buffer)
79                 return PUI_INT_ERROR_INVALID_BUFFER;
80
81         err = pui_ani_set_buffer(ani->ani_h, buffer);
82
83         return err;
84 }
85
86 pui_int_error
87 pui_backend_ani_update(pui_ani_t *ani)
88 {
89         pui_int_error err = PUI_INT_ERROR_NONE;
90
91         if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
92         {
93                 PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
94                 return PUI_INT_ERROR_INVALID_HANDLE;
95         }
96
97         err = pui_ani_update(ani->ani_h);
98
99         return err;
100 }
101
102 pui_ani_status
103 pui_backend_ani_status_get(pui_ani_t *ani)
104 {
105         return pui_ani_status_get(ani);
106 }
107
108 pui_bool
109 pui_backend_ani_add_frame_cb(pui_ani_t *ani, pui_bool (*frame_cb)(void *data, int serial), double frame_interval)
110 {
111         return pui_ani_add_frame_cb(ani, frame_cb, frame_interval);
112 }
113
114 void
115 pui_backend_ani_remove_frame_cb(pui_ani_t *ani)
116 {
117         pui_ani_remove_frame_cb(ani);
118 }
119
120 void
121 pui_backend_ani_status_update(pui_ani_t *ani, pui_ani_status status)
122 {
123         pui_ani_status_update(ani, status);
124 }
125
126 pui_backend_ani_func *
127 pui_backend_ani_alloc_ani_func(void)
128 {
129         pui_backend_ani_func *ani_func = NULL;
130
131         ani_func = (pui_backend_ani_func *)calloc(1, sizeof(pui_backend_ani_func));
132
133         if (!ani_func)
134         {
135                 pui_err("Failed to allocate memory !\n");
136                 return NULL;
137         }
138
139         return ani_func;
140 }
141
142 void
143 pui_backend_ani_free_ani_func(pui_backend_ani_func *ani_func)
144 {
145         if (!ani_func)
146         {
147                 pui_err("Invalid ani backend_func pointer !\n");
148                 return;
149         }
150
151         free(ani_func);
152 }
153
154 pui_backend_ani_data *
155 pui_backend_ani_get_ani_data(pui_ani_t *ani)
156 {
157         return pui_ani_get_ani_data(ani);
158 }
159