forked from enlightenment/efl
evas: change mapping policy to be less agressive into loading file in memory.
Should fix T271.
This commit is contained in:
parent
aa75297381
commit
e60baa0061
|
@ -1,3 +1,8 @@
|
||||||
|
2013-08-02 Cedric Bail
|
||||||
|
|
||||||
|
* Evas: change mapping policy for image loader (RANDOM during header,
|
||||||
|
SEQUENTIAL or WILLNEED during pixels reading).
|
||||||
|
|
||||||
2013-08-01 Cedric Bail
|
2013-08-01 Cedric Bail
|
||||||
|
|
||||||
* Edje: faster load time for Edje_Object using Evas_Object_Textblocks and many styles.
|
* Edje: faster load time for Edje_Object using Evas_Object_Textblocks and many styles.
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -57,6 +57,7 @@ Additions:
|
||||||
- Add Cserve2 scalecache support
|
- Add Cserve2 scalecache support
|
||||||
- Add evas_object_image_source_clip_set()/get()
|
- Add evas_object_image_source_clip_set()/get()
|
||||||
- Use eina_file_virtualize() for evas_object_image_memfile_set().
|
- Use eina_file_virtualize() for evas_object_image_memfile_set().
|
||||||
|
- Change mapping policy for image loader.
|
||||||
* Ecore_X:
|
* Ecore_X:
|
||||||
- Add window profile support.
|
- Add window profile support.
|
||||||
ECORE_X_ATOM_E_WINDOW_PROFILE_SUPPORTED
|
ECORE_X_ATOM_E_WINDOW_PROFILE_SUPPORTED
|
||||||
|
|
|
@ -344,7 +344,7 @@ evas_image_load_file_head_bmp(void *loader_data,
|
||||||
fsize = eina_file_size_get(f);
|
fsize = eina_file_size_get(f);
|
||||||
if (fsize < 2) goto close_file;
|
if (fsize < 2) goto close_file;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!map) goto close_file;
|
if (!map) goto close_file;
|
||||||
|
|
||||||
memset(&header, 0, sizeof (header));
|
memset(&header, 0, sizeof (header));
|
||||||
|
|
|
@ -615,7 +615,7 @@ evas_image_load_file_head_gif(void *loader_data,
|
||||||
prop->h = 0;
|
prop->h = 0;
|
||||||
a = 0;
|
a = 0;
|
||||||
|
|
||||||
egi.map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
egi.map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!egi.map)
|
if (!egi.map)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||||
|
@ -762,7 +762,7 @@ evas_image_load_specific_frame(Eina_File *f,
|
||||||
Evas_GIF_Info egi;
|
Evas_GIF_Info egi;
|
||||||
Eina_Bool r = EINA_FALSE;
|
Eina_Bool r = EINA_FALSE;
|
||||||
|
|
||||||
egi.map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
egi.map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!egi.map)
|
if (!egi.map)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||||
|
@ -869,7 +869,7 @@ evas_image_load_file_data_gif(void *loader_data,
|
||||||
GifFileType *gif = NULL;
|
GifFileType *gif = NULL;
|
||||||
Eina_Bool r = EINA_FALSE;
|
Eina_Bool r = EINA_FALSE;
|
||||||
|
|
||||||
egi.map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
egi.map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!egi.map)
|
if (!egi.map)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||||
|
@ -951,7 +951,7 @@ evas_image_load_frame_duration_gif(void *loader_data,
|
||||||
if ((start_frame + frame_num) > frame_count) return -1;
|
if ((start_frame + frame_num) > frame_count) return -1;
|
||||||
if (frame_num < 0) return -1;
|
if (frame_num < 0) return -1;
|
||||||
|
|
||||||
egi.map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
egi.map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!egi.map) goto on_error;
|
if (!egi.map) goto on_error;
|
||||||
egi.length = eina_file_size_get(f);
|
egi.length = eina_file_size_get(f);
|
||||||
egi.position = 0;
|
egi.position = 0;
|
||||||
|
|
|
@ -151,7 +151,7 @@ evas_image_load_file_head_ico(void *loader_data,
|
||||||
fsize = eina_file_size_get(f);
|
fsize = eina_file_size_get(f);
|
||||||
if (fsize < (6 + 16 + 40)) goto close_file;
|
if (fsize < (6 + 16 + 40)) goto close_file;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!map) goto close_file;
|
if (!map) goto close_file;
|
||||||
|
|
||||||
// key:
|
// key:
|
||||||
|
@ -381,7 +381,7 @@ evas_image_load_file_data_ico(void *loader_data,
|
||||||
fsize = eina_file_size_get(f);
|
fsize = eina_file_size_get(f);
|
||||||
if (fsize < (6 + 16 + 40)) goto close_file;
|
if (fsize < (6 + 16 + 40)) goto close_file;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!map) goto close_file;
|
if (!map) goto close_file;
|
||||||
|
|
||||||
// key:
|
// key:
|
||||||
|
|
|
@ -1306,7 +1306,7 @@ evas_image_load_file_head_jpeg(void *loader_data,
|
||||||
opts = loader->opts;
|
opts = loader->opts;
|
||||||
f = loader->f;
|
f = loader->f;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_WILLNEED);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct Pmaps_Buffer
|
||||||
};
|
};
|
||||||
|
|
||||||
/* internal used functions */
|
/* internal used functions */
|
||||||
static Eina_Bool pmaps_buffer_open(Pmaps_Buffer *b, Eina_File *f, int *error);
|
static Eina_Bool pmaps_buffer_open(Pmaps_Buffer *b, Eina_File *f, Eina_Bool header, int *error);
|
||||||
static void pmaps_buffer_close(Pmaps_Buffer *b);
|
static void pmaps_buffer_close(Pmaps_Buffer *b);
|
||||||
static Eina_Bool pmaps_buffer_header_parse(Pmaps_Buffer *b, int *error);
|
static Eina_Bool pmaps_buffer_header_parse(Pmaps_Buffer *b, int *error);
|
||||||
static int pmaps_buffer_plain_int_get(Pmaps_Buffer *b, int *val);
|
static int pmaps_buffer_plain_int_get(Pmaps_Buffer *b, int *val);
|
||||||
|
@ -77,7 +77,7 @@ evas_image_load_file_head_pmaps(void *loader_data,
|
||||||
Eina_File *f = loader_data;
|
Eina_File *f = loader_data;
|
||||||
Pmaps_Buffer b;
|
Pmaps_Buffer b;
|
||||||
|
|
||||||
if (!pmaps_buffer_open(&b, f, error))
|
if (!pmaps_buffer_open(&b, f, EINA_TRUE, error))
|
||||||
{
|
{
|
||||||
pmaps_buffer_close(&b);
|
pmaps_buffer_close(&b);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
@ -109,7 +109,7 @@ evas_image_load_file_data_pmaps(void *loader_data,
|
||||||
DATA32 *ptr;
|
DATA32 *ptr;
|
||||||
Eina_Bool r = EINA_FALSE;
|
Eina_Bool r = EINA_FALSE;
|
||||||
|
|
||||||
if (!pmaps_buffer_open(&b, f, error))
|
if (!pmaps_buffer_open(&b, f, EINA_FALSE, error))
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
if (!pmaps_buffer_header_parse(&b, error))
|
if (!pmaps_buffer_header_parse(&b, error))
|
||||||
|
@ -161,12 +161,12 @@ evas_image_load_file_data_pmaps(void *loader_data,
|
||||||
|
|
||||||
/* internal used functions */
|
/* internal used functions */
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
pmaps_buffer_open(Pmaps_Buffer *b, Eina_File *f, int *error)
|
pmaps_buffer_open(Pmaps_Buffer *b, Eina_File *f, Eina_Bool header, int *error)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
b->file = f;
|
b->file = f;
|
||||||
b->map = eina_file_map_all(b->file, EINA_FILE_SEQUENTIAL);
|
b->map = eina_file_map_all(b->file, header ? EINA_FILE_RANDOM : EINA_FILE_SEQUENTIAL);
|
||||||
if (!b->map)
|
if (!b->map)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||||
|
|
|
@ -90,7 +90,7 @@ evas_image_load_file_head_png(void *loader_data,
|
||||||
f = loader->f;
|
f = loader->f;
|
||||||
|
|
||||||
hasa = 0;
|
hasa = 0;
|
||||||
epi.map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
epi.map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!epi.map)
|
if (!epi.map)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||||
|
|
|
@ -175,7 +175,7 @@ evas_image_load_file_head_psd(void *loader_data,
|
||||||
|
|
||||||
*error = EVAS_LOAD_ERROR_NONE;
|
*error = EVAS_LOAD_ERROR_NONE;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
length = eina_file_size_get(f);
|
length = eina_file_size_get(f);
|
||||||
position = 0;
|
position = 0;
|
||||||
if (!map || length < 1)
|
if (!map || length < 1)
|
||||||
|
|
|
@ -87,7 +87,7 @@ evas_image_load_file_head_tga(void *loader_data,
|
||||||
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
||||||
if (eina_file_size_get(f) < (off_t)(sizeof(tga_header) + sizeof(tga_footer)))
|
if (eina_file_size_get(f) < (off_t)(sizeof(tga_header) + sizeof(tga_footer)))
|
||||||
goto close_file;
|
goto close_file;
|
||||||
seg = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
seg = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (seg == NULL) goto close_file;
|
if (seg == NULL) goto close_file;
|
||||||
filedata = seg;
|
filedata = seg;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ static int _evas_loader_tiff_log_dom = -1;
|
||||||
#define INF(...) EINA_LOG_DOM_INFO(_evas_loader_tiff_log_dom, __VA_ARGS__)
|
#define INF(...) EINA_LOG_DOM_INFO(_evas_loader_tiff_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
typedef struct TIFFRGBAImage_Extra TIFFRGBAImage_Extra;
|
typedef struct TIFFRGBAImage_Extra TIFFRGBAImage_Extra;
|
||||||
|
typedef struct TIFFRGBAMap TIFFRGBAMap;
|
||||||
|
|
||||||
struct TIFFRGBAImage_Extra {
|
struct TIFFRGBAImage_Extra {
|
||||||
TIFFRGBAImage rgba;
|
TIFFRGBAImage rgba;
|
||||||
|
@ -35,6 +36,11 @@ struct TIFFRGBAImage_Extra {
|
||||||
uint32 py;
|
uint32 py;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TIFFRGBAMap {
|
||||||
|
tdata_t mem;
|
||||||
|
toff_t size;
|
||||||
|
};
|
||||||
|
|
||||||
static tsize_t
|
static tsize_t
|
||||||
_evas_tiff_RWProc(thandle_t handle EINA_UNUSED,
|
_evas_tiff_RWProc(thandle_t handle EINA_UNUSED,
|
||||||
tdata_t data EINA_UNUSED,
|
tdata_t data EINA_UNUSED,
|
||||||
|
@ -60,28 +66,25 @@ _evas_tiff_CloseProc(thandle_t handle EINA_UNUSED)
|
||||||
static toff_t
|
static toff_t
|
||||||
_evas_tiff_SizeProc(thandle_t handle)
|
_evas_tiff_SizeProc(thandle_t handle)
|
||||||
{
|
{
|
||||||
Eina_File *f = (Eina_File *) handle;
|
TIFFRGBAMap *map = (TIFFRGBAMap*) handle;
|
||||||
|
|
||||||
return eina_file_size_get(f);
|
return map->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_evas_tiff_MapProc(thandle_t handle, tdata_t *mem, toff_t *size)
|
_evas_tiff_MapProc(thandle_t handle, tdata_t *mem, toff_t *size)
|
||||||
{
|
{
|
||||||
Eina_File *f = (Eina_File *) handle;
|
TIFFRGBAMap *map = (TIFFRGBAMap*) handle;
|
||||||
|
|
||||||
*mem = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
*mem = map->mem;
|
||||||
*size = eina_file_size_get(f);
|
*size = map->size;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_evas_tiff_UnmapProc(thandle_t handle, tdata_t data, toff_t size EINA_UNUSED)
|
_evas_tiff_UnmapProc(thandle_t handle EINA_UNUSED, tdata_t data EINA_UNUSED, toff_t size EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Eina_File *f = (Eina_File *) handle;
|
|
||||||
|
|
||||||
eina_file_map_free(f, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -106,12 +109,13 @@ evas_image_load_file_head_tiff(void *loader_data,
|
||||||
Eina_File *f = loader_data;
|
Eina_File *f = loader_data;
|
||||||
char txt[1024];
|
char txt[1024];
|
||||||
TIFFRGBAImage tiff_image;
|
TIFFRGBAImage tiff_image;
|
||||||
|
TIFFRGBAMap tiff_map;
|
||||||
TIFF *tif = NULL;
|
TIFF *tif = NULL;
|
||||||
unsigned char *map;
|
unsigned char *map;
|
||||||
uint16 magic_number;
|
uint16 magic_number;
|
||||||
Eina_Bool r = EINA_FALSE;
|
Eina_Bool r = EINA_FALSE;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!map || eina_file_size_get(f) < 3)
|
if (!map || eina_file_size_get(f) < 3)
|
||||||
{
|
{
|
||||||
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
||||||
|
@ -127,7 +131,10 @@ evas_image_load_file_head_tiff(void *loader_data,
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tif = TIFFClientOpen("evas", "rM", f,
|
tiff_map.mem = map;
|
||||||
|
tiff_map.size = eina_file_size_get(f);
|
||||||
|
|
||||||
|
tif = TIFFClientOpen("evas", "rM", &tiff_map,
|
||||||
_evas_tiff_RWProc, _evas_tiff_RWProc,
|
_evas_tiff_RWProc, _evas_tiff_RWProc,
|
||||||
_evas_tiff_SeekProc, _evas_tiff_CloseProc,
|
_evas_tiff_SeekProc, _evas_tiff_CloseProc,
|
||||||
_evas_tiff_SizeProc,
|
_evas_tiff_SizeProc,
|
||||||
|
@ -186,6 +193,7 @@ evas_image_load_file_data_tiff(void *loader_data,
|
||||||
Eina_File *f = loader_data;
|
Eina_File *f = loader_data;
|
||||||
char txt[1024];
|
char txt[1024];
|
||||||
TIFFRGBAImage_Extra rgba_image;
|
TIFFRGBAImage_Extra rgba_image;
|
||||||
|
TIFFRGBAMap rgba_map;
|
||||||
TIFF *tif = NULL;
|
TIFF *tif = NULL;
|
||||||
unsigned char *map;
|
unsigned char *map;
|
||||||
uint32 *rast = NULL;
|
uint32 *rast = NULL;
|
||||||
|
@ -210,7 +218,10 @@ evas_image_load_file_data_tiff(void *loader_data,
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tif = TIFFClientOpen("evas", "rM", f,
|
rgba_map.mem = map;
|
||||||
|
rgba_map.size = eina_file_size_get(f);
|
||||||
|
|
||||||
|
tif = TIFFClientOpen("evas", "rM", &rgba_map,
|
||||||
_evas_tiff_RWProc, _evas_tiff_RWProc,
|
_evas_tiff_RWProc, _evas_tiff_RWProc,
|
||||||
_evas_tiff_SeekProc, _evas_tiff_CloseProc,
|
_evas_tiff_SeekProc, _evas_tiff_CloseProc,
|
||||||
_evas_tiff_SizeProc,
|
_evas_tiff_SizeProc,
|
||||||
|
|
|
@ -59,7 +59,7 @@ evas_image_load_file_head_wbmp(void *loader_data,
|
||||||
length = eina_file_size_get(f);
|
length = eina_file_size_get(f);
|
||||||
if (length <= 4) goto bail;
|
if (length <= 4) goto bail;
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
if (!map) goto bail;
|
if (!map) goto bail;
|
||||||
|
|
||||||
if (read_mb(&type, map, length, &position) < 0) goto bail;
|
if (read_mb(&type, map, length, &position) < 0) goto bail;
|
||||||
|
|
|
@ -65,7 +65,7 @@ evas_image_load_file_head_webp(void *loader_data,
|
||||||
|
|
||||||
*error = EVAS_LOAD_ERROR_NONE;
|
*error = EVAS_LOAD_ERROR_NONE;
|
||||||
|
|
||||||
data = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
data = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||||
|
|
||||||
r = evas_image_load_file_check(f, data,
|
r = evas_image_load_file_check(f, data,
|
||||||
&prop->w, &prop->h, &prop->alpha,
|
&prop->w, &prop->h, &prop->alpha,
|
||||||
|
|
|
@ -172,7 +172,7 @@ evas_image_load_file_xpm(Eina_File *f, Evas_Image_Property *prop, void *pixels,
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
map = eina_file_map_all(f, load_data ? EINA_FILE_WILLNEED : EINA_FILE_RANDOM);
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
ERR("XPM ERROR: file failed to mmap");
|
ERR("XPM ERROR: file failed to mmap");
|
||||||
|
@ -712,7 +712,7 @@ module_open(Evas_Module *em)
|
||||||
if (!rgb_txt) rgb_txt = eina_file_open("/usr/X11R6/lib/X11/rgb.txt", 0);
|
if (!rgb_txt) rgb_txt = eina_file_open("/usr/X11R6/lib/X11/rgb.txt", 0);
|
||||||
if (!rgb_txt) rgb_txt = eina_file_open("/usr/openwin/lib/X11/rgb.txt", 0);
|
if (!rgb_txt) rgb_txt = eina_file_open("/usr/openwin/lib/X11/rgb.txt", 0);
|
||||||
if (rgb_txt)
|
if (rgb_txt)
|
||||||
rgb_txt_map = eina_file_map_all(rgb_txt, EINA_FILE_SEQUENTIAL);
|
rgb_txt_map = eina_file_map_all(rgb_txt, EINA_FILE_WILLNEED);
|
||||||
em->functions = (void *)(&evas_image_load_xpm_func);
|
em->functions = (void *)(&evas_image_load_xpm_func);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue