371daf4ea1ac753a070c903b57d77ee6b6ad6fbf
[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_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_buffer(ani->ani_h);
41
42         if (!buffer)
43                 return NULL;
44
45         return buffer;
46 }
47
48 pui_int_error
49 pui_backend_ani_set_buffer(pui_ani_t *ani, pui_ani_control_buffer *buffer)
50 {
51         pui_int_error err = PUI_INT_ERROR_NONE;
52
53         if (!PUI_MAGIC_CHECK(ani, PUI_MAGIC_ANI_T))
54         {
55                 PUI_MAGIC_FAIL(ani, PUI_MAGIC_ANI_T, __FUNCTION__);
56                 return PUI_INT_ERROR_INVALID_BUFFER;
57         }
58
59         if (!buffer)
60                 return PUI_INT_ERROR_INVALID_BUFFER;
61
62         err = pui_ani_set_buffer(ani->ani_h, buffer);
63
64         return err;
65 }
66
67 pui_int_error
68 pui_backend_ani_update(pui_ani_t *ani)
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_HANDLE;
76         }
77
78         err = pui_ani_update(ani->ani_h);
79
80         return err;
81 }
82
83 pui_ani_status
84 pui_backend_ani_status_get(pui_ani_t *ani)
85 {
86         return pui_ani_status_get(ani);
87 }
88
89 pui_bool
90 pui_backend_ani_add_frame_cb(pui_ani_t *ani, pui_bool (*frame_cb)(void *data, int serial), double frame_interval)
91 {
92         return pui_ani_add_frame_cb(ani, frame_cb, frame_interval);
93 }
94
95 void
96 pui_backend_ani_remove_frame_cb(pui_ani_t *ani)
97 {
98         pui_ani_remove_frame_cb(ani);
99 }
100
101 void
102 pui_backend_ani_status_update(pui_ani_t *ani, pui_ani_status status)
103 {
104         pui_ani_status_update(ani, status);
105 }
106
107 pui_backend_ani_func *
108 pui_backend_ani_alloc_ani_func(void)
109 {
110         pui_backend_ani_func *ani_func = NULL;
111
112         ani_func = (pui_backend_ani_func *)calloc(1, sizeof(pui_backend_ani_func));
113
114         if (!ani_func)
115         {
116                 pui_err("Failed to allocate memory !\n");
117                 return NULL;
118         }
119
120         return ani_func;
121 }
122
123 void
124 pui_backend_ani_free_ani_func(pui_backend_ani_func *ani_func)
125 {
126         if (!ani_func)
127         {
128                 pui_err("Invalid ani backend_func pointer !\n");
129                 return;
130         }
131
132         free(ani_func);
133 }
134
135 pui_backend_ani_data *
136 pui_backend_ani_get_ani_data(pui_ani_t *ani)
137 {
138         return pui_ani_get_ani_data(ani);
139 }
140