cedric's cache changes patch

SVN revision: 34253
This commit is contained in:
Carsten Haitzler 2008-04-12 00:32:30 +00:00
parent c290fa032d
commit ae1977a214
72 changed files with 2361 additions and 2151 deletions

View File

@ -335,14 +335,6 @@ if test "x$want_evas_software_16_x11" = "xyes"; then
fi
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16_X11, test "x$have_evas_software_16_x11" = "xyes")
### if software 16 x11 is enabled - build software_16 (the generic 16bit
### engine). later enable it fb_16 or other "16" bit engines are enabled.
have_evas_software_16="no"
if test "x$have_evas_software_16_x11" = "xyes" -o "x$have_evas_software_16_ddraw" = "xyes"; then
have_evas_software_16="yes"
fi
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16, test "x$have_evas_software_16" = "xyes")
#######################################
## Check if we should build the software_xcb engine
want_evas_software_xcb="no";
@ -428,6 +420,19 @@ if test "x$want_evas_sdl" = "xyes"; then
fi
AM_CONDITIONAL(BUILD_ENGINE_SDL, test "x$have_evas_sdl" = "xyes")
## Check if we want to use some SDL primitive
sdl_primitive="no";
AC_ARG_ENABLE(sdl-primitive,
AC_HELP_STRING([--enable-sdl-primitive], []),
[ sdl_primitive=$enableval ]
)
AC_MSG_RESULT($sdl_primitive)
if test "x$sdl_primitive" = "xyes"; then
AC_DEFINE(ENGINE_SDL_PRIMITIVE, 1, [Use SDL primitive when possible])
fi
#######################################
## Check if we should build the fb engine
want_evas_fb="no";
@ -1518,6 +1523,20 @@ if test x$want_valgrind = "xyes"; then
)
fi
### if software 16 x11 is enabled - build software_16 (the generic 16bit
### engine). later enable it fb_16 or other "16" bit engines are enabled.
have_evas_software_16="no"
if test "x$have_evas_software_16_x11" = "xyes"; then
have_evas_software_16="yes"
fi
if test "x$have_evas_sdl" = "xyes"; then
have_evas_software_16="yes"
fi
if test "x$have_evas_software_16_ddraw" = "xyes"; then
have_evas_software_16="yes"
fi
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16, test "x$have_evas_software_16" = "xyes")
#####################################################################
## Fill in flags
@ -1591,6 +1610,7 @@ src/lib/engines/common/evas_op_copy/Makefile
src/lib/engines/common/evas_op_mask/Makefile
src/lib/engines/common/evas_op_mul/Makefile
src/lib/engines/common/evas_op_sub/Makefile
src/lib/engines/common_16/Makefile
src/modules/Makefile
src/modules/engines/Makefile
src/modules/engines/software_generic/Makefile
@ -1615,6 +1635,7 @@ src/modules/engines/glitz_x11/Makefile
src/modules/engines/software_16/Makefile
src/modules/engines/software_16_x11/Makefile
src/modules/engines/software_16_ddraw/Makefile
src/modules/engines/software_16_sdl/Makefile
src/modules/loaders/Makefile
src/modules/loaders/edb/Makefile
src/modules/loaders/eet/Makefile
@ -1657,15 +1678,17 @@ echo " Software Framebuffer.......: $have_evas_fb"
echo " Software Qtopia............: $have_evas_qtopia"
echo " Software Memory Buffer.....: $have_evas_buffer"
echo " DirectFB...................: $have_evas_directfb"
echo " Software SDL...............: $have_evas_sdl"
echo " Software SDL...............: $have_evas_sdl (primitive: $sdl_primitive)"
echo " OpenGL Glew................: $have_evas_gl_glew"
echo " OpenGL X11.................: $have_evas_gl_x11"
echo " Cairo X11..................: $have_evas_cairo_x11"
echo " XRender X11................: $have_evas_xrender_x11"
echo " XRender XCB................: $have_evas_xrender_xcb"
echo " Glitz X11..................: $have_evas_glitz_x11"
echo " Software 16bit ............: $have_evas_software_16"
echo " Software 16bit X11.........: $have_evas_software_16_x11"
echo " Software 16bit Directdraw..: $have_evas_software_16_ddraw"
echo " Software 16bit SDL.........: $have_evas_sdl (primitive: $sdl_primitive)"
# FIXME: opengl engine needs to be fixed and tested lots for all drivers
# FIXME: xrender engine to be written
echo

View File

@ -30,6 +30,7 @@ libevas_la_LIBADD = \
cache/libevas_cache.la \
imaging/libevas_imaging.la \
engines/common/libevas_engine_common.la \
engines/common_16/libevas_engine_common_16.la \
-lm \
@fnmatch_libs@ \
@dlopen_libs@ \
@ -45,7 +46,8 @@ libevas_la_DEPENDENCIES = \
file/libevas_file.la \
cache/libevas_cache.la \
imaging/libevas_imaging.la \
engines/common/libevas_engine_common.la
engines/common/libevas_engine_common.la \
engines/common_16/libevas_engine_common_16.la
libevas_la_LDFLAGS = @create_shared_lib@ -version-info @version_info@

View File

@ -3,6 +3,144 @@
#include "evas_common.h"
#include "evas_private.h"
static void
_evas_cache_engine_image_make_dirty(Evas_Cache_Engine_Image *cache,
Engine_Image_Entry *eim)
{
eim->flags.cached = 1;
eim->flags.dirty = 1;
eim->flags.loaded = 1;
eim->flags.activ = 0;
cache->dirty = evas_object_list_prepend(cache->dirty, eim);
}
static void
_evas_cache_engine_image_make_active(Evas_Cache_Engine_Image *cache,
Engine_Image_Entry *eim,
const char *key)
{
eim->flags.cached = 1;
eim->flags.activ = 1;
eim->flags.dirty = 0;
cache->activ = evas_hash_add(cache->activ, key, eim);
}
static void
_evas_cache_engine_image_make_inactive(Evas_Cache_Engine_Image *cache,
Engine_Image_Entry *eim,
const char *key)
{
eim->flags.cached = 1;
eim->flags.dirty = 0;
eim->flags.activ = 0;
cache->inactiv = evas_hash_add(cache->inactiv, key, eim);
cache->lru = evas_object_list_prepend(cache->lru, eim);
cache->usage += cache->func.mem_size_get(eim);
}
static void
_evas_cache_engine_image_remove_activ(Evas_Cache_Engine_Image *cache,
Engine_Image_Entry *eim)
{
if (eim->flags.cached)
{
if (eim->flags.dirty)
{
cache->dirty = evas_object_list_remove(cache->dirty, eim);
}
else
if (eim->flags.activ)
{
cache->activ = evas_hash_del(cache->activ, eim->cache_key, eim);
}
else
{
cache->usage -= cache->func.mem_size_get(eim);
cache->inactiv = evas_hash_del(cache->inactiv, eim->cache_key, eim);
cache->lru = evas_object_list_remove(cache->lru, eim);
}
eim->flags.cached = 0;
eim->flags.dirty = 0;
eim->flags.activ = 0;
}
}
static Engine_Image_Entry *
_evas_cache_engine_image_alloc(Evas_Cache_Engine_Image *cache,
Image_Entry *ie,
const char *hkey)
{
Engine_Image_Entry *eim;
assert(cache);
if (cache->func.alloc)
eim = cache->func.alloc();
else
eim = malloc(sizeof (Engine_Image_Entry));
if (!eim) goto on_error;
memset(eim, 0, sizeof (Engine_Image_Entry));
eim->cache = cache;
if (ie)
{
eim->w = ie->w;
eim->h = ie->h;
eim->src = ie;
eim->flags.need_parent = 1;
}
else
{
eim->w = -1;
eim->h = -1;
eim->flags.need_parent = 0;
eim->src = NULL;
}
eim->flags.cached = 0;
eim->references = 0;
eim->cache_key = hkey;
if (hkey)
_evas_cache_engine_image_make_active(cache, eim, hkey);
else
_evas_cache_engine_image_make_dirty(cache, eim);
return eim;
on_error:
if (eim)
evas_cache_engine_image_drop(eim);
evas_stringshare_del(hkey);
evas_cache_image_drop(ie);
return NULL;
}
static void
_evas_cache_engine_image_dealloc(Evas_Cache_Engine_Image *cache, Engine_Image_Entry *eim)
{
Image_Entry *im;
if (cache->func.debug) cache->func.debug("delete", eim);
_evas_cache_engine_image_remove_activ(cache, eim);
im = eim->src;
cache->func.destructor(eim);
if (im) evas_cache_image_drop(im);
if (cache->func.delete)
{
cache->func.delete(eim);
}
else
{
memset(eim, 0, sizeof (Engine_Image_Entry));
free(eim);
}
}
EAPI int
evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache)
{
@ -42,11 +180,57 @@ evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_
new->usage = 0;
new->dirty = NULL;
new->lru = NULL;
new->activ = NULL;
new->inactiv = NULL;
new->parent = parent;
parent->references++;
new->brother = NULL;
return new;
}
EAPI Evas_Cache_Engine_Image *
evas_cache_engine_image_dup(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Engine_Image *brother)
{
Evas_Cache_Engine_Image *new;
new = malloc(sizeof (Evas_Cache_Engine_Image));
if (!new)
return NULL;
new->func = brother->func;
#define ORD(Func) if (cb->Func) new->func.Func = cb->Func;
ORD(key);
ORD(constructor);
ORD(destructor);
ORD(dirty_region);
ORD(dirty);
ORD(size_set);
ORD(update_data);
ORD(load);
ORD(mem_size_get);
ORD(debug);
#undef ORD
new->limit = -1;
new->usage = 0;
new->references = 1;
new->dirty = NULL;
new->activ = NULL;
new->parent = brother->parent;
new->parent->references++;
new->brother = brother;
brother->references++;
return new;
}
@ -54,130 +238,126 @@ static Evas_Bool
_evas_cache_engine_image_free_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata)
{
Evas_Cache_Engine_Image *cache = fdata;
RGBA_Engine_Image *eim = data;
RGBA_Image *im;
Engine_Image_Entry *eim = data;
if (cache->func.debug)
cache->func.debug("shutdown-engine-activ", eim);
evas_stringshare_del(eim->cache_key);
eim->cache_key = NULL;
im = eim->src;
cache->func.destructor(eim);
if (im) evas_cache_image_drop(im);
free(eim);
_evas_cache_engine_image_dealloc(cache, eim);
return 1;
}
EAPI void
evas_cache_engine_image_flush(Evas_Cache_Engine_Image *cache)
{
assert(cache != NULL);
while ((cache->lru) && (cache->limit < cache->usage))
{
Engine_Image_Entry *eim;
eim = (Engine_Image_Entry *) cache->lru->last;
_evas_cache_engine_image_dealloc(cache, eim);
}
}
EAPI void
evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache)
{
RGBA_Engine_Image *eim;
RGBA_Image *im;
Engine_Image_Entry *eim;
assert(cache != NULL);
if (cache->func.debug) cache->func.debug("shutdown-engine", NULL);
evas_hash_foreach(cache->inactiv, _evas_cache_engine_image_free_cb, cache);
evas_hash_free(cache->inactiv);
/* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
while (cache->dirty)
{
eim = (RGBA_Engine_Image *) cache->dirty;
im = eim->src;
cache->dirty = evas_object_list_remove(cache->dirty, eim);
if (cache->func.debug)
cache->func.debug("shutdown-engine-dirty", eim);
cache->func.destructor(eim);
if (im) evas_cache_image_drop(im);
free(eim);
eim = (Engine_Image_Entry *) cache->dirty;
_evas_cache_engine_image_dealloc(cache, eim);
}
evas_hash_foreach(cache->activ, _evas_cache_engine_image_free_cb, cache);
evas_hash_free(cache->activ);
evas_cache_image_shutdown(cache->parent);
if (cache->brother)
evas_cache_engine_image_shutdown(cache->brother);
free(cache);
}
EAPI RGBA_Engine_Image *
evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key,
EAPI Engine_Image_Entry *
evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache,
const char *file, const char *key,
RGBA_Image_Loadopts *lo, void *data, int *error)
{
RGBA_Engine_Image *eim;
RGBA_Image *im;
Engine_Image_Entry *eim;
Image_Entry *im;
const char *ekey;
assert(cache != NULL);
*error = -1;
ekey = NULL;
eim = NULL;
im = evas_cache_image_request(cache->parent, file, key, lo, error);
if (!im)
{
*error = -1;
return NULL;
}
goto on_error;
if (cache->func.key)
ekey = cache->func.key(im, file, key, lo, data);
else
ekey = evas_stringshare_add(im->cache_key);
if (!ekey)
{
*error = -1;
evas_cache_image_drop(im);
return NULL;
}
goto on_error;
eim = evas_hash_find(cache->activ, ekey);
if (eim) goto on_ok;
if (eim)
{
evas_cache_image_drop(im);
goto on_ok;
}
eim = malloc(sizeof(RGBA_Engine_Image));
if (!eim) goto on_error;
eim = evas_hash_find(cache->inactiv, ekey);
if (eim)
{
_evas_cache_engine_image_remove_activ(cache, eim);
_evas_cache_engine_image_make_active(cache, eim, ekey);
evas_cache_image_drop(im);
goto on_ok;
}
eim->src = im;
eim->engine_data = NULL;
eim->flags.dirty = 0;
eim->flags.loaded = 0;
eim->cache = cache;
eim->cache_key = ekey;
eim->references = 0;
eim = _evas_cache_engine_image_alloc(cache, im, ekey);
if (!eim) return NULL;
*error = cache->func.constructor(eim, data);
if (*error != 0) goto on_error;
if (cache->func.debug)
cache->func.debug("constructor-engine", eim);
if (*error != 0) goto on_error;
cache->activ = evas_hash_add(cache->activ, ekey, eim);
cache->usage += strlen(eim->cache_key) + 1 + cache->func.mem_size_get(eim);
on_ok:
eim->references++;
return eim;
on_error:
evas_cache_image_drop(im);
evas_stringshare_del(ekey);
if (eim) free(eim);
if (!eim)
{
if (im) evas_cache_image_drop(im);
if (ekey) evas_stringshare_del(ekey);
}
else
{
_evas_cache_engine_image_dealloc(cache, eim);
}
return NULL;
}
static void
_evas_cache_engine_image_free(Evas_Cache_Engine_Image *cache, RGBA_Engine_Image *eim)
{
int size;
size = cache->func.mem_size_get(eim);
cache->usage -= size;
if (cache->func.debug)
cache->func.debug("drop-engine", eim);
cache->func.destructor(eim);
if (eim->src) evas_cache_image_drop(eim->src);
if (eim->cache_key) evas_stringshare_del(eim->cache_key);
free(eim);
}
EAPI void
evas_cache_engine_image_drop(RGBA_Engine_Image *eim)
evas_cache_engine_image_drop(Engine_Image_Entry *eim)
{
Evas_Cache_Engine_Image *cache;
@ -189,28 +369,27 @@ evas_cache_engine_image_drop(RGBA_Engine_Image *eim)
if (eim->flags.dirty)
{
cache->dirty = evas_object_list_remove(cache->dirty, eim);
_evas_cache_engine_image_free(cache, eim);
_evas_cache_engine_image_dealloc(cache, eim);
return ;
}
if (eim->references == 0)
{
cache->activ = evas_hash_del(cache->activ, eim->cache_key, eim);
_evas_cache_engine_image_free(cache, eim);
_evas_cache_engine_image_remove_activ(cache, eim);
_evas_cache_engine_image_make_inactive(cache, eim, eim->cache_key);
evas_cache_engine_image_flush(cache);
return ;
}
}
EAPI RGBA_Engine_Image *
evas_cache_engine_image_dirty(RGBA_Engine_Image *eim, int x, int y, int w, int h)
EAPI Engine_Image_Entry *
evas_cache_engine_image_dirty(Engine_Image_Entry *eim, int x, int y, int w, int h)
{
RGBA_Engine_Image *eim_dirty = eim;
RGBA_Image *im;
RGBA_Image *im_dirty;
Evas_Cache_Engine_Image *cache;
Engine_Image_Entry *eim_dirty = eim;
Image_Entry *im_dirty = NULL;
Image_Entry *im;
Evas_Cache_Engine_Image *cache;
unsigned char alloc_eim;
assert(eim);
assert(eim->cache);
@ -218,56 +397,56 @@ evas_cache_engine_image_dirty(RGBA_Engine_Image *eim, int x, int y, int w, int h
cache = eim->cache;
if (!(eim->flags.dirty))
{
im = eim->src;
im_dirty = evas_cache_image_dirty(im, x, y, w, h);
alloc_eim = 0;
/* If im == im_dirty, this meens that we have only one reference to the eim. */
if (im != im_dirty)
if (eim->flags.need_parent == 1)
{
if (eim->references == 1)
im = eim->src;
im_dirty = evas_cache_image_dirty(im, x, y, w, h);
/* If im == im_dirty, this meens that we have only one reference to the eim. */
if (im != im_dirty)
{
const char *hkey;
if (eim->references == 1)
{
_evas_cache_engine_image_remove_activ(cache, eim);
_evas_cache_engine_image_make_dirty(cache, eim);
hkey = eim->cache_key;
cache->activ = evas_hash_del(cache->activ, hkey, eim);
cache->usage -= strlen(hkey) + 1;
evas_stringshare_del(hkey);
eim_dirty = eim;
eim_dirty->src = im_dirty;
eim->src = im_dirty;
}
else
alloc_eim = 1;
}
else
{
int error;
}
else
if (eim->references > 1)
{
alloc_eim = 1;
}
else
{
_evas_cache_engine_image_remove_activ(cache, eim_dirty);
_evas_cache_engine_image_make_dirty(cache, eim_dirty);
}
eim_dirty = malloc(sizeof(RGBA_Engine_Image));
if (!eim_dirty) goto on_error;
if (alloc_eim == 1)
{
int error;
eim_dirty->src = im_dirty;
eim_dirty->engine_data = NULL;
eim_dirty->flags.dirty = 1;
eim_dirty->flags.loaded = 1;
eim_dirty->cache = cache;
eim_dirty->cache_key = NULL;
eim_dirty->references = 1;
eim_dirty = _evas_cache_engine_image_alloc(cache, im_dirty, NULL);
if (!eim_dirty) goto on_error;
error = cache->func.dirty(eim_dirty, eim);
if (cache->func.debug)
cache->func.debug("dirty-engine", eim_dirty);
eim_dirty->w = eim->w;
eim_dirty->h = eim->h;
eim_dirty->references = 1;
if (error != 0) goto on_error;
error = cache->func.dirty(eim_dirty, eim);
if (cache->func.debug)
cache->func.debug("dirty-engine", eim_dirty);
cache->usage += cache->func.mem_size_get(eim_dirty);
if (error != 0) goto on_error;
evas_cache_engine_image_drop(eim);
}
eim_dirty->cache_key = NULL;
eim_dirty->flags.dirty = 1;
cache->dirty = evas_object_list_prepend(cache->dirty, eim_dirty);
evas_cache_engine_image_drop(eim);
}
}
@ -280,7 +459,7 @@ evas_cache_engine_image_dirty(RGBA_Engine_Image *eim, int x, int y, int w, int h
on_error:
if (eim) evas_cache_engine_image_drop(eim);
if (eim_dirty)
if (eim_dirty && eim_dirty != eim)
evas_cache_engine_image_drop(eim_dirty);
else
if (im_dirty) evas_cache_image_drop(im_dirty);
@ -288,21 +467,43 @@ evas_cache_engine_image_dirty(RGBA_Engine_Image *eim, int x, int y, int w, int h
return NULL;
}
static RGBA_Engine_Image *
_evas_cache_engine_image_push_dirty(Evas_Cache_Engine_Image *cache, RGBA_Image *im, void *engine_data)
EAPI Engine_Image_Entry *
evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data)
{
RGBA_Engine_Image *eim;
Evas_Cache_Engine_Image *cache;
Image_Entry *im;
assert(eim);
assert(eim->cache);
cache = eim->cache;
im = evas_cache_image_alone(eim->src);
if (im != eim->src)
{
eim = _evas_cache_engine_image_alloc(cache, im, NULL);
if (!eim) goto on_error;
eim->references = 1;
if (cache->func.constructor(eim, data)) goto on_error;
}
/* FIXME */
return eim;
on_error:
evas_cache_image_drop(im);
return NULL;
}
static Engine_Image_Entry *
_evas_cache_engine_image_push_dirty(Evas_Cache_Engine_Image *cache, Image_Entry *im, void *engine_data)
{
Engine_Image_Entry *eim;
int error;
eim = malloc(sizeof(RGBA_Engine_Image));
eim = _evas_cache_engine_image_alloc(cache, im, NULL);
if (!eim) goto on_error;
eim->src = im;
eim->engine_data = NULL;
eim->flags.dirty = 1;
eim->flags.loaded = 1;
eim->cache = cache;
eim->cache_key = NULL;
eim->references = 1;
error = cache->func.update_data(eim, engine_data);
@ -310,22 +511,18 @@ _evas_cache_engine_image_push_dirty(Evas_Cache_Engine_Image *cache, RGBA_Image *
cache->func.debug("dirty-update_data-engine", eim);
if (error != 0) goto on_error;
cache->dirty = evas_object_list_prepend(cache->dirty, eim);
return eim;
on_error:
if (eim)
evas_cache_engine_image_drop(eim);
else
evas_cache_image_drop(im);
return NULL;
}
EAPI RGBA_Engine_Image *
EAPI Engine_Image_Entry *
evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data)
{
RGBA_Image *im;
Image_Entry *im;
assert(cache);
@ -334,10 +531,10 @@ evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h
return _evas_cache_engine_image_push_dirty(cache, im, engine_data);
}
EAPI RGBA_Engine_Image *
EAPI Engine_Image_Entry *
evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data)
{
RGBA_Image *im;
Image_Entry *im;
assert(cache);
@ -346,64 +543,48 @@ evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA3
return _evas_cache_engine_image_push_dirty(cache, im, engine_data);
}
EAPI RGBA_Engine_Image *
evas_cache_engine_image_size_set(RGBA_Engine_Image *eim, int w, int h)
EAPI Engine_Image_Entry *
evas_cache_engine_image_size_set(Engine_Image_Entry *eim, int w, int h)
{
Evas_Cache_Engine_Image *cache;
RGBA_Engine_Image *new;
RGBA_Image *im;
int error;
Evas_Cache_Engine_Image *cache;
Engine_Image_Entry *new;
Image_Entry *im;
const char *hkey;
int error;
assert(eim);
assert(eim->src);
assert(eim->cache);
assert(eim->references > 0);
if (eim->src->image->w == w
&& eim->src->image->h == h)
return eim;
im = NULL;
cache = eim->cache;
im = evas_cache_image_size_set(eim->src, w, h);
/* Good idea to call update_data ? */
if (im == eim->src) return eim;
eim->src = NULL;
if (eim->flags.need_parent == 1)
{
assert(eim->src);
new = malloc(sizeof(RGBA_Engine_Image));
if (eim->src->w == w
&& eim->src->h == h)
return eim;
im = evas_cache_image_size_set(eim->src, w, h);
/* FIXME: Good idea to call update_data ? */
if (im == eim->src) return eim;
eim->src = NULL;
}
hkey = (eim->references > 1 ) ? evas_stringshare_add(eim->cache_key) : NULL;
new = _evas_cache_engine_image_alloc(cache, im, hkey);
if (!new) goto on_error;
new->src = im;
new->engine_data = NULL;
new->flags = eim->flags;
new->flags.loaded = 1;
new->cache = cache;
new->cache_key = NULL;
new->w = w;
new->h = h;
new->references = 1;
error = cache->func.size_set(new, eim);
if (error) goto on_error;
assert(new->engine_data != eim->engine_data);
cache->usage += cache->func.mem_size_get(new);
if (new->flags.dirty || eim->references > 1)
{
new->flags.dirty = 1;
cache->dirty = evas_object_list_prepend(cache->dirty, new);
}
else
{
const char *cache_key = NULL;
cache_key = eim->cache_key ? evas_stringshare_add(eim->cache_key) : NULL;
new->cache_key = cache_key;
cache->activ = evas_hash_add(cache->activ, cache_key, new);
cache->usage += strlen(new->cache_key) + 1;
}
evas_cache_engine_image_drop(eim);
return new;
@ -419,10 +600,10 @@ evas_cache_engine_image_size_set(RGBA_Engine_Image *eim, int w, int h)
}
EAPI void
evas_cache_engine_image_load_data(RGBA_Engine_Image *eim)
evas_cache_engine_image_load_data(Engine_Image_Entry *eim)
{
Evas_Cache_Engine_Image *cache;
int size;
int size = 0;
assert(eim);
assert(eim->src);
@ -430,37 +611,35 @@ evas_cache_engine_image_load_data(RGBA_Engine_Image *eim)
if (eim->flags.loaded) return ;
evas_cache_image_load_data(eim->src);
if (eim->src)
evas_cache_image_load_data(eim->src);
cache = eim->cache;
if (cache->func.debug)
cache->func.debug("load-engine", eim);
size = cache->func.mem_size_get(eim);
if (eim->flags.dirty)
size = cache->func.mem_size_get(eim);
cache = eim->cache;
cache->func.load(eim, eim->src);
cache->usage += cache->func.mem_size_get(eim) - size;
if (eim->flags.dirty)
cache->usage += cache->func.mem_size_get(eim) - size;
eim->flags.loaded = 1;
}
EAPI RGBA_Engine_Image *
EAPI Engine_Image_Entry *
evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data)
{
RGBA_Engine_Image *eim;
int error;
Engine_Image_Entry *eim;
Image_Entry *ie;
int error;
eim = malloc(sizeof(RGBA_Engine_Image));
ie = evas_cache_image_empty(cache->parent);
if (!ie) return NULL;
eim = _evas_cache_engine_image_alloc(cache, ie, NULL);
if (!eim) goto on_error;
eim->src = evas_cache_image_empty(cache->parent);
if (!eim->src) goto on_error;
eim->engine_data = NULL;
eim->flags.dirty = 1;
eim->flags.loaded = 1;
eim->cache = cache;
eim->cache_key = NULL;
eim->references = 1;
error = cache->func.update_data(eim, engine_data);
@ -469,18 +648,23 @@ evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data
if (error != 0) goto on_error;
cache->dirty = evas_object_list_prepend(cache->dirty, eim);
return eim;
on_error:
if (eim)
evas_cache_engine_image_drop(eim);
if (!eim)
{
if (ie)
evas_cache_image_drop(ie);
}
else
{
evas_cache_engine_image_drop(eim);
}
return NULL;
}
EAPI void
evas_cache_engine_image_colorspace(RGBA_Engine_Image *eim, int cspace, void *engine_data)
evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data)
{
Evas_Cache_Engine_Image *cache = eim->cache;
@ -493,3 +677,12 @@ evas_cache_engine_image_colorspace(RGBA_Engine_Image *eim, int cspace, void *eng
cache->func.debug("cosntructor-colorspace-engine", eim);
}
EAPI void
evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim)
{
assert(eim);
assert(eim->cache);
eim->flags.need_parent = 0;
evas_cache_image_data_not_needed(eim->src);
}

View File

@ -4,6 +4,221 @@
#include "evas_common.h"
#include "evas_private.h"
#define FREESTRC(Var) \
if (Var) \
{ \
evas_stringshare_del(Var); \
Var = NULL; \
}
static void
_evas_cache_image_make_dirty(Evas_Cache_Image *cache,
Image_Entry *im)
{
im->flags.cached = 1;
im->flags.dirty = 1;
im->flags.activ = 0;
im->flags.lru_nodata = 0;
cache->dirty = evas_object_list_prepend(cache->dirty, im);
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
}
static void
_evas_cache_image_make_activ(Evas_Cache_Image *cache,
Image_Entry *im,
const char *key)
{
im->cache_key = key;
if (key != NULL)
{
im->flags.cached = 1;
im->flags.activ = 1;
im->flags.lru_nodata = 0;
im->flags.dirty = 0;
cache->activ = evas_hash_direct_add(cache->activ, key, im);
}
else
{
_evas_cache_image_make_dirty(cache, im);
}
}
static void
_evas_cache_image_make_inactiv(Evas_Cache_Image *cache,
Image_Entry *im,
const char *key)
{
im->flags.activ = 0;
im->flags.dirty = 0;
im->flags.cached = 1;
cache->inactiv = evas_hash_direct_add(cache->inactiv, key, im);
cache->lru = evas_object_list_prepend(cache->lru, im);
cache->usage += cache->func.mem_size_get(im);
}
static void
_evas_cache_image_remove_lru_nodata(Evas_Cache_Image *cache,
Image_Entry *im)
{
if (im->flags.lru_nodata)
{
im->flags.lru_nodata = 0;
cache->lru_nodata = evas_object_list_remove(cache->lru_nodata, im);
cache->usage -= cache->func.mem_size_get(im);
}
}
static void
_evas_cache_image_activ_lru_nodata(Evas_Cache_Image *cache,
Image_Entry *im)
{
im->flags.need_data = 0;
im->flags.lru_nodata = 1;
cache->lru_nodata = evas_object_list_prepend(cache->lru_nodata, im);
cache->usage += cache->func.mem_size_get(im);
}
static void
_evas_cache_image_remove_activ(Evas_Cache_Image *cache,
Image_Entry *ie)
{
if (ie->flags.cached)
{
if (ie->flags.activ)
{
cache->activ = evas_hash_del(cache->activ, ie->cache_key, ie);
_evas_cache_image_remove_lru_nodata(cache, ie);
}
else
{
if (ie->flags.dirty)
{
cache->dirty = evas_object_list_remove(cache->dirty, ie);
}
else
{
cache->inactiv = evas_hash_del(cache->inactiv, ie->cache_key, ie);
cache->lru = evas_object_list_remove(cache->lru, ie);
cache->usage -= cache->func.mem_size_get(ie);
}
}
ie->flags.cached = 0;
ie->flags.dirty = 0;
ie->flags.activ = 0;
}
}
static void
_evas_cache_image_entry_delete(Evas_Cache_Image *cache, Image_Entry *ie)
{
if (!ie) return ;
if (cache->func.debug)
cache->func.debug("deleting", ie);
cache->func.destructor(ie);
_evas_cache_image_remove_activ(cache, ie);
if (ie->cache_key)
{
evas_stringshare_del(ie->cache_key);
ie->cache_key = NULL;
}
FREESTRC(ie->file);
FREESTRC(ie->key);
cache->func.surface_delete(ie);
cache->func.delete(ie);
}
static Image_Entry *
_evas_cache_image_entry_new(Evas_Cache_Image *cache,
const char *hkey,
time_t timestamp,
const char *file,
const char *key,
RGBA_Image_Loadopts *lo,
int *error)
{
Image_Entry *ie;
const char *cache_key;
ie = cache->func.alloc();
if (!ie)
return NULL;
cache_key = hkey ? evas_stringshare_add(hkey) : NULL;
ie->flags.loaded = 0;
ie->flags.need_data = 1;
_evas_cache_image_make_activ(cache, ie, cache_key);
ie->space = EVAS_COLORSPACE_ARGB8888;
ie->w = -1;
ie->h = -1;
ie->references = 0;
ie->cache = cache;
ie->file = file ? evas_stringshare_add(file) : NULL;
ie->key = key ? evas_stringshare_add(key) : NULL;
ie->timestamp = timestamp;
ie->laststat = time(NULL);
ie->load_opts.scale_down_by = 0;
ie->load_opts.dpi = 0;
ie->load_opts.w = 0;
ie->load_opts.h = 0;
ie->scale = 1;
if (lo)
ie->load_opts = *lo;
ie->references = 0;
if (file)
{
*error = cache->func.constructor(ie);
if (*error != 0)
{
_evas_cache_image_entry_delete(cache, ie);
return NULL;
}
}
if (cache->func.debug)
cache->func.debug("build", ie);
return ie;
}
static void
_evas_cache_image_entry_surface_alloc(Evas_Cache_Image *cache,
Image_Entry *ie,
int w,
int h)
{
int wmin;
int hmin;
wmin = w > 0 ? w : 1;
hmin = h > 0 ? h : 1;
if (cache->func.surface_alloc(ie, wmin, hmin))
{
wmin = 0;
hmin = 0;
}
ie->w = wmin;
ie->h = hmin;
}
EAPI int
evas_cache_image_usage_get(Evas_Cache_Image *cache)
{
@ -45,6 +260,7 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
new->dirty = NULL;
new->lru = NULL;
new->lru_nodata = NULL;
new->inactiv = NULL;
new->activ = NULL;
@ -57,26 +273,17 @@ static Evas_Bool
_evas_cache_image_free_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata)
{
Evas_Cache_Image *cache = fdata;
RGBA_Image *im = data;
Image_Entry *im = data;
if (cache->func.debug)
cache->func.debug("shutdown-activ", im);
_evas_cache_image_entry_delete(cache, im);
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
cache->func.destructor(im);
evas_common_image_delete(im);
return 1;
}
EAPI void
evas_cache_image_shutdown(Evas_Cache_Image *cache)
{
RGBA_Image *im;
Image_Entry *im;
assert(cache != NULL);
cache->references--;
@ -86,31 +293,21 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
while (cache->lru)
{
im = (RGBA_Image *) cache->lru;
cache->lru = evas_object_list_remove(cache->lru, im);
im = (Image_Entry *) cache->lru;
_evas_cache_image_entry_delete(cache, im);
}
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
if (cache->func.debug)
cache->func.debug("shutdown-lru", im);
cache->func.destructor(im);
evas_common_image_delete(im);
while (cache->lru_nodata)
{
im = (Image_Entry *) cache->lru_nodata;
_evas_cache_image_entry_delete(cache, im);
}
/* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
while (cache->dirty)
{
im = (RGBA_Image *) cache->dirty;
cache->dirty = evas_object_list_remove(cache->dirty, im);
if (cache->func.debug)
cache->func.debug("shutdown-dirty", im);
cache->func.destructor(im);
evas_common_image_delete(im);
im = (Image_Entry *) cache->dirty;
_evas_cache_image_entry_delete(cache, im);
}
evas_hash_foreach(cache->activ, _evas_cache_image_free_cb, cache);
@ -120,14 +317,17 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
free(cache);
}
EAPI RGBA_Image *
#define STAT_GAP 2
EAPI Image_Entry *
evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error)
{
const char *format;
char *hkey;
RGBA_Image *im;
Image_Entry *im;
Evas_Image_Load_Opts prevent;
int size;
int stat_done = 0;
struct stat st;
assert(cache != NULL);
@ -157,106 +357,86 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
hkey = alloca(sizeof (char) * size);
snprintf(hkey, size, format, file, key, lo->scale_down_by, lo->dpi, lo->w, lo->h);
if (stat(file, &st) < 0)
{
im = evas_hash_find(cache->inactiv, hkey);
if (im)
{
cache->lru = evas_object_list_remove(cache->lru, im);
cache->inactiv = evas_hash_del(cache->inactiv, im->cache_key, im);
// printf("IMG %p %ix%i %s SUB %i\n",
// im, im->image->w, im->image->h, im->cache_key,
// cache->func.mem_size_get(im));
cache->usage -= cache->func.mem_size_get(im);
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
cache->func.destructor(im);
evas_common_image_delete(im);
}
return NULL;
}
im = evas_hash_find(cache->activ, hkey);
if (im)
{
if (st.st_mtime == im->timestamp)
goto on_ok;
time_t t;
int ok;
ok = 1;
t = time(NULL);
if ((t - im->laststat) > STAT_GAP)
{
stat_done = 1;
if (stat(file, &st) < 0) goto on_error;
im->laststat = t;
if (st.st_mtime != im->timestamp) ok = 0;
}
if (ok) goto on_ok;
}
im = evas_hash_find(cache->inactiv, hkey);
if (im)
{
if (st.st_mtime == im->timestamp)
{
cache->lru = evas_object_list_remove(cache->lru, im);
cache->inactiv = evas_hash_del(cache->inactiv, im->cache_key, im);
cache->activ = evas_hash_direct_add(cache->activ, im->cache_key, im);
// printf("IMG %p %ix%i %s SUB %i\n",
// im, im->image->w, im->image->h, im->cache_key,
// cache->func.mem_size_get(im));
cache->usage -= cache->func.mem_size_get(im);
goto on_ok;
}
else
{
cache->lru = evas_object_list_remove(cache->lru, im);
cache->inactiv = evas_hash_del(cache->inactiv, im->cache_key, im);
// printf("IMG %p %ix%i %s SUB %i\n",
// im, im->image->w, im->image->h, im->cache_key,
// cache->func.mem_size_get(im));
cache->usage -= cache->func.mem_size_get(im);
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
cache->func.destructor(im);
evas_common_image_delete(im);
}
int ok;
ok = 1;
if (!stat_done)
{
time_t t;
t = time(NULL);
if ((t - im->laststat) > STAT_GAP)
{
stat_done = 1;
if (stat(file, &st) < 0) goto on_error;
im->laststat = t;
if (st.st_mtime != im->timestamp) ok = 0;
}
}
else
if (st.st_mtime != im->timestamp) ok = 0;
if (ok)
{
_evas_cache_image_remove_activ(cache, im);
_evas_cache_image_make_activ(cache, im, im->cache_key);
goto on_ok;
}
_evas_cache_image_entry_delete(cache, im);
}
im = evas_common_image_new();
if (!stat_done)
{
if (stat(file, &st) < 0) return NULL;
}
im = _evas_cache_image_entry_new(cache, hkey, st.st_mtime, file, key, lo, error);
if (!im)
{
*error = -1;
return NULL;
}
im->timestamp = st.st_mtime;
im->laststat = time(NULL);
if (lo) im->load_opts = *lo;
im->info.file = (char *) evas_stringshare_add(file);
if (key) im->info.key = (char *) evas_stringshare_add(key);
*error = cache->func.constructor(im);
if (*error != 0)
{
evas_common_image_delete(im);
return NULL;
}
return NULL;
if (cache->func.debug)
cache->func.debug("request", im);
im->references = 0;
im->cache_key = evas_stringshare_add(hkey);
im->cache = cache;
cache->activ = evas_hash_direct_add(cache->activ, im->cache_key, im);
on_ok:
on_ok:
*error = 0;
im->references++;
if (im->references > 1 && im->flags.lru_nodata)
_evas_cache_image_remove_lru_nodata(cache, im);
return im;
on_error:
_evas_cache_image_entry_delete(cache, im);
return NULL;
}
EAPI void
evas_cache_image_drop(RGBA_Image *im)
evas_cache_image_drop(Image_Entry *im)
{
Evas_Cache_Image *cache;
@ -266,72 +446,59 @@ evas_cache_image_drop(RGBA_Image *im)
im->references--;
cache = im->cache;
// if (im->cache_key) printf("DROP %s -> ref = %i\n", im->cache_key, im->references);
if ((im->flags & RGBA_IMAGE_IS_DIRTY) == RGBA_IMAGE_IS_DIRTY)
if (im->flags.dirty)
{
// printf("IMG %p %ix%i %s SUB %i\n",
// im, im->image->w, im->image->h, im->cache_key,
// cache->func.mem_size_get(im));
//// don't decrement cache usage - unless we remove from the lru
// cache->usage -= cache->func.mem_size_get(im);
// if (im->cache_key) printf("IM-- %s, cache = %i\n", im->cache_key, cache->usage);
cache->dirty = evas_object_list_remove(cache->dirty, im);
if (cache->func.debug)
cache->func.debug("drop", im);
cache->func.destructor(im);
evas_common_image_delete(im);
_evas_cache_image_entry_delete(cache, im);
return ;
}
if (im->references == 0)
{
cache->activ = evas_hash_del(cache->activ, im->cache_key, im);
cache->inactiv = evas_hash_direct_add(cache->inactiv, im->cache_key, im);
cache->lru = evas_object_list_prepend(cache->lru, im);
// printf("IMG %p %ix%i %s ADD %i\n",
// im, im->image->w, im->image->h, im->cache_key,
// cache->func.mem_size_get(im));
cache->usage += cache->func.mem_size_get(im);
// printf("FLUSH!\n");
_evas_cache_image_remove_activ(cache, im);
_evas_cache_image_make_inactiv(cache, im, im->cache_key);
evas_cache_image_flush(cache);
}
}
EAPI RGBA_Image *
evas_cache_image_dirty(RGBA_Image *im, int x, int y, int w, int h)
EAPI void
evas_cache_image_data_not_needed(Image_Entry *im)
{
RGBA_Image *im_dirty = im;
Evas_Cache_Image *cache;
assert(im);
assert(im->cache);
cache = im->cache;
if (!(im->flags & RGBA_IMAGE_IS_DIRTY))
if (im->references > 1) return ;
if (im->flags.dirty || !im->flags.need_data) return ;
_evas_cache_image_activ_lru_nodata(cache, im);
}
EAPI Image_Entry *
evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h)
{
Image_Entry *im_dirty = im;
Evas_Cache_Image *cache;
assert(im);
assert(im->cache);
cache = im->cache;
if (!(im->flags.dirty))
{
if (im->references == 1)
{
if (im->cache_key)
{
cache->activ = evas_hash_del(cache->activ, im->cache_key, im);
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
_evas_cache_image_remove_activ(cache, im);
im_dirty = im;
}
else
{
int error;
im_dirty = evas_common_image_new();
im_dirty = _evas_cache_image_entry_new(cache, NULL, im->timestamp, im->file, im->key, &im->load_opts, &error);
if (!im_dirty) goto on_error;
im_dirty->image = evas_common_image_surface_new(im);
if (!im_dirty->image) goto on_error;
im_dirty->image->w = w;
im_dirty->image->h = h;
if (cache->func.debug)
cache->func.debug("dirty-src", im);
@ -341,34 +508,32 @@ evas_cache_image_dirty(RGBA_Image *im, int x, int y, int w, int h)
if (error != 0) goto on_error;
im_dirty->cache = cache;
im_dirty->references = 1;
evas_cache_image_drop(im);
}
im_dirty->flags |= RGBA_IMAGE_IS_DIRTY;
cache->dirty = evas_object_list_prepend(cache->dirty, im_dirty);
_evas_cache_image_make_dirty(cache, im_dirty);
}
if (cache->func.debug)
cache->func.debug("dirty-region", im_dirty);
if (cache->func.dirty_region)
cache->func.dirty_region(im_dirty, x, y, w, h);
return im_dirty;
on_error:
if (im_dirty) evas_common_image_delete(im_dirty);
on_error:
if (im_dirty) _evas_cache_image_entry_delete(cache, im_dirty);
evas_cache_image_drop(im);
return NULL;
}
EAPI RGBA_Image *
evas_cache_image_alone(RGBA_Image *im)
EAPI Image_Entry *
evas_cache_image_alone(Image_Entry *im)
{
RGBA_Image *im_dirty = im;
Evas_Cache_Image *cache;
Evas_Cache_Image *cache;
Image_Entry *im_dirty = im;
assert(im);
assert(im->cache);
@ -376,28 +541,18 @@ evas_cache_image_alone(RGBA_Image *im)
cache = im->cache;
if (im->references == 1)
{
if (!(im->flags & RGBA_IMAGE_IS_DIRTY))
if (!(im->flags.dirty))
{
if (im->cache_key)
{
cache->activ = evas_hash_del(cache->activ, im->cache_key, im);
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
im->flags |= RGBA_IMAGE_IS_DIRTY;
cache->dirty = evas_object_list_prepend(cache->dirty, im);
_evas_cache_image_remove_activ(cache, im);
_evas_cache_image_make_dirty(cache, im);
}
}
else
{
int error;
im_dirty = evas_common_image_new();
im_dirty = _evas_cache_image_entry_new(cache, NULL, im->timestamp, im->file, im->key, &im->load_opts, &error);
if (!im_dirty) goto on_error;
im_dirty->image = evas_common_image_surface_new(im);
if (!im_dirty->image) goto on_error;
im_dirty->image->w = im->image->w;
im_dirty->image->h = im->image->h;
if (cache->func.debug)
cache->func.debug("dirty-src", im);
@ -407,46 +562,23 @@ evas_cache_image_alone(RGBA_Image *im)
if (error != 0) goto on_error;
if (im_dirty->cache_key)
{
evas_stringshare_del(im_dirty->cache_key);
im_dirty->cache_key = NULL;
}
im_dirty->flags |= RGBA_IMAGE_IS_DIRTY;
im_dirty->references = 1;
cache->dirty = evas_object_list_prepend(cache->dirty, im_dirty);
evas_cache_image_drop(im);
}
return im_dirty;
on_error:
if (im_dirty) evas_common_image_delete(im_dirty);
if (im_dirty) _evas_cache_image_entry_delete(cache, im_dirty);
evas_cache_image_drop(im);
return NULL;
}
static RGBA_Image *
_evas_cache_image_push_dirty(Evas_Cache_Image *cache, RGBA_Image *im)
{
cache->dirty = evas_object_list_prepend(cache->dirty, im);
im->flags |= RGBA_IMAGE_IS_DIRTY;
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
im->cache = cache;
return im;
}
EAPI RGBA_Image *
EAPI Image_Entry *
evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
RGBA_Image *im;
Image_Entry *im;
assert(cache);
@ -454,122 +586,132 @@ evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *imag
(cspace == EVAS_COLORSPACE_YCBCR422P709_PL))
w &= ~0x1;
im = evas_common_image_create(w, h);
im = _evas_cache_image_entry_new(cache, NULL, 0, NULL, NULL, NULL, NULL);
if (!im) return NULL;
im->space = cspace;
_evas_cache_image_entry_surface_alloc(cache, im, w, h);
if (cache->func.copied_data(im, w, h, image_data, alpha, cspace) != 0)
{
evas_common_image_delete(im);
_evas_cache_image_entry_delete(cache, im);
return NULL;
}
im->references = 1;
return _evas_cache_image_push_dirty(cache, im);
if (cache->func.debug)
cache->func.debug("copied-data", im);
return im;
}
EAPI RGBA_Image *
EAPI Image_Entry *
evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
RGBA_Image *im;
Image_Entry *im;
assert(cache);
im = evas_common_image_new();
if (!im) return NULL;
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
evas_common_image_delete(im);
return NULL;
}
im = _evas_cache_image_entry_new(cache, NULL, 0, NULL, NULL, NULL, NULL);
im->w = w;
im->h = h;
if (cache->func.data(im, w, h, image_data, alpha, cspace) != 0)
{
evas_common_image_delete(im);
_evas_cache_image_entry_delete(cache, im);
return NULL;
}
im->references = 1;
return _evas_cache_image_push_dirty(cache, im);
if (cache->func.debug)
cache->func.debug("data", im);
return im;
}
EAPI RGBA_Image *
evas_cache_image_size_set(RGBA_Image *im, int w, int h)
EAPI void
evas_cache_image_surface_alloc(Image_Entry *im, int w, int h)
{
Evas_Cache_Image *cache;
assert(im);
assert(im->cache);
cache = im->cache;
_evas_cache_image_entry_surface_alloc(cache, im, w, h);
if (cache->func.debug)
cache->func.debug("surface-alloc", im);
}
EAPI Image_Entry *
evas_cache_image_size_set(Image_Entry *im, int w, int h)
{
Evas_Cache_Image *cache;
RGBA_Image *new;
Image_Entry *new;
int error;
assert(im);
assert(im->image);
assert(im->cache);
assert(im->references > 0);
if ((im->image->w == w) && (im->image->h == h))
if ((im->w == w) && (im->h == h))
return im;
cache = im->cache;
new = evas_common_image_new();
new = _evas_cache_image_entry_new(cache, NULL, 0, NULL, NULL, NULL, &error);
if (!new) goto on_error;
new->image = evas_common_image_surface_new(im);
if (!new->image) goto on_error;
new->image->w = w;
new->image->h = h;
if (cache->func.debug)
cache->func.debug("size_set-in", im);
_evas_cache_image_entry_surface_alloc(cache, new, w, h);
new->space = im->space;
new->load_opts = im->load_opts;
error = cache->func.size_set(new, im, w, h);
if (cache->func.debug)
cache->func.debug("size_set-out", new);
if (error != 0) goto on_error;
new->cache = cache;
new->cache_key = NULL;
new->references = 1;
// cache->usage += cache->func.mem_size_get(new);
if (((im->flags & RGBA_IMAGE_IS_DIRTY) == RGBA_IMAGE_IS_DIRTY)
|| (im->references > 1))
{
new->flags |= RGBA_IMAGE_IS_DIRTY;
cache->dirty = evas_object_list_prepend(cache->dirty, new);
}
else
{
new->cache_key = im->cache_key ? evas_stringshare_add(im->cache_key) : NULL;
cache->activ = evas_hash_direct_add(cache->activ, new->cache_key, new);
}
evas_cache_image_drop(im);
if (cache->func.debug)
cache->func.debug("size_set", new);
return new;
on_error:
if (new) evas_common_image_delete(new);
on_error:
if (new) _evas_cache_image_entry_delete(cache, new);
evas_cache_image_drop(im);
return NULL;
}
EAPI void
evas_cache_image_load_data(RGBA_Image *im)
evas_cache_image_load_data(Image_Entry *im)
{
Evas_Cache_Image *cache;
int error;
assert(im);
assert(im->image);
assert(im->cache);
if ((im->flags & RGBA_IMAGE_LOADED) == RGBA_IMAGE_LOADED) return ;
if (im->flags.loaded) return ;
cache = im->cache;
error = cache->func.load(im);
if (cache->func.debug)
cache->func.debug("load", im);
cache->func.load(im);
im->flags |= RGBA_IMAGE_LOADED;
if (error)
{
_evas_cache_image_entry_surface_alloc(cache, im, im->w, im->h);
im->flags.loaded = 0;
assert(im->image->data);
return ;
}
im->flags.loaded = 1;
}
EAPI int
@ -583,58 +725,53 @@ evas_cache_image_flush(Evas_Cache_Image *cache)
while ((cache->lru) && (cache->limit < cache->usage))
{
RGBA_Image *im;
Image_Entry *im;
im = (RGBA_Image *) cache->lru->last;
cache->lru = evas_object_list_remove(cache->lru, im);
cache->inactiv = evas_hash_del(cache->inactiv, im->cache_key, im);
// printf("IMG %p %ix%i %s SUB %i\n",
// im, im->image->w, im->image->h, im->cache_key,
// cache->func.mem_size_get(im));
cache->usage -= cache->func.mem_size_get(im);
if (im->cache_key)
{
evas_stringshare_del(im->cache_key);
im->cache_key = NULL;
}
// printf("DEL IMG FROM CACHE\n");
cache->func.destructor(im);
evas_common_image_delete(im);
im = (Image_Entry *) cache->lru->last;
_evas_cache_image_entry_delete(cache, im);
}
while ((cache->lru_nodata) && (cache->limit < cache->usage))
{
Image_Entry *im;
im = (Image_Entry *) cache->lru_nodata->last;
_evas_cache_image_remove_lru_nodata(cache, im);
cache->func.surface_delete(im);
im->flags.loaded = 0;
}
return cache->usage;
}
EAPI RGBA_Image *
EAPI Image_Entry *
evas_cache_image_empty(Evas_Cache_Image *cache)
{
RGBA_Image *new;
Image_Entry *new;
new = evas_common_image_new();
if (!new) goto on_error;
new->image = evas_common_image_surface_new(new);
if (!new->image) goto on_error;
new = _evas_cache_image_entry_new(cache, NULL, 0, NULL, NULL, NULL, NULL);
if (!new) return NULL;
new->cache = cache;
new->references = 1;
new->cache_key = NULL;
new->flags |= RGBA_IMAGE_IS_DIRTY;
cache->dirty = evas_object_list_prepend(cache->dirty, new);
return new;
on_error:
if (new) evas_common_image_delete(new);
return NULL;
}
EAPI void
evas_cache_image_colorspace(RGBA_Image *im, int cspace)
evas_cache_image_colorspace(Image_Entry *im, int cspace)
{
if (!im) return ;
if (im->cs.space == cspace) return ;
Evas_Cache_Image *cache;
evas_common_image_colorspace_set(im, cspace);
assert(im);
assert(im->cache);
cache = im->cache;
if (!im) return ;
if (im->space == cspace) return ;
im->space = cspace;
cache->func.color_space(im, cspace);
}

View File

@ -1121,18 +1121,17 @@ evas_object_image_save(const Evas_Object *obj, const char *file, const char *key
else break;
}
}
im = evas_cache_image_empty(evas_common_image_cache_get());
im = (RGBA_Image*) evas_cache_image_data(evas_common_image_cache_get(),
o->cur.image.w,
o->cur.image.h,
data,
o->cur.has_alpha,
EVAS_COLORSPACE_ARGB8888);
if (im)
{
if (o->cur.has_alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA;
im->image->data = data;
im->image->w = o->cur.image.w;
im->image->h = o->cur.image.h;
im->image->no_free = 1;
ok = evas_common_save_image_to_file(im, file, key, quality, compress);
evas_cache_image_drop(im);
evas_cache_image_drop(&im->cache_entry);
}
return ok;
}
@ -2332,7 +2331,7 @@ static int
evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
Evas_Object_Image *o;
void *data;
DATA32 *data;
int w, h, stride;
int a;
@ -2354,7 +2353,7 @@ evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
o->engine_data = obj->layer->evas->engine.func->image_data_get(obj->layer->evas->engine.data.output,
o->engine_data,
0,
(DATA32**) &data);
&data);
if (!data)
return 0;
@ -2365,8 +2364,8 @@ evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
a = (*((DATA32*)(data)) >> 24) & 0xff;
break;
case EVAS_COLORSPACE_RGB565_A5P:
data = ((DATA16*)(data) + (h * stride));
data = ((DATA8*)(data) + ((y * stride) + x));
data = (void*) ((DATA16*)(data) + (h * stride));
data = (void*) ((DATA8*)(data) + ((y * stride) + x));
a = (*((DATA8*)(data))) & 0x1f;
break;
default:

View File

@ -2,4 +2,4 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = \
common
common common_16

View File

@ -32,7 +32,7 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
/* clip clip clip */
if (w <= 0) return;
if (src_x + w > src->image->w) w = src->image->w - src_x;
if (src_x + w > src->cache_entry.w) w = src->cache_entry.w - src_x;
if (w <= 0) return;
if (src_x < 0)
{
@ -43,7 +43,7 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
if (w <= 0) return;
if (h <= 0) return;
if (src_y + h > src->image->h) h = src->image->h - src_y;
if (src_y + h > src->cache_entry.h) h = src->cache_entry.h - src_y;
if (h <= 0) return;
if (src_y < 0)
{
@ -54,7 +54,7 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
if (h <= 0) return;
if (w <= 0) return;
if (dst_x + w > dst->image->w) w = dst->image->w - dst_x;
if (dst_x + w > dst->cache_entry.w) w = dst->cache_entry.w - dst_x;
if (w <= 0) return;
if (dst_x < 0)
{
@ -65,7 +65,7 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
if (w <= 0) return;
if (h <= 0) return;
if (dst_y + h > dst->image->h) h = dst->image->h - dst_y;
if (dst_y + h > dst->cache_entry.h) h = dst->cache_entry.h - dst_y;
if (h <= 0) return;
if (dst_y < 0)
{
@ -78,13 +78,13 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
if (dst == src)
{
/* src after dst - go forward */
if (((src_y * src->image->w) + src_x) > ((dst_y * dst->image->w) + dst_x))
if (((src_y * src->cache_entry.w) + src_x) > ((dst_y * dst->cache_entry.w) + dst_x))
{
func = evas_common_draw_func_copy_get(w, 0);
for (y = 0; y < h; y++)
{
src_ptr = src->image->data + ((y + src_y) * src->image->w) + src_x;
dst_ptr = dst->image->data + ((y + dst_y) * dst->image->w) + dst_x;
src_ptr = src->image.data + ((y + src_y) * src->cache_entry.w) + src_x;
dst_ptr = dst->image.data + ((y + dst_y) * dst->cache_entry.w) + dst_x;
func(src_ptr, dst_ptr, w);
}
}
@ -94,8 +94,8 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
func = evas_common_draw_func_copy_get(w, 1);
for (y = h - 1; y >= 0; y--)
{
src_ptr = src->image->data + ((y + src_y) * src->image->w) + src_x;
dst_ptr = dst->image->data + ((y + dst_y) * dst->image->w) + dst_x;
src_ptr = src->image.data + ((y + src_y) * src->cache_entry.w) + src_x;
dst_ptr = dst->image.data + ((y + dst_y) * dst->cache_entry.w) + dst_x;
func(src_ptr, dst_ptr, w);
}
}
@ -105,8 +105,8 @@ evas_common_blit_rectangle(const RGBA_Image *src, RGBA_Image *dst, int src_x, in
func = evas_common_draw_func_copy_get(w, 0);
for (y = 0; y < h; y++)
{
src_ptr = src->image->data + ((y + src_y) * src->image->w) + src_x;
dst_ptr = dst->image->data + ((y + dst_y) * dst->image->w) + dst_x;
src_ptr = src->image.data + ((y + src_y) * src->cache_entry.w) + src_x;
dst_ptr = dst->image.data + ((y + dst_y) * dst->cache_entry.w) + dst_x;
func(src_ptr, dst_ptr, w);
}
}

View File

@ -146,9 +146,9 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
fi = fn->fonts->data;
im = dst->image->data;
im_w = dst->image->w;
im_h = dst->image->h;
im = dst->image.data;
im_w = dst->cache_entry.w;
im_h = dst->cache_entry.h;
ext_x = 0; ext_y = 0; ext_w = im_w; ext_h = im_h;
if (dc->clip.use)

View File

@ -432,7 +432,7 @@ evas_common_gradient_draw(RGBA_Image *dst, RGBA_Draw_Context *dc,
float angle;
int direct_copy = 0, buf_step = 0;
if (!dst || !dc || !gr || !dst || !dst->image || !dst->image->data)
if (!dst || !dc || !gr || !dst || !dst->image.data)
return;
if (!gr->map.data || !gr->type.geometer)
return;
@ -440,7 +440,7 @@ evas_common_gradient_draw(RGBA_Image *dst, RGBA_Draw_Context *dc,
return;
if ((w < 1) || (h < 1))
return;
clx = 0; cly = 0; clw = dst->image->w; clh = dst->image->h;
clx = 0; cly = 0; clw = dst->cache_entry.w; clh = dst->cache_entry.h;
if ((clw < 1) || (clh < 1)) return;
if (dc->clip.use)
@ -459,14 +459,14 @@ evas_common_gradient_draw(RGBA_Image *dst, RGBA_Draw_Context *dc,
if ((dc->render_op == _EVAS_RENDER_FILL) ||
(dc->render_op == _EVAS_RENDER_COPY))
{
direct_copy = 1; buf_step = dst->image->w;
direct_copy = 1; buf_step = dst->cache_entry.w;
if (gr->type.geometer->has_alpha(gr, dc->render_op))
dst->flags |= RGBA_IMAGE_HAS_ALPHA;
}
else if ((dc->render_op == _EVAS_RENDER_BLEND) &&
!gr->type.geometer->has_alpha(gr, dc->render_op))
{
direct_copy = 1; buf_step = dst->image->w;
direct_copy = 1; buf_step = dst->cache_entry.w;
}
}
if (!direct_copy)
@ -514,13 +514,13 @@ evas_common_gradient_draw(RGBA_Image *dst, RGBA_Draw_Context *dc,
map = gr->map.data;
len = gr->map.len;
pdst = dst->image->data + (y * dst->image->w) + x;
dst_end = pdst + (h * dst->image->w);
pdst = dst->image.data + (y * dst->cache_entry.w) + x;
dst_end = pdst + (h * dst->cache_entry.w);
if (!direct_copy)
{
buf = argb_buf->image->data;
buf = argb_buf->image.data;
if (alpha_buf)
mask = (DATA8 *)alpha_buf->image->data;
mask = (DATA8 *)alpha_buf->image.data;
}
else
buf = pdst;
@ -536,7 +536,7 @@ evas_common_gradient_draw(RGBA_Image *dst, RGBA_Draw_Context *dc,
evas_common_cpu_end_opt();
}
buf += buf_step;
pdst += dst->image->w;
pdst += dst->cache_entry.w;
yoff++;
}

View File

@ -3,16 +3,18 @@
#include <assert.h>
EAPI int
evas_common_image_from_data(RGBA_Image* dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
int
evas_common_rgba_image_from_data(Image_Entry* ie_dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
RGBA_Image *dst = (RGBA_Image *) ie_dst;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
dst->image->w = w;
dst->image->h = h;
dst->image->data = image_data;
dst->image->no_free = 1;
dst->cache_entry.w = w;
dst->cache_entry.h = h;
dst->image.data = image_data;
dst->image.no_free = 1;
if (alpha)
dst->flags |= RGBA_IMAGE_HAS_ALPHA;
else
@ -21,9 +23,8 @@ evas_common_image_from_data(RGBA_Image* dst, int w, int h, DATA32 *image_data, i
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
w &= ~0x1;
dst->image->w = w;
dst->image->h = h;
evas_common_image_surface_alloc(dst->image);
dst->cache_entry.w = w;
dst->cache_entry.h = h;
dst->cs.data = image_data;
dst->cs.no_free = 1;
break;
@ -31,14 +32,17 @@ evas_common_image_from_data(RGBA_Image* dst, int w, int h, DATA32 *image_data, i
abort();
break;
}
dst->cs.space = cspace;
dst->cache_entry.space = cspace;
evas_common_image_colorspace_dirty(dst);
return 0;
}
EAPI int
evas_common_image_from_copied_data(RGBA_Image* dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
int
evas_common_rgba_image_from_copied_data(Image_Entry* ie_dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
RGBA_Image *dst = (RGBA_Image *) ie_dst;
/* FIXME: Is dst->image.data valid. */
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
@ -47,46 +51,49 @@ evas_common_image_from_copied_data(RGBA_Image* dst, int w, int h, DATA32 *image_
else
dst->flags &= ~RGBA_IMAGE_HAS_ALPHA;
if (image_data)
memcpy(dst->image->data, image_data, w * h * sizeof(DATA32));
memcpy(dst->image.data, image_data, w * h * sizeof(DATA32));
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
dst->cs.data = calloc(1, dst->image->h * sizeof(unsigned char*) * 2);
dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char*) * 2);
if (image_data && (dst->cs.data))
memcpy(dst->cs.data, image_data, dst->image->h * sizeof(unsigned char*) * 2);
memcpy(dst->cs.data, image_data, dst->cache_entry.h * sizeof(unsigned char*) * 2);
break;
default:
abort();
break;
}
dst->cs.space = cspace;
dst->cache_entry.space = cspace;
evas_common_image_colorspace_dirty(dst);
return 0;
}
EAPI int
evas_common_image_size_set(RGBA_Image* dst, const RGBA_Image* im, int w, int h)
int
evas_common_rgba_image_size_set(Image_Entry *ie_dst, const Image_Entry *ie_im, int w, int h)
{
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
RGBA_Image *dst = (RGBA_Image *) ie_dst;
RGBA_Image *im = (RGBA_Image *) ie_im;
if ((im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P709_PL))
w &= ~0x1;
dst->cs.space = im->cs.space;
dst->flags = im->flags;
dst->cs.no_free = 0;
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
dst->cs.data = calloc(1, dst->image->h * sizeof(unsigned char *) * 2);
evas_common_image_surface_alloc(dst->image);
if ((im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P709_PL))
dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
evas_common_image_colorspace_dirty(dst);
return 0;
}
EAPI int
evas_common_image_colorspace_set(RGBA_Image* dst, int cspace)
int
evas_common_rgba_image_colorspace_set(Image_Entry* ie_dst, int cspace)
{
RGBA_Image *dst = (RGBA_Image *) ie_dst;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
@ -99,24 +106,24 @@ evas_common_image_colorspace_set(RGBA_Image* dst, int cspace)
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
if (dst->image->no_free)
if (dst->image.no_free)
{
dst->image->data = NULL;
dst->image->no_free = 0;
evas_common_image_surface_alloc(dst->image);
dst->image.data = NULL;
dst->image.no_free = 0;
/* FIXME: Must allocate image.data surface cleanly. */
}
if (dst->cs.data)
{
if (!dst->cs.no_free) free(dst->cs.data);
}
dst->cs.data = calloc(1, dst->image->h * sizeof(unsigned char *) * 2);
dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
dst->cs.no_free = 0;
break;
default:
abort();
break;
}
dst->cs.space = cspace;
dst->cache_entry.space = cspace;
evas_common_image_colorspace_dirty(dst);
return 0;

View File

@ -29,17 +29,18 @@ static struct ext_loader_s loaders[] = {
{ "pnm", "pmaps" }
};
EAPI int
evas_common_load_image_module_from_file(RGBA_Image *im)
int
evas_common_load_rgba_image_module_from_file(Image_Entry *ie)
{
Evas_Image_Load_Func *evas_image_load_func = NULL;
RGBA_Image *im = (RGBA_Image *) ie;
const char *loader = NULL;
char *dot;
Evas_List *l;
Evas_Module *em;
int i;
char *dot;
int i;
dot = strrchr (im->info.file, '.');
dot = strrchr (ie->file, '.');
if (dot)
{
for (i = 0, ++dot; i < (sizeof (loaders) / sizeof (struct ext_loader_s)); ++i)
@ -61,7 +62,7 @@ evas_common_load_image_module_from_file(RGBA_Image *im)
{
evas_module_use(em);
evas_image_load_func = em->functions;
if (evas_image_load_func->file_head(im, im->info.file, im->info.key))
if (evas_image_load_func->file_head(im, ie->file, ie->key))
goto ok;
}
}
@ -74,7 +75,7 @@ evas_common_load_image_module_from_file(RGBA_Image *im)
if (!evas_module_load(em)) continue;
evas_image_load_func = em->functions;
evas_module_use(em);
if (evas_image_load_func->file_head(im, im->info.file, im->info.key))
if (evas_image_load_func->file_head(im, ie->file, ie->key))
{
if (evas_modules != l)
{
@ -87,39 +88,28 @@ evas_common_load_image_module_from_file(RGBA_Image *im)
return -1;
ok:
im->info.module = (void *)em;
im->info.loader = (void *)evas_image_load_func;
evas_module_ref((Evas_Module *)im->info.module);
im->info.module = (void*) em;
im->info.loader = (void*) evas_image_load_func;
evas_module_ref((Evas_Module*) im->info.module);
return 0;
}
EAPI void
evas_common_load_image_data_from_file(RGBA_Image *im)
int
evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
{
Evas_Image_Load_Func *evas_image_load_func = NULL;
RGBA_Image *im = (RGBA_Image *) ie;
if ((im->flags & RGBA_IMAGE_LOADED) == RGBA_IMAGE_LOADED) return;
if (!im->info.module) return;
if (!im->info.module) return -1;
if (ie->flags.loaded) return -1;
evas_image_load_func = im->info.loader;
evas_module_use((Evas_Module *)im->info.module);
if (!evas_image_load_func->file_data(im, im->info.file, im->info.key))
{
if (!im->image->data) evas_common_image_surface_alloc(im->image);
if (!im->image->data)
{
const DATA32 pixel = 0xffffffff;
evas_module_use((Evas_Module*) im->info.module);
if (!evas_image_load_func->file_data(im, ie->file, ie->key))
return -1;
im->image->w = 1;
im->image->h = 1;
im->image->data = (DATA32 *)&pixel;
im->image->no_free = 1;
}
}
else
{
evas_module_unref((Evas_Module *)im->info.module);
im->info.module = NULL;
}
im->flags |= RGBA_IMAGE_LOADED;
evas_module_unref((Evas_Module*) im->info.module);
im->info.module = NULL;
return 0;
}

View File

@ -26,28 +26,47 @@ static int reference = 0;
#define EVAS_ALPHA_LINE_BUFFER_MIN_LEN 256
#define EVAS_ALPHA_LINE_BUFFER_MAX_LEN 2048
/* The cache is doing the allocation and deallocation, you must just do the rest. */
static void _evas_common_image_unload(RGBA_Image* im);
static void _evas_common_image_dirty_region(RGBA_Image* im, int x, int y, int w, int h);
static Image_Entry *_evas_common_rgba_image_new(void);
static void _evas_common_rgba_image_delete(Image_Entry *ie);
static int _evas_common_rgba_image_surface_alloc(Image_Entry *ie, int w, int h);
static void _evas_common_rgba_image_surface_delete(Image_Entry *ie);
static void _evas_common_rgba_image_unload(Image_Entry *im);
static void _evas_common_rgba_image_dirty_region(Image_Entry *im, int x, int y, int w, int h);
static int _evas_common_rgba_image_ram_usage(Image_Entry *ie);
/* 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. */
static int _evas_common_image_dirty(RGBA_Image* dst, const RGBA_Image* src);
static int _evas_common_rgba_image_dirty(Image_Entry* dst, const Image_Entry* src);
static void
_evas_common_rgba_image_debug(const char* context, Image_Entry *eim)
{
fprintf(stderr, "%p = [%s] {%s,%s} %i [%i|%i]\n", eim, context, eim->file, eim->key, eim->references, eim->w, eim->h);
}
static const Evas_Cache_Image_Func _evas_common_image_func =
{
evas_common_load_image_module_from_file,
_evas_common_image_unload,
_evas_common_image_dirty_region,
_evas_common_image_dirty,
evas_common_image_size_set,
evas_common_image_from_copied_data,
evas_common_image_from_data,
evas_common_image_colorspace_set,
evas_common_load_image_data_from_file,
evas_common_image_ram_usage,
NULL
_evas_common_rgba_image_new,
_evas_common_rgba_image_delete,
_evas_common_rgba_image_surface_alloc,
_evas_common_rgba_image_surface_delete,
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
};
EAPI void
@ -91,36 +110,24 @@ evas_common_image_shutdown(void)
#endif
}
static void
_evas_common_image_unload(RGBA_Image* im)
static Image_Entry *
_evas_common_rgba_image_new(void)
{
RGBA_Image *im;
im = calloc(1, sizeof(RGBA_Image));
if (!im) return NULL;
im->flags = RGBA_IMAGE_NOTHING;
im->ref = 1;
return &im->cache_entry;
}
static void
_evas_common_image_dirty_region(RGBA_Image* im, int x, int y, int w, int h)
_evas_common_rgba_image_delete(Image_Entry *ie)
{
}
RGBA_Image *im = (RGBA_Image *) ie;
void
evas_common_image_delete(RGBA_Image* im)
{
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;
evas_common_pipe_free(im);
if (im->image) evas_common_image_surface_free(im->image);
if (im->info.file) evas_stringshare_del(im->info.file);
if (im->info.key) evas_stringshare_del(im->info.key);
if (im->info.module) evas_module_unref((Evas_Module *)im->info.module);
/* 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
@ -132,20 +139,97 @@ evas_common_image_delete(RGBA_Image* im)
free(im);
}
static int
_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->flags & RGBA_IMAGE_ALPHA_ONLY)
siz = w * h * sizeof(DATA8);
else
siz = w * h * sizeof(DATA32);
im->image.data = realloc(im->image.data, siz);
if (im->image.data == NULL) return -1;
#ifdef HAVE_VALGRIND
VALGRIND_MAKE_READABLE(im->image.data, siz);
#endif
return 0;
}
static void
_evas_common_rgba_image_surface_delete(Image_Entry *ie)
{
RGBA_Image *im = (RGBA_Image *) ie;
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;
if (im->image.data && !im->image.no_free)
free(im->image.data);
im->image.data = NULL;
im->image.no_free = 1;
}
static void
_evas_common_rgba_image_unload(Image_Entry* im)
{
}
static void
_evas_common_rgba_image_dirty_region(Image_Entry* im, int x, int y, int w, int h)
{
}
/* Only called when references > 0. Need to provide a fresh copie of im. */
static int
_evas_common_image_dirty(RGBA_Image* dst, const RGBA_Image* src)
_evas_common_rgba_image_dirty(Image_Entry *ie_dst, const Image_Entry *ie_src)
{
evas_common_load_image_data_from_file(src);
RGBA_Image *dst = (RGBA_Image *) ie_dst;
RGBA_Image *src = (RGBA_Image *) ie_src;
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))
return 1;
evas_common_image_colorspace_normalize(src);
evas_common_image_colorspace_normalize(dst);
evas_common_image_surface_alloc(dst->image);
evas_common_blit_rectangle(src, dst, 0, 0, src->image->w, src->image->h, 0, 0);
evas_common_cpu_end_opt();
/* 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;
}
static int
_evas_common_rgba_image_ram_usage(Image_Entry *ie)
{
RGBA_Image *im = (RGBA_Image *) ie;
// ram += sizeof(struct _RGBA_Image);
// if (im->info.real_file) ram += strlen(im->info.real_file);
// if (im->info.comment) ram += strlen(im->info.comment);
if ((im->image.data) && (!im->image.no_free))
return im->cache_entry.w * im->cache_entry.h * sizeof(DATA32);
return 0;
}
#if 0
void
evas_common_image_surface_alpha_tiles_calc(RGBA_Surface *is, int tsize)
@ -212,138 +296,73 @@ evas_common_image_surface_alpha_tiles_calc(RGBA_Surface *is, int tsize)
}
#endif
EAPI RGBA_Surface *
evas_common_image_surface_new(RGBA_Image *im)
{
RGBA_Surface *is;
/* EAPI void */
/* evas_common_image_surface_dealloc(RGBA_Surface *is) */
/* { */
/* if ((is->data) && (!is->no_free)) */
/* { */
/* free(is->data); */
/* is->data = NULL; */
/* } */
/* } */
is = calloc(1, sizeof(RGBA_Surface));
is->im = im;
return is;
}
EAPI void
evas_common_image_surface_free(RGBA_Surface *is)
{
evas_common_image_surface_dealloc(is);
free(is);
}
EAPI void
evas_common_image_surface_alloc(RGBA_Surface *is)
{
size_t siz = 0;
if (is->data) return ;
if (is->im->flags & RGBA_IMAGE_ALPHA_ONLY)
siz = is->w * is->h * sizeof(DATA8);
else
siz = is->w * is->h * sizeof(DATA32);
is->data = malloc(siz);
#ifdef HAVE_VALGRIND
VALGRIND_MAKE_READABLE(is->data, siz);
#endif
}
EAPI void
evas_common_image_surface_dealloc(RGBA_Surface *is)
{
if ((is->data) && (!is->no_free))
{
free(is->data);
is->data = NULL;
}
}
EAPI RGBA_Image *
static RGBA_Image *
evas_common_image_create(int w, int h)
{
RGBA_Image *im;
im = evas_common_image_new();
im = (RGBA_Image *) _evas_common_rgba_image_new();
if (!im) return NULL;
im->image = evas_common_image_surface_new(im);
if (!im->image)
im->cache_entry.w = w;
im->cache_entry.h = h;
if (_evas_common_rgba_image_surface_alloc(&im->cache_entry, w, h))
{
evas_common_image_delete(im);
return NULL;
_evas_common_rgba_image_delete(&im->cache_entry);
return NULL;
}
im->image->w = w;
im->image->h = h;
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
{
evas_common_image_delete(im);
return NULL;
}
im->flags = RGBA_IMAGE_IS_DIRTY;
im->references = 1;
im->cache_entry.flags.cached = 0;
return im;
}
EAPI RGBA_Image *
evas_common_image_alpha_create(int w, int h)
{
RGBA_Image *im;
RGBA_Image *im;
im = evas_common_image_new();
im = (RGBA_Image *) _evas_common_rgba_image_new();
if (!im) return NULL;
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
evas_common_image_delete(im);
return NULL;
}
im->image->w = w;
im->image->h = h;
im->cache_entry.w = w;
im->cache_entry.h = h;
im->flags |= RGBA_IMAGE_ALPHA_ONLY;
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
if (_evas_common_rgba_image_surface_alloc(&im->cache_entry, w, h))
{
evas_common_image_delete(im);
return NULL;
_evas_common_rgba_image_delete(&im->cache_entry);
return NULL;
}
im->flags = RGBA_IMAGE_IS_DIRTY;
im->references = 1;
im->cache_entry.flags.cached = 0;
return im;
}
EAPI RGBA_Image *
evas_common_image_new(void)
{
RGBA_Image *im;
im = calloc(1, sizeof(RGBA_Image));
if (!im) return NULL;
im->flags = RGBA_IMAGE_NOTHING;
im->ref = 1;
im->cs.space = EVAS_COLORSPACE_ARGB8888;
return im;
}
EAPI void
void
evas_common_image_colorspace_normalize(RGBA_Image *im)
{
if ((!im->cs.data) ||
((!im->cs.dirty) && (!(im->flags & RGBA_IMAGE_IS_DIRTY)))) return;
switch (im->cs.space)
switch (im->cache_entry.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (im->image->data != im->cs.data)
if (im->image.data != im->cs.data)
{
if (!im->image->no_free) free(im->image->data);
im->image->data = im->cs.data;
im->cs.no_free = im->image->no_free;
if (!im->image.no_free) free(im->image.data);
im->image.data = im->cs.data;
im->cs.no_free = im->image.no_free;
}
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
#ifdef BUILD_CONVERT_YUV
if ((im->image->data) && (*((unsigned char **)im->cs.data)))
evas_common_convert_yuv_420p_601_rgba(im->cs.data, (DATA8*) im->image->data,
im->image->w, im->image->h);
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);
#endif
break;
default:
@ -374,25 +393,10 @@ evas_common_image_get_cache(void)
EAPI RGBA_Image *
evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_Loadopts *lo)
{
int error;
int error;
if (file == NULL) return NULL;
return evas_cache_image_request(eci, file, key, lo, &error);
}
EAPI int
evas_common_image_ram_usage(RGBA_Image *im)
{
int ram = 0;
// ram += sizeof(struct _RGBA_Image);
// if (im->info.file) ram += strlen(im->info.file);
// if (im->info.real_file) ram += strlen(im->info.real_file);
// if (im->info.key) ram += strlen(im->info.key);
// if (im->info.comment) ram += strlen(im->info.comment);
if ((im->image) && (im->image->data) && (!im->image->no_free))
ram += im->image->w * im->image->h * sizeof(DATA32);
return ram;
return (RGBA_Image *) evas_cache_image_request(eci, file, key, lo, &error);
}
EAPI void
@ -438,7 +442,7 @@ evas_common_image_line_buffer_obtain(int len)
EAPI void
evas_common_image_line_buffer_release(RGBA_Image *im)
{
evas_common_image_delete(im);
_evas_common_rgba_image_delete(&im->cache_entry);;
/*
if (!evas_rgba_line_buffer) return;
if (EVAS_RGBA_LINE_BUFFER_MAX_LEN < evas_rgba_line_buffer->image->w)
@ -458,7 +462,7 @@ evas_common_image_line_buffer_release(RGBA_Image *im)
EAPI void
evas_common_image_line_buffer_free(RGBA_Image *im)
{
evas_common_image_delete(im);
_evas_common_rgba_image_delete(&im->cache_entry);;
/*
if (!evas_rgba_line_buffer) return;
evas_common_image_free(evas_rgba_line_buffer);
@ -496,7 +500,7 @@ evas_common_image_alpha_line_buffer_obtain(int len)
EAPI void
evas_common_image_alpha_line_buffer_release(RGBA_Image *im)
{
evas_common_image_delete(im);
_evas_common_rgba_image_delete(&im->cache_entry);;
/*
if (!evas_alpha_line_buffer) return;
if (EVAS_ALPHA_LINE_BUFFER_MAX_LEN < evas_alpha_line_buffer->image->w)
@ -519,11 +523,11 @@ evas_common_image_premul(RGBA_Image *im)
DATA32 *s, *se;
DATA32 nas = 0;
if (!im || !im->image || !im->image->data) return;
if (!im || !im->image.data) return;
if (!(im->flags & RGBA_IMAGE_HAS_ALPHA)) return;
s = im->image->data;
se = s + (im->image->w * im->image->h);
s = im->image.data;
se = s + (im->cache_entry.w * im->cache_entry.h);
while (s < se)
{
DATA32 a = 1 + (*s >> 24);
@ -534,7 +538,7 @@ evas_common_image_premul(RGBA_Image *im)
if ((a == 1) || (a == 256))
nas++;
}
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->image->w * im->image->h))
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->cache_entry.w * im->cache_entry.h))
im->flags |= RGBA_IMAGE_ALPHA_SPARSE;
}
@ -544,11 +548,11 @@ evas_common_image_set_alpha_sparse(RGBA_Image *im)
DATA32 *s, *se;
DATA32 nas = 0;
if (!im || !im->image || !im->image->data) return;
if (!im || !im->image.data) return;
if (!(im->flags & RGBA_IMAGE_HAS_ALPHA)) return;
s = im->image->data;
se = s + (im->image->w * im->image->h);
s = im->image.data;
se = s + (im->cache_entry.w * im->cache_entry.h);
while (s < se)
{
DATA32 p = *s & 0xff000000;
@ -557,6 +561,6 @@ evas_common_image_set_alpha_sparse(RGBA_Image *im)
nas++;
s++;
}
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->image->w * im->image->h))
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->cache_entry.w * im->cache_entry.h))
im->flags |= RGBA_IMAGE_ALPHA_SPARSE;
}

View File

@ -52,8 +52,8 @@ evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, in
}
clx = cly = 0;
clw = dst->image->w;
clh = dst->image->h;
clw = dst->cache_entry.w;
clh = dst->cache_entry.h;
/* save out clip info */
cuse = dc->clip.use;
@ -104,13 +104,13 @@ _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y)
{
RGBA_Gfx_Pt_Func pfunc;
if (!IN_RANGE(x, y, dst->image->w, dst->image->h))
if (!IN_RANGE(x, y, dst->cache_entry.w, dst->cache_entry.h))
return;
if ((dc->clip.use) && (!IN_RECT(x, y, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h)))
return;
pfunc = evas_common_gfx_func_composite_color_pt_get(dc->col.col, dst, dc->render_op);
if (pfunc)
pfunc(0, 255, dc->col.col, dst->image->data + (dst->image->w * y) + x);
pfunc(0, 255, dc->col.col, dst->image.data + (dst->cache_entry.w * y) + x);
}
/*
@ -129,7 +129,7 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
RGBA_Gfx_Pt_Func pfunc;
RGBA_Gfx_Func sfunc;
dstw = dst->image->w;
dstw = dst->cache_entry.w;
color = dc->col.col;
if (y0 > y1)
@ -170,7 +170,7 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
if (x1 > rx) x1 = rx;
len = x1 - x0 + 1;
p = dst->image->data + (dstw * y0) + x0;
p = dst->image.data + (dstw * y0) + x0;
sfunc = evas_common_gfx_func_composite_color_span_get(color, dst, len, dc->render_op);
if (sfunc)
sfunc(NULL, NULL, color, p, len);
@ -190,7 +190,7 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
if (y1 > by) y1 = by;
len = y1 - y0 + 1;
p = dst->image->data + (dstw * y0) + x0;
p = dst->image.data + (dstw * y0) + x0;
while (len--)
{
#ifdef EVAS_SLI
@ -268,7 +268,7 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
}
if (y1 > y0)
{
p = dst->image->data + (dstw * y0) + x0;
p = dst->image.data + (dstw * y0) + x0;
len = y1 - y0 + 1;
if (dx > 0) dstw++;
else dstw--;
@ -276,7 +276,7 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
else
{
len = y0 - y1 + 1;
p = dst->image->data + (dstw * y1) + x1;
p = dst->image.data + (dstw * y1) + x1;
if (dx > 0) dstw--;
else dstw++;
}
@ -472,8 +472,8 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
clw = dc->clip.w;
clh = dc->clip.h;
data = dst->image->data;
dstw = dst->image->w;
data = dst->image.data;
dstw = dst->cache_entry.w;
data += (dstw * cly) + clx;
x0 -= clx;
@ -579,8 +579,8 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
clw = dc->clip.w;
clh = dc->clip.h;
data = dst->image->data;
dstw = dst->image->w;
data = dst->image.data;
dstw = dst->cache_entry.w;
data += (dstw * cly) + clx;
x0 -= clx;

View File

@ -139,26 +139,26 @@ evas_common_pipe_begin(RGBA_Image *im)
}
}
y = 0;
h = im->image->h / thread_num;
h = im->cache_entry.h / thread_num;
if (h < 1) h = 1;
for (i = 0; i < thread_num; i++)
{
RGBA_Pipe_Thread_Info *info;
// if (y >= im->image->h) break;
// if (y >= im->cache_entry.h) break;
info = calloc(1, sizeof(RGBA_Pipe_Thread_Info));
info->im = im;
#ifdef EVAS_SLI
info->x = 0;
info->w = im->image->w;
info->w = im->cache_entry.w;
info->y = i;
info->h = thread_num;
#else
info->x = 0;
info->y = y;
info->w = im->image->w;
info->w = im->cache_entry.w;
if (i == (thread_num - 1))
info->h = im->image->h - y;
info->h = im->cache_entry.h - y;
else
info->h = h;
y += info->h;
@ -485,7 +485,7 @@ evas_common_pipe_op_image_free(RGBA_Pipe_Op *op)
{
op->op.image.src->ref--;
if (op->op.image.src->ref == 0)
evas_cache_image_drop(op->op.image.src);
evas_cache_image_drop(&op->op.image.src->cache_entry);
evas_common_pipe_op_free(op);
}

View File

@ -134,8 +134,8 @@ evas_common_polygon_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Polygon_Po
ext_x = 0;
ext_y = 0;
ext_w = dst->image->w;
ext_h = dst->image->h;
ext_w = dst->cache_entry.w;
ext_h = dst->cache_entry.h;
if (dc->clip.use)
{
if (dc->clip.x > ext_x)
@ -280,7 +280,7 @@ evas_common_polygon_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Polygon_Po
if (((span->y) % dc->sli.h) == dc->sli.y)
#endif
{
ptr = dst->image->data + (span->y * (dst->image->w)) + span->x;
ptr = dst->image.data + (span->y * (dst->cache_entry.w)) + span->x;
func(NULL, NULL, dc->col.col, ptr, span->w);
}
}

View File

@ -17,11 +17,11 @@ evas_common_rectangle_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
/* handle cutouts here! */
if ((w <= 0) || (h <= 0)) return;
if (!(RECTS_INTERSECT(x, y, w, h, 0, 0, dst->image->w, dst->image->h)))
if (!(RECTS_INTERSECT(x, y, w, h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
/* save out clip info */
c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
evas_common_draw_context_clip_clip(dc, 0, 0, dst->image->w, dst->image->h);
evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
/* no cutouts - cut right to the chase */
if (!dc->cutout.rects)
{
@ -58,7 +58,7 @@ rectangle_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, in
if ((w <= 0) || (h <= 0)) return;
func = evas_common_gfx_func_composite_color_span_get(dc->col.col, dst, w, dc->render_op);
ptr = dst->image->data + (y * dst->image->w) + x;
ptr = dst->image.data + (y * dst->cache_entry.w) + x;
for (yy = 0; yy < h; yy++)
{
#ifdef EVAS_SLI
@ -67,6 +67,6 @@ rectangle_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, in
{
func(NULL, NULL, dc->col.col, ptr, w);
}
ptr += dst->image->w;
ptr += dst->cache_entry.w;
}
}

View File

@ -37,7 +37,7 @@ evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst,
/* handle cutouts here! */
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->image->w, dst->image->h)))
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
/* no cutouts - cut right to the chase */
if (!dc->cutout.rects)
@ -51,7 +51,7 @@ evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst,
}
/* save out clip info */
c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
evas_common_draw_context_clip_clip(dc, 0, 0, dst->image->w, dst->image->h);
evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
/* our clip is 0 size.. abort */
if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
@ -94,18 +94,18 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
int src_w, src_h, dst_w, dst_h;
RGBA_Gfx_Func func;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->image->w, dst->image->h)))
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
if (!(RECTS_INTERSECT(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src->image->w, src->image->h)))
if (!(RECTS_INTERSECT(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src->cache_entry.w, src->cache_entry.h)))
return;
src_w = src->image->w;
src_h = src->image->h;
dst_w = dst->image->w;
dst_h = dst->image->h;
src_w = src->cache_entry.w;
src_h = src->cache_entry.h;
dst_w = dst->cache_entry.w;
dst_h = dst->cache_entry.h;
src_data = src->image->data;
dst_data = dst->image->data;
src_data = src->image.data;
dst_data = dst->image.data;
if (dc->clip.use)
{

View File

@ -454,7 +454,7 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
/* handle cutouts here! */
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->image->w, dst->image->h)))
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
# ifdef BUILD_MMX
evas_common_cpu_can_do(&mmx, &sse, &sse2);
@ -482,7 +482,7 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
}
/* save out clip info */
c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
evas_common_draw_context_clip_clip(dc, 0, 0, dst->image->w, dst->image->h);
evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
/* our clip is 0 size.. abort */
if ((dc->clip.w <= 0) || (dc->clip.h <= 0))

View File

@ -11,15 +11,15 @@ SCALE_FUNC(RGBA_Image *src, RGBA_Image *dst,
int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
int src_w, src_h, dst_w, dst_h;
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->image->w, dst->image->h)))
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
if (!(RECTS_INTERSECT(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src->image->w, src->image->h)))
if (!(RECTS_INTERSECT(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src->cache_entry.w, src->cache_entry.h)))
return;
src_w = src->image->w;
src_h = src->image->h;
dst_w = dst->image->w;
dst_h = dst->image->h;
src_w = src->cache_entry.w;
src_h = src->cache_entry.h;
dst_w = dst->cache_entry.w;
dst_h = dst->cache_entry.h;
if (dc->clip.use)
{
@ -141,7 +141,7 @@ SCALE_FUNC(RGBA_Image *src, RGBA_Image *dst,
dst_jump = dst_w - dst_clip_w;
/* figure out dest start ptr */
dst_ptr = dst->image->data + dst_clip_x + (dst_clip_y * dst_w);
dst_ptr = dst->image.data + dst_clip_x + (dst_clip_y * dst_w);
/* FIXME:
*

View File

@ -7,7 +7,7 @@
RGBA_Gfx_Func func;
src_data = src->image->data;
src_data = src->image.data;
xpoints = scale_calc_x_points(src_region_w, dst_region_w);
ypoints = scale_calc_y_points(src_data, src_w, src_region_h, dst_region_h);

View File

@ -5,7 +5,7 @@
int ysli = dst_clip_y;
#endif
ptr = src->image->data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x;
ptr = src->image.data + ((dst_clip_y - dst_region_y + src_region_y) * src_w) + (dst_clip_x - dst_region_x) + src_region_x;
if (dc->mul.use)
func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op);
else

View File

@ -18,10 +18,10 @@
if (!dc->mul.use)
{
if ((dc->render_op == _EVAS_RENDER_BLEND) && !(src->flags & RGBA_IMAGE_HAS_ALPHA))
{ direct_scale = 1; buf_step = dst->image->w; }
{ direct_scale = 1; buf_step = dst->cache_entry.w; }
else if (dc->render_op == _EVAS_RENDER_COPY)
{
direct_scale = 1; buf_step = dst->image->w;
direct_scale = 1; buf_step = dst->cache_entry.w;
if (src->flags & RGBA_IMAGE_HAS_ALPHA)
dst->flags |= RGBA_IMAGE_HAS_ALPHA;
}
@ -61,7 +61,7 @@
#ifdef EVAS_SLI
int ysli = dst_clip_y;
#endif
psrc = src->image->data + (src_w * (sry + cy)) + srx;
psrc = src->image.data + (src_w * (sry + cy)) + srx;
while (pdst < pdst_end)
{
#ifdef EVAS_SLI
@ -117,7 +117,7 @@
}
else if (drw == srw)
{
DATA32 *ps = src->image->data + (src_w * sry) + srx + cx;
DATA32 *ps = src->image.data + (src_w * sry) + srx + cx;
#ifdef EVAS_SLI
int ysli = dst_clip_y;
#endif
@ -176,7 +176,7 @@
}
{
DATA32 *ps = src->image->data + (src_w * sry) + srx;
DATA32 *ps = src->image.data + (src_w * sry) + srx;
int sxx0 = sxx;
#ifdef EVAS_SLI
int ysli = dst_clip_y;

View File

@ -24,7 +24,7 @@ evas_imaging_image_load(const char *file, const char *key)
im = calloc(1, sizeof(Evas_Imaging_Image));
if (!im)
{
evas_cache_image_drop(image);
evas_cache_image_drop(&image->cache_entry);
return NULL;
}
im->image = image;
@ -35,7 +35,7 @@ EAPI void
evas_imaging_image_free(Evas_Imaging_Image *im)
{
if (!im) return;
evas_cache_image_drop(im->image);
evas_cache_image_drop(&im->image->cache_entry);
free(im);
}
@ -43,8 +43,8 @@ EAPI void
evas_imaging_image_size_get(const Evas_Imaging_Image *im, int *w, int *h)
{
if (!im) return;
if (w) *w = im->image->image->w;
if (h) *h = im->image->image->h;
if (w) *w = im->image->cache_entry.w;
if (h) *h = im->image->cache_entry.h;
}
EAPI Evas_Bool

View File

@ -7,4 +7,5 @@ evas_options.h \
evas_macros.h \
evas_mmx.h \
evas_common.h \
evas_common_soft16.h \
evas_blend_ops.h

View File

@ -134,13 +134,14 @@ typedef struct _Evas_Object_List Evas_Object_List;
typedef struct _Evas_Hash_El Evas_Hash_El;
typedef struct _Image_Entry Image_Entry;
typedef struct _Engine_Image_Entry Engine_Image_Entry;
typedef struct _RGBA_Image_Loadopts RGBA_Image_Loadopts;
typedef struct _RGBA_Pipe_Op RGBA_Pipe_Op;
typedef struct _RGBA_Pipe RGBA_Pipe;
typedef struct _RGBA_Pipe_Thread_Info RGBA_Pipe_Thread_Info;
typedef struct _RGBA_Image RGBA_Image;
typedef struct _RGBA_Engine_Image RGBA_Engine_Image;
typedef struct _RGBA_Surface RGBA_Surface;
typedef struct _RGBA_Image_Span RGBA_Image_Span;
typedef struct _RGBA_Draw_Context RGBA_Draw_Context;
typedef struct _RGBA_Gradient RGBA_Gradient;
@ -198,7 +199,8 @@ typedef enum _RGBA_Image_Flags
RGBA_IMAGE_ALPHA_ONLY = (1 << 3),
RGBA_IMAGE_ALPHA_TILES = (1 << 4),
RGBA_IMAGE_ALPHA_SPARSE = (1 << 5),
RGBA_IMAGE_LOADED = (1 << 6)
RGBA_IMAGE_LOADED = (1 << 6),
RGBA_IMAGE_NEED_DATA = (1 << 7)
} RGBA_Image_Flags;
typedef enum _Convert_Pal_Mode
@ -258,6 +260,72 @@ struct _Evas_Hash_El
void *data;
};
struct _RGBA_Image_Loadopts
{
int scale_down_by; // if > 1 then use this
double dpi; // if > 0.0 use this
int w, h; // if > 0 use this
};
struct _Image_Entry
{
Evas_Object_List _list_data;
Evas_Cache_Image *cache;
const char *cache_key;
const char *file;
const char *key;
time_t timestamp;
time_t laststat;
struct
{
unsigned int loaded : 1;
unsigned int dirty : 1;
unsigned int activ : 1;
unsigned int need_data : 1;
unsigned int lru_nodata : 1;
unsigned int cached : 1;
} flags;
int references;
unsigned char scale;
RGBA_Image_Loadopts load_opts;
int space;
int w;
int h;
};
struct _Engine_Image_Entry
{
Evas_Object_List _list_data;
/* Upper Engine data. */
Image_Entry *src;
/* Cache stuff. */
Evas_Cache_Engine_Image *cache;
const char *cache_key;
struct
{
unsigned int cached : 1;
unsigned int activ : 1;
unsigned int dirty : 1;
unsigned int loaded : 1;
unsigned int need_parent : 1;
} flags;
int references;
int w;
int h;
};
struct _Cutout_Rect
{
int x, y, w, h;
@ -302,14 +370,6 @@ struct _RGBA_Draw_Context
unsigned char anti_alias : 1;
};
struct _RGBA_Surface
{
int w, h;
DATA32 *data;
RGBA_Image *im;
char no_free : 1;
};
struct _RGBA_Pipe_Op
{
RGBA_Draw_Context context;
@ -359,72 +419,39 @@ struct _RGBA_Pipe_Thread_Info
int x, y, w, h;
};
struct _RGBA_Image_Loadopts
{
int scale_down_by; // if > 1 then use this
double dpi; // if > 0.0 use this
int w, h; // if > 0 use this
};
struct _RGBA_Image
{
Evas_Object_List _list_data;
RGBA_Surface *image;
Image_Entry cache_entry;
RGBA_Image_Flags flags;
struct
{
void *module;
void *loader;
char *file;
char *real_file;
char *key;
/* char *real_file; */
char *comment;
// int format;
} info;
void *extended_info;
RGBA_Pipe *pipe;
int references;
RGBA_Image_Loadopts load_opts;
unsigned char scale;
int ref;
/* unsigned char scale; */
/* Colorspace stuff. */
time_t timestamp;
time_t laststat;
struct {
void *data;
int space;
unsigned char no_free : 1;
unsigned char dirty : 1;
void *data;
unsigned int no_free : 1;
unsigned int dirty : 1;
} cs;
/* Cache stuff. */
Evas_Cache_Image *cache;
const char *cache_key;
};
struct _RGBA_Engine_Image
{
Evas_Object_List _list_data;
/* Engine specific data. */
void *engine_data;
/* Upper Engine data. */
RGBA_Image *src;
/* Cache stuff. */
int references;
/* RGBA stuff */
struct
{
int dirty : 1;
int loaded : 1;
} flags;
Evas_Cache_Engine_Image *cache;
const char *cache_key;
DATA32 *data;
unsigned int no_free : 1;
} image;
};
struct _RGBA_Gradient_Color_Stop
@ -709,77 +736,93 @@ struct _Convert_Pal
/****/
struct _Evas_Cache_Image_Func
{
/* The cache is doing the allocation and deallocation, you must just do the rest. */
int (*constructor)(RGBA_Image* im);
void (*destructor)(RGBA_Image* im);
Image_Entry *(*alloc)(void);
void (*delete)(Image_Entry *im);
void (*dirty_region)(RGBA_Image* im, int x, int y, int w, int h);
int (*surface_alloc)(Image_Entry *im, int w, int h);
void (*surface_delete)(Image_Entry *im);
/* The cache is doing the allocation and deallocation, you must just do the rest. */
int (*constructor)(Image_Entry *im);
void (*destructor)(Image_Entry *im);
void (*dirty_region)(Image_Entry *im, int x, int y, int w, int h);
/* 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. */
int (*dirty)(RGBA_Image* dst, const RGBA_Image* src);
int (*dirty)(Image_Entry *dst, const Image_Entry *src);
/* Only called when references == 1. We will call drop on `im'. */
/* The destination surface does not have any surface. */
int (*size_set)(RGBA_Image* dst, const RGBA_Image* src, int w, int h);
int (*size_set)(Image_Entry *dst, const Image_Entry *src, int w, int h);
/* The destination surface does not have any surface. */
int (*copied_data)(RGBA_Image* dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
int (*copied_data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
/* The destination surface does not have any surface. */
int (*data)(RGBA_Image* dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
int (*color_space)(RGBA_Image* dst, int cspace);
int (*data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
int (*color_space)(Image_Entry *dst, int cspace);
void (*load)(RGBA_Image* im);
int (*mem_size_get)(RGBA_Image* im);
void (*debug)(const char* context, RGBA_Image* im);
/* This function need to update im->w and im->h. */
int (*load)(Image_Entry *im);
int (*mem_size_get)(Image_Entry *im);
void (*debug)(const char *context, Image_Entry *im);
};
struct _Evas_Cache_Image
{
int usage;
int limit;
int references;
Evas_Cache_Image_Func func;
Evas_Cache_Image_Func func;
Evas_Object_List *dirty;
Evas_Object_List* dirty;
Evas_Object_List *lru;
Evas_Object_List *lru_nodata;
Evas_Hash *inactiv;
Evas_Hash *activ;
Evas_Object_List* lru;
Evas_Hash* inactiv;
Evas_Hash* activ;
int usage;
int limit;
int references;
};
struct _Evas_Cache_Engine_Image_Func
{
/* Must return a char* allocated with evas_stringshare_add. */
char* (*key)(RGBA_Image *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);
char* (*key)(Image_Entry *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);
int (*constructor)(RGBA_Engine_Image*, void* data);
void (*destructor)(RGBA_Engine_Image *eim);
Engine_Image_Entry* (*alloc)(void);
void (*delete)(Engine_Image_Entry *eim);
void (*dirty_region)(RGBA_Engine_Image *eim, int x, int y, int w, int h);
int (*constructor)(Engine_Image_Entry *eim, void* data);
void (*destructor)(Engine_Image_Entry *eim);
void (*dirty_region)(Engine_Image_Entry *eim, int x, int y, int w, int h);
/* Only called when references > 0. Need to provide a fresh copie of im. */
int (*dirty)(RGBA_Engine_Image *dst, const RGBA_Engine_Image *src);
int (*dirty)(Engine_Image_Entry *dst, const Engine_Image_Entry *src);
/* Only called when references == 1. We will call drop on `im'. */
int (*size_set)(RGBA_Engine_Image *dst, const RGBA_Engine_Image *src);
int (*size_set)(Engine_Image_Entry *dst, const Engine_Image_Entry *src);
int (*update_data)(RGBA_Engine_Image* dst, void* data);
int (*update_data)(Engine_Image_Entry* dst, void* data);
void (*load)(RGBA_Engine_Image *eim, const RGBA_Image* im);
int (*mem_size_get)(RGBA_Engine_Image *eim);
void (*debug)(const char* context, RGBA_Engine_Image *eim);
void (*load)(Engine_Image_Entry *eim, const Image_Entry* im);
int (*mem_size_get)(Engine_Image_Entry *eim);
void (*debug)(const char* context, Engine_Image_Entry *eim);
};
struct _Evas_Cache_Engine_Image
{
int usage;
int limit;
Evas_Cache_Engine_Image_Func func;
Evas_Object_List* dirty;
Evas_Hash* activ;
Evas_Hash* inactiv;
Evas_Object_List* lru;
Evas_Cache_Image* parent;
Evas_Cache_Engine_Image* brother;
int usage;
int limit;
int references;
};
/*****************************************************************************/
@ -1020,36 +1063,31 @@ EAPI void evas_common_scale_hsva_a8_span (DATA32 *src, DATA8
/****/
/*done*/
EAPI void evas_common_image_init (void);
EAPI void evas_common_image_shutdown (void);
EAPI void evas_common_image_init (void);
EAPI void evas_common_image_shutdown (void);
/*done - internal - dont use */
EAPI RGBA_Surface *evas_common_image_surface_new (RGBA_Image *im);/*2*/
EAPI void evas_common_image_surface_free (RGBA_Surface *is);/*2*/
EAPI void evas_common_image_surface_alloc (RGBA_Surface *is);/*2*/
EAPI void evas_common_image_surface_dealloc (RGBA_Surface *is);/*2*/
EAPI void evas_common_image_colorspace_normalize(RGBA_Image *im);
int evas_common_load_rgba_image_module_from_file (Image_Entry *im);
int evas_common_load_rgba_image_data_from_file (Image_Entry *im);
int evas_common_rgba_image_size_set (Image_Entry* dst, const Image_Entry* im, int w, int h);
int evas_common_rgba_image_from_copied_data (Image_Entry* dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
int evas_common_rgba_image_from_data (Image_Entry* dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
int evas_common_rgba_image_colorspace_set (Image_Entry* dst, int cspace);
EAPI void evas_common_image_colorspace_normalize (RGBA_Image *im);
EAPI void evas_common_image_colorspace_dirty (RGBA_Image *im);
EAPI void evas_common_image_cache_free (void); /*2*/
EAPI void evas_common_image_premul (RGBA_Image *im); /*2*/
EAPI void evas_common_image_set_alpha_sparse (RGBA_Image *im); /*2*/
EAPI RGBA_Image *evas_common_image_alpha_create (int w, int h);
EAPI RGBA_Image *evas_common_image_create (int w, int h);
/* EAPI RGBA_Image *evas_common_image_alpha_create (int w, int h); */
/* EAPI RGBA_Image *evas_common_image_create (int w, int h); */
EAPI RGBA_Image *evas_common_image_new (void);
EAPI void evas_common_image_delete (RGBA_Image *im);
EAPI Evas_Cache_Image* evas_common_image_cache_get (void);
EAPI int evas_common_load_image_module_from_file (RGBA_Image *im);
EAPI void evas_common_load_image_data_from_file (RGBA_Image *im);
EAPI int evas_common_image_colorspace_set (RGBA_Image* dst, int cspace);
EAPI int evas_common_image_size_set (RGBA_Image* dst, const RGBA_Image* im, int w, int h);
EAPI int evas_common_image_from_copied_data (RGBA_Image* dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
EAPI int evas_common_image_from_data (RGBA_Image* dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
/*done*/
EAPI void evas_common_image_set_cache (int size);
EAPI int evas_common_image_get_cache (void);
EAPI int evas_common_image_ram_usage (RGBA_Image *im);
EAPI RGBA_Image *evas_common_image_line_buffer_obtain (int len);
EAPI void evas_common_image_line_buffer_release (RGBA_Image *im);
@ -1233,44 +1271,48 @@ void evas_stringshare_init(void);
void evas_stringshare_shutdown(void);
/****/
Evas_Cache_Image* evas_cache_image_init(const Evas_Cache_Image_Func* cb);
void evas_cache_image_shutdown(Evas_Cache_Image* cache);
RGBA_Image* evas_cache_image_request(Evas_Cache_Image* cache, const char* file, const char* key, RGBA_Image_Loadopts* lo, int* error);
void evas_cache_image_drop(RGBA_Image* im);
int evas_cache_image_flush(Evas_Cache_Image* cache);
Evas_Cache_Image* evas_cache_image_init(const Evas_Cache_Image_Func *cb);
void evas_cache_image_shutdown(Evas_Cache_Image *cache);
Image_Entry* evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);
void evas_cache_image_drop(Image_Entry *im);
void evas_cache_image_data_not_needed(Image_Entry *im);
int evas_cache_image_flush(Evas_Cache_Image *cache);
int evas_cache_image_usage_get(Evas_Cache_Image* cache);
int evas_cache_image_get(Evas_Cache_Image* cache);
void evas_cache_image_set(Evas_Cache_Image* cache, int size);
int evas_cache_image_usage_get(Evas_Cache_Image *cache);
int evas_cache_image_get(Evas_Cache_Image *cache);
void evas_cache_image_set(Evas_Cache_Image *cache, int size);
RGBA_Image* evas_cache_image_alone(RGBA_Image *im);
RGBA_Image* evas_cache_image_dirty(RGBA_Image* im, int x, int y, int w, int h);
void evas_cache_image_load_data(RGBA_Image* im);
RGBA_Image* evas_cache_image_copied_data(Evas_Cache_Image* cache, int w, int h, DATA32* image_data, int alpha, int cspace);
RGBA_Image* evas_cache_image_data(Evas_Cache_Image* cache, int w, int h, DATA32* image_data, int alpha, int cspace);
void evas_cache_image_colorspace(RGBA_Image* im, int cspace);
RGBA_Image* evas_cache_image_empty(Evas_Cache_Image* cache);
Image_Entry* evas_cache_image_alone(Image_Entry *im);
Image_Entry* evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h);
void evas_cache_image_load_data(Image_Entry *im);
void evas_cache_image_surface_alloc(Image_Entry *im, int w, int h);
Image_Entry* evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
Image_Entry* evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
void evas_cache_image_colorspace(Image_Entry *im, int cspace);
Image_Entry* evas_cache_image_empty(Evas_Cache_Image *cache);
Image_Entry* evas_cache_image_size_set(Image_Entry *im, int w, int h);
RGBA_Image* evas_cache_image_size_set(RGBA_Image* im, int w, int h);
/****/
Evas_Cache_Engine_Image* evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent);
void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image* cache);
void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache);
int evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image* cache);
int evas_cache_engine_image_get(Evas_Cache_Engine_Image* cache);
void evas_cache_engine_image_set(Evas_Cache_Engine_Image* cache, int limit);
void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache);
int evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache);
int evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache);
void evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit);
RGBA_Engine_Image* evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key,
Engine_Image_Entry* evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key,
RGBA_Image_Loadopts *lo, void *engine_data, int *error);
RGBA_Engine_Image* evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data);
void evas_cache_engine_image_drop(RGBA_Engine_Image *eim);
RGBA_Engine_Image* evas_cache_engine_image_dirty(RGBA_Engine_Image *eim, int x, int y, int w, int h);
RGBA_Engine_Image* evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void* engine_data);
RGBA_Engine_Image* evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void* engine_data);
void evas_cache_engine_image_colorspace(RGBA_Engine_Image *eim, int cspace, void* engine_data);
RGBA_Engine_Image* evas_cache_engine_image_size_set(RGBA_Engine_Image *eim, int w, int h);
void evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim);
Engine_Image_Entry* evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data);
void evas_cache_engine_image_drop(Engine_Image_Entry *eim);
Engine_Image_Entry* evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data);
Engine_Image_Entry* evas_cache_engine_image_dirty(Engine_Image_Entry *eim, int x, int y, int w, int h);
Engine_Image_Entry* evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data);
Engine_Image_Entry* evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data);
void evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data);
Engine_Image_Entry* evas_cache_engine_image_size_set(Engine_Image_Entry *eim, int w, int h);
void evas_cache_engine_image_load_data(RGBA_Engine_Image *eim);
void evas_cache_engine_image_load_data(Engine_Image_Entry *eim);
/*****************************************************************************/

View File

@ -22,4 +22,6 @@ glitz_x11 \
software_16 \
software_16_x11 \
direct3d \
software_16_ddraw
software_16_ddraw \
software_16_sdl

View File

@ -19,15 +19,15 @@ enum _Outbuf_Depth
struct _Outbuf
{
int w, h;
Outbuf_Depth depth;
int w, h;
Outbuf_Depth depth;
void *dest;
int dest_row_bytes;
void *dest;
int dest_row_bytes;
int alpha_level;
DATA32 color_key;
char use_color_key : 1;
int alpha_level;
DATA32 color_key;
char use_color_key : 1;
struct {
void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes);
@ -35,7 +35,7 @@ struct _Outbuf
} func;
struct {
RGBA_Image *back_buf;
RGBA_Image *back_buf;
} priv;
};

View File

@ -12,7 +12,7 @@ evas_buffer_outbuf_buf_free(Outbuf *buf)
{
if (buf->priv.back_buf)
{
evas_common_image_delete(buf->priv.back_buf);
evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
}
free(buf);
}
@ -48,29 +48,25 @@ evas_buffer_outbuf_buf_setup_fb(int w, int h, Outbuf_Depth depth, void *dest, in
if ((buf->depth == OUTBUF_DEPTH_RGB_24BPP_888_888) ||
(buf->depth == OUTBUF_DEPTH_BGR_24BPP_888_888))
bpp = 3;
if ((buf->depth == OUTBUF_DEPTH_ARGB_32BPP_8888_8888) &&
(buf->dest) && (buf->dest_row_bytes == (buf->w * sizeof(DATA32))))
{
for (y = 0; y < h; y++)
memset(((unsigned char *)(buf->dest)) + (y * buf->dest_row_bytes),
0, w * bpp);
buf->priv.back_buf = evas_common_image_new();
buf->priv.back_buf->image = evas_common_image_surface_new(buf->priv.back_buf);
buf->priv.back_buf->image->w = w;
buf->priv.back_buf->image->h = h;
buf->priv.back_buf->image->data = buf->dest;
buf->priv.back_buf->image->no_free = 1;
buf->priv.back_buf->flags |= RGBA_IMAGE_HAS_ALPHA;
buf->priv.back_buf = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
w, h,
buf->dest,
1, EVAS_COLORSPACE_ARGB8888);
}
else if ((buf->depth == OUTBUF_DEPTH_RGB_32BPP_888_8888) &&
(buf->dest) && (buf->dest_row_bytes == (buf->w * sizeof(DATA32))))
{
buf->priv.back_buf = evas_common_image_new();
buf->priv.back_buf->image = evas_common_image_surface_new(buf->priv.back_buf);
buf->priv.back_buf->image->w = w;
buf->priv.back_buf->image->h = h;
buf->priv.back_buf->image->data = buf->dest;
buf->priv.back_buf->image->no_free = 1;
buf->priv.back_buf = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
w, h,
buf->dest,
0, EVAS_COLORSPACE_ARGB8888);
}
return buf;
@ -88,13 +84,13 @@ evas_buffer_outbuf_buf_new_region_for_update(Outbuf *buf, int x, int y, int w, i
if (buf->priv.back_buf->flags & RGBA_IMAGE_HAS_ALPHA)
{
int ww = w;
ptr = buf->priv.back_buf->image->data + (y * buf->priv.back_buf->image->w) + x;
ptr = buf->priv.back_buf->image.data + (y * buf->priv.back_buf->cache_entry.w) + x;
while (h--)
{
while (w--)
*ptr++ = 0;
w = ww;
ptr += (buf->priv.back_buf->image->w - w);
ptr += (buf->priv.back_buf->cache_entry.w - w);
}
}
return buf->priv.back_buf;
@ -102,16 +98,20 @@ evas_buffer_outbuf_buf_new_region_for_update(Outbuf *buf, int x, int y, int w, i
else
{
*cx = 0; *cy = 0; *cw = w; *ch = h;
im = evas_common_image_create(w, h);
if (im)
{
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
if (im)
{
if (((buf->depth == OUTBUF_DEPTH_ARGB_32BPP_8888_8888)) ||
((buf->depth == OUTBUF_DEPTH_BGRA_32BPP_8888_8888)))
{
im->flags |= RGBA_IMAGE_HAS_ALPHA;
memset(im->image->data, 0, w * h * sizeof(DATA32));
}
}
im = (RGBA_Image *) evas_cache_image_size_set(&im->cache_entry, w, h);
if (im)
{
memset(im->image.data, 0, w * h * sizeof(DATA32));
}
}
}
}
return im;
}
@ -119,7 +119,7 @@ evas_buffer_outbuf_buf_new_region_for_update(Outbuf *buf, int x, int y, int w, i
void
evas_buffer_outbuf_buf_free_region_for_update(Outbuf *buf, RGBA_Image *update)
{
if (update != buf->priv.back_buf) evas_common_image_delete(update);
if (update != buf->priv.back_buf) evas_cache_image_drop(&update->cache_entry);
}
void
@ -153,7 +153,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
for (yy = 0; yy < h; yy++)
{
dst = dest + (yy * row_bytes);
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
for (xx = 0; xx < w; xx++)
{
if (A_VAL(src) > thresh)
@ -177,7 +177,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
for (yy = 0; yy < h; yy++)
{
dst = dest + (yy * row_bytes);
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
for (xx = 0; xx < w; xx++)
{
*dst++ = R_VAL(src);
@ -218,7 +218,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
for (yy = 0; yy < h; yy++)
{
dst = dest + (yy * row_bytes);
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
for (xx = 0; xx < w; xx++)
{
if (A_VAL(src) > thresh)
@ -242,7 +242,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
for (yy = 0; yy < h; yy++)
{
dst = dest + (yy * row_bytes);
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
for (xx = 0; xx < w; xx++)
{
*dst++ = B_VAL(src);
@ -280,7 +280,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
{
for (yy = 0; yy < h; yy++)
{
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
dst = (DATA8 *)(buf->dest) + ((y + yy) * row_bytes);
func(src, dst, w);
}
@ -308,7 +308,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
for (yy = 0; yy < h; yy++)
{
dst = dest + (yy * row_bytes);
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
for (xx = 0; xx < w; xx++)
{
A_VAL(dst) = B_VAL(src);
@ -339,7 +339,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
for (yy = 0; yy < h; yy++)
{
dst = dest + (yy * row_bytes);
src = update->image->data + (yy * update->image->w);
src = update->image.data + (yy * update->cache_entry.w);
for (xx = 0; xx < w; xx++)
{
A_VAL(dst) = B_VAL(src);

View File

@ -133,10 +133,8 @@ evas_direct3d_outbuf_new_region_for_update(Outbuf *buf,
}
else
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = width;
im->image->h = height;
evas_common_image_surface_alloc(im->image);
im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
evas_cache_image_surface_alloc(&im->cache_entry, width, height);
im->extended_info = d3dob;
if ((buf->rot == 0) || (buf->rot == 180))
d3dob = evas_direct3d_output_buffer_new(buf->priv.d3d.depth,

View File

@ -14,7 +14,7 @@ evas_fb_outbuf_fb_free(Outbuf *buf)
/* FIXME: impliment */
printf("destroying fb info.. not implemented!!!! WARNING. LEAK!\n");
if (buf->priv.back_buf)
evas_common_image_delete(buf->priv.back_buf);
evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
free(buf);
}
@ -182,7 +182,7 @@ evas_fb_outbuf_fb_update(Outbuf *buf, int x, int y, int w, int h)
{
DATA32 *src_data;
src_data = buf->priv.back_buf->image->data + (y * buf->w) + x;
src_data = buf->priv.back_buf->image.data + (y * buf->w) + x;
if (buf->rot == 0 || buf->rot == 180)
{
conv_func(src_data, data,
@ -216,12 +216,13 @@ evas_fb_outbuf_fb_new_region_for_update(Outbuf *buf, int x, int y, int w, int h,
RGBA_Image *im;
*cx = 0; *cy = 0; *cw = w; *ch = h;
im = evas_common_image_create(w, h);
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
im->flags |= RGBA_IMAGE_HAS_ALPHA;
im = (RGBA_Image *) evas_cache_image_size_set(&im->cache_entry, w, h);
/* handle framebuffers with alpha channel */
if (buf->priv.fb.fb->fb_var.transp.length > 0) {
im->flags |= RGBA_IMAGE_HAS_ALPHA;
memset(im->image->data, 0, w * h * sizeof(DATA32));
memset(im->image.data, 0, w * h * sizeof(DATA32));
}
return im;
}
@ -231,7 +232,7 @@ evas_fb_outbuf_fb_new_region_for_update(Outbuf *buf, int x, int y, int w, int h,
void
evas_fb_outbuf_fb_free_region_for_update(Outbuf *buf, RGBA_Image *update)
{
if (update != buf->priv.back_buf) evas_common_image_delete(update);
if (update != buf->priv.back_buf) evas_cache_image_drop(&update->cache_entry);
}
void
@ -304,7 +305,7 @@ evas_fb_outbuf_fb_push_updated_region(Outbuf *buf, RGBA_Image *update, int x, in
{
DATA32 *src_data;
src_data = update->image->data;
src_data = update->image.data;
if (buf->rot == 0 || buf->rot == 180)
{
conv_func(src_data, data,
@ -333,7 +334,7 @@ evas_fb_outbuf_fb_reconfigure(Outbuf *buf, int w, int h, int rot, Outbuf_Depth d
return;
if (buf->priv.back_buf)
{
evas_common_image_delete(buf->priv.back_buf);
evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
buf->priv.back_buf = NULL;
}
if (buf->priv.fb.fb)
@ -382,7 +383,7 @@ evas_fb_outbuf_fb_set_have_backbuf(Outbuf *buf, int have_backbuf)
if (buf->priv.back_buf)
{
if (have_backbuf) return;
evas_common_image_delete(buf->priv.back_buf);
evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
buf->priv.back_buf = NULL;
}
else
@ -392,7 +393,8 @@ evas_fb_outbuf_fb_set_have_backbuf(Outbuf *buf, int have_backbuf)
{
if (buf->priv.fb.fb->fb_var.bits_per_pixel < 24)
{
buf->priv.back_buf = evas_common_image_create(buf->w, buf->h);
buf->priv.back_buf = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
buf->priv.back_buf = (RGBA_Image *) evas_cache_image_size_set(&buf->priv.back_buf->cache_entry, buf->w, buf->h);
}
}
}

View File

@ -21,7 +21,7 @@
#include <unistd.h>
#ifdef BUILD_ENGINE_GL_GLEW
# include <GL/glew.h>
#include <GL/glew.h>
#endif /* BUILD_ENGINE_GL_GLEW */
#include <GL/gl.h>
@ -196,8 +196,8 @@ Evas_GL_Texture *evas_gl_common_ycbcr601pl_texture_new(Evas_GL_Context *gc, uns
void evas_gl_common_ycbcr601pl_texture_update(Evas_GL_Texture *tex, unsigned char **rows, int w, int h, int smooth);
Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo);
Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace);
Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace);
Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace);
Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace);
Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspace);
void evas_gl_common_image_free(Evas_GL_Image *im);
void evas_gl_common_image_dirty(Evas_GL_Image *im);

View File

@ -1,7 +1,5 @@
#include "evas_gl_private.h"
static void _evas_gl_common_gradient_texture_build(Evas_GL_Context *gc, Evas_GL_Gradient *gr);
Evas_GL_Gradient *
evas_gl_common_gradient_new(void)
{
@ -211,9 +209,10 @@ evas_gl_common_gradient_draw(Evas_GL_Context *gc,
{
RGBA_Image *im;
int op = dc->render_op, cuse = dc->clip.use;
im = evas_common_image_create(w, h);
if (!im) return;
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
if (!im) return;
im = (RGBA_Image *) evas_cache_image_size_set(&im->cache_entry, w, h);
dc->render_op = _EVAS_RENDER_FILL;
dc->clip.use = 0;
evas_common_gradient_draw(im, dc, 0, 0, w, h, gr->grad);
@ -221,8 +220,9 @@ evas_gl_common_gradient_draw(Evas_GL_Context *gc,
gr->tex = evas_gl_common_texture_new(gc, im, 0);
else
evas_gl_common_texture_update(gr->tex, im, 0);
evas_common_image_delete(im);
evas_cache_image_drop(&im->cache_entry);
dc->render_op = op;
dc->clip.use = cuse;
if (!gr->tex) return;

View File

@ -3,9 +3,9 @@
Evas_GL_Image *
evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo)
{
Evas_GL_Image *im;
RGBA_Image *im_im;
Evas_List *l;
Evas_GL_Image *im;
RGBA_Image *im_im;
Evas_List *l;
im_im = evas_common_load_image_from_file(file, key, lo);
if (!im_im) return NULL;
@ -15,7 +15,7 @@ evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key
im = l->data;
if (im->im == im_im)
{
evas_cache_image_drop(im_im);
evas_cache_image_drop(&im_im->cache_entry);
gc->images = evas_list_remove_list(gc->images, l);
gc->images = evas_list_prepend(gc->images, im);
im->references++;
@ -42,7 +42,7 @@ evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key
}
Evas_GL_Image *
evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace)
evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace)
{
Evas_GL_Image *im;
Evas_List *l;
@ -50,9 +50,9 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data,
for (l = gc->images; l; l = l->next)
{
im = l->data;
if (((void *)(im->im->image->data) == (void *)data) &&
(im->im->image->w == w) &&
(im->im->image->h == h))
if (((void *)(im->im->image.data) == (void *)data) &&
(im->im->cache_entry.w == w) &&
(im->im->cache_entry.h == h))
{
gc->images = evas_list_remove_list(gc->images, l);
gc->images = evas_list_prepend(gc->images, im);
@ -63,25 +63,18 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data,
im = calloc(1, sizeof(Evas_GL_Image));
if (!im) return NULL;
im->references = 1;
im->im = evas_cache_image_empty(evas_common_image_cache_get());
im->im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
w, h, data, alpha, cspace);
if (!im->im)
{
free(im);
return NULL;
}
im->gc = gc;
im->im->image->w = w;
im->im->image->h = h;
im->cs.space = cspace;
if (alpha)
im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
else
im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
im->im->image->data = data;
im->im->image->no_free = 1;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
@ -103,42 +96,34 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data,
}
Evas_GL_Image *
evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace)
evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace)
{
Evas_GL_Image *im;
im = calloc(1, sizeof(Evas_GL_Image));
if (!im) return NULL;
im->references = 1;
im->im = evas_cache_image_empty(evas_common_image_cache_get());
im->im = (RGBA_Image *) evas_cache_image_copied_data(evas_common_image_cache_get(),
w, h, data, alpha, cspace);
if (!im->im)
{
free(im);
return NULL;
}
im->im->image->w = w;
im->im->image->h = h;
im->gc = gc;
im->cs.space = cspace;
if (alpha)
im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
else
im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
evas_common_image_surface_alloc(im->im->image);
if (data)
memcpy(im->im->image->data, data, w * h * sizeof(DATA32));
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
if (im->tex) evas_gl_common_texture_free(im->tex);
im->tex = NULL;
im->cs.no_free = 0;
im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
if ((data) && (im->cs.data))
memcpy(im->cs.data, data, im->im->image->h * sizeof(unsigned char *) * 2);
memcpy(im->cs.data, data, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
break;
default:
abort();
@ -155,37 +140,30 @@ evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspac
im = calloc(1, sizeof(Evas_GL_Image));
if (!im) return NULL;
im->references = 1;
im->im = evas_cache_image_empty(evas_common_image_cache_get());
im->im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
if (!im->im)
{
free(im);
return NULL;
}
im->im->image->w = w;
im->im->image->h = h;
im->gc = gc;
im->cs.space = cspace;
if (alpha)
im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
else
im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
evas_cache_image_colorspace(&im->im->cache_entry, cspace);
im->im = (RGBA_Image *) evas_cache_image_size_set(&im->im->cache_entry, w, h);
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
evas_common_image_surface_alloc(im->im->image);
// if (data)
// memcpy(im->im->image->data, data, w * h * sizeof(DATA32));
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
evas_common_image_surface_dealloc(im->im->image);
im->im->image->data = NULL;
// if (im->tex) evas_gl_common_texture_free(im->tex);
im->tex = NULL;
im->cs.no_free = 0;
im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
// if ((data) && (im->cs.data))
// memcpy(im->cs.data, data, im->im->image->h * sizeof(unsigned char *) * 2);
im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
break;
default:
abort();
@ -205,7 +183,7 @@ evas_gl_common_image_free(Evas_GL_Image *im)
if (!im->cs.no_free) free(im->cs.data);
}
if (im->cached) im->gc->images = evas_list_remove(im->gc->images, im);
if (im->im) evas_cache_image_drop(im->im);
if (im->im) evas_cache_image_drop(&im->im->cache_entry);
if (im->tex) evas_gl_common_texture_free(im->tex);
free(im);
}
@ -213,7 +191,7 @@ evas_gl_common_image_free(Evas_GL_Image *im)
void
evas_gl_common_image_dirty(Evas_GL_Image *im)
{
im->im = evas_cache_image_dirty(im->im, 0, 0, im->im->image->w, im->im->image->h);
im->im = (RGBA_Image *) evas_cache_image_dirty(&im->im->cache_entry, 0, 0, im->im->cache_entry.w, im->im->cache_entry.h);
im->dirty = 1;
}
@ -246,14 +224,14 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
{
if ((im->cs.data) && (*((unsigned char **)im->cs.data)))
{
if (im->dirty || !im->im->image->data)
if (im->dirty || !im->im->image.data)
{
free(im->im->image->data);
im->im->image->data = malloc(im->im->image->w * im->im->image->h * sizeof(DATA32));
if (im->im->image->data)
free(im->im->image.data);
im->im->image.data = malloc(im->im->cache_entry.w * im->im->cache_entry.h * sizeof(DATA32));
if (im->im->image.data)
evas_common_convert_yuv_420p_601_rgba(im->cs.data,
(void *)im->im->image->data,
im->im->image->w, im->im->image->h);
(void *)im->im->image.data,
im->im->cache_entry.w, im->im->cache_entry.h);
}
}
space = EVAS_COLORSPACE_ARGB8888;
@ -265,7 +243,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
switch (space)
{
case EVAS_COLORSPACE_ARGB8888:
evas_cache_image_load_data(im->im);
evas_cache_image_load_data(&im->im->cache_entry);
if ((im->tex) && (im->dirty))
{
evas_gl_common_texture_update(im->tex, im->im, im->tex->smooth);
@ -295,12 +273,12 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
case EVAS_COLORSPACE_YCBCR422P709_PL:
if ((im->tex) && (im->dirty))
{
evas_gl_common_ycbcr601pl_texture_update(im->tex, im->cs.data, im->im->image->w, im->im->image->h, smooth);
evas_gl_common_ycbcr601pl_texture_update(im->tex, im->cs.data, im->im->cache_entry.w, im->im->cache_entry.h, smooth);
im->dirty = 0;
}
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
{
im->tex = evas_gl_common_ycbcr601pl_texture_new(gc, im->cs.data, im->im->image->w, im->im->image->h, smooth);
im->tex = evas_gl_common_ycbcr601pl_texture_new(gc, im->cs.data, im->im->cache_entry.w, im->im->cache_entry.h, smooth);
}
if (!im->tex) return;
ow = (dw * im->tex->tw) / sw;

View File

@ -4,7 +4,7 @@ Evas_GL_Texture *
evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
{
Evas_GL_Texture *tex;
int *im_data;
DATA32 *im_data;
int im_w, im_h;
int tw, th;
int shift;
@ -13,16 +13,16 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
if ((gc->ext.nv_texture_rectangle) &&
(!(gc->ext.arb_texture_non_power_of_two &&
if ((gc->ext.nv_texture_rectangle) &&
(!(gc->ext.arb_texture_non_power_of_two &&
gc->ext.sgis_generate_mipmap)))
{
tex->gc = gc;
tex->w = im->image->w;
tex->h = im->image->h;
tex->w = im->cache_entry.w;
tex->h = im->cache_entry.h;
tex->rectangle = 1;
tex->tw = im->image->w;
tex->th = im->image->h;
tex->tw = im->cache_entry.w;
tex->th = im->cache_entry.h;
tex->references = 0;
tex->smooth = smooth;
tex->changed = 1;
@ -53,25 +53,25 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0,
texfmt, tex->w, tex->h, 0,
pixfmt, NATIVE_PIX_UNIT, im->image->data);
pixfmt, NATIVE_PIX_UNIT, im->image.data);
return tex;
}
if ((gc->ext.arb_texture_non_power_of_two) && (gc->ext.sgis_generate_mipmap))
{
tw = im->image->w;
th = im->image->h;
tw = im->cache_entry.w;
th = im->cache_entry.h;
}
else
{
shift = 1; while (im->image->w > shift) shift = shift << 1; tw = shift;
shift = 1; while (im->image->h > shift) shift = shift << 1; th = shift;
shift = 1; while (im->cache_entry.w > shift) shift = shift << 1; tw = shift;
shift = 1; while (im->cache_entry.h > shift) shift = shift << 1; th = shift;
}
tex->gc = gc;
tex->w = tw;
tex->h = th;
tex->tw = im->image->w;
tex->th = im->image->h;
tex->tw = im->cache_entry.w;
tex->th = im->cache_entry.h;
tex->references = 0;
tex->smooth = 0;
tex->changed = 1;
@ -84,15 +84,15 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
tex->references++;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
im_data = im->image->data;
im_w = im->image->w;
im_h = im->image->h;
im_data = im->image.data;
im_w = im->cache_entry.w;
im_h = im->cache_entry.h;
if (im->flags & RGBA_IMAGE_HAS_ALPHA) texfmt = GL_RGBA8;
else texfmt = GL_RGB8;
@ -152,7 +152,7 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
void
evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
{
int *im_data;
DATA32 *im_data;
int im_w, im_h;
int tw, th;
GLenum pixfmt, texfmt, target;
@ -165,7 +165,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
glEnable(GL_TEXTURE_RECTANGLE_NV);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex->texture);
data = im->image->data;
data = im->image.data;
#if 0 // trying the glXAllocateMemoryNV() thing but its abysmally slow
tmp = glXAllocateMemoryNV(tex->w * tex->h * sizeof(DATA32),
0.0, 1.0, 1.0);
@ -177,7 +177,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
tmp);
// evas_common_copy_pixels_rgba_to_rgba_mmx2(im->image->data, tmp,
// tex->w * tex->h);
memcpy(tmp, im->image->data,
memcpy(tmp, im->image.data,
tex->w * tex->h * sizeof(DATA32));
data = tmp;
}
@ -245,9 +245,9 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
tex->smooth = 0;
im_data = im->image->data;
im_w = im->image->w;
im_h = im->image->h;
im_data = im->image.data;
im_w = im->cache_entry.w;
im_h = im->cache_entry.h;
if (im->flags & RGBA_IMAGE_HAS_ALPHA) texfmt = GL_RGBA8;
else texfmt = GL_RGB8;
@ -312,7 +312,7 @@ evas_gl_common_texture_free(Evas_GL_Texture *tex)
void
evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
{
int *im_data;
DATA32 *im_data;
int tw, th;
int im_w, im_h, w, h;
GLenum pixfmt, texfmt;
@ -329,8 +329,8 @@ evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int s
#endif
tw = tex->w;
th = tex->h;
w = im->image->w;
h = im->image->h;
w = im->cache_entry.w;
h = im->cache_entry.h;
level = 0;
im1 = im;
@ -365,30 +365,31 @@ evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int s
th /= 2;
level++;
im2 = evas_common_image_create(w, h);
im2 = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
im2 = (RGBA_Image *) evas_cache_image_size_set(&im2->cache_entry, w, h);
#ifdef BUILD_MMX
if (mmx)
{
evas_common_scale_rgba_mipmap_down_2x2_mmx(im1->image->data,
im2->image->data,
evas_common_scale_rgba_mipmap_down_2x2_mmx(im1->image.data,
im2->image.data,
pw, ph);
}
else
#endif
{
if (im->flags & RGBA_IMAGE_HAS_ALPHA)
evas_common_scale_rgba_mipmap_down_2x2_c(im1->image->data,
im2->image->data,
evas_common_scale_rgba_mipmap_down_2x2_c(im1->image.data,
im2->image.data,
pw, ph);
else
evas_common_scale_rgb_mipmap_down_2x2_c(im1->image->data,
im2->image->data,
evas_common_scale_rgb_mipmap_down_2x2_c(im1->image.data,
im2->image.data,
pw, ph);
}
if (im1 != im) evas_cache_image_drop(im1);
if (im1 != im) evas_cache_image_drop(&im1->cache_entry);
im1 = NULL;
im_data = im2->image->data;
im_data = im2->image.data;
im_w = w;
im_h = h;
glTexSubImage2D(GL_TEXTURE_2D, level,
@ -413,7 +414,7 @@ evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int s
im1 = im2;
im2 = NULL;
}
if ((im1 != im) && (im1)) evas_common_image_delete(im1);
if ((im1 != im) && (im1)) evas_cache_image_drop(&im1->cache_entry);
tex->have_mipmaps = 1;
#ifdef BUILD_MMX
if (mmx) evas_common_cpu_end_opt();

View File

@ -572,6 +572,7 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space == cspace) return;
evas_cache_image_colorspace(&im->im.cache_entry, cspace);
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
@ -581,13 +582,9 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
im->cs.data = NULL;
im->cs.no_free = 0;
}
if (!im->im->image->no_free)
evas_common_image_surface_alloc(im->im->image);
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
evas_common_image_surface_dealloc(im->im->image);
im->im->image->data = NULL;
if (im->tex) evas_gl_common_texture_free(im->tex);
im->tex = NULL;
if (im->cs.data)
@ -844,14 +841,10 @@ eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y
static RGBA_Image *im = NULL;
if (!im)
{
im = evas_common_image_new();
im->image = evas_common_image_surface_new(im);
im->image->no_free = 1;
}
im->image->w = re->window->width;
im->image->h = re->window->height;
im->image->data = NULL;
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
if (!im) return ;
evas_cache_image_surface_alloc(&im->cache_entry, re->window->width, re->window->height);
evas_common_draw_context_font_ext_set(context,
re->window->gl_context,
evas_gl_font_texture_new,

View File

@ -1,12 +1,20 @@
#ifdef HAVE_GL_GLEW_H
# include <GL/glxew.h>
#else
# include <GL/glx.h>
#endif
#include "evas_gl_common.h"
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_GL_X11.h"
#include "evas_gl_common.h"
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
@ -15,9 +23,6 @@ static Visual *eng_best_visual_get(Display *disp, int screen);
static Colormap eng_best_colormap_get(Display *disp, int screen);
static int eng_best_depth_get(Display *disp, int screen);
static void eng_font_hinting_set(void *data, void *font, int hinting);
static int eng_font_hinting_can_hint(void *data, int hinting);
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
@ -548,7 +553,7 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
{
Evas_GL_Image *im_new;
im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data,
im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->cache_entry.w, im->im->cache_entry.h, im->im->image.data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
if (!im_new) return im;
@ -615,6 +620,7 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space == cspace) return;
evas_cache_image_colorspace(&im->im->cache_entry, cspace);
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
@ -624,20 +630,16 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
im->cs.data = NULL;
im->cs.no_free = 0;
}
if (!im->im->image->no_free)
evas_common_image_surface_alloc(im->im->image);
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
evas_common_image_surface_dealloc(im->im->image);
im->im->image->data = NULL;
if (im->tex) evas_gl_common_texture_free(im->tex);
im->tex = NULL;
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
}
im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
im->cs.no_free = 0;
break;
default:
@ -712,8 +714,8 @@ eng_image_size_get(void *data, void *image, int *w, int *h)
*h = 0;
return;
}
if (w) *w = ((Evas_GL_Image *)image)->im->image->w;
if (h) *h = ((Evas_GL_Image *)image)->im->image->h;
if (w) *w = ((Evas_GL_Image *)image)->im->cache_entry.w;
if (h) *h = ((Evas_GL_Image *)image)->im->cache_entry.h;
}
static void *
@ -729,7 +731,7 @@ eng_image_size_set(void *data, void *image, int w, int h)
if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
w &= ~0x1;
if ((im_old) && (im_old->im->image->w == w) && (im_old->im->image->h == h))
if ((im_old) && (im_old->im->cache_entry.w == w) && (im_old->im->cache_entry.h == h))
return image;
if (im_old)
{
@ -776,7 +778,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
}
im = image;
eng_window_use(re->win);
evas_common_load_image_data_from_file(im->im);
evas_cache_image_load_data(&im->im->cache_entry);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
@ -786,7 +788,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
{
Evas_GL_Image *im_new;
im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data,
im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->cache_entry.w, im->im->cache_entry.h, im->im->image.data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
if (!im_new)
@ -800,7 +802,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
else
evas_gl_common_image_dirty(im);
}
*image_data = im->im->image->data;
*image_data = im->im->image.data;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
@ -826,12 +828,12 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (image_data != im->im->image->data)
if (image_data != im->im->image.data)
{
int w, h;
w = im->im->image->w;
h = im->im->image->h;
w = im->im->cache_entry.w;
h = im->im->cache_entry.h;
im2 = eng_image_new_from_data(data, w, h, image_data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
@ -876,7 +878,7 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
}
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text)
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
{
Render_Engine *re;
@ -885,14 +887,9 @@ eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y
static RGBA_Image *im = NULL;
if (!im)
{
im = evas_common_image_new();
im->image = evas_common_image_surface_new(im);
im->image->no_free = 1;
}
im->image->w = re->win->w;
im->image->h = re->win->h;
im->image->data = NULL;
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
evas_cache_image_surface_alloc(&im->cache_entry, re->win->w, re->win->h);
evas_common_draw_context_font_ext_set(context,
re->win->gl_context,
evas_gl_font_texture_new,

View File

@ -1,12 +1,14 @@
#include "evas_gl_common.h"
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_GL_X11.h"
#include "evas_gl_common.h"
static Evas_GL_X11_Window *_evas_gl_x11_window = NULL;

View File

@ -15,17 +15,7 @@ pkgdir = $(libdir)/evas/modules/engines/software_16/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = \
evas_engine.c \
evas_soft16.h \
evas_soft16_dither_mask.c \
evas_soft16_main.c \
evas_soft16_image_cache.c \
evas_soft16_image_unscaled.c \
evas_soft16_image_scaled_sampled.c \
evas_soft16_font.c \
evas_soft16_rectangle.c \
evas_soft16_polygon.c \
evas_soft16_line.c
evas_engine.c
module_la_LIBADD = $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = @create_shared_lib@ -module -avoid-version
@ -35,17 +25,4 @@ module_la_DEPENDENCIES = $(top_builddir)/config.h
endif
EXTRA_DIST = \
evas_engine.c \
evas_soft16.h \
evas_soft16_dither_mask.c \
evas_soft16_main.c \
evas_soft16_image_cache.c \
evas_soft16_image_unscaled.c \
evas_soft16_image_scaled_sampled.c \
evas_soft16_font.c \
evas_soft16_rectangle.c \
evas_soft16_polygon.c \
evas_soft16_line.c \
evas_soft16_scanline_fill.c \
evas_soft16_scanline_blend.c
evas_engine.c

View File

@ -1,6 +1,6 @@
#include "evas_common.h"
#include "evas_private.h"
#include "evas_soft16.h"
#include "evas_common_soft16.h"
/*
*****
@ -330,7 +330,7 @@ eng_image_alpha_get(void *data, void *image)
if (!image) return 0;
im = image;
return im->have_alpha;
return im->flags.have_alpha;
}
static int
@ -394,7 +394,7 @@ eng_image_native_get(void *data, void *image)
static void *
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
{
return soft16_image_load(file, key, error, lo);
return evas_cache_image_request(evas_common_soft16_image_cache_get(), file, key, lo, error);
}
static void *
@ -406,7 +406,7 @@ eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha,
cspace, __FUNCTION__, __FILE__, __LINE__);
return NULL;
}
return soft16_image_new(w, h, -1, alpha, (DATA16 *)image_data, 0);
return evas_cache_image_data(evas_common_soft16_image_cache_get(), w, h, image_data, alpha, EVAS_COLORSPACE_RGB565_A5P);
}
static void *
@ -418,13 +418,13 @@ eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int
cspace, __FUNCTION__, __FILE__, __LINE__);
return NULL;
}
return soft16_image_new(w, h, -1, alpha, (DATA16 *)image_data, 1);
return evas_cache_image_copied_data(evas_common_soft16_image_cache_get(), w, h, image_data, alpha, EVAS_COLORSPACE_RGB565_A5P);
}
static void
eng_image_free(void *data, void *image)
{
soft16_image_free(image);
evas_cache_image_drop((Image_Entry *) image);
}
static void
@ -436,8 +436,8 @@ eng_image_size_get(void *data, void *image, int *w, int *h)
if (h) *h = 0;
if (!image) return;
im = image;
if (w) *w = im->w;
if (h) *h = im->h;
if (w) *w = im->cache_entry.w;
if (h) *h = im->cache_entry.h;
}
static void *
@ -446,10 +446,10 @@ eng_image_size_set(void *data, void *image, int w, int h)
if (!image) return NULL;
if ((w <= 0) || (h <= 0))
{
soft16_image_free(image);
evas_cache_image_drop((Image_Entry *) image);
return NULL;
}
return soft16_image_size_set(image, w, h);
return evas_cache_image_size_set((Image_Entry *) image, w, h);
}
static void
@ -483,27 +483,10 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
}
im = image;
soft16_image_load_data(im);
evas_cache_image_load_data(&im->cache_entry);
if (to_write)
{
if (im->references > 1)
{
Soft16_Image *im_new;
im_new = soft16_image_new(im->w, im->h, im->stride, im->have_alpha,
im->pixels, 1);
if (!im_new)
{
if (image_data) *image_data = NULL;
return im;
}
soft16_image_free(im);
im = im_new;
}
if (im->cache_key)
soft16_image_cache_del(im);
}
im = (Soft16_Image *) evas_cache_image_alone(&im->cache_entry);
if (image_data) *image_data = (DATA32 *) im->pixels;
@ -520,17 +503,22 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
old_im = image;
if ((DATA16 *)image_data == old_im->pixels) return old_im;
new_im = soft16_image_new(old_im->w, old_im->h, old_im->stride,
old_im->have_alpha, (DATA16 *)image_data, 0);
soft16_image_free(old_im);
new_im = (Soft16_Image *) evas_cache_image_copied_data(evas_common_soft16_image_cache_get(), old_im->cache_entry.w, old_im->cache_entry.h, image_data, old_im->flags.have_alpha, EVAS_COLORSPACE_RGB565_A5P);
evas_cache_image_drop(&old_im->cache_entry);
return new_im;
}
#include <assert.h>
static void
eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{
soft16_image_load_data(image);
soft16_image_draw(image, surface, context,
Soft16_Image *im;
im = (Soft16_Image *) image;
evas_cache_image_load_data(&im->cache_entry);
soft16_image_draw(im, surface, context,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
smooth);
@ -539,19 +527,19 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
static void
eng_image_cache_flush(void *data)
{
soft16_image_cache_flush();
evas_cache_image_flush(evas_common_soft16_image_cache_get());
}
static void
eng_image_cache_set(void *data, int bytes)
{
soft16_image_cache_size_set(bytes);
evas_cache_image_set(evas_common_soft16_image_cache_get(), bytes);
}
static int
eng_image_cache_get(void *data)
{
return soft16_image_cache_size_get();
return evas_cache_image_get(evas_common_soft16_image_cache_get());
}
static void *
@ -653,17 +641,12 @@ eng_font_char_at_coords_get(void *data, void *font, const char *text, int x, int
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
{
static RGBA_Image *im = NULL;
Soft16_Image *dst = surface;
static RGBA_Image *im = NULL;
Soft16_Image *dst = surface;
if (!im)
{
im = evas_common_image_new();
im->image = evas_common_image_surface_new(im);
im->image->no_free = 1;
}
im->image->w = dst->w;
im->image->h = dst->h;
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
evas_cache_image_surface_alloc(&im->cache_entry, dst->cache_entry.w, dst->cache_entry.h);
evas_common_draw_context_font_ext_set(context,
surface,
soft16_font_glyph_new,

View File

@ -2,7 +2,7 @@
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_Software_16_DDraw.h"
#include "evas_soft16.h"
#include "evas_common_soft16.h"
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
@ -144,6 +144,7 @@ eng_setup(Evas *e, void *in)
evas_common_font_init();
evas_common_draw_init();
evas_common_tilebuf_init();
evas_common_soft16_image_init();
/* render engine specific data */
re = calloc(1, sizeof(Render_Engine));
@ -209,6 +210,7 @@ eng_output_free(void *data)
evas_common_font_shutdown();
evas_common_image_shutdown();
evas_common_soft16_image_shutdown();
}
static void

View File

@ -5,7 +5,7 @@
#include <windows.h>
#include <ddraw.h>
#include "evas_soft16.h"
#include "evas_common_soft16.h"
typedef struct _DDraw_Output_Buffer DDraw_Output_Buffer;

View File

@ -2,7 +2,7 @@
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_Software_16_X11.h"
#include "evas_soft16.h"
#include "evas_common_soft16.h"
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
@ -64,13 +64,6 @@ eng_info_free(Evas *e, void *info)
free(in);
}
static void
_tmp_out_free(Soft16_Image *tmp_out)
{
free(tmp_out->pixels);
free(tmp_out);
}
static void
_tmp_out_alloc(Render_Engine *re)
{
@ -85,9 +78,9 @@ _tmp_out_alloc(Render_Engine *re)
if (re->tmp_out)
{
if ((re->tmp_out->w < w) || (re->tmp_out->h < h))
if ((re->tmp_out->cache_entry.w < w) || (re->tmp_out->cache_entry.h < h))
{
_tmp_out_free(re->tmp_out);
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
@ -96,14 +89,9 @@ _tmp_out_alloc(Render_Engine *re)
{
Soft16_Image *im;
im = calloc(1, sizeof(Soft16_Image));
im->w = w;
im->h = h;
im->stride = w + ((w % 4) ? (4 - (w % 4)) : 0);
im->have_alpha = 0;
im->references = 1;
im->free_pixels = 1;
im->pixels = malloc(h * im->stride * sizeof(DATA16));
im = (Soft16_Image *) evas_cache_image_empty(evas_common_soft16_image_cache_get());
im->flags.have_alpha = 0;
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
re->tmp_out = im;
}
@ -115,7 +103,7 @@ eng_setup(Evas *e, void *in)
{
Render_Engine *re;
Evas_Engine_Info_Software_16_X11 *info;
X_Output_Buffer *xob;
/* X_Output_Buffer *xob; */
XGCValues gcv;
info = (Evas_Engine_Info_Software_16_X11 *)in;
@ -144,7 +132,8 @@ eng_setup(Evas *e, void *in)
evas_common_font_init();
evas_common_draw_init();
evas_common_tilebuf_init();
evas_common_soft16_image_init();
/* render engine specific data */
re = calloc(1, sizeof(Render_Engine));
e->engine.data.output = re;
@ -179,7 +168,7 @@ eng_setup(Evas *e, void *in)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
if (re->tmp_out)
{
_tmp_out_free(re->tmp_out);
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
@ -203,11 +192,12 @@ eng_output_free(void *data)
if (re->gc) XFreeGC(re->disp, re->gc);
if (re->tb) evas_common_tilebuf_free(re->tb);
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
if (re->tmp_out) _tmp_out_free(re->tmp_out);
if (re->tmp_out) evas_cache_image_drop(&re->tmp_out->cache_entry);
free(re);
evas_common_font_shutdown();
evas_common_image_shutdown();
evas_common_soft16_image_shutdown();
}
static void
@ -237,7 +227,7 @@ eng_output_resize(void *data, int w, int h)
}
if (re->tmp_out)
{
_tmp_out_free(re->tmp_out);
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
@ -343,7 +333,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
if (re->rot == 0)
{
*cx = ux; *cy = uy; *cw = uw; *ch = uh;
return &re->shbuf->im;
return re->shbuf->im;
}
else
{
@ -449,10 +439,10 @@ _tmp_out_process(Render_Engine *re, int out_x, int out_y, int w, int h)
DATA16 *dp, *sp;
int y, x, d_dir;
d = &re->shbuf->im;
d = re->shbuf->im;
s = re->tmp_out;
if ((w < 1) || (h < 1) || (out_x >= d->w) || (out_y >= d->h))
if ((w < 1) || (h < 1) || (out_x >= d->cache_entry.w) || (out_y >= d->cache_entry.h))
return;
if (re->rot == 90)
@ -524,7 +514,7 @@ eng_output_flush(void *data)
else return;
evas_software_x11_x_output_buffer_paste
(re->shbuf, re->draw, re->gc, 0, 0, re->shbuf->im.w, re->shbuf->im.h, 1);
(re->shbuf, re->draw, re->gc, 0, 0, re->shbuf->im->cache_entry.w, re->shbuf->im->cache_entry.h, 1);
XSetClipMask(re->disp, re->gc, None);
}
@ -546,7 +536,7 @@ eng_output_idle_flush(void *data)
}
if (re->tmp_out)
{
_tmp_out_free(re->tmp_out);
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}

View File

@ -8,13 +8,13 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include "evas_soft16.h"
#include "evas_common_soft16.h"
typedef struct _X_Output_Buffer X_Output_Buffer;
struct _X_Output_Buffer
{
Soft16_Image im;
Soft16_Image *im;
Display *display;
XImage *xim;
XShmSegmentInfo *shm_info;

View File

@ -81,11 +81,9 @@ evas_software_x11_x_output_buffer_new(Display *d, Visual *v, int depth, int w, i
XSetErrorHandler((XErrorHandler)ph);
if (!_x_err)
{
xob->im.pixels = xob->xim->data;
xob->im.w = w;
xob->im.h = h;
xob->im.stride = xob->xim->bytes_per_line / sizeof(DATA16);
xob->im.references = 1;
xob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), w, h, (DATA32 *) xob->xim->data, 0, EVAS_COLORSPACE_RGB565_A5P);
if (xob->im)
xob->im->stride = xob->xim->bytes_per_line / sizeof(DATA16);
return xob;
}
}
@ -121,11 +119,12 @@ evas_software_x11_x_output_buffer_new(Display *d, Visual *v, int depth, int w, i
return NULL;
}
}
xob->im.pixels = xob->xim->data;
xob->im.w = w;
xob->im.h = h;
xob->im.stride = xob->xim->bytes_per_line / sizeof(DATA16);
xob->im.references = 1;
if (xob->im)
evas_cache_image_drop(&xob->im->cache_entry);
xob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), w, h, (DATA32 *) xob->xim->data, 0, EVAS_COLORSPACE_RGB565_A5P);
if (xob->im)
xob->im->stride = xob->xim->bytes_per_line / sizeof(DATA16);
return xob;
}

View File

@ -117,24 +117,23 @@ evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
(buf->priv.mask.g == 0x00ff00) &&
(buf->priv.mask.b == 0x0000ff))
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = width;
im->image->h = height;
im->image->data = NULL;
im->image->no_free = 1;
im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
if (!im) return NULL;
im = (RGBA_Image*) evas_cache_image_size_set(&im->cache_entry, width, height);
if (!im) return NULL;
im->image.no_free = 1;
ddob = evas_software_ddraw_output_buffer_new(buf->priv.dd.depth,
width,
height,
NULL);
im->extended_info = ddob;
im->image->data = (DATA32 *)evas_software_ddraw_output_buffer_data(ddob, &bpl);
im->image.data = (DATA32 *)evas_software_ddraw_output_buffer_data(ddob, &bpl);
}
else
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = width;
im->image->h = height;
evas_common_image_surface_alloc(im->image);
if (!im) return NULL;
evas_cache_image_surface_alloc(&im->cache_entry, width, height);
im->extended_info = ddob;
if ((buf->rot == 0) || (buf->rot == 180))
ddob = evas_software_ddraw_output_buffer_new(buf->priv.dd.depth,

View File

@ -336,7 +336,7 @@ eng_image_alpha_get(void *data, void *image)
if (!image) return 1;
im = image;
switch (im->cs.space)
switch (im->cache_entry.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
@ -353,7 +353,7 @@ eng_image_colorspace_get(void *data, void *image)
if (!image) return EVAS_COLORSPACE_ARGB8888;
im = image;
return im->cs.space;
return im->cache_entry.space;
}
static void *
@ -363,12 +363,12 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
if (!image) return NULL;
im = image;
if (im->cs.space != EVAS_COLORSPACE_ARGB8888)
if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
{
im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
return im;
}
im = evas_cache_image_alone(im);
im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
evas_common_image_colorspace_dirty(im);
if (has_alpha)
@ -415,41 +415,10 @@ static void
eng_image_colorspace_set(void *data, void *image, int cspace)
{
RGBA_Image *im;
if (!image) return;
im = image;
if (im->cs.space == cspace) return;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
im->cs.data = NULL;
im->cs.no_free = 0;
}
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
if (im->image->no_free)
{
im->image->data = NULL;
im->image->no_free = 0;
evas_common_image_surface_alloc(im->image);
}
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
}
im->cs.data = calloc(1, im->image->h * sizeof(unsigned char *) * 2);
im->cs.no_free = 0;
break;
default:
abort();
break;
}
im->cs.space = cspace;
evas_common_image_colorspace_dirty(im);
evas_cache_image_colorspace(&im->cache_entry, cspace);
}
static void
@ -494,8 +463,8 @@ eng_image_size_get(void *data, void *image, int *w, int *h)
RGBA_Image *im;
im = image;
if (w) *w = im->image->w;
if (h) *h = im->image->h;
if (w) *w = im->cache_entry.w;
if (h) *h = im->cache_entry.h;
}
static void *
@ -513,7 +482,7 @@ eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
RGBA_Image* im = image;
if (!image) return NULL;
im = evas_cache_image_dirty(im, x, y, w, h);
im = (RGBA_Image *) evas_cache_image_dirty(&im->cache_entry, x, y, w, h);
return im;
}
@ -528,13 +497,13 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
return NULL;
}
im = image;
evas_common_load_image_data_from_file(im);
switch (im->cs.space)
evas_cache_image_load_data(&im->cache_entry);
switch (im->cache_entry.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (to_write)
im = evas_cache_image_alone(im);
*image_data = im->image->data;
im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
*image_data = im->image.data;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
@ -554,19 +523,19 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
if (!image) return NULL;
im = image;
switch (im->cs.space)
switch (im->cache_entry.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (image_data != im->image->data)
if (image_data != im->image.data)
{
int w, h;
w = im->image->w;
h = im->image->h;
im2 = eng_image_new_from_data(data, w, h, image_data,
w = im->cache_entry.w;
h = im->cache_entry.h;
im2 = eng_image_new_from_data(data, w, h, image_data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
evas_cache_image_drop(im);
evas_cache_image_drop(&im->cache_entry);
im = im2;
}
break;
@ -596,8 +565,8 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
if (!image) return;
im = image;
if (im->cs.space == EVAS_COLORSPACE_ARGB8888)
evas_common_load_image_data_from_file(im);
if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
evas_cache_image_load_data(&im->cache_entry);
evas_common_image_colorspace_normalize(im);
#ifdef BUILD_PTHREAD
if (cpunum > 1)

View File

@ -12,11 +12,11 @@ struct _Evas_Engine_Info_SDL
Evas_Engine_Info magic;
struct {
SDL_Surface *surface;
int fullscreen : 1;
int hwsurface : 1;
int noframe : 1;
int alpha : 1;
int rotation;
int fullscreen : 1;
int hwsurface : 1;
int noframe : 1;
int alpha : 1;
} info;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -5,29 +5,42 @@
#include "evas_private.h"
#include "Evas_Engine_SDL.h"
typedef struct _Render_Engine Render_Engine;
typedef struct _SDL_Engine_Image_Entry SDL_Engine_Image_Entry;
struct _SDL_Engine_Image_Entry
{
Engine_Image_Entry cache_entry;
SDL_Surface *surface;
struct
{
unsigned int engine_surface : 1;
} flags;
};
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
RGBA_Engine_Image* rgba_engine_image;
SDL_Surface* surface;
SDL_Engine_Image_Entry *rgba_engine_image;
Tilebuf* tb;
Tilebuf_Rect* rects;
Evas_Object_List* cur_rect;
Tilebuf *tb;
Tilebuf_Rect *rects;
Evas_Object_List *cur_rect;
Evas_Cache_Engine_Image* cache;
Evas_Cache_Engine_Image *cache;
SDL_Rect* update_rects;
int update_rects_count;
int update_rects_limit;
SDL_Rect *update_rects;
int update_rects_count;
int update_rects_limit;
int fullscreen:1;
int noframe:1;
int alpha:1;
int hwsurface:1;
int end:1;
struct
{
unsigned int fullscreen : 1;
unsigned int noframe : 1;
unsigned int alpha : 1;
unsigned int hwsurface : 1;
unsigned int end : 1;
} flags;
};
#endif

View File

@ -330,6 +330,7 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
Outbuf_Region *obr;
int bpl = 0;
int use_shm = 1;
int alpha;
if ((buf->onebuf) && (buf->priv.x.shm))
{
@ -360,7 +361,7 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
im = buf->priv.onebuf;
for (yy = y; yy < (y + h); yy++)
{
memset(im->image->data + (im->image->w * yy) + x,
memset(im->image.data + (im->cache_entry.w * yy) + x,
0, w * sizeof(DATA32));
}
}
@ -375,26 +376,26 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
*cy = y;
*cw = w;
*ch = h;
alpha = ((buf->priv.x.mask) || (buf->priv.destination_alpha));
use_shm = buf->priv.x.shm;
if ((buf->rot == 0) &&
(buf->priv.mask.r == 0xff0000) &&
(buf->priv.mask.g == 0x00ff00) &&
(buf->priv.mask.b == 0x0000ff))
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = buf->w;
im->image->h = buf->h;
im->image->data = NULL;
im->image->no_free = 1;
im->extended_info = obr;
obr->xob = evas_software_x11_x_output_buffer_new(buf->priv.x.disp,
buf->priv.x.vis,
buf->priv.x.depth,
buf->w, buf->h,
use_shm,
NULL);
im->image->data = (DATA32 *) evas_software_x11_x_output_buffer_data(obr->xob, &bpl);
im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
buf->w, buf->h,
(DATA32 *) evas_software_x11_x_output_buffer_data(obr->xob, &bpl),
alpha, EVAS_COLORSPACE_ARGB8888);
im->extended_info = obr;
if (buf->priv.x.mask)
obr->mxob = evas_software_x11_x_output_buffer_new(buf->priv.x.disp,
buf->priv.x.vis,
@ -405,10 +406,9 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
}
else
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = buf->w;
im->image->h = buf->h;
evas_common_image_surface_alloc(im->image);
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
im->flags |= alpha ? RGBA_IMAGE_HAS_ALPHA : 0;
evas_cache_image_surface_alloc(&im->cache_entry, buf->w, buf->h);
im->extended_info = obr;
if ((buf->rot == 0) || (buf->rot == 180))
obr->xob = evas_software_x11_x_output_buffer_new(buf->priv.x.disp,
@ -431,22 +431,14 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
use_shm,
NULL);
}
if ((buf->priv.x.mask) || (buf->priv.destination_alpha))
{
im->flags |= RGBA_IMAGE_HAS_ALPHA;
/* FIXME: faster memset! */
memset(im->image->data, 0, w * h * sizeof(DATA32));
}
buf->priv.onebuf = im;
if (alpha)
/* FIXME: faster memset! */
memset(im->image.data, 0, w * h * sizeof(DATA32));
buf->priv.onebuf = im;
return im;
}
obr = calloc(1, sizeof(Outbuf_Region));
obr->x = x;
obr->y = y;
@ -464,32 +456,30 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
// use_shm = 0; /* 630 -> 1006 fps */
// if ((w * h) < (200 * 200)) use_shm = 0; /* 630 -> 962 fps */
alpha = ((buf->priv.x.mask) || (buf->priv.destination_alpha));
if ((buf->rot == 0) &&
(buf->priv.mask.r == 0xff0000) &&
(buf->priv.mask.g == 0x00ff00) &&
(buf->priv.mask.b == 0x0000ff))
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = w;
im->image->h = h;
im->image->data = NULL;
im->image->no_free = 1;
im->extended_info = obr;
obr->xob = _find_xob(buf->priv.x.disp,
buf->priv.x.vis,
buf->priv.x.depth,
w, h,
use_shm,
NULL);
/*
obr->xob = evas_software_x11_x_output_buffer_new(buf->priv.x.disp,
buf->priv.x.vis,
buf->priv.x.depth,
w, h,
use_shm,
NULL);
*/
im->image->data = (DATA32 *) evas_software_x11_x_output_buffer_data(obr->xob, &bpl);
/* obr->xob = evas_software_x11_x_output_buffer_new(buf->priv.x.disp, */
/* buf->priv.x.vis, */
/* buf->priv.x.depth, */
/* w, h, */
/* use_shm, */
/* NULL); */
im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
w, h,
(DATA32 *) evas_software_x11_x_output_buffer_data(obr->xob, &bpl),
alpha, EVAS_COLORSPACE_ARGB8888);
im->extended_info = obr;
if (buf->priv.x.mask)
obr->mxob = _find_xob(buf->priv.x.disp,
buf->priv.x.vis,
@ -506,10 +496,9 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
}
else
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = w;
im->image->h = h;
evas_common_image_surface_alloc(im->image);
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
im->flags |= alpha ? RGBA_IMAGE_HAS_ALPHA : 0;
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
im->extended_info = obr;
if ((buf->rot == 0) || (buf->rot == 180))
obr->xob = _find_xob(buf->priv.x.disp,
@ -556,11 +545,9 @@ evas_software_x11_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w,
*/
}
if ((buf->priv.x.mask) || (buf->priv.destination_alpha))
{
im->flags |= RGBA_IMAGE_HAS_ALPHA;
/* FIXME: faster memset! */
memset(im->image->data, 0, w * h * sizeof(DATA32));
}
/* FIXME: faster memset! */
memset(im->image.data, 0, w * h * sizeof(DATA32));
buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
return im;
}
@ -692,7 +679,7 @@ evas_software_x11_outbuf_flush(Outbuf *buf)
RGBA_Image *im;
Outbuf_Region *obr;
im = buf->priv.pending_writes->data;
im = evas_list_data(buf->priv.pending_writes);
buf->priv.pending_writes = evas_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
obr = im->extended_info;
evas_cache_image_drop(im);
@ -703,6 +690,7 @@ evas_software_x11_outbuf_flush(Outbuf *buf)
if (obr->mxob) evas_software_x11_x_output_buffer_free(obr->mxob, 0);
*/
free(obr);
evas_cache_image_drop(&im->cache_entry);
}
#endif
}
@ -720,10 +708,10 @@ evas_software_x11_outbuf_idle_flush(Outbuf *buf)
im = buf->priv.onebuf;
buf->priv.onebuf = NULL;
obr = im->extended_info;
evas_cache_image_drop(im);
if (obr->xob) evas_software_x11_x_output_buffer_free(obr->xob, 0);
if (obr->mxob) evas_software_x11_x_output_buffer_free(obr->mxob, 0);
free(obr);
evas_cache_image_drop(&im->cache_entry);
}
else
{
@ -790,7 +778,7 @@ evas_software_x11_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
if (!conv_func) return;
data = evas_software_x11_x_output_buffer_data(obr->xob, &bpl);
src_data = update->image->data;
src_data = update->image.data;
if (buf->rot == 0)
{
obr->x = x;

View File

@ -508,24 +508,19 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf,
(buf->priv.mask.g == 0x00ff00) &&
(buf->priv.mask.b == 0x0000ff))
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = w;
im->image->h = h;
im->image->data = NULL;
im->image->no_free = 1;
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
if (!im) return NULL;
im = (RGBA_Image *) evas_cache_image_size_set(&im->cache_entry, w, h);
if (!im) return NULL;
im->extended_info = obr;
obr->xcbob = _find_xcbob(buf->priv.x.conn,
buf->priv.x.depth,
w, h,
use_shm,
NULL);
/* obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn, */
/* buf->priv.x.depth, */
/* w, */
/* h, */
/* use_shm, */
/* NULL); */
im->image->data = (DATA32 *)evas_software_xcb_x_output_buffer_data(obr->xcbob, &bpl);
im->image.no_free = 1;
im->image.data = (DATA32 *)evas_software_xcb_x_output_buffer_data(obr->xcbob, &bpl);
if (buf->priv.x.mask)
obr->mxcbob = _find_xcbob(buf->priv.x.conn,
1, w, h,
@ -541,9 +536,8 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf,
else
{
im = evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = w;
im->image->h = h;
evas_common_image_surface_alloc(im->image);
if (!im) return NULL;
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
im->extended_info = obr;
if ((buf->rot == 0) || (buf->rot == 180))
obr->xcbob = _find_xcbob(buf->priv.x.conn,
@ -585,7 +579,7 @@ evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf,
{
im->flags |= RGBA_IMAGE_HAS_ALPHA;
/* FIXME: faster memset! */
memset(im->image->data, 0, w * h * sizeof(DATA32));
memset(im->image.data, 0, w * h * sizeof(DATA32));
}
buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
return im;
@ -832,7 +826,7 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf,
if (!conv_func) return;
data = evas_software_xcb_x_output_buffer_data(obr->xcbob, &bpl);
src_data = update->image->data;
src_data = update->image.data;
if (buf->rot == 0)
{
obr->x = x;

View File

@ -529,11 +529,11 @@ eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
_xre_image_border_get((XR_Image *)image, l, r, t, b);
}
static const char *
static char *
eng_image_comment_get(void *data, void *image, char *key)
{
if (!image) return NULL;
return ((XR_Image *)image)->comment;
return strdup(((XR_Image *)image)->comment);
}
static char *
@ -551,6 +551,10 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
if (!image) return;
im = (XR_Image *)image;
if (im->cs.space == cspace) return;
if (im->im) evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
@ -560,15 +564,11 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
im->cs.data = NULL;
im->cs.no_free = 0;
}
if (im->im) evas_cache_image_drop(im->im);
im->im = NULL;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
if ((im->free_data) && (im->data)) free(im->data);
im->data = NULL;
if (im->im) evas_cache_image_drop(im->im);
im->im = NULL;
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
@ -693,7 +693,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
}
im = (XR_Image *)image;
if (im->im)
evas_common_load_image_data_from_file(im->im);
evas_cache_image_load_data(&im->im->cache_entry);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
@ -832,35 +832,32 @@ eng_image_cache_get(void *data)
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
{
Render_Engine *re;
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *)data;
{
static RGBA_Image *im = NULL;
if (!im)
{
im = evas_common_image_new();
im->image = evas_common_image_surface_new(im);
im->image->no_free = 1;
}
im->image->w = ((Xrender_Surface *)surface)->w;
im->image->h = ((Xrender_Surface *)surface)->h;
_xr_render_surface_clips_set((Xrender_Surface *)surface, (RGBA_Draw_Context *)context, x, y, w, h);
im->image->data = surface;
evas_common_draw_context_font_ext_set(context,
re->xinf,
_xre_font_surface_new,
_xre_font_surface_free,
_xre_font_surface_draw);
evas_common_font_draw(im, context, font, x, y, text);
evas_common_draw_context_font_ext_set(context,
NULL,
NULL,
NULL,
NULL);
evas_common_cpu_end_opt();
}
_xr_render_surface_clips_set((Xrender_Surface *)surface, (RGBA_Draw_Context *)context, x, y, w, h);
im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
((Xrender_Surface *)surface)->w,
((Xrender_Surface *)surface)->h,
surface,
0, EVAS_COLORSPACE_ARGB8888);
evas_common_draw_context_font_ext_set(context,
re->xinf,
_xre_font_surface_new,
_xre_font_surface_free,
_xre_font_surface_draw);
evas_common_font_draw(im, context, font, x, y, text);
evas_common_draw_context_font_ext_set(context,
NULL,
NULL,
NULL,
NULL);
evas_common_cpu_end_opt();
evas_cache_image_drop(&im->cache_entry);
}
/* module advertising code */

View File

@ -162,8 +162,8 @@ _xre_font_surface_draw(Ximage_Info *xinf, RGBA_Image *surface, RGBA_Draw_Context
fs = fg->ext_dat;
if (!fs || !fs->xinf || !dc || !dc->col.col) return;
if (!surface || !surface->image || !surface->image->data) return;
target_surface = (Xrender_Surface *)(surface->image->data);
if (!surface || !surface->image.data) return;
target_surface = (Xrender_Surface *)(surface->image.data);
a = (dc->col.col >> 24) & 0xff;
r = (dc->col.col >> 16) & 0xff;
g = (dc->col.col >> 8 ) & 0xff;

View File

@ -160,32 +160,26 @@ _xre_gradient_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, XR_Gradient *gr,
RGBA_Image *im;
Ximage_Image *xim;
im = evas_common_image_new();
if (!im)
{
_xr_render_surface_free(gr->surface);
gr->surface = NULL;
return;
}
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
evas_common_image_delete(im);
_xr_render_surface_free(gr->surface);
gr->surface = NULL;
return;
}
xim = _xr_image_new(gr->xinf, w, h, gr->surface->depth);
if (!xim)
{
evas_common_image_delete(im);
_xr_render_surface_free(gr->surface);
gr->surface = NULL;
return;
}
im->image->data = (DATA32 *)xim->data;
im->image->w = w; im->image->h = h;
im->image->no_free = 1;
im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
w, h,
(DATA32 *)xim->data,
1, EVAS_COLORSPACE_ARGB8888);
if (!im)
{
/* FIXME: xim is leaking. */
_xr_render_surface_free(gr->surface);
gr->surface = NULL;
return;
}
dc->render_op = _EVAS_RENDER_FILL;
dc->clip.use = 0;
evas_common_gradient_draw(im, dc, 0, 0, w, h, gr->grad);
@ -196,7 +190,7 @@ _xre_gradient_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, XR_Gradient *gr,
(xim->xim->byte_order == MSBFirst)
#endif
{
DATA32 *p = im->image->data, *pe = p + (w * h);
DATA32 *p = im->image.data, *pe = p + (w * h);
while (p < pe)
{
*p = (*p << 24) + ((*p << 8) & 0xff0000) + ((*p >> 8) & 0xff00) + (*p >> 24);
@ -204,7 +198,7 @@ _xre_gradient_draw(Xrender_Surface *rs, RGBA_Draw_Context *dc, XR_Gradient *gr,
}
}
_xr_image_put(xim, gr->surface->draw, 0, 0, w, h);
evas_common_image_delete(im);
evas_cache_image_drop(&im->cache_entry);
dc->render_op = op;
dc->clip.use = cuse;
}

View File

@ -106,8 +106,8 @@ _xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image
im->fkey = strdup(buf);
im->file = evas_stringshare_add(file);
if (key) im->key = evas_stringshare_add(key);
im->w = im->im->image->w;
im->h = im->im->image->h;
im->w = im->im->cache_entry.w;
im->h = im->im->cache_entry.h;
im->references = 1;
if (lo) im->load_opts = *lo;
if (im->im->info.comment) im->comment = evas_stringshare_add(im->im->info.comment);
@ -235,7 +235,7 @@ __xre_image_real_free(XR_Image *im)
if (im->file) evas_stringshare_del(im->file);
if (im->key) evas_stringshare_del(im->key);
if (im->fkey) free(im->fkey);
if (im->im) evas_cache_image_drop(im->im);
if (im->im) evas_cache_image_drop(&im->im->cache_entry);
if ((im->data) && (im->dirty)) __xre_image_dirty_hash_del(im);
if ((im->free_data) && (im->data)) free(im->data);
if (im->surface) _xr_render_surface_free(im->surface);
@ -301,8 +301,8 @@ _xre_image_copy(XR_Image *im)
im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
if (im->im)
{
evas_common_load_image_data_from_file(im->im);
data = im->im->image->data;
evas_cache_image_load_data(&im->im->cache_entry);
data = im->im->image.data;
}
}
if (!data) return NULL;
@ -334,7 +334,7 @@ _xre_image_resize(XR_Image *im, int w, int h)
}
else if (im->im)
{
evas_cache_image_drop(im->im);
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
if (im->free_data)
{
@ -360,7 +360,7 @@ _xre_image_resize(XR_Image *im, int w, int h)
}
if (im->im)
{
evas_cache_image_drop(im->im);
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (!im->cs.no_free)
@ -391,8 +391,8 @@ _xre_image_data_get(XR_Image *im)
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
if (im->im)
{
evas_common_load_image_data_from_file(im->im);
data = im->im->image->data;
evas_cache_image_load_data(&im->im->cache_entry);
data = im->im->image.data;
}
}
return data;
@ -420,8 +420,8 @@ _xre_image_data_put(XR_Image *im, void *data)
case EVAS_COLORSPACE_ARGB8888:
if (im->im)
{
if (data == im->im->image->data) return;
evas_cache_image_drop(im->im);
if (data == im->im->image.data) return;
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (im->cs.data == data) return;
@ -519,7 +519,7 @@ _xre_image_alpha_get(XR_Image *im)
{
if (im->im)
{
if (im->im->cs.space != EVAS_COLORSPACE_ARGB8888) return 0;
if (im->im->cache_entry.space != EVAS_COLORSPACE_ARGB8888) return 0;
}
return im->alpha;
}
@ -559,8 +559,8 @@ _xre_image_surface_gen(XR_Image *im)
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
if (im->im)
{
evas_common_load_image_data_from_file(im->im);
data = im->im->image->data;
evas_cache_image_load_data(&im->im->cache_entry);
data = im->im->image.data;
}
}
if (!data)
@ -656,7 +656,7 @@ _xre_image_surface_gen(XR_Image *im)
im->w + 2, 1);
if ((im->im) && (!im->dirty))
{
evas_cache_image_drop(im->im);
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
if (tdata) free(tdata);

View File

@ -761,35 +761,31 @@ eng_image_cache_get(void *data)
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
{
Render_Engine *re;
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *)data;
{
static RGBA_Image *im = NULL;
if (!im)
{
im = evas_common_image_new();
im->image = evas_common_image_surface_new(im);
im->image->no_free = 1;
}
im->image->w = ((Xcb_Render_Surface *)surface)->w;
im->image->h = ((Xcb_Render_Surface *)surface)->h;
_xr_render_surface_clips_set((Xcb_Render_Surface *)surface, (RGBA_Draw_Context *)context, x, y, w, h);
im->image->data = surface;
evas_common_draw_context_font_ext_set(context,
re->xcbinf,
_xre_font_surface_new,
_xre_font_surface_free,
_xre_font_surface_draw);
evas_common_font_draw(im, context, font, x, y, text);
evas_common_draw_context_font_ext_set(context,
NULL,
NULL,
NULL,
NULL);
evas_common_cpu_end_opt();
}
im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
((Xcb_Render_Surface *)surface)->w,
((Xcb_Render_Surface *)surface)->h,
surface,
0, EVAS_COLORSPACE_ARGB8888);
_xr_render_surface_clips_set((Xcb_Render_Surface *)surface, (RGBA_Draw_Context *)context, x, y, w, h);
evas_common_draw_context_font_ext_set(context,
re->xcbinf,
_xre_font_surface_new,
_xre_font_surface_free,
_xre_font_surface_draw);
evas_common_font_draw(im, context, font, x, y, text);
evas_common_draw_context_font_ext_set(context,
NULL,
NULL,
NULL,
NULL);
evas_common_cpu_end_opt();
}
/* module advertising code */

View File

@ -167,7 +167,7 @@ _xre_font_surface_draw(Xcb_Image_Info *xcbinf, RGBA_Image *surface, RGBA_Draw_Co
fs = fg->ext_dat;
if (!fs) return;
target_surface = (Xcb_Render_Surface *)(surface->image->data);
target_surface = (Xcb_Render_Surface *)(surface->image.data);
a = (dc->col.col >> 24) & 0xff;
r = (dc->col.col >> 16) & 0xff;
g = (dc->col.col >> 8 ) & 0xff;

View File

@ -159,18 +159,19 @@ _xre_gradient_draw(Xcb_Render_Surface *rs, RGBA_Draw_Context *dc, XR_Gradient *g
int op = dc->render_op, cuse = dc->clip.use;
RGBA_Image *im;
im = evas_common_image_create(w, h);
if (!im)
im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
if (!im)
{
_xr_render_surface_free(gr->surface);
gr->surface = NULL;
return;
}
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
dc->render_op = _EVAS_RENDER_FILL;
dc->clip.use = 0;
evas_common_gradient_draw(im, dc, 0, 0, w, h, gr->grad);
_xr_render_surface_argb_pixels_fill(gr->surface, w, h, im->image->data, 0, 0, w, h);
evas_common_image_free(im);
_xr_render_surface_argb_pixels_fill(gr->surface, w, h, im->image.data, 0, 0, w, h);
evas_cache_image_drop(&im->cache_entry);
dc->render_op = op;
dc->clip.use = cuse;
}

View File

@ -105,8 +105,8 @@ _xre_image_load(Xcb_Image_Info *xcbinf, const char *file, const char *key, Evas_
im->fkey = strdup(buf);
im->file = (char *)evas_stringshare_add(file);
if (key) im->key = (char *)evas_stringshare_add(key);
im->w = im->im->image->w;
im->h = im->im->image->h;
im->w = im->im->cache_entry.w;
im->h = im->im->cache_entry.h;
im->references = 1;
if (lo) im->load_opts = *lo;
if (im->im->info.comment) im->comment = (char *)evas_stringshare_add(im->im->info.comment);
@ -199,7 +199,7 @@ __xre_image_real_free(XR_Image *im)
if (im->file) evas_stringshare_del(im->file);
if (im->key) evas_stringshare_del(im->key);
if (im->fkey) free(im->fkey);
if (im->im) evas_cache_image_drop(im->im);
if (im->im) evas_cache_image_drop(&im->im->cache_entry);
if ((im->data) && (im->dirty)) __xre_image_dirty_hash_del(im);
if ((im->free_data) && (im->data)) free(im->data);
if (im->surface) _xr_render_surface_free(im->surface);
@ -263,8 +263,8 @@ _xre_image_copy(XR_Image *im)
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
if (im->im)
{
evas_common_load_image_data_from_file(im->im);
data = im->im->image->data;
evas_cache_image_load_data(&im->im->cache_entry);
data = im->im->image.data;
}
}
if (!data) return NULL;
@ -272,7 +272,7 @@ _xre_image_copy(XR_Image *im)
if (im2) im2->alpha = im->alpha;
if ((im->im) && (!im->dirty))
{
evas_cache_image_drop(im->im);
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
return im2;
@ -337,7 +337,7 @@ _xre_image_resize(XR_Image *im, int w, int h)
RGBA_Image *im_old;
im_old = im->im;
im->im = evas_cache_image_empty(evas_common_image_cache_get());
im->im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
if (!im->im)
{
im->im = im_old;
@ -348,11 +348,8 @@ _xre_image_resize(XR_Image *im, int w, int h)
}
return;
}
im->im->image->w = w;
im->im->image->h = h;
evas_common_image_surface_alloc(im->im->image);
evas_common_load_image_data_from_file(im_old);
if (im_old->image->data)
evas_cache_image_load_data(&im->im->cache_entry);
if (im_old->image.data)
{
int x = 0, y = 0, ww, hh;
@ -363,11 +360,11 @@ _xre_image_resize(XR_Image *im, int w, int h)
}
im->free_data = 1;
/* FIXME: Hum ? */
im->data = im->im->image->data;
im->im->image->data = NULL;
evas_cache_image_drop(im->im);
im->data = im->im->image.data;
im->im->image.data = NULL;
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
evas_cache_image_drop(im_old);
evas_cache_image_drop(&im_old->cache_entry);
__xre_image_dirty_hash_add(im);
}
else
@ -391,8 +388,8 @@ _xre_image_data_get(XR_Image *im)
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
if (im->im)
{
evas_common_load_image_data_from_file(im->im);
data = im->im->image->data;
evas_cache_image_load_data(&im->im->cache_entry);
data = im->im->image.data;
}
}
return data;
@ -426,11 +423,11 @@ _xre_image_data_put(XR_Image *im, void *data)
}
else
{
if (im->im) imdata = im->im->image->data;
if (im->im) imdata = im->im->image.data;
if (data == imdata) return;
if (im->im)
{
evas_cache_image_drop(im->im);
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
}
@ -525,8 +522,8 @@ _xre_image_surface_gen(XR_Image *im)
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
if (im->im)
{
evas_common_load_image_data_from_file(im->im);
data = im->im->image->data;
evas_cache_image_load_data(&im->im->cache_entry);
data = im->im->image.data;
}
}
if (!data) return;
@ -584,7 +581,7 @@ _xre_image_surface_gen(XR_Image *im)
1, 1);
if ((im->im) && (!im->dirty))
{
evas_cache_image_drop(im->im);
evas_cache_image_drop(&im->im->cache_entry);
im->im = NULL;
}
}

View File

@ -73,16 +73,8 @@ evas_image_load_file_head_edb(RGBA_Image *im, const char *file, const char *key)
return 0;
}
if (alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
free(ret);
e_db_close(db);
return 0;
}
im->image->w = w;
im->image->h = h;
im->cache_entry.w = w;
im->cache_entry.h = h;
free(ret);
e_db_close(db);
return 1;
@ -145,19 +137,9 @@ evas_image_load_file_data_edb(RGBA_Image *im, const char *file, const char *key)
return 0;
}
if (alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
free(ret);
e_db_close(db);
return 0;
}
im->image->w = w;
im->image->h = h;
body = &(ret[8]);
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
if (!im->image.data)
{
free(ret);
e_db_close(db);
@ -169,11 +151,11 @@ evas_image_load_file_data_edb(RGBA_Image *im, const char *file, const char *key)
{
int x;
memcpy(im->image->data, body, w * h * sizeof(DATA32));
for (x = 0; x < (w * h); x++) SWAP32(im->image->data[x]);
memcpy(im->image.data, body, w * h * sizeof(DATA32));
for (x = 0; x < (w * h); x++) SWAP32(im->image.data[x]);
}
#else
memcpy(im->image->data, body, w * h * sizeof(DATA32));
memcpy(im->image.data, body, w * h * sizeof(DATA32));
#endif
}
else
@ -181,13 +163,13 @@ evas_image_load_file_data_edb(RGBA_Image *im, const char *file, const char *key)
uLongf dlen;
dlen = w * h * sizeof(DATA32);
uncompress((Bytef *)im->image->data, &dlen, (Bytef *)body,
uncompress((Bytef *)im->image.data, &dlen, (Bytef *)body,
(uLongf)(size - 32));
#ifdef WORDS_BIGENDIAN
{
int x;
for (x = 0; x < (w * h); x++) SWAP32(im->image->data[x]);
for (x = 0; x < (w * h); x++) SWAP32(im->image.data[x]);
}
#endif
}

View File

@ -42,15 +42,8 @@ evas_image_load_file_head_eet(RGBA_Image *im, const char *file, const char *key)
return 0;
}
if (alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
eet_close(ef);
return 0;
}
im->image->w = w;
im->image->h = h;
im->cache_entry.w = w;
im->cache_entry.h = h;
eet_close(ef);
return 1;
}
@ -65,7 +58,7 @@ evas_image_load_file_data_eet(RGBA_Image *im, const char *file, const char *key)
DATA32 nas = 0;
if ((!file) || (!key)) return 0;
if ((im->image) && (im->image->data)) return 1;
if (im->image.data) return 1;
ef = eet_open((char *)file, EET_FILE_MODE_READ);
if (!ef) return 0;
body = eet_data_image_read(ef, (char *)key,
@ -82,18 +75,10 @@ evas_image_load_file_data_eet(RGBA_Image *im, const char *file, const char *key)
return 0;
}
if (alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
free(body);
eet_close(ef);
return 0;
}
im->image->w = w;
im->image->h = h;
im->image->data = body;
im->image->no_free = 0;
im->cache_entry.w = w;
im->cache_entry.h = h;
im->image.data = body;
im->image.no_free = 0;
if (alpha)
{
end = body +(w * h);
@ -111,7 +96,7 @@ evas_image_load_file_data_eet(RGBA_Image *im, const char *file, const char *key)
if (b > a) b = a;
*p = ARGB_JOIN(a, r, g, b);
}
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->image->w * im->image->h))
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->cache_entry.w * im->cache_entry.h))
im->flags |= RGBA_IMAGE_ALPHA_SPARSE;
}
// result is already premultiplied now if u compile with edje

View File

@ -94,15 +94,8 @@ evas_image_load_file_head_gif(RGBA_Image *im, const char *file, const char *key)
} while (rec != TERMINATE_RECORD_TYPE);
if (alpha >= 0) im->flags |= RGBA_IMAGE_HAS_ALPHA;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
DGifCloseFile(gif);
return 0;
}
im->image->w = w;
im->image->h = h;
im->cache_entry.w = w;
im->cache_entry.h = h;
DGifCloseFile(gif);
return 1;
@ -241,20 +234,9 @@ evas_image_load_file_data_gif(RGBA_Image *im, const char *file, const char *key)
} while (rec != TERMINATE_RECORD_TYPE);
if (alpha >= 0) im->flags |= RGBA_IMAGE_HAS_ALPHA;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
if (!im->image.data)
{
DGifCloseFile(gif);
return 0;
}
im->image->w = w;
im->image->h = h;
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
{
evas_common_image_surface_free(im->image);
DGifCloseFile(gif);
for (i = 0; i < h; i++)
{
@ -267,7 +249,7 @@ evas_image_load_file_data_gif(RGBA_Image *im, const char *file, const char *key)
bg = gif->SBackGroundColor;
cmap = (gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap);
ptr = im->image->data;
ptr = im->image.data;
per_inc = 100.0 / (((double)w) * h);
for (i = 0; i < h; i++)

View File

@ -89,16 +89,11 @@ evas_image_load_file_head_jpeg_internal(RGBA_Image *im, FILE *f)
jpeg_read_header(&cinfo, TRUE);
cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE;
cinfo.dct_method = JDCT_IFAST;
cinfo.dither_mode = JDITHER_ORDERED;
jpeg_start_decompress(&cinfo);
/* head decoding */
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
jpeg_destroy_decompress(&cinfo);
return 0;
}
w = cinfo.output_width;
h = cinfo.output_height;
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
@ -106,27 +101,27 @@ evas_image_load_file_head_jpeg_internal(RGBA_Image *im, FILE *f)
jpeg_destroy_decompress(&cinfo);
return 0;
}
if (im->load_opts.scale_down_by > 1)
if (im->cache_entry.load_opts.scale_down_by > 1)
{
w /= im->load_opts.scale_down_by;
h /= im->load_opts.scale_down_by;
w /= im->cache_entry.load_opts.scale_down_by;
h /= im->cache_entry.load_opts.scale_down_by;
}
else if (im->load_opts.dpi > 0.0)
else if (im->cache_entry.load_opts.dpi > 0.0)
{
w = (w * im->load_opts.dpi) / 90.0;
h = (h * im->load_opts.dpi) / 90.0;
w = (w * im->cache_entry.load_opts.dpi) / 90.0;
h = (h * im->cache_entry.load_opts.dpi) / 90.0;
}
else if ((im->load_opts.w > 0) &&
(im->load_opts.h > 0))
else if ((im->cache_entry.load_opts.w > 0) &&
(im->cache_entry.load_opts.h > 0))
{
int w2, h2;
w2 = im->load_opts.w;
h2 = (im->load_opts.w * h) / w;
if (h2 > im->load_opts.h)
w2 = im->cache_entry.load_opts.w;
h2 = (im->cache_entry.load_opts.w * h) / w;
if (h2 > im->cache_entry.load_opts.h)
{
h2 = im->load_opts.h;
w2 = (im->load_opts.h * w) / h;
h2 = im->cache_entry.load_opts.h;
w2 = (im->cache_entry.load_opts.h * w) / h;
}
w = w2;
h = h2;
@ -139,19 +134,19 @@ evas_image_load_file_head_jpeg_internal(RGBA_Image *im, FILE *f)
scalew = cinfo.output_width / w;
scaleh = cinfo.output_height / h;
im->scale = scalew;
if (scaleh < scalew) im->scale = scaleh;
im->cache_entry.scale = scalew;
if (scaleh < scalew) im->cache_entry.scale = scaleh;
if (im->scale > 8) im->scale = 8;
else if (im->scale < 1) im->scale = 1;
if (im->cache_entry.scale > 8) im->cache_entry.scale = 8;
else if (im->cache_entry.scale < 1) im->cache_entry.scale = 1;
if (im->scale == 3) im->scale = 2;
else if (im->scale == 5) im->scale = 4;
else if (im->scale == 6) im->scale = 4;
else if (im->scale == 7) im->scale = 4;
if (im->cache_entry.scale == 3) im->cache_entry.scale = 2;
else if (im->cache_entry.scale == 5) im->cache_entry.scale = 4;
else if (im->cache_entry.scale == 6) im->cache_entry.scale = 4;
else if (im->cache_entry.scale == 7) im->cache_entry.scale = 4;
}
if (im->scale > 1)
if (im->cache_entry.scale > 1)
{
jpeg_destroy_decompress(&cinfo);
@ -162,13 +157,13 @@ evas_image_load_file_head_jpeg_internal(RGBA_Image *im, FILE *f)
cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE;
cinfo.scale_num = 1;
cinfo.scale_denom = im->scale;
cinfo.scale_denom = im->cache_entry.scale;
jpeg_calc_output_dimensions(&(cinfo));
jpeg_start_decompress(&cinfo);
}
im->image->w = cinfo.output_width;
im->image->h = cinfo.output_height;
im->cache_entry.w = cinfo.output_width;
im->cache_entry.h = cinfo.output_height;
/* end head decoding */
jpeg_destroy_decompress(&cinfo);
@ -201,11 +196,12 @@ evas_image_load_file_data_jpeg_internal(RGBA_Image *im, FILE *f)
cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE;
cinfo.dct_method = JDCT_IFAST;
if (im->scale > 1)
cinfo.dither_mode = JDITHER_ORDERED;
if (im->cache_entry.scale > 1)
{
cinfo.scale_num = 1;
cinfo.scale_denom = im->scale;
cinfo.scale_denom = im->cache_entry.scale;
}
/* head decoding */
@ -215,7 +211,7 @@ evas_image_load_file_data_jpeg_internal(RGBA_Image *im, FILE *f)
w = cinfo.output_width;
h = cinfo.output_height;
if ((w != im->image->w) || (h != im->image->h))
if ((w != im->cache_entry.w) || (h != im->cache_entry.h))
{
jpeg_destroy_decompress(&cinfo);
return 0;
@ -229,13 +225,13 @@ evas_image_load_file_data_jpeg_internal(RGBA_Image *im, FILE *f)
return 0;
}
data = alloca(w * 16 * 3);
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
if (!im->image.data)
{
jpeg_destroy_decompress(&cinfo);
return 0;
}
ptr2 = im->image->data;
ptr2 = im->image.data;
count = 0;
prevy = 0;
if (cinfo.output_components == 3)

View File

@ -80,16 +80,8 @@ evas_image_load_file_head_pmaps(RGBA_Image *im, const char *file,
return 0;
}
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
pmaps_buffer_close(&b);
return 0;
}
im->image->w = b.w;
im->image->h = b.h;
im->cache_entry.w = b.w;
im->cache_entry.h = b.h;
pmaps_buffer_close(&b);
return 1;
@ -122,23 +114,14 @@ evas_image_load_file_data_pmaps(RGBA_Image *im, const char *file,
pixels = b.w * b.h;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
evas_cache_image_surface_alloc(&im->cache_entry, b.w, b.h);
if (!im->image.data)
{
pmaps_buffer_close(&b);
return 0;
}
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
{
evas_common_image_surface_free(im->image);
pmaps_buffer_close(&b);
return 0;
}
ptr = im->image->data;
ptr = im->image.data;
if (b.type[1] != '4')
{

View File

@ -80,16 +80,8 @@ evas_image_load_file_head_png(RGBA_Image *im, const char *file, const char *key)
fclose(f);
return 0;
}
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(f);
return 0;
}
im->image->w = (int) w32;
im->image->h = (int) h32;
im->cache_entry.w = (int) w32;
im->cache_entry.h = (int) h32;
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) hasa = 1;
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) hasa = 1;
if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) hasa = 1;
@ -151,7 +143,14 @@ evas_image_load_file_data_png(RGBA_Image *im, const char *file, const char *key)
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *) (&w32),
(png_uint_32 *) (&h32), &bit_depth, &color_type,
&interlace_type, NULL, NULL);
if ((w32 != im->image->w) || (h32 != im->image->h))
evas_cache_image_surface_alloc(&im->cache_entry, w32, h32);
if (!im->image.data)
{
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(f);
return 0;
}
if ((w32 != im->cache_entry.w) || (h32 != im->cache_entry.h))
{
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(f);
@ -179,9 +178,9 @@ evas_image_load_file_data_png(RGBA_Image *im, const char *file, const char *key)
if (bit_depth > 8) png_set_strip_16(png_ptr);
/* pack all pixels to byte boundaries */
png_set_packing(png_ptr);
w = im->image->w;
h = im->image->h;
w = im->cache_entry.w;
h = im->cache_entry.h;
/* we want ARGB */
#ifdef WORDS_BIGENDIAN
png_set_swap_alpha(png_ptr);
@ -190,23 +189,16 @@ evas_image_load_file_data_png(RGBA_Image *im, const char *file, const char *key)
png_set_bgr(png_ptr);
if (!hasa) png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
#endif
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
{
evas_common_image_surface_free(im->image);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(f);
return 0;
}
lines = (unsigned char **) alloca(h * sizeof(unsigned char *));
for (i = 0; i < h; i++)
lines[i] = ((unsigned char *)(im->image->data)) + (i * w * sizeof(DATA32));
lines[i] = ((unsigned char *)(im->image.data)) + (i * w * sizeof(DATA32));
png_read_image(png_ptr, lines);
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(f);
evas_common_image_premul(im);
return 1;
key = 0;
}

View File

@ -50,7 +50,7 @@ evas_image_load_file_head_svg(RGBA_Image *im, const char *file, const char *key)
/* ignore all files not called .svg or .svg.gz - because rsvg has a leak
* where closing the handle doesn't free mem */
ext = strrchr(file, '.');
if (!ext) return;
if (!ext) return 0;
if (!strcasecmp(ext, ".gz"))
{
if (p > file)
@ -81,61 +81,47 @@ evas_image_load_file_head_svg(RGBA_Image *im, const char *file, const char *key)
chdir(pcwd);
return 0;
}
if (!im->image)
{
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
// rsvg_handle_free(rsvg);
chdir(pcwd);
return 0;
}
}
rsvg_handle_get_dimensions(rsvg, &dim);
w = dim.width;
h = dim.height;
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
evas_common_image_surface_free(im->image);
im->image = NULL;
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
// rsvg_handle_free(rsvg);
chdir(pcwd);
return 0;
}
if (im->load_opts.scale_down_by > 1)
if (im->cache_entry.load_opts.scale_down_by > 1)
{
w /= im->load_opts.scale_down_by;
h /= im->load_opts.scale_down_by;
w /= im->cache_entry.load_opts.scale_down_by;
h /= im->cache_entry.load_opts.scale_down_by;
}
else if (im->load_opts.dpi > 0.0)
else if (im->cache_entry.load_opts.dpi > 0.0)
{
w = (w * im->load_opts.dpi) / 90.0;
h = (h * im->load_opts.dpi) / 90.0;
w = (w * im->cache_entry.load_opts.dpi) / 90.0;
h = (h * im->cache_entry.load_opts.dpi) / 90.0;
}
else if ((im->load_opts.w > 0) &&
(im->load_opts.h > 0))
else if ((im->cache_entry.load_opts.w > 0) &&
(im->cache_entry.load_opts.h > 0))
{
int w2, h2;
w2 = im->load_opts.w;
h2 = (im->load_opts.w * h) / w;
if (h2 > im->load_opts.h)
w2 = im->cache_entry.load_opts.w;
h2 = (im->cache_entry.load_opts.w * h) / w;
if (h2 > im->cache_entry.load_opts.h)
{
h2 = im->load_opts.h;
w2 = (im->load_opts.h * w) / h;
h2 = im->cache_entry.load_opts.h;
w2 = (im->cache_entry.load_opts.h * w) / h;
}
w = w2;
h = h2;
}
if (w < 1) w = 1;
if (h < 1) h = 1;
im->image->w = w;
im->image->h = h;
im->cache_entry.w = w;
im->cache_entry.h = h;
im->flags |= RGBA_IMAGE_HAS_ALPHA;
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
@ -157,12 +143,11 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
char *ext;
if (!file) return 0;
if (!im->image) return 0;
/* ignore all files not called .svg or .svg.gz - because rsvg has a leak
* where closing the handle doesn't free mem */
ext = strrchr(file, '.');
if (!ext) return;
if (!ext) return 0;
if (!strcasecmp(ext, ".gz"))
{
if (p > file)
@ -190,8 +175,6 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
rsvg = rsvg_handle_new_from_file(file, NULL);
if (!rsvg)
{
evas_common_image_surface_free(im->image);
im->image = NULL;
chdir(pcwd);
return 0;
}
@ -201,49 +184,43 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
h = dim.height;
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
evas_common_image_surface_free(im->image);
im->image = NULL;
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
// rsvg_handle_free(rsvg);
chdir(pcwd);
return 0;
}
if (im->load_opts.scale_down_by > 1)
if (im->cache_entry.load_opts.scale_down_by > 1)
{
w /= im->load_opts.scale_down_by;
h /= im->load_opts.scale_down_by;
w /= im->cache_entry.load_opts.scale_down_by;
h /= im->cache_entry.load_opts.scale_down_by;
}
else if (im->load_opts.dpi > 0.0)
else if (im->cache_entry.load_opts.dpi > 0.0)
{
w = (w * im->load_opts.dpi) / 90.0;
h = (h * im->load_opts.dpi) / 90.0;
w = (w * im->cache_entry.load_opts.dpi) / 90.0;
h = (h * im->cache_entry.load_opts.dpi) / 90.0;
}
else if ((im->load_opts.w > 0) &&
(im->load_opts.h > 0))
else if ((im->cache_entry.load_opts.w > 0) &&
(im->cache_entry.load_opts.h > 0))
{
int w2, h2;
w2 = im->load_opts.w;
h2 = (im->load_opts.w * h) / w;
if (h2 > im->load_opts.h)
w2 = im->cache_entry.load_opts.w;
h2 = (im->cache_entry.load_opts.w * h) / w;
if (h2 > im->cache_entry.load_opts.h)
{
h2 = im->load_opts.h;
w2 = (im->load_opts.h * w) / h;
h2 = im->cache_entry.load_opts.h;
w2 = (im->cache_entry.load_opts.h * w) / h;
}
w = w2;
h = h2;
}
if (w < 1) w = 1;
if (h < 1) h = 1;
im->image->w = w;
im->image->h = h;
im->flags |= RGBA_IMAGE_HAS_ALPHA;
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
if (!im->image.data)
{
evas_common_image_surface_free(im->image);
im->image = NULL;
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
// rsvg_handle_free(rsvg);
@ -251,14 +228,12 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
return 0;
}
memset(im->image->data, 0, w * h * sizeof(DATA32));
memset(im->image.data, 0, w * h * sizeof(DATA32));
surface = cairo_image_surface_create_for_data((unsigned char *)im->image->data, CAIRO_FORMAT_ARGB32,
surface = cairo_image_surface_create_for_data((unsigned char *)im->image.data, CAIRO_FORMAT_ARGB32,
w, h, w * sizeof(DATA32));
if (!surface)
{
evas_common_image_surface_free(im->image);
im->image = NULL;
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
// rsvg_handle_free(rsvg);
@ -269,8 +244,6 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
if (!cr)
{
cairo_surface_destroy(surface);
evas_common_image_surface_free(im->image);
im->image = NULL;
// rsvg_handle_close(rsvg, NULL);
g_object_unref(rsvg);
// rsvg_handle_free(rsvg);
@ -279,8 +252,8 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
}
cairo_scale(cr,
(double)im->image->w / dim.em,
(double)im->image->h / dim.ex);
(double)im->cache_entry.w / dim.em,
(double)im->cache_entry.h / dim.ex);
rsvg_handle_render_cairo(rsvg, cr);
cairo_surface_destroy(surface);
/* need to check if this is required... */

View File

@ -69,11 +69,11 @@ raster(TIFFRGBAImage_Extra * img, uint32 * rast,
int image_width, image_height;
uint32 *pixel, pixel_value;
int i, j, dy, rast_offset;
DATA32 *buffer_pixel, *buffer = img->image->image->data;
DATA32 *buffer_pixel, *buffer = img->image->image.data;
int alpha_premult;
image_width = img->image->image->w;
image_height = img->image->image->h;
image_width = img->image->cache_entry.w;
image_height = img->image->cache_entry.h;
dy = h > y ? -1 : y - h;
@ -163,13 +163,6 @@ evas_image_load_file_head_tiff(RGBA_Image *im, const char *file, const char *key
return 0;
}
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
TIFFClose(tif);
return 0;
}
if (tiff_image.alpha != EXTRASAMPLE_UNSPECIFIED)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
if ((tiff_image.width < 1) || (tiff_image.height < 1) ||
@ -178,8 +171,8 @@ evas_image_load_file_head_tiff(RGBA_Image *im, const char *file, const char *key
TIFFClose(tif);
return 0;
}
im->image->w = tiff_image.width;
im->image->h = tiff_image.height;
im->cache_entry.w = tiff_image.width;
im->cache_entry.h = tiff_image.height;
TIFFClose(tif);
return 1;
@ -238,36 +231,26 @@ evas_image_load_file_data_tiff(RGBA_Image *im, const char *file, const char *key
}
rgba_image.image = im;
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
TIFFClose(tif);
return 0;
}
if (rgba_image.rgba.alpha != EXTRASAMPLE_UNSPECIFIED)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
if ((rgba_image.rgba.width != im->image->w) ||
(rgba_image.rgba.height != im->image->h))
if ((rgba_image.rgba.width != im->cache_entry.w) ||
(rgba_image.rgba.height != im->cache_entry.h))
{
TIFFClose(tif);
return 0;
}
im->image->w = rgba_image.rgba.width;
im->image->h = rgba_image.rgba.height;
rgba_image.num_pixels = num_pixels = im->image->w * im->image->h;
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
evas_cache_image_surface_alloc(&im->cache_entry, rgba_image.rgba.width, rgba_image.rgba.height);
if (!im->image.data)
{
evas_common_image_surface_free(im->image);
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
TIFFClose(tif);
return 0;
}
rgba_image.num_pixels = num_pixels = im->cache_entry.w * im->cache_entry.h;
rgba_image.pper = rgba_image.py = 0;
rast = (uint32 *) _TIFFmalloc(sizeof(uint32) * num_pixels);
@ -285,7 +268,6 @@ evas_image_load_file_data_tiff(RGBA_Image *im, const char *file, const char *key
{
fprintf(stderr, "Evas Tiff loader: no put function");
evas_common_image_surface_free(im->image);
_TIFFfree(rast);
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
TIFFClose(tif);
@ -305,13 +287,13 @@ evas_image_load_file_data_tiff(RGBA_Image *im, const char *file, const char *key
rgba_image.rgba.put.separate = put_separate_and_raster;
}
}
/* if (rgba_image.rgba.samplesperpixel == 8)*/
if (rgba_image.rgba.bitspersample == 8)
{
if (!TIFFRGBAImageGet((TIFFRGBAImage *) &rgba_image, rast,
rgba_image.rgba.width, rgba_image.rgba.height))
{
evas_common_image_surface_free(im->image);
_TIFFfree(rast);
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
TIFFClose(tif);

View File

@ -249,20 +249,8 @@ evas_image_load_file_xpm(RGBA_Image *im, const char *file, const char *key, int
return 0;
}
}
if (!im->image)
{
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
free(cmap);
free(line);
fclose(f);
xpm_parse_done();
return 0;
}
}
im->image->w = w;
im->image->h = h;
im->cache_entry.w = w;
im->cache_entry.h = h;
j = 0;
context++;
@ -376,22 +364,16 @@ evas_image_load_file_xpm(RGBA_Image *im, const char *file, const char *key, int
if (load_data)
{
if (im->image->data)
evas_common_image_surface_dealloc(im->image);
im->image->w = w;
im->image->h = h;
evas_common_image_surface_alloc(im->image);
if (!im->image->data)
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
if (!im->image.data)
{
evas_common_image_surface_free(im->image);
im->image = NULL;
free(cmap);
free(line);
fclose(f);
xpm_parse_done();
return 0;
}
ptr = im->image->data;
ptr = im->image.data;
end = ptr + (w * h);
pixels = w * h;
}
@ -612,7 +594,7 @@ evas_image_load_file_xpm(RGBA_Image *im, const char *file, const char *key, int
if (!tl) break;
line = tl;
}
if (((ptr) && ((ptr - im->image->data) >= (w * h * sizeof(DATA32)))) ||
if (((ptr) && ((ptr - im->image.data) >= (w * h * sizeof(DATA32)))) ||
((context > 1) && (count >= pixels)))
break;
}

View File

@ -21,7 +21,7 @@ evas_image_save_file_eet(RGBA_Image *im, const char *file, const char *key, int
int alpha = 0, lossy = 0, ok = 0;
DATA32 *data;
if (!im || !im->image || !im->image->data || !file)
if (!im || !im->image.data || !file)
return 0;
ef = eet_open((char *)file, EET_FILE_MODE_READ_WRITE);
@ -41,9 +41,9 @@ evas_image_save_file_eet(RGBA_Image *im, const char *file, const char *key, int
// evas_common_convert_argb_unpremul(data, im->image->w * im->image->h);
// }
// else
data = im->image->data;
data = im->image.data;
ok = eet_data_image_write(ef, (char *)key, data,
im->image->w, im->image->h, alpha, compress,
im->cache_entry.w, im->cache_entry.h, alpha, compress,
quality, lossy);
// if (alpha)
// free(data);

View File

@ -63,10 +63,10 @@ save_image_jpeg(RGBA_Image *im, const char *file, int quality)
int y = 0;
int i, j;
if (!im || !im->image || !im->image->data || !file)
if (!im || !im->image.data || !file)
return 0;
buf = alloca(im->image->w * 3 * sizeof(DATA8));
buf = alloca(im->cache_entry.w * 3 * sizeof(DATA8));
f = fopen(file, "wb");
if (!f)
{
@ -84,17 +84,17 @@ save_image_jpeg(RGBA_Image *im, const char *file, int quality)
}
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, f);
cinfo.image_width = im->image->w;
cinfo.image_height = im->image->h;
cinfo.image_width = im->cache_entry.w;
cinfo.image_height = im->cache_entry.h;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE);
jpeg_start_compress(&cinfo, TRUE);
ptr = im->image->data;
ptr = im->image.data;
while (cinfo.next_scanline < cinfo.image_height)
{
for (j = 0, i = 0; i < im->image->w; i++)
for (j = 0, i = 0; i < im->cache_entry.w; i++)
{
buf[j++] = ((*ptr) >> 16) & 0xff;
buf[j++] = ((*ptr) >> 8) & 0xff;

View File

@ -27,7 +27,7 @@ save_image_png(RGBA_Image *im, const char *file, int compress, int interlace)
png_color_8 sig_bit;
int num_passes = 1, pass;
if (!im || !im->image || !im->image->data || !file)
if (!im || !im->image.data || !file)
return 0;
f = fopen(file, "wb");
@ -64,7 +64,7 @@ save_image_png(RGBA_Image *im, const char *file, int compress, int interlace)
if (im->flags & RGBA_IMAGE_HAS_ALPHA)
{
data = malloc(im->image->w * im->image->h * sizeof(DATA32));
data = malloc(im->cache_entry.w * im->cache_entry.h * sizeof(DATA32));
if (!data)
{
fclose(f);
@ -72,10 +72,10 @@ save_image_png(RGBA_Image *im, const char *file, int compress, int interlace)
png_destroy_info_struct(png_ptr, (png_infopp) & info_ptr);
return 0;
}
memcpy(data, im->image->data, im->image->w * im->image->h * sizeof(DATA32));
evas_common_convert_argb_unpremul(data, im->image->w * im->image->h);
memcpy(data, im->image.data, im->cache_entry.w * im->cache_entry.h * sizeof(DATA32));
evas_common_convert_argb_unpremul(data, im->cache_entry.w * im->cache_entry.h);
png_init_io(png_ptr, f);
png_set_IHDR(png_ptr, info_ptr, im->image->w, im->image->h, 8,
png_set_IHDR(png_ptr, info_ptr, im->cache_entry.w, im->cache_entry.h, 8,
PNG_COLOR_TYPE_RGB_ALPHA, png_ptr->interlaced,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
#ifdef WORDS_BIGENDIAN
@ -86,12 +86,12 @@ save_image_png(RGBA_Image *im, const char *file, int compress, int interlace)
}
else
{
data = im->image->data;
data = im->image.data;
png_init_io(png_ptr, f);
png_set_IHDR(png_ptr, info_ptr, im->image->w, im->image->h, 8,
png_set_IHDR(png_ptr, info_ptr, im->cache_entry.w, im->cache_entry.h, 8,
PNG_COLOR_TYPE_RGB, png_ptr->interlaced,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_data = alloca(im->image->w * 3 * sizeof(char));
png_data = alloca(im->cache_entry.w * 3 * sizeof(char));
}
sig_bit.red = 8;
sig_bit.green = 8;
@ -108,13 +108,13 @@ save_image_png(RGBA_Image *im, const char *file, int compress, int interlace)
{
ptr = data;
for (y = 0; y < im->image->h; y++)
for (y = 0; y < im->cache_entry.h; y++)
{
if (im->flags & RGBA_IMAGE_HAS_ALPHA)
row_ptr = (png_bytep) ptr;
else
{
for (j = 0, x = 0; x < im->image->w; x++)
for (j = 0, x = 0; x < im->cache_entry.w; x++)
{
png_data[j++] = (ptr[x] >> 16) & 0xff;
png_data[j++] = (ptr[x] >> 8) & 0xff;
@ -123,7 +123,7 @@ save_image_png(RGBA_Image *im, const char *file, int compress, int interlace)
row_ptr = (png_bytep) png_data;
}
png_write_rows(png_ptr, &row_ptr, 1);
ptr += im->image->w;
ptr += im->cache_entry.w;
}
}
png_write_end(png_ptr, info_ptr);

View File

@ -22,11 +22,11 @@ save_image_tiff(RGBA_Image *im, const char *file, int compress, int interlace)
int i = 0;
int has_alpha;
if (!im || !im->image || !im->image->data || !file)
if (!im || !im->image.data || !file)
return 0;
has_alpha = im->flags & RGBA_IMAGE_HAS_ALPHA;
data = im->image->data;
data = im->image.data;
tif = TIFFOpen(file, "w");
if (!tif)
@ -35,8 +35,8 @@ save_image_tiff(RGBA_Image *im, const char *file, int compress, int interlace)
/* None of the TIFFSetFields are checked for errors, but since they */
/* shouldn't fail, this shouldn't be a problem */
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, im->image->h);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, im->image->w);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, im->cache_entry.h);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, im->cache_entry.w);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
@ -67,12 +67,12 @@ save_image_tiff(RGBA_Image *im, const char *file, int compress, int interlace)
return 0;
}
for (y = 0; y < im->image->h; y++)
for (y = 0; y < im->cache_entry.h; y++)
{
i = 0;
for (x = 0; x < im->image->w; x++)
for (x = 0; x < im->cache_entry.w; x++)
{
pixel = data[(y * im->image->w) + x];
pixel = data[(y * im->cache_entry.w) + x];
r = (pixel >> 16) & 0xff;
g = (pixel >> 8) & 0xff;