tizen 2.3 release
[apps/livebox/livebox.git] / dynamicbox / patch / pixmap_ee.patch
1 diff --git a/src/virtual_window.c b/src/virtual_window.c
2 index 1c42a7c..7a487ff 100644
3 --- a/src/virtual_window.c
4 +++ b/src/virtual_window.c
5 @@ -40,9 +40,14 @@
6  static struct static_info {
7         Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data);
8         Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data);
9 +       Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent,
10 +                                       int x, int y, int w, int h,
11 +                                       Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int *depth),
12 +                                       void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data);
13  } s_info = {
14         .alloc_canvas = NULL,
15         .alloc_canvas_with_stride = NULL,
16 +       .alloc_canvas_with_pixmap = NULL,
17  };
18  
19  /*!
20 @@ -639,12 +644,70 @@ static void ecore_evas_free_cb(Ecore_Evas *ee)
21         info->ee = NULL;
22  }
23  
24 +/**
25 + * @note
26 + * This callback can be called twice (or more) to get a several pixmaps
27 + * Acquired pixmaps are used for double/tripple buffering for canvas
28 + */
29 +static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, int h, int *depth)
30 +{
31 +       struct info *info = data;
32 +
33 +       if (info->ee) {
34 +               ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h);
35 +               DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info);
36 +       }
37 +
38 +       /*!
39 +        * Acquire a buffer for canvas.
40 +        */
41 +       info->handle = dynamicbox_acquire_buffer(info->id, info->is_gbar,
42 +                                       info->w, info->h, sizeof(int), 0,
43 +                                       event_handler_cb, info);
44 +       if (!info->handle) {
45 +               ErrPrint("Failed to get the buffer\n");
46 +               return 0u;
47 +       }
48 +
49 +       info->is_hw = 0;
50 +       return (Ecore_X_Pixmap)dynamicbox_resource_id(info->handle);
51 +}
52 +
53 +static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap)
54 +{
55 +       struct info *info = data;
56 +
57 +       if (!info->handle) {
58 +               return;
59 +       }
60 +
61 +       if (info->is_hw) {
62 +               ErrPrint("Impossible\n");
63 +       }
64 +
65 +       dynamicbox_release_buffer(info->handle);
66 +       info->handle = NULL;
67 +
68 +       if (info->deleted) {
69 +               free(info->id);
70 +               info->id = NULL;
71 +
72 +               free(info);
73 +       }
74 +}
75 +
76  PUBLIC Evas_Object *dynamicbox_get_evas_object(const char *id, int is_pd)
77  {
78         struct info *info;
79         Evas_Object *rect;
80 +       const char *engine;
81 +
82 +       if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) {
83 +               s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new");
84 +               if (!s_info.alloc_canvas_with_pixmap) {
85 +                       DbgPrint("pixmap_allocfunc_new is not found\n");
86 +               }
87  
88 -       if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride) {
89                 s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new");
90                 if (!s_info.alloc_canvas_with_stride) {
91                         DbgPrint("allocfunc_with_stirde_new is not found\n");
92 @@ -655,7 +718,7 @@ PUBLIC Evas_Object *dynamicbox_get_evas_object(const char *id, int is_pd)
93                         ErrPrint("allocfunc_new is not found\n");
94                 }
95  
96 -               if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas) {
97 +               if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) {
98                         ErrPrint("No way to allocate canvas\n");
99                         return NULL;
100                 }
101 @@ -687,10 +750,23 @@ PUBLIC Evas_Object *dynamicbox_get_evas_object(const char *id, int is_pd)
102         info->w = 1;
103         info->h = 1;
104  
105 -       if (!dynamicbox_conf_auto_align() && s_info.alloc_canvas_with_stride) {
106 -               info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info);
107 -       } else {
108 -               info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info);
109 +       engine = elm_config_preferred_engine_get();
110 +       DbgPrint("Preferred engine: %s\n", engine);
111 +       if (engine && !strcmp(engine, "opengl_x11")) {
112 +               if (s_info.alloc_canvas_with_pixmap) {
113 +                       info->ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, 1, 1, alloc_pixmap_cb, free_pixmap_cb, info);
114 +               }
115 +       }
116 +
117 +       if (!info->ee) {
118 +               /**
119 +                * Fallback to buffer backend
120 +                */
121 +               if (!dynamicbox_conf_auto_align() && s_info.alloc_canvas_with_stride) {
122 +                       info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info);
123 +               } else {
124 +                       info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info);
125 +               }
126         }
127  
128         if (!info->ee) {