summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/wayland_shm/evas_shm.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-04-08 15:11:21 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-04-19 15:11:09 -0400
commitcd124f938f4ac9c23687d51a017d616f53468b76 (patch)
treedd5dcba6d576c3e663da0731bc6cc6b19f6f1e85 /src/modules/evas/engines/wayland_shm/evas_shm.c
parentd6e5bdf4289bdb1d594145ad8cc704368df6e518 (diff)
wayland_shm: Make new Surface abstraction to wrap Shm_Surface
Wraps the Shm_Surface allocator in a new Surface type that will potentially use different allocators, such as dmabuf in a future commit.
Diffstat (limited to 'src/modules/evas/engines/wayland_shm/evas_shm.c')
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_shm.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c
index 69e776fd1e..22a277805e 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -395,15 +395,19 @@ _shm_leaf_destroy(Shm_Leaf *leaf)
395 leaf->resize_pool = NULL; 395 leaf->resize_pool = NULL;
396} 396}
397 397
398Shm_Surface * 398Surface *
399_evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, int compositor_version) 399_evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, int compositor_version)
400{ 400{
401 Surface *s;
401 Shm_Surface *surf; 402 Shm_Surface *surf;
402 int i = 0; 403 int i = 0;
403 404
404 LOGFN(__FILE__, __LINE__, __FUNCTION__); 405 LOGFN(__FILE__, __LINE__, __FUNCTION__);
405 406
406 if (!(surf = calloc(1, sizeof(Shm_Surface)))) return NULL; 407 if (!(s = calloc(1, sizeof(Surface)))) return NULL;
408 if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err;
409 s->type = SURFACE_SHM;
410 surf = s->surf.shm;
407 411
408 surf->dx = 0; 412 surf->dx = 0;
409 surf->dy = 0; 413 surf->dy = 0;
@@ -426,33 +430,38 @@ _evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, struct wl_
426 } 430 }
427 } 431 }
428 432
429 return surf; 433 return s;
430 434
431err: 435err:
432 _evas_shm_surface_destroy(surf); 436 _evas_shm_surface_destroy(s);
433 return NULL; 437 return NULL;
434} 438}
435 439
436void 440void
437_evas_shm_surface_destroy(Shm_Surface *surface) 441_evas_shm_surface_destroy(Surface *surface)
438{ 442{
439 int i = 0; 443 int i = 0;
440 444
441 LOGFN(__FILE__, __LINE__, __FUNCTION__); 445 LOGFN(__FILE__, __LINE__, __FUNCTION__);
442 446
443 for (; i < surface->num_buff; i++) 447 if (!surface) return;
444 _shm_leaf_destroy(&surface->leaf[i]); 448
449 for (; i < surface->surf.shm->num_buff; i++)
450 _shm_leaf_destroy(&surface->surf.shm->leaf[i]);
445 451
452 free(surface->surf.shm);
446 free(surface); 453 free(surface);
447} 454}
448 455
449void 456void
450_evas_shm_surface_reconfigure(Shm_Surface *surface, int dx, int dy, int w, int h, int num_buff, uint32_t flags) 457_evas_shm_surface_reconfigure(Surface *s, int dx, int dy, int w, int h, int num_buff, uint32_t flags)
451{ 458{
459 Shm_Surface *surface;
452 int i = 0, resize = 0; 460 int i = 0, resize = 0;
453 461
454 LOGFN(__FILE__, __LINE__, __FUNCTION__); 462 LOGFN(__FILE__, __LINE__, __FUNCTION__);
455 463
464 surface = s->surf.shm;
456 resize = !!flags; 465 resize = !!flags;
457 466
458 for (; i < surface->num_buff; i++) 467 for (; i < surface->num_buff; i++)
@@ -511,10 +520,12 @@ _evas_shm_surface_wait(Shm_Surface *surface)
511} 520}
512 521
513int 522int
514_evas_shm_surface_assign(Shm_Surface *surface) 523_evas_shm_surface_assign(Surface *s)
515{ 524{
516 int i; 525 int i;
526 Shm_Surface *surface;
517 527
528 surface = s->surf.shm;
518 surface->current = _evas_shm_surface_wait(surface); 529 surface->current = _evas_shm_surface_wait(surface);
519 530
520 /* If we ran out of buffers we're in trouble, reset all ages */ 531 /* If we ran out of buffers we're in trouble, reset all ages */
@@ -550,10 +561,12 @@ _evas_shm_surface_assign(Shm_Surface *surface)
550} 561}
551 562
552void * 563void *
553_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h) 564_evas_shm_surface_data_get(Surface *s, int *w, int *h)
554{ 565{
566 Shm_Surface *surface;
555 LOGFN(__FILE__, __LINE__, __FUNCTION__); 567 LOGFN(__FILE__, __LINE__, __FUNCTION__);
556 568
569 surface = s->surf.shm;
557 if (w) *w = 0; 570 if (w) *w = 0;
558 if (h) *h = 0; 571 if (h) *h = 0;
559 572
@@ -572,13 +585,15 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h)
572} 585}
573 586
574void 587void
575_evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int count) 588_evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
576{ 589{
577 /* struct wl_callback *frame_cb; */ 590 /* struct wl_callback *frame_cb; */
591 Shm_Surface *surface;
578 Shm_Leaf *leaf; 592 Shm_Leaf *leaf;
579 593
580 LOGFN(__FILE__, __LINE__, __FUNCTION__); 594 LOGFN(__FILE__, __LINE__, __FUNCTION__);
581 595
596 surface = s->surf.shm;
582 leaf = surface->current; 597 leaf = surface->current;
583 if (!leaf) return; 598 if (!leaf) return;
584 599