Tizen 2.1 release
[platform/core/uifw/e17.git] / src / modules / wl_drm / e_sprite.c
1 #include "e.h"
2 #include "e_mod_main.h"
3
4 /* local function prototypes */
5 static void _e_sprite_cb_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__);
6 static void _e_sprite_cb_pending_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__);
7
8 /* local variables */
9 /* wayland interfaces */
10 /* external variables */
11
12 EINTERN E_Sprite *
13 e_sprite_create(E_Drm_Compositor *dcomp, drmModePlane *plane)
14 {
15    E_Sprite *es;
16
17    DLOGFN(__FILE__, __LINE__, __FUNCTION__);
18
19    if (!plane) return NULL;
20
21    es = malloc(sizeof(E_Sprite) + ((sizeof(unsigned int)) * plane->count_formats));
22    if (!es) return NULL;
23
24    memset(es, 0, sizeof(E_Sprite));
25
26    es->compositor = dcomp;
27    es->possible_crtcs = plane->possible_crtcs;
28    es->plane_id = plane->plane_id;
29    es->surface = NULL;
30    es->pending_surface = NULL;
31    es->fb_id = 0;
32    es->pending_fb_id = 0;
33    es->destroy_listener.notify = _e_sprite_cb_buffer_destroy;
34    es->pending_destroy_listener.notify = _e_sprite_cb_pending_buffer_destroy;
35    es->format_count = plane->count_formats;
36    memcpy(es->formats, plane->formats, 
37           plane->count_formats * sizeof(plane->formats[0]));
38
39    return es;
40 }
41
42 EINTERN Eina_Bool 
43 e_sprite_crtc_supported(E_Output *output, unsigned int supported)
44 {
45    E_Compositor *comp;
46    E_Drm_Compositor *dcomp;
47    E_Drm_Output *doutput;
48    int crtc = 0;
49
50    DLOGFN(__FILE__, __LINE__, __FUNCTION__);
51
52    comp = output->compositor;
53    dcomp = (E_Drm_Compositor *)comp;
54    doutput = (E_Drm_Output *)output;
55
56    for (crtc = 0; crtc < dcomp->num_crtcs; crtc++)
57      {
58         if (dcomp->crtcs[crtc] != doutput->crtc_id)
59           continue;
60         if (supported & (1 << crtc)) 
61           return EINA_TRUE;
62      }
63
64    return EINA_FALSE;
65 }
66
67 /* local functions */
68 static void 
69 _e_sprite_cb_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__)
70 {
71    E_Sprite *es;
72
73    DLOGFN(__FILE__, __LINE__, __FUNCTION__);
74
75    es = container_of(listener, E_Sprite, destroy_listener);
76    es->surface = NULL;
77 }
78
79 static void 
80 _e_sprite_cb_pending_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__)
81 {
82    E_Sprite *es;
83
84    DLOGFN(__FILE__, __LINE__, __FUNCTION__);
85
86    es = container_of(listener, E_Sprite, pending_destroy_listener);
87    es->pending_surface = NULL;
88 }