Modify expedite wayland shm engine to work with new Evas one.

Signed-off-by: Christopher Michael <cp.michael@samsung.com>

SVN revision: 83295
This commit is contained in:
Christopher Michael 2013-01-24 12:16:33 +00:00 committed by Christopher Michael
parent 4db2eca350
commit a9e39877d2
1 changed files with 47 additions and 40 deletions

View File

@ -22,7 +22,7 @@ struct _engine_wayland_shm_display
struct wl_shell *shell;
struct wl_shell_surface *shell_surface;
struct wl_shm *shm;
struct wl_buffer *buffer;
/* struct wl_buffer *buffer; */
void *data;
int width;
int height;
@ -33,7 +33,7 @@ static struct _engine_wayland_shm_display wl;
/*
* Function Prototypes
*/
static void _engine_wayland_shm_create_buffer(int width, int height);
/* static void _engine_wayland_shm_create_buffer(int width, int height); */
/* Registry handler */
static void _registry_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__);
@ -68,6 +68,12 @@ engine_wayland_shm_args(const char *engine __UNUSED__, int width, int height)
}
wl.display = wl_display_connect(NULL);
if (!wl.display)
{
printf("Expedite cannot connect to wayland display\n");
return EINA_FALSE;
}
wl.registry = wl_display_get_registry(wl.display);
wl_registry_add_listener(wl.registry, &_registry_listener, NULL);
wl_display_roundtrip(wl.display);
@ -79,14 +85,15 @@ engine_wayland_shm_args(const char *engine __UNUSED__, int width, int height)
wl.surface = wl_compositor_create_surface(wl.compositor);
wl.shell_surface = engine_wayland_create_shell_surface(wl.shell, wl.surface, "Expedite Wayland SHM");
_engine_wayland_shm_create_buffer(width, height);
/* _engine_wayland_shm_create_buffer(width, height); */
assert(wl.buffer != NULL);
assert(wl.data != NULL);
/* assert(wl.buffer != NULL); */
/* assert(wl.data != NULL); */
wl_surface_attach(wl.surface, wl.buffer, 0, 0);
/* wl_surface_attach(wl.surface, wl.buffer, 0, 0); */
einfo->info.dest = wl.data;
einfo->info.wl_shm = wl.shm;
einfo->info.wl_surface = wl.surface;
if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo))
{
printf("Evas can not setup the informations of the Wayland SHM Engine\n");
@ -114,7 +121,7 @@ engine_wayland_shm_shutdown(void)
if (wl.frame_callback)
wl_callback_destroy(wl.frame_callback);
wl_buffer_destroy(wl.buffer);
/* wl_buffer_destroy(wl.buffer); */
wl_shell_surface_destroy(wl.shell_surface);
wl_surface_destroy(wl.surface);
wl_shm_destroy(wl.shm);
@ -141,44 +148,44 @@ _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, uns
wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
}
static void
_engine_wayland_shm_create_buffer(int width, int height)
{
struct wl_shm_pool *pool;
int fd, size, stride;
char tmp[PATH_MAX];
/* static void */
/* _engine_wayland_shm_create_buffer(int width, int height) */
/* { */
/* struct wl_shm_pool *pool; */
/* int fd, size, stride; */
/* char tmp[PATH_MAX]; */
stride = width * 4;
size = stride * height;
/* stride = width * 4; */
/* size = stride * height; */
strcpy(tmp, "/tmp/expedite-wayland_shm-XXXXXX");
if ((fd = mkstemp(tmp)) < 0)
{
fprintf(stderr, "Could not create temporary file.\n");
return;
}
/* strcpy(tmp, "/tmp/expedite-wayland_shm-XXXXXX"); */
/* if ((fd = mkstemp(tmp)) < 0) */
/* { */
/* fprintf(stderr, "Could not create temporary file.\n"); */
/* return; */
/* } */
if (ftruncate(fd, size) < 0)
{
fprintf(stderr, "Could not truncate temporary file.\n");
goto end;
}
/* if (ftruncate(fd, size) < 0) */
/* { */
/* fprintf(stderr, "Could not truncate temporary file.\n"); */
/* goto end; */
/* } */
wl.data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (wl.data == MAP_FAILED)
{
wl.data = NULL;
fprintf(stderr, "mmap failed\n");
goto end;
}
/* wl.data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); */
/* if (wl.data == MAP_FAILED) */
/* { */
/* wl.data = NULL; */
/* fprintf(stderr, "mmap failed\n"); */
/* goto end; */
/* } */
pool = wl_shm_create_pool(wl.shm, fd, size);
wl.buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, WL_SHM_FORMAT_XRGB8888);
wl_shm_pool_destroy(pool);
/* pool = wl_shm_create_pool(wl.shm, fd, size); */
/* wl.buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, WL_SHM_FORMAT_XRGB8888); */
/* wl_shm_pool_destroy(pool); */
end:
close(fd);
}
/* end: */
/* close(fd); */
/* } */
static void
_surface_frame_handle_complete(void *data __UNUSED__, struct wl_callback *callback __UNUSED__, uint32_t time __UNUSED__)