Update the H/W buffer support API
[apps/livebox/livebox.git] / include / livebox.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __LIVEBOX_HELPER_H
18 #define __LIVEBOX_HELPER_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 struct livebox_buffer; /* Defined by provider */
25
26 /*!
27  * \brief
28  * Return values of livebox programming interfaces.
29  */
30 extern const int DONE; /*!< Operation is successfully done */
31 extern const int OUTPUT_UPDATED; /*!< Contents is updated */
32
33 extern const int NEED_TO_SCHEDULE; /*!< Need to call the livebox_need_to_update and livebox_update_content */
34 extern const int NEED_TO_CREATE; /*!< Need to create a new instance */
35 extern const int NEED_TO_DESTROY; /*!< Need to destroy this instance */
36 extern const int NEED_TO_UPDATE;
37
38 extern const int USE_NET; /*!< Using network */
39
40 extern const int LB_SYS_EVENT_FONT_CHANGED; /*!< System font is changed */
41 extern const int LB_SYS_EVENT_LANG_CHANGED; /*!< System language is changed */
42 extern const int LB_SYS_EVENT_TIME_CHANGED; /*!< System time is changed */
43 extern const int LB_SYS_EVENT_PAUSED;
44 extern const int LB_SYS_EVENT_RESUMED;
45
46 #define LB_DESC_TYPE_COLOR "color"
47 #define LB_DESC_TYPE_TEXT "text"
48 #define LB_DESC_TYPE_IMAGE "image"
49 #define LB_DESC_TYPE_SIGNAL "signal"
50 #define LB_DESC_TYPE_INFO "info"
51 #define LB_DESC_TYPE_DRAG "drag"
52 #define LB_DESC_TYPE_SCRIPT "script"
53
54 /*!
55  * \brief
56  * Extra event informatino for livebox_content_event interface function
57  */
58 #ifndef __PROVIDER_H
59 struct event_info {
60         struct {
61                 double x;
62                 double y;
63                 int down;
64         } pointer; /*!< Down/Up state and mouse position */
65
66         struct {
67                 double sx;
68                 double sy;
69                 double ex;
70                 double ey;
71         } part; /*!< Geometry of event received part */
72 };
73 #endif
74
75 struct livebox_desc;
76
77 /*!
78  * \brief Update a description file.
79  * \param[in] filename
80  * \param[in] for_pd
81  * \return handle
82  */
83 extern struct livebox_desc *livebox_desc_open(const char *filename, int for_pd);
84
85 /*!
86  * \brief Complete the description file updating
87  * \param[in] handle
88  * \return int
89  */
90 extern int livebox_desc_close(struct livebox_desc *handle);
91
92 /*!
93  * \brief Set the category information of current description data
94  * \param[in] handle
95  * \param[in] id
96  * \param[in] category
97  * \return int
98  */
99 extern int livebox_desc_set_category(struct livebox_desc *handle, const char *id, const char *category);
100
101 /*!
102  * \brief Set the content size
103  * \param[in] handle
104  * \param[in] id
105  * \param[in] w
106  * \param[in] h
107  * \return int
108  */
109 extern int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int w, int h);
110
111 /*!
112  * \breif Set the target id of given block
113  *        Only available for the script block
114  * \param[in] handle
115  * \param[in] idx
116  * \param[in] id
117  * \return ret
118  */
119 extern int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id);
120
121 /*!
122  * \brief Add a new block
123  * \param[in] handle
124  * \param[in] id ID of source script object
125  * \param[in] type image|text|script|signal|...
126  * \param[in] part target part to update with given content(data)
127  * \param[in] data content for specified part
128  * \param[in] option option for the block. (script: group, image: option, ...)
129  * \return idx Index of current description block
130  */
131 extern int livebox_desc_add_block(struct livebox_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option);
132
133 /*!
134  * \brief Delete a added block
135  * \param[in] handle
136  * \param[in] idx Index of added block
137  * \return int
138  */
139 extern int livebox_desc_del_block(struct livebox_desc *handle, int idx);
140
141 /*!
142  * \brief Replace '\n' with '<br>'
143  * \param[in] str Source string
144  * \return char* allocated string
145  */
146 extern char *livebox_util_nl2br(const char *str);
147
148
149 /*!
150  * Interfaces for direct buffer management (Available only for the PD area)
151  */
152
153
154 #ifndef __PROVIDER_BUFFER_H
155 /*!
156  * \NOTE
157  * This enumeration value should be sync'd with provider
158  */
159 enum buffer_event {
160         BUFFER_EVENT_ENTER, /*!< Mouse cursor enter */
161         BUFFER_EVENT_LEAVE, /*!< Mouse cursor leave */
162         BUFFER_EVENT_DOWN, /*!< Mouse down */
163         BUFFER_EVENT_MOVE, /*!< Mouse move */
164         BUFFER_EVENT_UP, /*!< Mouse up */
165
166         BUFFER_EVENT_KEY_DOWN, /*!< Key down */
167         BUFFER_EVENT_KEY_UP, /*!< Key up */
168 };
169 #endif
170
171 /*!
172  * \brief Acquire a buffer for PD or LB, Currently, we only supporting the PD.
173  * \param[in] id Id of a livebox instance
174  * \param[in] is_pd 1 for PD or 0 for livebox
175  * \param[in] width Width
176  * \param[in] height Height
177  * \param[in] handler Event handling callback
178  * \param[in] data user data for event handling callback
179  * \return handler Buffer handle
180  */
181 extern struct livebox_buffer *livebox_acquire_buffer(const char *id, int is_pd, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data);
182
183 /*!
184  * \brief Acquire the ID of pixmap resource
185  *        Only if the provider uses pixmap for providing render buffer.
186  * \param[in] handle Buffer handle
187  * \return pixmap ID if succeed or 0lu
188  * \see livebox_acquire_buffer
189  */
190 extern unsigned long livebox_pixmap_id(struct livebox_buffer *handle);
191
192 /*!
193  * \brief
194  * \param[in] handle Buffer handle
195  * \return int
196  * \see livebox_acquire_buffer
197  */
198 extern int livebox_release_buffer(struct livebox_buffer *handle);
199
200 /*!
201  * \brief Get the address of S/W render buffer.
202  *        If you try to use this, after create_hw_buffer, you will get NULL
203  * \param[in] handle Buffer handle
204  * \return void* address of the render buffer
205  * \see livebox_unref_buffer
206  */
207 extern void *livebox_ref_buffer(struct livebox_buffer *handle);
208
209 /*!
210  * \brief Release the S/W render buffer.
211  * \param[in] void* Address of render buffer
212  * \return int 0 if succeed or errno < 0
213  * \see livebox_ref_buffer
214  */
215 extern int livebox_unref_buffer(void *buffer);
216
217 /*!
218  * \brief Sync the updated buffer
219  *        This is only needed for non-H/W accelerated buffer
220  * \param[in] handler Buffer handle
221  * \return int 0 if succeed or errno < 0
222  * \see livebox_acquire_buffer
223  */
224 extern int livebox_sync_buffer(struct livebox_buffer *handle);
225
226 /*!
227  * \brief Request schedule the update operation to a provider.
228  * \param[in] id Livebox Id
229  * \return int 0 if succeed or errno < 0
230  */
231 extern int livebox_request_update(const char *id);
232
233 /*!
234  * \brief Checking wether the livebox support H/W acceleration or not.
235  * \param[in] handle Buffer handle.
236  * \return 1 if support or 0
237  * \see livebox_acquire_buffer
238  */
239 extern int livebox_support_hw_buffer(struct livebox_buffer *handle);
240
241 /*!
242  * \brief Create the H/W accelerated buffer.
243  * \param[in] handle Buffer handle
244  * \return 0 if succeed to create it or errno < 0
245  * \see livebox_support_hw_buffer
246  */
247 extern int livebox_create_hw_buffer(struct livebox_buffer *handle);
248
249 /*!
250  * \brief Destroy the H/W accelerated buffer.
251  * \param[in] handle Buffer handle
252  * \return 0 if succeed to destroy it or errno < 0
253  * \see livebox_create_hw_buffer
254  */
255 extern int livebox_destroy_hw_buffer(struct livebox_buffer *handle);
256
257 /*!
258  * \brief Get the address of accelerated H/W buffer
259  * \param[in] handle Buffer handle
260  * \return void
261  * \see livebox_create_hw_buffer
262  */
263 extern void *livebox_buffer_hw_buffer(struct livebox_buffer *handle);
264
265 /*!
266  * \brief Pre-processing for rendering content.
267  *        This is only needed for accessing H/W accelerated buffer.
268  * \param[in] handle Buffer handle
269  * \return 0 if succeed or errno < 0
270  * \see livebox_support_hw_buffer
271  */
272 extern int livebox_buffer_pre_render(struct livebox_buffer *handle);
273
274 /*!
275  * \brief Post-processing for rendering content.
276  * \param[in] handle Buffer handle
277  * \return 0 if succeed or errno < 0
278  * \see livebox_support_hw_buffer
279  */
280 extern int livebox_buffer_post_render(struct livebox_buffer *handle);
281
282 #ifdef __cplusplus
283 }
284 #endif
285
286 #endif
287 /* End of a file */