Support wayland build.
[platform/framework/web/provider.git] / include / provider_buffer.h
1 /*
2  * Copyright 2013  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.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 __PROVIDER_BUFFER_H
18 #define __PROVIDER_BUFFER_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /*!
25  * \addtogroup CAPI_PROVIDER_MODULE
26  * \{
27  */
28
29 /*!
30  * \note
31  * This enumeration value has to be sync'd with the liblivebox interface. (only for inhouse livebox)
32  */
33 enum target_type {
34         TYPE_LB, /*!< */
35         TYPE_PD, /*!< */
36         TYPE_ERROR /*!< */
37 };
38
39 /*!
40  * \note
41  * This enumeration value should be sync'd with liblivebox interface. (only for inhouse livebox)
42  */
43 enum buffer_event {
44         BUFFER_EVENT_ENTER, /*!< */
45         BUFFER_EVENT_LEAVE, /*!< */
46         BUFFER_EVENT_DOWN, /*!< */
47         BUFFER_EVENT_MOVE, /*!< */
48         BUFFER_EVENT_UP, /*!< */
49
50         BUFFER_EVENT_KEY_DOWN, /*!< */
51         BUFFER_EVENT_KEY_UP, /*!< */
52         BUFFER_EVENT_KEY_FOCUS_IN, /*!< */
53         BUFFER_EVENT_KEY_FOCUS_OUT, /*!< */
54
55         BUFFER_EVENT_HIGHLIGHT,
56         BUFFER_EVENT_HIGHLIGHT_NEXT,
57         BUFFER_EVENT_HIGHLIGHT_PREV,
58         BUFFER_EVENT_ACTIVATE,
59         BUFFER_EVENT_ACTION_UP,
60         BUFFER_EVENT_ACTION_DOWN,
61         BUFFER_EVENT_SCROLL_UP,
62         BUFFER_EVENT_SCROLL_MOVE,
63         BUFFER_EVENT_SCROLL_DOWN,
64         BUFFER_EVENT_UNHIGHLIGHT
65 };
66
67 struct buffer_event_data {
68         enum buffer_event type;
69         double timestamp;
70
71         union input_data {
72                 struct mouse {
73                         int x;
74                         int y;
75                 } pointer;
76
77                 unsigned int keycode;
78         } info;
79 };
80
81 struct livebox_buffer;
82
83 /*!
84  * \brief Send request for acquiring buffer of given type.
85  * \details N/A
86  * \remarks N/A
87  * \param[in] type TYPE_LB or TYPE_PD, select the type of buffer. is it for LB? or PD?
88  * \param[in] pkgname Package name of a livebox instance
89  * \param[in] id Instance Id
90  * \param[in] width Width of buffer
91  * \param[in] height Height of buffer
92  * \param[in] pixel_size Normally, use "4" for this. it is fixed.
93  * \param[in] handler Event handler. Viewer will send the events such as mouse down,move,up, accessibilty event, etc,. via this callback function.
94  * \param[in] data Callback data for event handler
95  * \return livebox_buffer
96  * \retval Livebox buffer object handler
97  * \retval NULL if it fails to acquire buffer
98  * \pre N/A
99  * \post N/A
100  * \see provider_buffer_release
101  */
102 extern struct livebox_buffer *provider_buffer_acquire(enum target_type type, const char *pkgname, const char *id, int width, int height, int pixel_size, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data);
103
104 /*!
105  */
106 extern struct livebox_buffer *provider_buffer_create(enum target_type type, const char *pkgname, const char *id, int (*handler)(struct livebox_buffer *, struct buffer_event_data *, void *), void *data);
107
108 /*!
109  */
110 extern int provider_buffer_acquire_NEW(struct livebox_buffer *info, int width, int height, int pixel_size);
111
112 /*!
113  * \brief
114  * \details N/A
115  * \remarks N/A
116  * \param[in] info
117  * \param[in] w
118  * \param[in] h
119  * \return int
120  * \retval LB_STATUS_ERROR_INVALID
121  * \retval LB_STATUS_SUCCESS
122  * \pre N/A
123  * \post N/A
124  * \see N/A
125  */
126 extern int provider_buffer_resize(struct livebox_buffer *info, int w, int h);
127
128 /*!
129  * \brief Get the buffer address of given livebox buffer handle.
130  * \details N/A
131  * \remarks N/A
132  * \param[in] info Handle of livebox buffer
133  * \return address
134  * \retval Address of buffer
135  * \retval NULL
136  * \pre N/A
137  * \post N/A
138  * \see provider_buffer_unref
139  */
140 extern void *provider_buffer_ref(struct livebox_buffer *info);
141
142 /*!
143  * \brief Decrease the reference count of given buffer handle.
144  * \details N/A
145  * \remarks N/A
146  * \param[in] ptr Address that gets by provider_buffer_ref
147  * \return int
148  * \pre N/A
149  * \post N/A
150  * \see provider_buffer_ref
151  */
152 extern int provider_buffer_unref(void *ptr);
153
154 /*!
155  * \brief Release the acquired buffer handle.
156  * \details N/A
157  * \remarks N/A
158  * \param[in] info Handle of livebox buffer
159  * \return int
160  * \retval LB_STATUS_ERROR_INVALID
161  * \retval LB_STATUS_SUCCESS
162  * \pre N/A
163  * \post N/A
164  * \see provider_buffer_acquire
165  */
166 extern int provider_buffer_release(struct livebox_buffer *info);
167
168 /*!
169  */
170 extern int provider_buffer_release_NEW(struct livebox_buffer *info);
171 /*!
172  */
173 extern int provider_buffer_destroy(struct livebox_buffer *info);
174
175 /*!
176  *\brief Make content sync with master.
177  * \details N/A
178  * \remarks N/A
179  * \param[in] info Handle of livebox buffer
180  * \return int
181  * \retval LB_STATUS_ERROR_INVALID
182  * \retval LB_STATUS_SUCCESS
183  * \pre N/A
184  * \post N/A
185  * \see N/A
186  */
187 extern int provider_buffer_sync(struct livebox_buffer *info);
188
189 /*!
190  * \brief Get the buffer type
191  * \details N/A
192  * \remarks N/A
193  * \param[in] info Handle of livebox buffer
194  * \return target type PD or LB
195  * \retval TYPE_LB
196  * \retval TYPE_PD
197  * \retval TYPE_ERROR
198  * \pre N/A
199  * \post N/A
200  * \see N/A
201  */
202 extern enum target_type provider_buffer_type(struct livebox_buffer *info);
203
204 /*!
205  * \brief Get the package name
206  * \details N/A
207  * \remarks N/A
208  * \param[in] info
209  * \return const char *
210  * \retval NULL
211  * \retval pkgname package name
212  * \pre N/A
213  * \post N/A
214  * \see N/A
215  */
216 extern const char *provider_buffer_pkgname(struct livebox_buffer *info);
217
218 /*!
219  * \brief
220  * \details N/A
221  * \remarks N/A
222  * \param[in] info Handle of livebox buffer
223  * \return const char *
224  * \retval instance Id
225  * \retval NULL
226  * \pre N/A
227  * \post N/A
228  * \see N/A
229  */
230 extern const char *provider_buffer_id(struct livebox_buffer *info);
231
232 /*!
233  * \brief Give the URI of buffer information.
234  * \details N/A
235  * \remarks N/A
236  * \param[in] info Handle of livebox buffer
237  * \return const char *
238  * \retval uri
239  * \retval NULL
240  * \pre N/A
241  * \post N/A
242  * \see N/A
243  */
244 extern const char *provider_buffer_uri(struct livebox_buffer *info);
245
246 /*!
247  * \brief
248  * \details N/A
249  * \remarks N/A
250  * \param[in] info Handle of livebox buffer
251  * \param[out] w
252  * \param[out] h
253  * \param[out] pixel_size
254  * \return int
255  * \retval LB_STATUS_SUCCESS
256  * \retval LB_STATUS_ERROR_INVALID
257  * \pre N/A
258  * \post N/A
259  * \see N/A
260  */
261 extern int provider_buffer_get_size(struct livebox_buffer *info, int *w, int *h, int *pixel_size);
262
263 /*!
264  * \brief Getting the PIXMAP id of mapped on this livebox_buffer
265  * \details N/A
266  * \remarks N/A
267  * \param[in] info Handle of livebox buffer
268  * \return int
269  * \retval 0 if fails
270  * \retval pixmap id, has to be casted to unsigned int type
271  * \pre N/A
272  * \post N/A
273  * \see N/A
274  */
275 extern unsigned long provider_buffer_pixmap_id(struct livebox_buffer *info);
276
277 /*!
278  * \brief Initialize the provider buffer system
279  * \details N/A
280  * \remarks N/A
281  * \param[in] disp Display information for handling the XPixmap type.
282  * \return int
283  * \retval LB_STATUS_ERROR_FAULT
284  * \retval LB_STATUS_SUCCESS
285  * \pre N/A
286  * \post N/A
287  * \see N/A
288  */
289 extern int provider_buffer_init(void *disp);
290
291 /*!
292  * \brief Finalize the provider buffer system
293  * \details N/A
294  * \remarks N/A
295  * \return int
296  * \retval LB_STATUS_SUCCESS
297  * \pre N/A
298  * \post N/A
299  * \see N/A
300  */
301 extern int provider_buffer_fini(void);
302
303 /*!
304  * \brief Check whether current livebox buffer support H/W(GEM) buffer
305  * \details N/A
306  * \remarks N/A
307  * \param[in] info Handle of livebox buffer
308  * \return int
309  * \retval LB_STATUS_ERROR_INVALID
310  * \retval 1 if support
311  * \retval 0 if not supported
312  * \pre N/A
313  * \post N/A
314  * \see N/A
315  */
316 extern int provider_buffer_pixmap_is_support_hw(struct livebox_buffer *info);
317
318 /*!
319  * \brief Create H/W(GEM) Buffer
320  * \details N/A
321  * \remarks N/A
322  * \param[in] info Handle of livebox buffer
323  * \return int
324  * \retval LB_STATUS_SUCCESS
325  * \retval LB_STATUS_ERROR_INVALID
326  * \retval LB_STATUS_ERROR_FAULT
327  * \pre N/A
328  * \post N/A
329  * \see provider_buffer_pixmap_destroy_hw
330  */
331 extern int provider_buffer_pixmap_create_hw(struct livebox_buffer *info);
332
333 /*!
334  * \brief Destroy H/W(GEM) Buffer
335  * \details N/A
336  * \remarks N/A
337  * \param[in] info Handle of livebox buffer
338  * \return int
339  * \retval LB_STATUS_SUCCESS
340  * \retval LB_STATUS_ERROR_INVALID
341  * \pre N/A
342  * \post N/A
343  * \see provider_buffer_pixmap_create_hw
344  */
345 extern int provider_buffer_pixmap_destroy_hw(struct livebox_buffer *info);
346
347 /*!
348  * \brief Get the H/W system mapped buffer address(GEM buffer) if a buffer support it.
349  * \details N/A
350  * \remarks N/A
351  * \param[in] info Handle of livebox buffer
352  * \return void *
353  * \retval H/W system mapped buffer address
354  * \retval NULL fails to get buffer address
355  * \pre N/A
356  * \post N/A
357  * \see provider_buffer_pixmap_create_hw
358  * \see provider_buffer_pixmap_destroy_hw
359  */
360 extern void *provider_buffer_pixmap_hw_addr(struct livebox_buffer *info);
361
362 /*!
363  * \brief Prepare the render buffer to write or read something on it.
364  * \details N/A
365  * \remarks N/A
366  * \param[in] info Handle of livebox buffer
367  * \return int
368  * \retval LB_STATUS_SUCCESS
369  * \retval LB_STATUS_ERROR_INVALID
370  * \retval LB_STATUS_ERROR_FAULT
371  * \pre N/A
372  * \post N/A
373  * \see provider_buffer_post_render
374  */
375 extern int provider_buffer_pre_render(struct livebox_buffer *info);
376
377 /*!
378  * \brief Finish the render buffer acessing.
379  * \details N/A
380  * \remarks N/A
381  * \param[in] info Handle of livebox buffer
382  * \return int
383  * \retval LB_STATUS_SUCCESS
384  * \retval LB_STATUS_ERROR_INVALID
385  * \pre N/A
386  * \post N/A
387  * \see provider_buffer_pre_render
388  */
389 extern int provider_buffer_post_render(struct livebox_buffer *info);
390
391 /*!
392  * \brief
393  * \details N/A
394  * \remarks N/A
395  * \param[in] handle Handle of livebox buffer
396  * \return void *
397  * \retval User data
398  * \pre N/A
399  * \post N/A
400  * \see provider_buffer_set_user_data
401  */
402 extern void *provider_buffer_user_data(struct livebox_buffer *handle);
403
404 /*!
405  * \brief
406  * \details N/A
407  * \remarks N/A
408  * \param[in] handle Handle of livebox buffer
409  * \param[in] data User data
410  * \return int
411  * \retval LB_STATUS_SUCCESS
412  * \retval LB_STATUS_ERROR_INVALID
413  * \pre N/A
414  * \post N/A
415  * \see provider_buffer_user_data
416  */
417 extern int provider_buffer_set_user_data(struct livebox_buffer *handle, void *data);
418
419 /*!
420  * \brief
421  * \details N/A
422  * \remarks N/A
423  * \param[in] type
424  * \param[in] pkgname
425  * \param[in] id
426  * \return livebox_buffer
427  * \retval NULL
428  * \retval handle
429  * \pre N/A
430  * \post N/A
431  */
432 extern struct livebox_buffer *provider_buffer_find_buffer(enum target_type type, const char *pkgname, const char *id);
433
434 /*!
435  * \}
436  */
437
438 #ifdef __cplusplus
439 }
440 #endif
441
442 #endif
443 /* End of a file */