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,6 +1,11 @@
|
|||
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
|
||||
|
||||
* 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.
|
||||
|
||||
2013-07-31 Carsten Haitzler (The Rasterman)
|
||||
|
||||
|
|
1
NEWS
1
NEWS
|
@ -57,6 +57,7 @@ Additions:
|
|||
- Add Cserve2 scalecache support
|
||||
- Add evas_object_image_source_clip_set()/get()
|
||||
- Use eina_file_virtualize() for evas_object_image_memfile_set().
|
||||
- Change mapping policy for image loader.
|
||||
* Ecore_X:
|
||||
- Add window profile support.
|
||||
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);
|
||||
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;
|
||||
|
||||
memset(&header, 0, sizeof (header));
|
||||
|
|
|
@ -615,7 +615,7 @@ evas_image_load_file_head_gif(void *loader_data,
|
|||
prop->h = 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)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
|
@ -762,7 +762,7 @@ evas_image_load_specific_frame(Eina_File *f,
|
|||
Evas_GIF_Info egi;
|
||||
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)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
|
@ -869,7 +869,7 @@ evas_image_load_file_data_gif(void *loader_data,
|
|||
GifFileType *gif = NULL;
|
||||
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)
|
||||
{
|
||||
*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 (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;
|
||||
egi.length = eina_file_size_get(f);
|
||||
egi.position = 0;
|
||||
|
|
|
@ -151,7 +151,7 @@ evas_image_load_file_head_ico(void *loader_data,
|
|||
fsize = eina_file_size_get(f);
|
||||
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;
|
||||
|
||||
// key:
|
||||
|
@ -381,7 +381,7 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
fsize = eina_file_size_get(f);
|
||||
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;
|
||||
|
||||
// key:
|
||||
|
|
|
@ -1306,7 +1306,7 @@ evas_image_load_file_head_jpeg(void *loader_data,
|
|||
opts = loader->opts;
|
||||
f = loader->f;
|
||||
|
||||
map = eina_file_map_all(f, EINA_FILE_WILLNEED);
|
||||
map = eina_file_map_all(f, EINA_FILE_RANDOM);
|
||||
if (!map)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
|
|
|
@ -41,7 +41,7 @@ struct Pmaps_Buffer
|
|||
};
|
||||
|
||||
/* 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 Eina_Bool pmaps_buffer_header_parse(Pmaps_Buffer *b, int *error);
|
||||
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;
|
||||
Pmaps_Buffer b;
|
||||
|
||||
if (!pmaps_buffer_open(&b, f, error))
|
||||
if (!pmaps_buffer_open(&b, f, EINA_TRUE, error))
|
||||
{
|
||||
pmaps_buffer_close(&b);
|
||||
return EINA_FALSE;
|
||||
|
@ -109,7 +109,7 @@ evas_image_load_file_data_pmaps(void *loader_data,
|
|||
DATA32 *ptr;
|
||||
Eina_Bool r = EINA_FALSE;
|
||||
|
||||
if (!pmaps_buffer_open(&b, f, error))
|
||||
if (!pmaps_buffer_open(&b, f, EINA_FALSE, error))
|
||||
goto on_error;
|
||||
|
||||
if (!pmaps_buffer_header_parse(&b, error))
|
||||
|
@ -161,12 +161,12 @@ evas_image_load_file_data_pmaps(void *loader_data,
|
|||
|
||||
/* internal used functions */
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
|
|
|
@ -90,7 +90,7 @@ evas_image_load_file_head_png(void *loader_data,
|
|||
f = loader->f;
|
||||
|
||||
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)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
|
|
|
@ -175,7 +175,7 @@ evas_image_load_file_head_psd(void *loader_data,
|
|||
|
||||
*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);
|
||||
position = 0;
|
||||
if (!map || length < 1)
|
||||
|
|
|
@ -87,7 +87,7 @@ evas_image_load_file_head_tga(void *loader_data,
|
|||
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
||||
if (eina_file_size_get(f) < (off_t)(sizeof(tga_header) + sizeof(tga_footer)))
|
||||
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;
|
||||
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__)
|
||||
|
||||
typedef struct TIFFRGBAImage_Extra TIFFRGBAImage_Extra;
|
||||
typedef struct TIFFRGBAMap TIFFRGBAMap;
|
||||
|
||||
struct TIFFRGBAImage_Extra {
|
||||
TIFFRGBAImage rgba;
|
||||
|
@ -35,6 +36,11 @@ struct TIFFRGBAImage_Extra {
|
|||
uint32 py;
|
||||
};
|
||||
|
||||
struct TIFFRGBAMap {
|
||||
tdata_t mem;
|
||||
toff_t size;
|
||||
};
|
||||
|
||||
static tsize_t
|
||||
_evas_tiff_RWProc(thandle_t handle EINA_UNUSED,
|
||||
tdata_t data EINA_UNUSED,
|
||||
|
@ -60,28 +66,25 @@ _evas_tiff_CloseProc(thandle_t handle EINA_UNUSED)
|
|||
static toff_t
|
||||
_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
|
||||
_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);
|
||||
*size = eina_file_size_get(f);
|
||||
*mem = map->mem;
|
||||
*size = map->size;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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 *
|
||||
|
@ -106,12 +109,13 @@ evas_image_load_file_head_tiff(void *loader_data,
|
|||
Eina_File *f = loader_data;
|
||||
char txt[1024];
|
||||
TIFFRGBAImage tiff_image;
|
||||
TIFFRGBAMap tiff_map;
|
||||
TIFF *tif = NULL;
|
||||
unsigned char *map;
|
||||
uint16 magic_number;
|
||||
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)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
||||
|
@ -127,7 +131,10 @@ evas_image_load_file_head_tiff(void *loader_data,
|
|||
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_SeekProc, _evas_tiff_CloseProc,
|
||||
_evas_tiff_SizeProc,
|
||||
|
@ -186,6 +193,7 @@ evas_image_load_file_data_tiff(void *loader_data,
|
|||
Eina_File *f = loader_data;
|
||||
char txt[1024];
|
||||
TIFFRGBAImage_Extra rgba_image;
|
||||
TIFFRGBAMap rgba_map;
|
||||
TIFF *tif = NULL;
|
||||
unsigned char *map;
|
||||
uint32 *rast = NULL;
|
||||
|
@ -210,7 +218,10 @@ evas_image_load_file_data_tiff(void *loader_data,
|
|||
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_SeekProc, _evas_tiff_CloseProc,
|
||||
_evas_tiff_SizeProc,
|
||||
|
|
|
@ -59,7 +59,7 @@ evas_image_load_file_head_wbmp(void *loader_data,
|
|||
length = eina_file_size_get(f);
|
||||
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 (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;
|
||||
|
||||
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,
|
||||
&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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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/openwin/lib/X11/rgb.txt", 0);
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue