pui: store a last updated buffer and return
[platform/core/uifw/libpui.git] / src / PUI_internal.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 #ifndef _LIBPUI_INTERNAL_H_
27 #define _LIBPUI_INTERNAL_H_
28
29 #define EFL_BETA_API_SUPPORT
30
31 #include <stdint.h>
32 #include <Ecore_Wl2.h>
33 #include <Eina.h>
34 #include <wayland-tbm-client.h>
35 #include <tbm_surface_internal.h>
36 #include "PUI_common.h"
37
38 #ifndef PATH_MAX
39 #define PATH_MAX 4096
40 #endif
41
42 #define PUI_MAGIC_NONE          0xfedc4321
43 #define PUI_MAGIC_PUI_M 0xDE9BBFAE
44 #define PUI_MAGIC_PUI_H 0xDE89C0AD
45 #define PUI_MAGIC_ANI_H 0xDE77C1AC
46 #define PUI_MAGIC_ANI_T 0xDE65C2AB
47
48 typedef unsigned int PUI_Magic;
49 #define PUI_MAGIC       PUI_Magic __magic
50
51 #define PUI_MAGIC_SET(p, m)             (p)->__magic = (m)
52 #define PUI_MAGIC_CHECK(p, m)   ((p) && ((p)->__magic == (m)))
53 #define PUI_MAGIC_FAIL(p, m, fn)        _pui_magic_fail((p), (p) ? (p)->__magic : 0, (m), (fn));
54
55 struct _pui_ani
56 {
57         PUI_MAGIC;
58
59         pui_h pui_handle;
60         pui_ani_t *ani;
61
62         Eina_Array *ecore_event_hdls;
63         Ecore_Wl2_Frame_Cb_Handle *frame_done_cb;
64
65         pui_id id;
66 };
67
68 struct _pui_ani_t
69 {
70         PUI_MAGIC;
71
72         pui_ani_h ani_h;
73         pui_id id;
74         pui_ani_cmd cmd;
75         int repeat;
76         pui_ani_status status;
77
78         int serial;
79         pui_ani_control_buffer *buffer;
80
81         Eina_Bool (*frame_cb)(void *data);
82         pui_bool (*backend_frame_cb)(void *data, int serial);
83         void *frame_cb_data;
84         double frame_interval;
85         Ecore_Timer *frame_cb_timer;
86
87         pui_backend_ani_data *ani_data;
88 };
89
90 struct _pui
91 {
92         PUI_MAGIC;
93
94         Ecore_Wl2_Window *win;
95         Ecore_Wl2_Display *ewd;
96         int visibility;
97
98         struct wayland_tbm_client *wl_tbm_client;
99         tbm_surface_queue_h tbm_queue;
100
101         pui_ani_h current_ani_h;
102         tbm_surface_info_s current_sinfo;
103         tbm_surface_h current_surface;
104         pui_ani_control_buffer last_buffer;
105         int is_buffer_set;
106         pui_bool manual_render;
107
108         Eina_List *ani_handles;
109
110         pui_backend_module_data *backend_module_data;
111 };
112
113 struct _pui_module_data
114 {
115         PUI_MAGIC;
116
117         void *module_info;
118         pui_backend_module *backend_module_info;
119         pui_backend_module_data *backend_module_data;
120 };
121
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125
126 void
127 _pui_magic_fail(const void *p, PUI_Magic m, PUI_Magic req_m, const char *fname);
128
129 pui_ani_control_buffer *
130 pui_ani_get_last_buffer(pui_ani_h ani_h);
131
132 pui_ani_control_buffer *
133 pui_ani_get_buffer(pui_ani_h ani_h);
134
135 pui_int_error
136 pui_ani_set_buffer(pui_ani_h ani_h, pui_ani_control_buffer *buffer);
137
138 pui_int_error
139 pui_ani_update(pui_ani_h ani_h);
140
141 pui_bool
142 pui_ani_add_frame_cb(pui_ani_t *ani, pui_bool (*frame_cb)(void *data, int serial), double frame_interval);
143
144 void
145 pui_ani_remove_frame_cb(pui_ani_t *ani);
146
147 void
148 pui_ani_status_update(pui_ani_t *ani, pui_ani_status status);
149
150 pui_ani_status
151 pui_ani_status_get(pui_ani_t *ani);
152
153 pui_backend_ani_data *
154 pui_ani_get_ani_data(pui_ani_t *ani);
155
156 #ifdef __cplusplus
157 }
158 #endif
159
160 #endif//_LIBPUI_INTERNAL_H_