summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-12-11 11:26:24 -0500
committerChris Michael <cp.michael@samsung.com>2015-12-11 11:26:24 -0500
commit757f530af96562eac570b0ac75541e6972b5c422 (patch)
tree074880e1c874c0038d7f6018c1f105592507c436 /src
parent8c85a89303db1eb878655a91f90021b32d04b76a (diff)
ecore-evas-wl: Defer creating surfaces for wayland canvas
This code adds support for deferring of surface creation and showing inside Ecore_Evas Wayland. This is needed for Enlightenment so that it does not try to create or show surfaces until the compositor has had a chance to sync globals. This fixes an issue where early surface creation would cause a crash in the compositor due to globals not being syncd. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c1
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c126
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h3
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c129
4 files changed, 228 insertions, 31 deletions
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index c43414d096..75ac4288d4 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -1362,6 +1362,7 @@ _ecore_evas_wl_common_render(Ecore_Evas *ee)
1362 1362
1363 if (!ee) return 0; 1363 if (!ee) return 0;
1364 if (!(wdata = ee->engine.data)) return 0; 1364 if (!(wdata = ee->engine.data)) return 0;
1365 if (!wdata->sync_done) return 0;
1365 1366
1366 /* TODO: handle comp no sync */ 1367 /* TODO: handle comp no sync */
1367 1368
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
index 651496898f..b9fa475529 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
@@ -114,6 +114,87 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
114 114
115/* external variables */ 115/* external variables */
116 116
117static Eina_Bool
118_ee_cb_sync_done(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
119{
120 Ecore_Evas *ee;
121 Evas_Engine_Info_Wayland_Shm *einfo;
122 Ecore_Evas_Engine_Wl_Data *wdata;
123
124 ee = data;
125 wdata = ee->engine.data;
126 if (wdata->sync_done) return ECORE_CALLBACK_PASS_ON;
127 wdata->sync_done = EINA_TRUE;
128
129 if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas)))
130 {
131 einfo->info.wl_disp = ecore_wl2_display_get(wdata->display);
132 einfo->info.wl_shm = ecore_wl2_display_shm_get(wdata->display);
133 einfo->info.destination_alpha = EINA_TRUE;
134 einfo->info.rotation = ee->rotation;
135 einfo->info.wl_surface = ecore_wl2_window_surface_get(wdata->win);
136
137 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
138 {
139 ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
140 }
141 }
142 else
143 {
144 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
145 }
146
147 if (wdata->defer_show)
148 {
149 int fw, fh;
150
151 wdata->defer_show = EINA_FALSE;
152
153 ecore_wl2_window_show(wdata->win);
154 ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
155 ecore_wl2_window_transparent_set(wdata->win, ee->transparent);
156
157 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
158
159 if (wdata->win)
160 {
161
162 einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
163 if (einfo)
164 {
165 struct wl_surface *surf;
166
167 surf = ecore_wl2_window_surface_get(wdata->win);
168 if ((!einfo->info.wl_surface) || (einfo->info.wl_surface != surf))
169 {
170 einfo->info.wl_surface = surf;
171 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
172 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w + fw, ee->h + fh);
173 }
174 }
175 }
176
177 if (wdata->frame)
178 {
179 evas_object_show(wdata->frame);
180 evas_object_resize(wdata->frame, ee->w + fw, ee->h + fh);
181 }
182
183 ee->prop.withdrawn = EINA_FALSE;
184 if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
185
186 if (!ee->visible)
187 {
188 ee->visible = 1;
189 ee->should_be_visible = 1;
190 ee->draw_ok = EINA_TRUE;
191 if (ee->func.fn_show) ee->func.fn_show(ee);
192 }
193 }
194
195 return ECORE_CALLBACK_PASS_ON;
196}
197
117/* external functions */ 198/* external functions */
118EAPI Ecore_Evas * 199EAPI Ecore_Evas *
119ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent, 200ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
@@ -218,6 +299,7 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
218 ee->alpha = ecore_wl2_window_alpha_get(p); 299 ee->alpha = ecore_wl2_window_alpha_get(p);
219 } 300 }
220 301
302 wdata->sync_done = EINA_FALSE;
221 wdata->parent = p; 303 wdata->parent = p;
222 wdata->display = ewd; 304 wdata->display = ewd;
223 wdata->win = ecore_wl2_window_new(ewd, p, x, y, w + fw, h + fh); 305 wdata->win = ecore_wl2_window_new(ewd, p, x, y, w + fw, h + fh);
@@ -243,24 +325,28 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
243 if (ee->prop.draw_frame) 325 if (ee->prop.draw_frame)
244 evas_output_framespace_set(ee->evas, fx, fy, fw, fh); 326 evas_output_framespace_set(ee->evas, fx, fy, fw, fh);
245 327
246 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas))) 328 if (ewd->sync_done)
247 { 329 {
248 einfo->info.display = ecore_wl2_display_get(ewd); 330 wdata->sync_done = EINA_TRUE;
249 einfo->info.destination_alpha = EINA_TRUE; 331 if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
250 einfo->info.rotation = ee->rotation;
251 einfo->info.depth = 32;
252 einfo->info.surface = ecore_wl2_window_surface_get(wdata->win);
253 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
254 { 332 {
255 ERR("Failed to set Evas Engine Info for '%s'", ee->driver); 333 einfo->info.display = ecore_wl2_display_get(ewd);
334 einfo->info.destination_alpha = EINA_TRUE;
335 einfo->info.rotation = ee->rotation;
336 einfo->info.depth = 32;
337 einfo->info.surface = ecore_wl2_window_surface_get(wdata->win);
338 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
339 {
340 ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
341 goto err;
342 }
343 }
344 else
345 {
346 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
256 goto err; 347 goto err;
257 } 348 }
258 } 349 }
259 else
260 {
261 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
262 goto err;
263 }
264 350
265 /* ecore_wl2_display_animator_source_set(ewd, ECORE_ANIMATOR_SOURCE_CUSTOM); */ 351 /* ecore_wl2_display_animator_source_set(ewd, ECORE_ANIMATOR_SOURCE_CUSTOM); */
266 352
@@ -285,6 +371,8 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
285 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process, 371 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
286 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process); 372 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
287 373
374 ecore_event_handler_add(ECORE_WL2_EVENT_SYNC_DONER, _ee_cb_sync_done, ee);
375
288 return ee; 376 return ee;
289 377
290err: 378err:
@@ -339,14 +427,19 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
339 427
340 if ((!ee) || (ee->visible)) return; 428 if ((!ee) || (ee->visible)) return;
341 429
430 wdata = ee->engine.data;
431 if (!wdata->sync_done)
432 {
433 wdata->defer_show = EINA_TRUE;
434 return;
435 }
436
342 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh); 437 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
343 438
344 wdata = ee->engine.data;
345 if (wdata->win) 439 if (wdata->win)
346 { 440 {
347 ecore_wl2_window_show(wdata->win); 441 ecore_wl2_window_show(wdata->win);
348 ecore_wl2_window_alpha_set(wdata->win, ee->alpha); 442 ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
349 /* ecore_wl_window_update_size(wdata->win, ee->w + fw, ee->h + fh); */
350 443
351 einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas); 444 einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas);
352 if (einfo) 445 if (einfo)
@@ -429,6 +522,7 @@ _ecore_evas_wayland_egl_alpha_do(Ecore_Evas *ee, int alpha)
429 if (ee->alpha == alpha) return; 522 if (ee->alpha == alpha) return;
430 ee->alpha = alpha; 523 ee->alpha = alpha;
431 wdata = ee->engine.data; 524 wdata = ee->engine.data;
525 if (!wdata->sync_done) return;
432 526
433 if (wdata->win) ecore_wl2_window_alpha_set(wdata->win, ee->alpha); 527 if (wdata->win) ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
434 528
@@ -470,6 +564,8 @@ _ecore_evas_wayland_egl_transparent_do(Ecore_Evas *ee, int transparent)
470 ee->transparent = transparent; 564 ee->transparent = transparent;
471 565
472 wdata = ee->engine.data; 566 wdata = ee->engine.data;
567 if (!wdata->sync_done) return;
568
473 if (wdata->win) 569 if (wdata->win)
474 ecore_wl2_window_transparent_set(wdata->win, ee->transparent); 570 ecore_wl2_window_transparent_set(wdata->win, ee->transparent);
475 571
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
index 6d6b69510f..ecbaede7d8 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
@@ -39,6 +39,9 @@ struct _Ecore_Evas_Engine_Wl_Data
39 struct wl_egl_window *egl_win; 39 struct wl_egl_window *egl_win;
40#endif 40#endif
41 struct wl_callback *anim_callback; 41 struct wl_callback *anim_callback;
42
43 Eina_Bool sync_done : 1;
44 Eina_Bool defer_show : 1;
42}; 45};
43 46
44Ecore_Evas_Interface_Wayland *_ecore_evas_wl_interface_new(void); 47Ecore_Evas_Interface_Wayland *_ecore_evas_wl_interface_new(void);
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c
index 0592febd47..c815f79945 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c
@@ -114,6 +114,87 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
114 114
115/* external variables */ 115/* external variables */
116 116
117static Eina_Bool
118_ee_cb_sync_done(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
119{
120 Ecore_Evas *ee;
121 Evas_Engine_Info_Wayland_Shm *einfo;
122 Ecore_Evas_Engine_Wl_Data *wdata;
123
124 ee = data;
125 wdata = ee->engine.data;
126 if (wdata->sync_done) return ECORE_CALLBACK_PASS_ON;
127 wdata->sync_done = EINA_TRUE;
128
129 if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas)))
130 {
131 einfo->info.wl_disp = ecore_wl2_display_get(wdata->display);
132 einfo->info.wl_shm = ecore_wl2_display_shm_get(wdata->display);
133 einfo->info.destination_alpha = EINA_TRUE;
134 einfo->info.rotation = ee->rotation;
135 einfo->info.wl_surface = ecore_wl2_window_surface_get(wdata->win);
136
137 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
138 {
139 ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
140 }
141 }
142 else
143 {
144 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
145 }
146
147 if (wdata->defer_show)
148 {
149 int fw, fh;
150
151 wdata->defer_show = EINA_FALSE;
152
153 ecore_wl2_window_show(wdata->win);
154 ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
155 ecore_wl2_window_transparent_set(wdata->win, ee->transparent);
156
157 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
158
159 if (wdata->win)
160 {
161
162 einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
163 if (einfo)
164 {
165 struct wl_surface *surf;
166
167 surf = ecore_wl2_window_surface_get(wdata->win);
168 if ((!einfo->info.wl_surface) || (einfo->info.wl_surface != surf))
169 {
170 einfo->info.wl_surface = surf;
171 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
172 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w + fw, ee->h + fh);
173 }
174 }
175 }
176
177 if (wdata->frame)
178 {
179 evas_object_show(wdata->frame);
180 evas_object_resize(wdata->frame, ee->w + fw, ee->h + fh);
181 }
182
183 ee->prop.withdrawn = EINA_FALSE;
184 if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
185
186 if (!ee->visible)
187 {
188 ee->visible = 1;
189 ee->should_be_visible = 1;
190 ee->draw_ok = EINA_TRUE;
191 if (ee->func.fn_show) ee->func.fn_show(ee);
192 }
193 }
194
195 return ECORE_CALLBACK_PASS_ON;
196}
197
117/* external functions */ 198/* external functions */
118EAPI Ecore_Evas * 199EAPI Ecore_Evas *
119ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame) 200ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame)
@@ -153,6 +234,7 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
153 ERR("Failed to allocate Ecore_Evas"); 234 ERR("Failed to allocate Ecore_Evas");
154 goto ee_err; 235 goto ee_err;
155 } 236 }
237
156 if (!(wdata = calloc(1, sizeof(Ecore_Evas_Engine_Wl_Data)))) 238 if (!(wdata = calloc(1, sizeof(Ecore_Evas_Engine_Wl_Data))))
157 { 239 {
158 ERR("Failed to allocate Ecore_Evas_Engine_Wl_Data"); 240 ERR("Failed to allocate Ecore_Evas_Engine_Wl_Data");
@@ -214,6 +296,7 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
214 ee->alpha = ecore_wl2_window_alpha_get(p); 296 ee->alpha = ecore_wl2_window_alpha_get(p);
215 } 297 }
216 298
299 wdata->sync_done = EINA_FALSE;
217 wdata->parent = p; 300 wdata->parent = p;
218 wdata->display = ewd; 301 wdata->display = ewd;
219 wdata->win = ecore_wl2_window_new(ewd, p, x, y, w + fw, h + fh); 302 wdata->win = ecore_wl2_window_new(ewd, p, x, y, w + fw, h + fh);
@@ -239,24 +322,29 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
239 if (ee->prop.draw_frame) 322 if (ee->prop.draw_frame)
240 evas_output_framespace_set(ee->evas, fx, fy, fw, fh); 323 evas_output_framespace_set(ee->evas, fx, fy, fw, fh);
241 324
242 if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) 325 if (ewd->sync_done)
243 { 326 {
244 einfo->info.wl_disp = ecore_wl2_display_get(ewd); 327 wdata->sync_done = EINA_TRUE;
245 einfo->info.wl_shm = ecore_wl2_display_shm_get(ewd); 328 if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas)))
246 einfo->info.destination_alpha = EINA_TRUE;
247 einfo->info.rotation = ee->rotation;
248 einfo->info.wl_surface = ecore_wl2_window_surface_get(wdata->win);
249 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
250 { 329 {
251 ERR("Failed to set Evas Engine Info for '%s'", ee->driver); 330 einfo->info.wl_disp = ecore_wl2_display_get(ewd);
331 einfo->info.wl_shm = ecore_wl2_display_shm_get(ewd);
332 einfo->info.destination_alpha = EINA_TRUE;
333 einfo->info.rotation = ee->rotation;
334 einfo->info.wl_surface = ecore_wl2_window_surface_get(wdata->win);
335
336 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
337 {
338 ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
339 goto err;
340 }
341 }
342 else
343 {
344 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
252 goto err; 345 goto err;
253 } 346 }
254 } 347 }
255 else
256 {
257 ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
258 goto err;
259 }
260 348
261 /* ecore_wl2_display_animator_source_set(ewd, ECORE_ANIMATOR_SOURCE_CUSTOM); */ 349 /* ecore_wl2_display_animator_source_set(ewd, ECORE_ANIMATOR_SOURCE_CUSTOM); */
262 350
@@ -281,6 +369,8 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
281 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process, 369 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
282 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process); 370 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
283 371
372 ecore_event_handler_add(ECORE_WL2_EVENT_SYNC_DONE, _ee_cb_sync_done, ee);
373
284 return ee; 374 return ee;
285 375
286err: 376err:
@@ -335,15 +425,19 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
335 425
336 if ((!ee) || (ee->visible)) return; 426 if ((!ee) || (ee->visible)) return;
337 427
338 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
339 wdata = ee->engine.data; 428 wdata = ee->engine.data;
429 if (!wdata->sync_done)
430 {
431 wdata->defer_show = EINA_TRUE;
432 return;
433 }
434
435 evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
340 436
341 if (wdata->win) 437 if (wdata->win)
342 { 438 {
343 ecore_wl2_window_show(wdata->win); 439 ecore_wl2_window_show(wdata->win);
344 ecore_wl2_window_alpha_set(wdata->win, ee->alpha); 440 ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
345 /* TODO: Needed ?? */
346 /* ecore_wl_window_update_size(wdata->win, ee->w + fw, ee->h + fh); */
347 441
348 einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas); 442 einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
349 if (einfo) 443 if (einfo)
@@ -426,6 +520,7 @@ _ecore_evas_wayland_shm_alpha_do(Ecore_Evas *ee, int alpha)
426 if (ee->alpha == alpha) return; 520 if (ee->alpha == alpha) return;
427 ee->alpha = alpha; 521 ee->alpha = alpha;
428 wdata = ee->engine.data; 522 wdata = ee->engine.data;
523 if (!wdata->sync_done) return;
429 524
430 if (wdata->win) ecore_wl2_window_alpha_set(wdata->win, ee->alpha); 525 if (wdata->win) ecore_wl2_window_alpha_set(wdata->win, ee->alpha);
431 526
@@ -466,6 +561,8 @@ _ecore_evas_wayland_shm_transparent_do(Ecore_Evas *ee, int transparent)
466 ee->transparent = transparent; 561 ee->transparent = transparent;
467 562
468 wdata = ee->engine.data; 563 wdata = ee->engine.data;
564 if (!wdata->sync_done) return;
565
469 if (wdata->win) 566 if (wdata->win)
470 ecore_wl2_window_transparent_set(wdata->win, ee->transparent); 567 ecore_wl2_window_transparent_set(wdata->win, ee->transparent);
471 568