From 825a3d837a33f226c879cd02ad15c3fba57e8b2c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 23 Jan 2012 23:30:42 +1000 Subject: Update the EFL to what I'm actually using, coz I'm using some stuff not yet released. --- .../evas/src/modules/loaders/pmaps/Makefile.in | 8 +++- .../modules/loaders/pmaps/evas_image_load_pmaps.c | 54 +++++++++++++++++----- 2 files changed, 49 insertions(+), 13 deletions(-) (limited to 'libraries/evas/src/modules/loaders/pmaps') diff --git a/libraries/evas/src/modules/loaders/pmaps/Makefile.in b/libraries/evas/src/modules/loaders/pmaps/Makefile.in index de7b779..745e79b 100644 --- a/libraries/evas/src/modules/loaders/pmaps/Makefile.in +++ b/libraries/evas/src/modules/loaders/pmaps/Makefile.in @@ -231,8 +231,6 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ PIXMAN_LIBS = @PIXMAN_LIBS@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PNG_CFLAGS = @PNG_CFLAGS@ PNG_LIBS = @PNG_LIBS@ RANLIB = @RANLIB@ @@ -249,6 +247,8 @@ VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ VALGRIND_LIBS = @VALGRIND_LIBS@ VERSION = @VERSION@ VMAJ = @VMAJ@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ WIN32_CFLAGS = @WIN32_CFLAGS@ WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ XCB_CFLAGS = @XCB_CFLAGS@ @@ -330,6 +330,10 @@ evas_engine_software_xcb_cflags = @evas_engine_software_xcb_cflags@ evas_engine_software_xcb_libs = @evas_engine_software_xcb_libs@ evas_engine_software_xlib_cflags = @evas_engine_software_xlib_cflags@ evas_engine_software_xlib_libs = @evas_engine_software_xlib_libs@ +evas_engine_wayland_egl_cflags = @evas_engine_wayland_egl_cflags@ +evas_engine_wayland_egl_libs = @evas_engine_wayland_egl_libs@ +evas_engine_wayland_shm_cflags = @evas_engine_wayland_shm_cflags@ +evas_engine_wayland_shm_libs = @evas_engine_wayland_shm_libs@ evas_image_loader_bmp_cflags = @evas_image_loader_bmp_cflags@ evas_image_loader_bmp_libs = @evas_image_loader_bmp_libs@ evas_image_loader_edb_cflags = @evas_image_loader_edb_cflags@ diff --git a/libraries/evas/src/modules/loaders/pmaps/evas_image_load_pmaps.c b/libraries/evas/src/modules/loaders/pmaps/evas_image_load_pmaps.c index 9ba8f81..393e407 100644 --- a/libraries/evas/src/modules/loaders/pmaps/evas_image_load_pmaps.c +++ b/libraries/evas/src/modules/loaders/pmaps/evas_image_load_pmaps.c @@ -19,7 +19,8 @@ Evas_Image_Load_Func evas_image_load_pmaps_func = { EINA_TRUE, evas_image_load_file_head_pmaps, evas_image_load_file_data_pmaps, - NULL + NULL, + EINA_FALSE }; /* The buffer to load pmaps images */ @@ -27,7 +28,9 @@ typedef struct Pmaps_Buffer Pmaps_Buffer; struct Pmaps_Buffer { - FILE *file; + Eina_File *file; + void *map; + size_t position; /* the buffer */ DATA8 buffer[FILE_BUFFER_SIZE]; @@ -160,13 +163,23 @@ pmaps_buffer_open(Pmaps_Buffer *b, const char *filename, int *error) { size_t len; - b->file = fopen(filename, "rb"); + b->file = eina_file_open(filename, EINA_FALSE); if (!b->file) { *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST; return EINA_FALSE; } + b->map = eina_file_map_all(b->file, EINA_FILE_SEQUENTIAL); + if (!b->map) + { + *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST; + eina_file_close(b->file); + b->file = NULL; + return EINA_FALSE; + } + + b->position = 0; *b->buffer = 0; *b->unread = 0; b->last_buffer = 0; @@ -177,7 +190,9 @@ pmaps_buffer_open(Pmaps_Buffer *b, const char *filename, int *error) if (len < 3) { *error = EVAS_LOAD_ERROR_CORRUPT_FILE; - fclose(b->file); + eina_file_map_free(b->file, b->map); + eina_file_close(b->file); + b->map = NULL; b->file = NULL; return EINA_FALSE; } @@ -197,7 +212,12 @@ static void pmaps_buffer_close(Pmaps_Buffer *b) { if (b->file) - fclose(b->file); + { + if (b->map) eina_file_map_free(b->file, b->map); + b->map = NULL; + eina_file_close(b->file); + b->file = NULL; + } } static Eina_Bool @@ -295,6 +315,7 @@ static size_t pmaps_buffer_plain_update(Pmaps_Buffer *b) { size_t r; + size_t max; /* if we already are in the last buffer we can not update it */ if (b->last_buffer) @@ -304,9 +325,14 @@ pmaps_buffer_plain_update(Pmaps_Buffer *b) * stuff */ if (b->unread_len) memcpy(b->buffer, b->unread, b->unread_len); - - r = fread(&b->buffer[b->unread_len], 1, - FILE_BUFFER_SIZE - b->unread_len - 1, b->file) + b->unread_len; + + max = FILE_BUFFER_SIZE - b->unread_len - 1; + if (b->position + max > eina_file_size_get(b->file)) + max = eina_file_size_get(b->file) - b->position; + + memcpy(&b->buffer[b->unread_len], b->map + b->position, max); + b->position += max; + r = max + b->unread_len; /* we haven't read anything nor have we bytes in the unread buffer */ if (r == 0) @@ -324,7 +350,7 @@ pmaps_buffer_plain_update(Pmaps_Buffer *b) } b->buffer[r] = 0; - + b->unread[0] = '\0'; b->unread_len = 0; @@ -339,6 +365,7 @@ static size_t pmaps_buffer_raw_update(Pmaps_Buffer *b) { size_t r; + size_t max; if (b->last_buffer) return 0; @@ -346,8 +373,13 @@ pmaps_buffer_raw_update(Pmaps_Buffer *b) if (b->unread_len) memcpy(b->buffer, b->unread, b->unread_len); - r = fread(&b->buffer[b->unread_len], 1, FILE_BUFFER_SIZE - b->unread_len, - b->file) + b->unread_len; + max = FILE_BUFFER_SIZE - b->unread_len; + if (b->position + max > eina_file_size_get(b->file)) + max = eina_file_size_get(b->file) - b->position; + + memcpy(&b->buffer[b->unread_len], b->map + b->position, max); + b->position += max; + r = max + b->unread_len; if (r < FILE_BUFFER_SIZE) { -- cgit v1.1