2008-03-14 09:49:49 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h" /* so that EAPI in Eet.h is correctly defined */
|
|
|
|
#endif
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2004-01-17 23:55:14 -08:00
|
|
|
#ifdef BUILD_LOADER_EET
|
2008-03-14 09:49:49 -07:00
|
|
|
# include <Eet.h>
|
2004-01-17 23:55:14 -08:00
|
|
|
#endif
|
|
|
|
|
2008-03-14 09:49:49 -07:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
2008-07-19 11:32:32 -07:00
|
|
|
#include "evas_image_private.h"
|
2008-07-10 15:53:33 -07:00
|
|
|
#include "evas_convert_yuv.h"
|
2009-12-21 07:52:12 -08:00
|
|
|
#include "evas_cs.h"
|
2008-03-14 09:49:49 -07:00
|
|
|
|
2004-05-02 01:41:11 -07:00
|
|
|
#ifdef HAVE_VALGRIND
|
2008-03-14 09:49:49 -07:00
|
|
|
# include <memcheck.h>
|
2004-05-02 01:41:11 -07:00
|
|
|
#endif
|
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
static Evas_Cache_Image * eci = NULL;
|
|
|
|
static int reference = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
/* static RGBA_Image *evas_rgba_line_buffer = NULL; */
|
2005-12-03 01:27:53 -08:00
|
|
|
|
|
|
|
#define EVAS_RGBA_LINE_BUFFER_MIN_LEN 256
|
2006-09-30 03:18:37 -07:00
|
|
|
#define EVAS_RGBA_LINE_BUFFER_MAX_LEN 2048
|
2005-12-03 01:27:53 -08:00
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
/* static RGBA_Image *evas_alpha_line_buffer = NULL; */
|
2006-05-02 00:28:49 -07:00
|
|
|
|
|
|
|
#define EVAS_ALPHA_LINE_BUFFER_MIN_LEN 256
|
2006-09-30 03:18:37 -07:00
|
|
|
#define EVAS_ALPHA_LINE_BUFFER_MAX_LEN 2048
|
2006-05-02 00:28:49 -07:00
|
|
|
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
static Image_Entry *_evas_common_rgba_image_new(void);
|
|
|
|
static void _evas_common_rgba_image_delete(Image_Entry *ie);
|
|
|
|
|
2010-09-18 16:16:25 -07:00
|
|
|
static int _evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned int h);
|
2008-04-11 17:32:30 -07:00
|
|
|
static void _evas_common_rgba_image_surface_delete(Image_Entry *ie);
|
2008-06-03 02:09:39 -07:00
|
|
|
static DATA32 *_evas_common_rgba_image_surface_pixels(Image_Entry *ie);
|
2008-04-11 17:32:30 -07:00
|
|
|
|
|
|
|
static void _evas_common_rgba_image_unload(Image_Entry *im);
|
|
|
|
|
2010-09-18 16:16:25 -07:00
|
|
|
static void _evas_common_rgba_image_dirty_region(Image_Entry *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
|
2008-04-11 17:32:30 -07:00
|
|
|
|
|
|
|
static int _evas_common_rgba_image_ram_usage(Image_Entry *ie);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
/* Only called when references > 0. Need to provide a fresh copie of im. */
|
|
|
|
/* The destination surface does have a surface, but no allocated pixel data. */
|
2008-04-11 17:32:30 -07:00
|
|
|
static int _evas_common_rgba_image_dirty(Image_Entry* dst, const Image_Entry* src);
|
|
|
|
|
2009-12-21 07:52:12 -08:00
|
|
|
#if 0
|
2008-04-11 17:32:30 -07:00
|
|
|
static void
|
|
|
|
_evas_common_rgba_image_debug(const char* context, Image_Entry *eim)
|
|
|
|
{
|
2009-10-22 08:22:22 -07:00
|
|
|
DBG("%p = [%s] {%s,%s} %i [%i|%i]", eim, context, eim->file, eim->key, eim->references, eim->w, eim->h);
|
2008-04-11 17:32:30 -07:00
|
|
|
}
|
2009-12-21 07:52:12 -08:00
|
|
|
#endif
|
2007-07-16 00:25:35 -07:00
|
|
|
|
|
|
|
static const Evas_Cache_Image_Func _evas_common_image_func =
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
_evas_common_rgba_image_new,
|
|
|
|
_evas_common_rgba_image_delete,
|
|
|
|
_evas_common_rgba_image_surface_alloc,
|
|
|
|
_evas_common_rgba_image_surface_delete,
|
2008-06-03 02:09:39 -07:00
|
|
|
_evas_common_rgba_image_surface_pixels,
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_common_load_rgba_image_module_from_file,
|
|
|
|
_evas_common_rgba_image_unload,
|
|
|
|
_evas_common_rgba_image_dirty_region,
|
|
|
|
_evas_common_rgba_image_dirty,
|
|
|
|
evas_common_rgba_image_size_set,
|
|
|
|
evas_common_rgba_image_from_copied_data,
|
|
|
|
evas_common_rgba_image_from_data,
|
|
|
|
evas_common_rgba_image_colorspace_set,
|
|
|
|
evas_common_load_rgba_image_data_from_file,
|
|
|
|
_evas_common_rgba_image_ram_usage,
|
|
|
|
/* _evas_common_rgba_image_debug */
|
|
|
|
NULL
|
2007-07-16 00:25:35 -07:00
|
|
|
};
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_image_init(void)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2007-07-16 00:25:35 -07:00
|
|
|
if (!eci)
|
|
|
|
eci = evas_cache_image_init(&_evas_common_image_func);
|
|
|
|
reference++;
|
2009-10-22 08:22:22 -07:00
|
|
|
//// ERR("REF++=%i", reference);
|
2007-07-16 00:25:35 -07:00
|
|
|
|
2004-01-17 08:27:58 -08:00
|
|
|
#ifdef BUILD_LOADER_EET
|
|
|
|
eet_init();
|
|
|
|
#endif
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_scalecache_init();
|
2004-01-17 08:27:58 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2004-01-17 08:27:58 -08:00
|
|
|
evas_common_image_shutdown(void)
|
|
|
|
{
|
2007-07-16 00:25:35 -07:00
|
|
|
if (--reference == 0)
|
|
|
|
{
|
2007-07-22 09:25:24 -07:00
|
|
|
//// printf("REF--=%i\n", reference);
|
|
|
|
// DISABLE for now - something wrong with cache shutdown freeing things
|
|
|
|
// still in use - rage_thumb segv's now.
|
2008-07-19 10:40:52 -07:00
|
|
|
//
|
2007-07-22 09:25:24 -07:00
|
|
|
// actually - i think i see it. cache ref goes to 0 (and thus gets freed)
|
|
|
|
// because in eng_setup() when a buffer changes size it is FIRST freed
|
|
|
|
// THEN allocated again - thus brignhjing ref to 0 then back to 1 immediately
|
|
|
|
// where it should stay at 1. - see evas_engine.c in the buffer enigne for
|
|
|
|
// example. eng_output_free() is called BEFORE _output_setup(). although this
|
|
|
|
// is only a SIGNE of the problem. we can patch this up with either freeing
|
2008-07-19 10:40:52 -07:00
|
|
|
// after the setup (so we just pt a ref of 2 then back to 1), or just
|
2007-07-22 09:25:24 -07:00
|
|
|
// evas_common_image_init() at the start and evas_common_image_shutdown()
|
|
|
|
// after it all. really ref 0 should only be reached when no more canvases
|
|
|
|
// with no more objects exist anywhere.
|
2009-01-22 16:08:11 -08:00
|
|
|
|
|
|
|
// ENABLE IT AGAIN, hope it is fixed. Gustavo @ January 22nd, 2009.
|
|
|
|
evas_cache_image_shutdown(eci);
|
|
|
|
eci = NULL;
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
|
2004-01-17 08:27:58 -08:00
|
|
|
#ifdef BUILD_LOADER_EET
|
|
|
|
eet_shutdown();
|
|
|
|
#endif
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_scalecache_shutdown();
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:23:53 -07:00
|
|
|
EAPI void
|
|
|
|
evas_common_image_image_all_unload(void)
|
|
|
|
{
|
2010-12-03 01:36:17 -08:00
|
|
|
evas_common_rgba_image_scalecache_dump();
|
2010-04-12 01:23:53 -07:00
|
|
|
evas_cache_image_unload_all(eci);
|
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
static Image_Entry *
|
|
|
|
_evas_common_rgba_image_new(void)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *im;
|
|
|
|
|
|
|
|
im = calloc(1, sizeof(RGBA_Image));
|
|
|
|
if (!im) return NULL;
|
|
|
|
im->flags = RGBA_IMAGE_NOTHING;
|
|
|
|
im->ref = 1;
|
2010-05-21 00:10:45 -07:00
|
|
|
#ifdef EVAS_FRAME_QUEUING
|
2010-07-16 15:52:04 -07:00
|
|
|
LKI(im->cache_entry.ref_fq_add);
|
|
|
|
LKI(im->cache_entry.ref_fq_del);
|
|
|
|
pthread_cond_init(&(im->cache_entry.cond_fq_del), NULL);
|
2010-05-21 00:10:45 -07:00
|
|
|
#endif
|
|
|
|
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_rgba_image_scalecache_init(&im->cache_entry);
|
2011-04-22 04:47:14 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
return &im->cache_entry;
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-11 17:32:30 -07:00
|
|
|
_evas_common_rgba_image_delete(Image_Entry *ie)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2011-04-20 23:21:51 -07:00
|
|
|
RGBA_Image *im = (RGBA_Image *)ie;
|
2008-04-11 17:32:30 -07:00
|
|
|
|
2009-03-26 18:48:58 -07:00
|
|
|
#ifdef BUILD_PIPE_RENDER
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_common_pipe_free(im);
|
2010-05-21 00:10:45 -07:00
|
|
|
# ifdef EVAS_FRAME_QUEUING
|
2010-07-16 15:52:04 -07:00
|
|
|
LKD(im->cache_entry.ref_fq_add);
|
|
|
|
LKD(im->cache_entry.ref_fq_del);
|
|
|
|
pthread_cond_destroy(&(im->cache_entry.cond_fq_del));
|
2010-05-21 00:10:45 -07:00
|
|
|
# endif
|
2009-03-26 18:48:58 -07:00
|
|
|
#endif
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_rgba_image_scalecache_shutdown(&im->cache_entry);
|
2008-06-03 02:09:39 -07:00
|
|
|
if (ie->info.module) evas_module_unref((Evas_Module *)ie->info.module);
|
2008-04-11 17:32:30 -07:00
|
|
|
/* memset the image to 0x99 because i recently saw a segv where an
|
|
|
|
* seemed to be used BUT its contents were wrong - it looks like it was
|
|
|
|
* overwritten by something from efreet - as there was an execute command
|
|
|
|
* for a command there and some other signs - but to make sure, I am
|
|
|
|
* going to empty this struct out in case this happens again so i know
|
|
|
|
* that something else is overwritign this struct - or not */
|
2009-03-26 00:14:08 -07:00
|
|
|
// memset(im, 0x99, sizeof(im));
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if (ie->data1) evas_cserve_image_free(ie);
|
|
|
|
#endif
|
2011-04-20 23:01:59 -07:00
|
|
|
/*
|
|
|
|
* FIXME: This doesn't seem to be needed... But I'm not sure why.
|
|
|
|
* -- nash
|
2011-04-18 22:47:56 -07:00
|
|
|
{
|
2011-04-20 23:21:51 -07:00
|
|
|
Filtered_Image *fi;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(im->filtered, fi)
|
|
|
|
{
|
|
|
|
free(fi->key);
|
|
|
|
_evas_common_rgba_image_delete((Image_Entry *)(fi->image));
|
|
|
|
free(fi);
|
|
|
|
}
|
2011-04-18 22:47:56 -07:00
|
|
|
}
|
2011-04-20 23:01:59 -07:00
|
|
|
*/
|
2008-04-11 17:32:30 -07:00
|
|
|
free(im);
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
|
2009-03-26 00:14:08 -07:00
|
|
|
EAPI void
|
|
|
|
evas_common_rgba_image_free(Image_Entry *ie)
|
|
|
|
{
|
2009-03-26 05:47:44 -07:00
|
|
|
_evas_common_rgba_image_surface_delete(ie);
|
2009-03-26 00:14:08 -07:00
|
|
|
_evas_common_rgba_image_delete(ie);
|
|
|
|
}
|
|
|
|
|
2009-03-26 23:06:45 -07:00
|
|
|
EAPI void
|
|
|
|
evas_common_rgba_image_unload(Image_Entry *ie)
|
|
|
|
{
|
|
|
|
RGBA_Image *im = (RGBA_Image *) ie;
|
|
|
|
|
|
|
|
if (!ie->flags.loaded) return;
|
2009-05-06 05:36:06 -07:00
|
|
|
if ((!ie->info.module) && (!ie->data1)) return;
|
2009-03-26 23:06:45 -07:00
|
|
|
if (!ie->file) return;
|
2009-09-16 02:48:05 -07:00
|
|
|
|
2009-03-26 23:06:45 -07:00
|
|
|
ie->flags.loaded = 0;
|
|
|
|
|
|
|
|
if ((im->cs.data) && (im->image.data))
|
|
|
|
{
|
|
|
|
if (im->cs.data != im->image.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (im->cs.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
}
|
|
|
|
im->cs.data = NULL;
|
|
|
|
|
2009-05-06 05:36:06 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if (ie->data1)
|
|
|
|
{
|
|
|
|
evas_cserve_image_useless(ie);
|
|
|
|
im->image.data = NULL;
|
|
|
|
ie->allocated.w = 0;
|
|
|
|
ie->allocated.h = 0;
|
2010-12-14 02:22:06 -08:00
|
|
|
ie->flags.loaded = 0;
|
2010-12-18 01:59:50 -08:00
|
|
|
#ifdef BUILD_ASYNC_PRELOAD
|
|
|
|
ie->flags.preload_done = 0;
|
|
|
|
#endif
|
2009-05-06 05:36:06 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-26 23:06:45 -07:00
|
|
|
if (im->image.data && !im->image.no_free)
|
|
|
|
free(im->image.data);
|
|
|
|
im->image.data = NULL;
|
|
|
|
ie->allocated.w = 0;
|
|
|
|
ie->allocated.h = 0;
|
2010-12-14 02:22:06 -08:00
|
|
|
ie->flags.loaded = 0;
|
2010-12-18 01:59:50 -08:00
|
|
|
#ifdef BUILD_ASYNC_PRELOAD
|
|
|
|
ie->flags.preload_done = 0;
|
|
|
|
#endif
|
2009-03-26 23:06:45 -07:00
|
|
|
}
|
|
|
|
|
2011-04-22 04:47:14 -07:00
|
|
|
void
|
|
|
|
_evas_common_rgba_image_post_surface(Image_Entry *ie)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_PIXMAN
|
|
|
|
RGBA_Image *im = (RGBA_Image *) ie;
|
|
|
|
|
|
|
|
if (im->pixman.im) pixman_image_unref(im->pixman.im);
|
|
|
|
if (im->cache_entry.flags.alpha)
|
|
|
|
{
|
|
|
|
im->pixman.im = pixman_image_create_bits
|
|
|
|
(
|
|
|
|
// FIXME: endianess determines this
|
|
|
|
PIXMAN_a8r8g8b8,
|
|
|
|
// PIXMAN_b8g8r8a8,
|
|
|
|
im->cache_entry.w, im->cache_entry.h,
|
|
|
|
im->image.data,
|
|
|
|
im->cache_entry.w * 4
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
im->pixman.im = pixman_image_create_bits
|
|
|
|
(
|
|
|
|
// FIXME: endianess determines this
|
|
|
|
PIXMAN_x8r8g8b8,
|
|
|
|
// PIXMAN_b8g8r8x8,
|
|
|
|
im->cache_entry.w, im->cache_entry.h,
|
|
|
|
im->image.data,
|
|
|
|
im->cache_entry.w * 4
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
ie = NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
static int
|
2010-09-18 16:16:25 -07:00
|
|
|
_evas_common_rgba_image_surface_alloc(Image_Entry *ie, unsigned int w, unsigned int h)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *im = (RGBA_Image *) ie;
|
|
|
|
size_t siz = 0;
|
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if (ie->data1) return 0;
|
|
|
|
#endif
|
2008-05-06 04:20:29 -07:00
|
|
|
if (im->image.no_free) return 0;
|
2008-04-11 17:32:30 -07:00
|
|
|
|
|
|
|
if (im->flags & RGBA_IMAGE_ALPHA_ONLY)
|
|
|
|
siz = w * h * sizeof(DATA8);
|
|
|
|
else
|
|
|
|
siz = w * h * sizeof(DATA32);
|
|
|
|
|
2008-05-06 04:20:29 -07:00
|
|
|
if (im->image.data) free(im->image.data);
|
|
|
|
im->image.data = malloc(siz);
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!im->image.data) return -1;
|
2008-05-06 04:20:29 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
#ifdef HAVE_VALGRIND
|
2008-07-19 10:40:52 -07:00
|
|
|
# ifdef VALGRIND_MAKE_READABLE
|
2008-04-11 17:32:30 -07:00
|
|
|
VALGRIND_MAKE_READABLE(im->image.data, siz);
|
2008-07-19 10:40:52 -07:00
|
|
|
# else
|
|
|
|
# ifdef VALGRIND_MAKE_MEM_DEFINED
|
2008-05-18 20:29:54 -07:00
|
|
|
VALGRIND_MAKE_MEM_DEFINED(im->image.data, siz);
|
2008-07-19 10:40:52 -07:00
|
|
|
# endif
|
2008-05-18 20:29:54 -07:00
|
|
|
# endif
|
2008-04-11 17:32:30 -07:00
|
|
|
#endif
|
2011-04-22 04:47:14 -07:00
|
|
|
_evas_common_rgba_image_post_surface(ie);
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_common_rgba_image_surface_delete(Image_Entry *ie)
|
|
|
|
{
|
|
|
|
RGBA_Image *im = (RGBA_Image *) ie;
|
|
|
|
|
2011-04-22 04:47:14 -07:00
|
|
|
#ifdef HAVE_PIXMAN
|
|
|
|
if (im->pixman.im)
|
|
|
|
{
|
|
|
|
pixman_image_unref(im->pixman.im);
|
|
|
|
im->pixman.im = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-12 20:00:29 -07:00
|
|
|
if (ie->file)
|
2010-10-07 16:46:42 -07:00
|
|
|
DBG("unload: [%p] %s %s", ie, ie->file, ie->key);
|
2008-04-11 17:32:30 -07:00
|
|
|
if ((im->cs.data) && (im->image.data))
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
if (im->cs.data != im->image.data)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (im->cs.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
}
|
|
|
|
im->cs.data = NULL;
|
2008-04-11 17:32:30 -07:00
|
|
|
|
|
|
|
if (im->image.data && !im->image.no_free)
|
|
|
|
free(im->image.data);
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
else if (ie->data1)
|
|
|
|
evas_cserve_image_free(ie);
|
|
|
|
#endif
|
2008-04-11 17:32:30 -07:00
|
|
|
im->image.data = NULL;
|
2010-12-14 02:22:06 -08:00
|
|
|
ie->allocated.w = 0;
|
|
|
|
ie->allocated.h = 0;
|
2010-12-18 02:09:58 -08:00
|
|
|
#ifdef BUILD_ASYNC_PRELOAD
|
2010-12-14 02:22:06 -08:00
|
|
|
ie->flags.preload_done = 0;
|
2010-12-18 02:09:58 -08:00
|
|
|
#endif
|
2010-12-14 02:22:06 -08:00
|
|
|
ie->flags.loaded = 0;
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_rgba_image_scalecache_dirty(&im->cache_entry);
|
2008-04-11 17:32:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-04-12 01:23:53 -07:00
|
|
|
_evas_common_rgba_image_unload(Image_Entry *im)
|
2008-04-11 17:32:30 -07:00
|
|
|
{
|
2010-10-07 16:46:42 -07:00
|
|
|
// DBG("unload: [%p] %s %s", im, im->file, im->key);
|
2010-08-18 08:11:07 -07:00
|
|
|
evas_common_rgba_image_scalecache_dirty(im);
|
2010-04-12 01:23:53 -07:00
|
|
|
evas_common_rgba_image_unload(im);
|
2008-04-11 17:32:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-18 16:16:25 -07:00
|
|
|
_evas_common_rgba_image_dirty_region(Image_Entry* ie, unsigned int x __UNUSED__, unsigned int y __UNUSED__, unsigned int w __UNUSED__, unsigned int h __UNUSED__)
|
2008-04-11 17:32:30 -07:00
|
|
|
{
|
2008-04-15 08:20:53 -07:00
|
|
|
RGBA_Image *im = (RGBA_Image *) ie;
|
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if (ie->data1) evas_cserve_image_free(ie);
|
|
|
|
#endif
|
2008-04-15 08:20:53 -07:00
|
|
|
im->flags |= RGBA_IMAGE_IS_DIRTY;
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_rgba_image_scalecache_dirty(&im->cache_entry);
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Only called when references > 0. Need to provide a fresh copie of im. */
|
|
|
|
static int
|
2008-04-11 17:32:30 -07:00
|
|
|
_evas_common_rgba_image_dirty(Image_Entry *ie_dst, const Image_Entry *ie_src)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *dst = (RGBA_Image *) ie_dst;
|
|
|
|
RGBA_Image *src = (RGBA_Image *) ie_src;
|
|
|
|
|
2010-04-12 20:00:29 -07:00
|
|
|
evas_common_rgba_image_scalecache_dirty((Image_Entry *)ie_src);
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_rgba_image_scalecache_dirty(ie_dst);
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_cache_image_load_data(&src->cache_entry);
|
|
|
|
if (_evas_common_rgba_image_surface_alloc(&dst->cache_entry,
|
|
|
|
src->cache_entry.w, src->cache_entry.h))
|
2009-05-01 00:11:07 -07:00
|
|
|
{
|
|
|
|
#ifdef EVAS_CSERVE
|
2009-12-21 07:52:12 -08:00
|
|
|
if (ie_src->data1) evas_cserve_image_free((Image_Entry*) ie_src);
|
2009-05-01 00:11:07 -07:00
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
2008-04-11 17:32:30 -07:00
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
2009-12-21 07:52:12 -08:00
|
|
|
if (ie_src->data1) evas_cserve_image_free((Image_Entry*) ie_src);
|
2009-05-01 00:11:07 -07:00
|
|
|
#endif
|
2007-10-27 21:01:56 -07:00
|
|
|
evas_common_image_colorspace_normalize(src);
|
2007-07-16 00:25:35 -07:00
|
|
|
evas_common_image_colorspace_normalize(dst);
|
2008-04-11 17:32:30 -07:00
|
|
|
/* evas_common_blit_rectangle(src, dst, 0, 0, src->cache_entry.w, src->cache_entry.h, 0, 0); */
|
|
|
|
/* evas_common_cpu_end_opt(); */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-07-16 00:25:35 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
static int
|
|
|
|
_evas_common_rgba_image_ram_usage(Image_Entry *ie)
|
|
|
|
{
|
2011-04-20 23:21:51 -07:00
|
|
|
RGBA_Image *im = (RGBA_Image *)ie;
|
|
|
|
int size = sizeof(struct _RGBA_Image);
|
|
|
|
|
|
|
|
if (ie->cache_key) size += strlen(ie->cache_key);
|
|
|
|
if (ie->file) size += strlen(ie->file);
|
|
|
|
if (ie->key) size += strlen(ie->key);
|
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
if (im->image.data)
|
|
|
|
{
|
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if ((!im->image.no_free) || (ie->data1))
|
|
|
|
#else
|
|
|
|
if ((!im->image.no_free))
|
|
|
|
#endif
|
|
|
|
size += im->cache_entry.w * im->cache_entry.h * sizeof(DATA32);
|
|
|
|
}
|
2009-03-26 00:14:08 -07:00
|
|
|
size += evas_common_rgba_image_scalecache_usage_get(&im->cache_entry);
|
|
|
|
return size;
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
|
2008-06-03 02:09:39 -07:00
|
|
|
static DATA32 *
|
|
|
|
_evas_common_rgba_image_surface_pixels(Image_Entry *ie)
|
|
|
|
{
|
|
|
|
RGBA_Image *im = (RGBA_Image *) ie;
|
|
|
|
|
|
|
|
return im->image.data;
|
|
|
|
}
|
|
|
|
|
2005-01-27 02:05:41 -08:00
|
|
|
#if 0
|
2005-01-26 08:42:31 -08:00
|
|
|
void
|
|
|
|
evas_common_image_surface_alpha_tiles_calc(RGBA_Surface *is, int tsize)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
DATA32 *ptr;
|
|
|
|
|
|
|
|
if (is->spans) return;
|
2008-06-03 02:09:39 -07:00
|
|
|
if (!is->im->cache_entry.flags.alpha) return;
|
2005-01-26 08:42:31 -08:00
|
|
|
/* FIXME: dont handle alpha only images yet */
|
|
|
|
if ((is->im->flags & RGBA_IMAGE_ALPHA_ONLY)) return;
|
|
|
|
if (tsize < 0) tsize = 0;
|
|
|
|
is->spans = calloc(1, sizeof(RGBA_Image_Span *) * is->h);
|
|
|
|
if (!is->spans) return;
|
|
|
|
ptr = is->data;
|
|
|
|
for (y = 0; y < is->h; y++)
|
|
|
|
{
|
|
|
|
RGBA_Image_Span *sp;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-01-26 08:42:31 -08:00
|
|
|
sp = NULL;
|
|
|
|
for (x = 0; x < is->w; x++)
|
|
|
|
{
|
|
|
|
DATA8 a;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-01-26 08:42:31 -08:00
|
|
|
a = A_VAL(ptr);
|
|
|
|
if (sp)
|
|
|
|
{
|
|
|
|
if (a == 0)
|
|
|
|
{
|
2008-10-17 04:23:18 -07:00
|
|
|
is->spans[y] = eina_inlist_append(is->spans[y], sp);
|
2005-01-26 08:42:31 -08:00
|
|
|
sp = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sp->w++;
|
|
|
|
if ((sp->v == 2) && (a != 255)) sp->v = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (a == 255)
|
|
|
|
{
|
|
|
|
sp = calloc(1, sizeof(RGBA_Image_Span));
|
|
|
|
sp->x = x;
|
|
|
|
sp->w = 1;
|
|
|
|
sp->v = 2;
|
|
|
|
}
|
|
|
|
else if (a > 0)
|
|
|
|
{
|
|
|
|
sp = calloc(1, sizeof(RGBA_Image_Span));
|
|
|
|
sp->x = x;
|
|
|
|
sp->w = 1;
|
|
|
|
sp->v = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
if (sp)
|
|
|
|
{
|
2008-10-17 04:23:18 -07:00
|
|
|
is->spans[y] = eina_inlist_append(is->spans[y], sp);
|
2005-01-26 08:42:31 -08:00
|
|
|
sp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
#endif
|
2005-01-26 08:42:31 -08:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
/* EAPI void */
|
|
|
|
/* evas_common_image_surface_dealloc(RGBA_Surface *is) */
|
|
|
|
/* { */
|
|
|
|
/* if ((is->data) && (!is->no_free)) */
|
|
|
|
/* { */
|
2008-07-19 10:40:52 -07:00
|
|
|
/* free(is->data); */
|
|
|
|
/* is->data = NULL; */
|
2008-04-11 17:32:30 -07:00
|
|
|
/* } */
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
static RGBA_Image *
|
2010-09-18 16:16:25 -07:00
|
|
|
evas_common_image_create(unsigned int w, unsigned int h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
RGBA_Image *im;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
im = (RGBA_Image *) _evas_common_rgba_image_new();
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!im) return NULL;
|
2008-04-11 17:32:30 -07:00
|
|
|
im->cache_entry.w = w;
|
|
|
|
im->cache_entry.h = h;
|
|
|
|
if (_evas_common_rgba_image_surface_alloc(&im->cache_entry, w, h))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
_evas_common_rgba_image_delete(&im->cache_entry);
|
|
|
|
return NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2008-04-11 17:32:30 -07:00
|
|
|
im->cache_entry.flags.cached = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Image *
|
2010-09-18 16:16:25 -07:00
|
|
|
evas_common_image_alpha_create(unsigned int w, unsigned int h)
|
2006-05-02 00:28:49 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *im;
|
2006-05-02 00:28:49 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
im = (RGBA_Image *) _evas_common_rgba_image_new();
|
2006-05-02 00:28:49 -07:00
|
|
|
if (!im) return NULL;
|
2008-04-11 17:32:30 -07:00
|
|
|
im->cache_entry.w = w;
|
|
|
|
im->cache_entry.h = h;
|
2009-03-27 07:11:27 -07:00
|
|
|
im->cache_entry.flags.alpha = 1;
|
2008-04-11 17:32:30 -07:00
|
|
|
if (_evas_common_rgba_image_surface_alloc(&im->cache_entry, w, h))
|
2006-05-02 00:28:49 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
_evas_common_rgba_image_delete(&im->cache_entry);
|
|
|
|
return NULL;
|
2006-05-02 00:28:49 -07:00
|
|
|
}
|
2008-04-11 17:32:30 -07:00
|
|
|
im->cache_entry.flags.cached = 0;
|
2006-05-02 00:28:49 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2009-03-26 00:14:08 -07:00
|
|
|
EAPI RGBA_Image *
|
2010-09-18 16:16:25 -07:00
|
|
|
evas_common_image_new(unsigned int w, unsigned int h, unsigned int alpha)
|
2009-03-26 00:14:08 -07:00
|
|
|
{
|
|
|
|
if (alpha)
|
|
|
|
return evas_common_image_alpha_create(w, h);
|
|
|
|
return evas_common_image_create(w, h);
|
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
void
|
2006-12-17 07:48:52 -08:00
|
|
|
evas_common_image_colorspace_normalize(RGBA_Image *im)
|
|
|
|
{
|
2008-04-15 08:20:53 -07:00
|
|
|
if ((!im->cs.data) ||
|
2007-07-17 21:42:23 -07:00
|
|
|
((!im->cs.dirty) && (!(im->flags & RGBA_IMAGE_IS_DIRTY)))) return;
|
2008-04-11 17:32:30 -07:00
|
|
|
switch (im->cache_entry.space)
|
2006-12-17 07:48:52 -08:00
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
2008-04-11 17:32:30 -07:00
|
|
|
if (im->image.data != im->cs.data)
|
2006-12-17 07:48:52 -08:00
|
|
|
{
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
2009-12-21 07:52:12 -08:00
|
|
|
if (((Image_Entry *)im)->data1) evas_cserve_image_free(&im->cache_entry);
|
2009-05-01 00:11:07 -07:00
|
|
|
#endif
|
2008-04-11 17:32:30 -07:00
|
|
|
if (!im->image.no_free) free(im->image.data);
|
|
|
|
im->image.data = im->cs.data;
|
|
|
|
im->cs.no_free = im->image.no_free;
|
2006-12-17 07:48:52 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
2007-04-16 07:30:22 -07:00
|
|
|
#ifdef BUILD_CONVERT_YUV
|
2008-04-11 17:32:30 -07:00
|
|
|
if ((im->image.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
evas_common_convert_yuv_420p_601_rgba(im->cs.data, (DATA8*) im->image.data,
|
|
|
|
im->cache_entry.w, im->cache_entry.h);
|
2007-04-16 07:30:22 -07:00
|
|
|
#endif
|
2006-12-17 07:48:52 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
im->cs.dirty = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_common_image_colorspace_dirty(RGBA_Image *im)
|
|
|
|
{
|
|
|
|
im->cs.dirty = 1;
|
2009-03-26 00:14:08 -07:00
|
|
|
evas_common_rgba_image_scalecache_dirty(&im->cache_entry);
|
2006-12-17 07:48:52 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2010-09-18 16:16:25 -07:00
|
|
|
evas_common_image_set_cache(unsigned int size)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2010-08-21 06:52:25 -07:00
|
|
|
if (eci)
|
2008-12-01 18:33:09 -08:00
|
|
|
evas_cache_image_set(eci, size);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2007-12-13 21:57:16 -08:00
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI int
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_image_get_cache(void)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2007-07-16 00:25:35 -07:00
|
|
|
return evas_cache_image_get(eci);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Image *
|
2009-12-22 15:11:57 -08:00
|
|
|
evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!file)
|
2009-12-22 15:11:57 -08:00
|
|
|
{
|
|
|
|
*error = EVAS_LOAD_ERROR_GENERIC;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return (RGBA_Image *) evas_cache_image_request(eci, file, key, lo, error);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2007-07-16 00:25:35 -07:00
|
|
|
evas_common_image_cache_free(void)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2007-07-16 00:25:35 -07:00
|
|
|
evas_common_image_set_cache(0);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
EAPI Evas_Cache_Image*
|
|
|
|
evas_common_image_cache_get(void)
|
2005-12-03 01:27:53 -08:00
|
|
|
{
|
2007-07-16 00:25:35 -07:00
|
|
|
return eci;
|
2005-12-03 01:27:53 -08:00
|
|
|
}
|
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
EAPI RGBA_Image *
|
2005-12-03 01:27:53 -08:00
|
|
|
evas_common_image_line_buffer_obtain(int len)
|
2005-11-30 00:45:20 -08:00
|
|
|
{
|
2005-12-03 01:27:53 -08:00
|
|
|
if (len < 1) return NULL;
|
|
|
|
if (len < EVAS_RGBA_LINE_BUFFER_MIN_LEN)
|
|
|
|
len = EVAS_RGBA_LINE_BUFFER_MIN_LEN;
|
2006-11-13 15:23:44 -08:00
|
|
|
return evas_common_image_create(len, 1);
|
2008-07-19 10:40:52 -07:00
|
|
|
/*
|
2005-12-03 01:27:53 -08:00
|
|
|
if (evas_rgba_line_buffer)
|
2005-11-30 00:45:20 -08:00
|
|
|
{
|
2005-12-03 01:27:53 -08:00
|
|
|
if (evas_rgba_line_buffer->image->w >= len)
|
|
|
|
return evas_rgba_line_buffer;
|
|
|
|
evas_rgba_line_buffer->image->data = (DATA32 *)realloc(evas_rgba_line_buffer->image->data, len * sizeof(DATA32));
|
|
|
|
if (!evas_rgba_line_buffer->image->data)
|
|
|
|
{
|
|
|
|
evas_common_image_free(evas_rgba_line_buffer);
|
|
|
|
evas_rgba_line_buffer = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
evas_rgba_line_buffer->image->w = len;
|
|
|
|
return evas_rgba_line_buffer;
|
2005-11-30 00:45:20 -08:00
|
|
|
}
|
2005-12-03 01:27:53 -08:00
|
|
|
evas_rgba_line_buffer = evas_common_image_create(len, 1);
|
|
|
|
if (!evas_rgba_line_buffer) return NULL;
|
|
|
|
return evas_rgba_line_buffer;
|
2006-11-13 15:23:44 -08:00
|
|
|
*/
|
2005-11-30 00:45:20 -08:00
|
|
|
}
|
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
EAPI void
|
2006-11-13 15:23:44 -08:00
|
|
|
evas_common_image_line_buffer_release(RGBA_Image *im)
|
2005-12-03 01:27:53 -08:00
|
|
|
{
|
2008-05-30 21:16:39 -07:00
|
|
|
_evas_common_rgba_image_delete(&im->cache_entry);
|
2008-07-19 10:40:52 -07:00
|
|
|
/*
|
2005-12-03 01:27:53 -08:00
|
|
|
if (!evas_rgba_line_buffer) return;
|
|
|
|
if (EVAS_RGBA_LINE_BUFFER_MAX_LEN < evas_rgba_line_buffer->image->w)
|
|
|
|
{
|
|
|
|
evas_rgba_line_buffer->image->w = EVAS_RGBA_LINE_BUFFER_MAX_LEN;
|
|
|
|
evas_rgba_line_buffer->image->data = (DATA32 *)realloc(evas_rgba_line_buffer->image->data,
|
|
|
|
evas_rgba_line_buffer->image->w * sizeof(DATA32));
|
|
|
|
if (!evas_rgba_line_buffer->image->data)
|
|
|
|
{
|
|
|
|
evas_common_image_free(evas_rgba_line_buffer);
|
|
|
|
evas_rgba_line_buffer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 15:23:44 -08:00
|
|
|
*/
|
2005-12-03 01:27:53 -08:00
|
|
|
}
|
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
EAPI void
|
2006-11-13 15:23:44 -08:00
|
|
|
evas_common_image_line_buffer_free(RGBA_Image *im)
|
2005-12-03 01:27:53 -08:00
|
|
|
{
|
2008-05-30 21:16:39 -07:00
|
|
|
_evas_common_rgba_image_delete(&im->cache_entry);
|
2008-07-19 10:40:52 -07:00
|
|
|
/*
|
2005-12-03 01:27:53 -08:00
|
|
|
if (!evas_rgba_line_buffer) return;
|
|
|
|
evas_common_image_free(evas_rgba_line_buffer);
|
|
|
|
evas_rgba_line_buffer = NULL;
|
2006-11-13 15:23:44 -08:00
|
|
|
*/
|
2005-12-03 01:27:53 -08:00
|
|
|
}
|
2006-05-02 00:28:49 -07:00
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
EAPI RGBA_Image *
|
2006-05-02 00:28:49 -07:00
|
|
|
evas_common_image_alpha_line_buffer_obtain(int len)
|
|
|
|
{
|
|
|
|
if (len < 1) return NULL;
|
|
|
|
if (len < EVAS_ALPHA_LINE_BUFFER_MIN_LEN)
|
|
|
|
len = EVAS_ALPHA_LINE_BUFFER_MIN_LEN;
|
2006-11-13 15:23:44 -08:00
|
|
|
return evas_common_image_alpha_create(len, 1);
|
2008-07-19 10:40:52 -07:00
|
|
|
/*
|
2006-05-02 00:28:49 -07:00
|
|
|
if (evas_alpha_line_buffer)
|
|
|
|
{
|
|
|
|
if (evas_alpha_line_buffer->image->w >= len)
|
|
|
|
return evas_alpha_line_buffer;
|
|
|
|
evas_alpha_line_buffer->image->data = realloc(evas_alpha_line_buffer->image->data, len * sizeof(DATA8));
|
|
|
|
if (!evas_alpha_line_buffer->image->data)
|
|
|
|
{
|
|
|
|
evas_common_image_free(evas_alpha_line_buffer);
|
|
|
|
evas_alpha_line_buffer = NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
evas_alpha_line_buffer->image->w = len;
|
|
|
|
return evas_alpha_line_buffer;
|
|
|
|
}
|
|
|
|
evas_alpha_line_buffer = evas_common_image_alpha_create(len, 1);
|
|
|
|
return evas_alpha_line_buffer;
|
2006-11-13 15:23:44 -08:00
|
|
|
*/
|
2006-05-02 00:28:49 -07:00
|
|
|
}
|
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
EAPI void
|
2006-11-13 15:23:44 -08:00
|
|
|
evas_common_image_alpha_line_buffer_release(RGBA_Image *im)
|
2006-05-02 00:28:49 -07:00
|
|
|
{
|
2008-05-30 21:16:39 -07:00
|
|
|
_evas_common_rgba_image_delete(&im->cache_entry);
|
2008-07-19 10:40:52 -07:00
|
|
|
/*
|
2006-05-02 00:28:49 -07:00
|
|
|
if (!evas_alpha_line_buffer) return;
|
|
|
|
if (EVAS_ALPHA_LINE_BUFFER_MAX_LEN < evas_alpha_line_buffer->image->w)
|
|
|
|
{
|
|
|
|
evas_alpha_line_buffer->image->w = EVAS_ALPHA_LINE_BUFFER_MAX_LEN;
|
|
|
|
evas_alpha_line_buffer->image->data = realloc(evas_alpha_line_buffer->image->data,
|
|
|
|
evas_alpha_line_buffer->image->w * sizeof(DATA8));
|
|
|
|
if (!evas_alpha_line_buffer->image->data)
|
|
|
|
{
|
|
|
|
evas_common_image_free(evas_alpha_line_buffer);
|
|
|
|
evas_alpha_line_buffer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 15:23:44 -08:00
|
|
|
*/
|
2006-05-02 00:28:49 -07:00
|
|
|
}
|
|
|
|
|
2006-09-30 03:18:37 -07:00
|
|
|
EAPI void
|
2008-06-03 02:09:39 -07:00
|
|
|
evas_common_image_premul(Image_Entry *ie)
|
2006-09-30 03:18:37 -07:00
|
|
|
{
|
|
|
|
DATA32 nas = 0;
|
|
|
|
|
2008-06-03 02:09:39 -07:00
|
|
|
if (!ie) return ;
|
|
|
|
if (!evas_cache_image_pixels(ie)) return ;
|
|
|
|
if (!ie->flags.alpha) return;
|
2006-09-30 03:18:37 -07:00
|
|
|
|
2009-07-01 07:05:04 -07:00
|
|
|
nas = evas_common_convert_argb_premul(evas_cache_image_pixels(ie), ie->w * ie->h);
|
2008-06-03 02:09:39 -07:00
|
|
|
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
|
|
|
|
ie->flags.alpha_sparse = 1;
|
2006-09-30 03:18:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2008-06-03 02:09:39 -07:00
|
|
|
evas_common_image_set_alpha_sparse(Image_Entry *ie)
|
2006-09-30 03:18:37 -07:00
|
|
|
{
|
|
|
|
DATA32 *s, *se;
|
|
|
|
DATA32 nas = 0;
|
|
|
|
|
2008-06-03 02:09:39 -07:00
|
|
|
if (!ie) return;
|
|
|
|
if (!evas_cache_image_pixels(ie)) return ;
|
|
|
|
if (!ie->flags.alpha) return;
|
2006-09-30 03:18:37 -07:00
|
|
|
|
2008-06-03 02:09:39 -07:00
|
|
|
s = evas_cache_image_pixels(ie);
|
|
|
|
se = s + (ie->w * ie->h);
|
2006-09-30 03:18:37 -07:00
|
|
|
while (s < se)
|
|
|
|
{
|
|
|
|
DATA32 p = *s & 0xff000000;
|
|
|
|
|
|
|
|
if (!p || (p == 0xff000000))
|
|
|
|
nas++;
|
|
|
|
s++;
|
|
|
|
}
|
2008-06-03 02:09:39 -07:00
|
|
|
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
|
|
|
|
ie->flags.alpha_sparse = 1;
|
2006-09-30 03:18:37 -07:00
|
|
|
}
|