Only call the allocation surface when required and correctly handle no_free.

SVN revision: 34480
This commit is contained in:
Cedric BAIL 2008-05-06 11:20:29 +00:00
parent abf7191322
commit 5f41def624
3 changed files with 17 additions and 17 deletions

View File

@ -164,6 +164,8 @@ _evas_cache_image_entry_new(Evas_Cache_Image *cache,
ie->space = EVAS_COLORSPACE_ARGB8888;
ie->w = -1;
ie->h = -1;
ie->allocated.w = 0;
ie->allocated.h = 0;
ie->references = 0;
ie->cache = cache;
@ -209,6 +211,9 @@ _evas_cache_image_entry_surface_alloc(Evas_Cache_Image *cache,
wmin = w > 0 ? w : 1;
hmin = h > 0 ? h : 1;
if (ie->allocated.w == wmin && ie->allocated.h == hmin)
return ;
if (cache->func.surface_alloc(ie, wmin, hmin))
{
wmin = 0;
@ -216,6 +221,8 @@ _evas_cache_image_entry_surface_alloc(Evas_Cache_Image *cache,
}
ie->w = wmin;
ie->h = hmin;
ie->allocated.w = wmin;
ie->allocated.h = hmin;
}
EAPI int

View File

@ -145,29 +145,17 @@ _evas_common_rgba_image_surface_alloc(Image_Entry *ie, int w, int h)
RGBA_Image *im = (RGBA_Image *) ie;
size_t siz = 0;
/* if (im->image.data) /\* return 0; *\/ */
/* free(im->image.data); */
if (im->image.no_free) return 0;
if (im->flags & RGBA_IMAGE_ALPHA_ONLY)
siz = w * h * sizeof(DATA8);
else
siz = w * h * sizeof(DATA32);
/* FIXME: this is wrong. we seem to realloc data here that ismaked "no_free"
* whihc is wrong, but when we fix it, we break all sorts of stuff
* whihc used to work. i suspect the cache changes in evas */
#if 1
im->image.data = realloc(im->image.data, siz);
if (im->image.data) free(im->image.data);
im->image.data = malloc(siz);
if (im->image.data == NULL) return -1;
#else
if (!im->image.no_free)
{
if (im->image.data) free(im->image.data);
im->image.data = malloc(siz);
if (im->image.data == NULL) return -1;
}
#endif
#ifdef HAVE_VALGRIND
VALGRIND_MAKE_READABLE(im->image.data, siz);
#endif
@ -196,7 +184,6 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie)
if (im->image.data && !im->image.no_free)
free(im->image.data);
im->image.data = NULL;
im->image.no_free = 1;
}
static void

View File

@ -299,6 +299,12 @@ struct _Image_Entry
int space;
int w;
int h;
struct
{
int w;
int h;
} allocated;
};
struct _Engine_Image_Entry