2003-09-07 04:24:48 -07:00
|
|
|
#include "evas_gl_private.h"
|
2003-09-04 00:40:34 -07:00
|
|
|
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
#include "evas_cs2_private.h"
|
|
|
|
#endif
|
|
|
|
|
2013-10-16 01:20:14 -07:00
|
|
|
void
|
|
|
|
evas_gl_common_image_alloc_ensure(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
if (!im->im) return;
|
2013-10-29 03:06:33 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
im->im = (RGBA_Image *)evas_cache2_image_size_set(&im->im->cache_entry,
|
|
|
|
im->w, im->h);
|
|
|
|
else
|
|
|
|
#endif
|
2017-01-01 05:15:24 -08:00
|
|
|
im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry,
|
|
|
|
im->w, im->h);
|
2013-10-16 01:20:14 -07:00
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI void
|
2011-03-16 10:32:49 -07:00
|
|
|
evas_gl_common_image_all_unload(Evas_Engine_GL_Context *gc)
|
2010-04-12 01:23:53 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_GL_Image *im;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2010-04-12 01:23:53 -07:00
|
|
|
EINA_LIST_FOREACH(gc->shared->images, l, im)
|
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
if (im->im)
|
|
|
|
{
|
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_unload_data(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_unload_data(&im->im->cache_entry);
|
|
|
|
}
|
2010-08-26 02:40:48 -07:00
|
|
|
if (im->tex)
|
|
|
|
{
|
|
|
|
if (!im->tex->pt->dyn.img)
|
|
|
|
{
|
2013-06-23 19:41:32 -07:00
|
|
|
evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2010-08-26 02:40:48 -07:00
|
|
|
im->tex = NULL;
|
|
|
|
}
|
|
|
|
}
|
2010-04-12 01:23:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-10 22:23:10 -08:00
|
|
|
static void
|
2011-03-16 10:32:49 -07:00
|
|
|
_evas_gl_image_cache_trim(Evas_Engine_GL_Context *gc)
|
2011-02-10 22:23:10 -08:00
|
|
|
{
|
|
|
|
int size = evas_common_image_get_cache();
|
|
|
|
|
|
|
|
while (gc->shared->images_size > size)
|
|
|
|
{
|
|
|
|
Evas_GL_Image *im2;
|
|
|
|
Eina_List *l = NULL;
|
2015-04-30 08:12:55 -07:00
|
|
|
Eina_Bool removed = EINA_FALSE;
|
2011-02-10 22:23:10 -08:00
|
|
|
|
|
|
|
EINA_LIST_REVERSE_FOREACH(gc->shared->images, l, im2)
|
|
|
|
{
|
|
|
|
if (im2->references == 0)
|
|
|
|
{
|
|
|
|
im2->cached = 0;
|
2011-06-17 00:47:28 -07:00
|
|
|
im2->gc->shared->images =
|
2011-02-10 22:23:10 -08:00
|
|
|
eina_list_remove_list(im2->gc->shared->images, l);
|
|
|
|
im2->gc->shared->images_size -= (im2->csize);
|
|
|
|
evas_gl_common_image_free(im2);
|
|
|
|
l = NULL;
|
2015-04-30 08:12:55 -07:00
|
|
|
removed = EINA_TRUE;
|
2011-02-10 22:23:10 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-04-30 08:12:55 -07:00
|
|
|
|
|
|
|
if (!removed || !gc->shared->images)
|
2011-02-10 22:23:10 -08:00
|
|
|
{
|
2015-05-22 01:12:14 -07:00
|
|
|
// still have referenced images - need to let others release
|
|
|
|
// refs on their own
|
2011-02-10 22:23:10 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_evas_gl_image_cache_add(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
if (im->references == 0)
|
|
|
|
{
|
|
|
|
im->csize = im->w * im->h * 4;
|
|
|
|
im->gc->shared->images_size += im->csize;
|
|
|
|
_evas_gl_image_cache_trim(im->gc);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
|
|
|
|
im->cached = 0;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI void
|
2011-02-10 22:23:10 -08:00
|
|
|
evas_gl_common_image_ref(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
if (im->references == 0)
|
|
|
|
{
|
|
|
|
im->gc->shared->images_size -= (im->csize);
|
|
|
|
}
|
|
|
|
im->references++;
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI void
|
2011-02-10 22:23:10 -08:00
|
|
|
evas_gl_common_image_unref(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
im->references--;
|
|
|
|
if (im->references == 0)
|
|
|
|
{
|
|
|
|
_evas_gl_image_cache_add(im);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-29 23:10:07 -07:00
|
|
|
static void
|
|
|
|
_evas_gl_cspace_list_fill(Evas_Engine_GL_Context *gc)
|
|
|
|
{
|
|
|
|
#define CS_APPEND(cs) gc->shared->info.cspaces = eina_list_append \
|
|
|
|
(gc->shared->info.cspaces, (void *) (intptr_t) cs)
|
|
|
|
if (gc->shared->info.etc2)
|
|
|
|
{
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGBA8_ETC2_EAC);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGB8_ETC2);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_ETC1);
|
2014-07-07 04:14:02 -07:00
|
|
|
CS_APPEND(EVAS_COLORSPACE_ETC1_ALPHA);
|
2014-06-29 23:10:07 -07:00
|
|
|
}
|
|
|
|
else if (gc->shared->info.etc1)
|
2014-07-07 04:14:02 -07:00
|
|
|
{
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_ETC1);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_ETC1_ALPHA);
|
|
|
|
}
|
2014-06-29 23:10:07 -07:00
|
|
|
if (gc->shared->info.s3tc)
|
|
|
|
{
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGB_S3TC_DXT1);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGBA_S3TC_DXT1);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGBA_S3TC_DXT2);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGBA_S3TC_DXT3);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGBA_S3TC_DXT4);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_RGBA_S3TC_DXT5);
|
|
|
|
}
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_GRY8);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_AGRY88);
|
|
|
|
CS_APPEND(EVAS_COLORSPACE_ARGB8888);
|
|
|
|
}
|
2014-04-24 22:51:42 -07:00
|
|
|
|
2017-01-01 05:15:24 -08:00
|
|
|
static void
|
|
|
|
preload_done(void *data)
|
|
|
|
{
|
|
|
|
Evas_GL_Image *im = data;
|
|
|
|
|
|
|
|
if (im->im)
|
|
|
|
{
|
|
|
|
Evas_Colorspace cspace = EVAS_COLORSPACE_ARGB8888;
|
|
|
|
|
|
|
|
if (im->im->cache_entry.cspaces)
|
|
|
|
{
|
|
|
|
Evas_Colorspace cs;
|
|
|
|
unsigned int i;
|
|
|
|
Eina_List *l2;
|
|
|
|
void *ldata;
|
|
|
|
|
|
|
|
cspace = EVAS_COLORSPACE_ARGB8888;
|
|
|
|
for (i = 0;
|
|
|
|
im->im->cache_entry.cspaces[i] != EVAS_COLORSPACE_ARGB8888;
|
|
|
|
i++)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(im->gc->shared->info.cspaces, l2, ldata)
|
|
|
|
{
|
|
|
|
cs = (Evas_Colorspace) (intptr_t) ldata;
|
|
|
|
if (cs == im->im->cache_entry.cspaces[i])
|
|
|
|
{
|
|
|
|
cspace = cs;
|
|
|
|
goto found_cspace;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
found_cspace:
|
|
|
|
if (cspace == EVAS_COLORSPACE_ETC1 && im->gc->shared->info.etc2)
|
|
|
|
cspace = EVAS_COLORSPACE_RGB8_ETC2;
|
|
|
|
im->im->cache_entry.space = cspace;
|
|
|
|
}
|
|
|
|
im->cs.space = cspace;
|
|
|
|
im->orient = EVAS_IMAGE_ORIENT_NONE;
|
|
|
|
im->alpha = im->im->cache_entry.flags.alpha;
|
|
|
|
im->w = im->im->cache_entry.w;
|
|
|
|
im->h = im->im->cache_entry.h;
|
|
|
|
}
|
|
|
|
evas_gl_common_image_preload_unwatch(im);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_gl_common_image_preload_watch(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
Evas_Cache_Target *tg;
|
|
|
|
|
|
|
|
if (!im->im) return;
|
|
|
|
tg = calloc(1, sizeof(Evas_Cache_Target));
|
|
|
|
if (tg)
|
|
|
|
{
|
|
|
|
tg->simple_cb = preload_done;
|
|
|
|
tg->simple_data = im;
|
|
|
|
im->im->cache_entry.targets = (Evas_Cache_Target *)
|
|
|
|
eina_inlist_append(EINA_INLIST_GET(im->im->cache_entry.targets),
|
|
|
|
EINA_INLIST_GET(tg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_gl_common_image_preload_unwatch(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
Eina_Inlist *l2;
|
|
|
|
Evas_Cache_Target *tg;
|
|
|
|
|
|
|
|
if (!im->im) return;
|
|
|
|
EINA_INLIST_FOREACH_SAFE(im->im->cache_entry.targets, l2, tg)
|
|
|
|
{
|
|
|
|
if ((tg->simple_cb != preload_done) || (tg->simple_data != im))
|
|
|
|
continue;
|
|
|
|
tg->delete_me = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 00:48:48 -08:00
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_new_from_rgbaimage(Evas_Engine_GL_Context *gc, RGBA_Image *im_im,
|
|
|
|
Evas_Image_Load_Opts *lo, int *error)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2013-05-07 23:37:37 -07:00
|
|
|
Evas_GL_Image *im;
|
|
|
|
Eina_List *l;
|
2014-04-08 01:19:38 -07:00
|
|
|
Evas_Colorspace cspace = EVAS_COLORSPACE_ARGB8888;
|
2011-10-26 01:33:41 -07:00
|
|
|
|
|
|
|
/* i'd LOVe to do this, but we can't because we load to load header
|
|
|
|
* to get image size to know if its too big or not! so this disallows
|
|
|
|
* us to know that - photocam thus suffers
|
2011-10-25 05:14:48 -07:00
|
|
|
if (((int)im_im->cache_entry.w > gc->shared->info.max_texture_size) ||
|
|
|
|
((int)im_im->cache_entry.h > gc->shared->info.max_texture_size))
|
2011-10-20 23:10:15 -07:00
|
|
|
{
|
|
|
|
evas_cache_image_drop(&(im_im->cache_entry));
|
|
|
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-10-26 01:33:41 -07:00
|
|
|
*/
|
2014-07-03 20:26:16 -07:00
|
|
|
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
if (error) *error = EVAS_LOAD_ERROR_NONE;
|
|
|
|
|
2011-02-08 03:41:38 -08:00
|
|
|
// FIXME: keep unreffed shared images around
|
2009-10-13 02:40:39 -07:00
|
|
|
EINA_LIST_FOREACH(gc->shared->images, l, im)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2014-07-03 20:26:16 -07:00
|
|
|
if (im->im == im_im)
|
|
|
|
{
|
|
|
|
evas_cache_image_drop(&(im_im->cache_entry));
|
|
|
|
gc->shared->images = eina_list_remove_list(gc->shared->images, l);
|
|
|
|
gc->shared->images = eina_list_prepend(gc->shared->images, im);
|
2011-02-10 22:23:10 -08:00
|
|
|
evas_gl_common_image_ref(im);
|
2014-07-03 20:26:16 -07:00
|
|
|
*error = EVAS_LOAD_ERROR_NONE;
|
|
|
|
return im;
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
im = calloc(1, sizeof(Evas_GL_Image));
|
2009-12-22 15:11:57 -08:00
|
|
|
if (!im)
|
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im_im->cache_entry))
|
|
|
|
evas_cache2_image_close(&(im_im->cache_entry));
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_drop(&(im_im->cache_entry));
|
2014-07-03 20:26:16 -07:00
|
|
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
|
|
|
return NULL;
|
2009-12-22 15:11:57 -08:00
|
|
|
}
|
2014-03-20 03:29:57 -07:00
|
|
|
if (im_im->cache_entry.cspaces)
|
|
|
|
{
|
2014-06-29 23:10:07 -07:00
|
|
|
Evas_Colorspace cs;
|
2014-03-20 03:29:57 -07:00
|
|
|
unsigned int i;
|
2014-06-29 23:10:07 -07:00
|
|
|
Eina_List *l2;
|
|
|
|
void *ldata;
|
2014-03-20 03:29:57 -07:00
|
|
|
|
2014-06-29 23:10:07 -07:00
|
|
|
if (!gc->shared->info.cspaces)
|
|
|
|
_evas_gl_cspace_list_fill(gc);
|
2014-03-26 21:12:12 -07:00
|
|
|
|
2014-06-29 23:10:07 -07:00
|
|
|
cspace = EVAS_COLORSPACE_ARGB8888;
|
2014-03-20 03:29:57 -07:00
|
|
|
for (i = 0; im_im->cache_entry.cspaces[i] != EVAS_COLORSPACE_ARGB8888; i++)
|
2014-06-29 23:10:07 -07:00
|
|
|
EINA_LIST_FOREACH(gc->shared->info.cspaces, l2, ldata)
|
|
|
|
{
|
|
|
|
cs = (Evas_Colorspace) (intptr_t) ldata;
|
|
|
|
if (cs == im_im->cache_entry.cspaces[i])
|
|
|
|
{
|
|
|
|
cspace = cs;
|
|
|
|
goto found_cspace;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
found_cspace:
|
2014-06-11 22:44:28 -07:00
|
|
|
// ETC2 is backwards compatible with ETC1 but we prefer ETC2
|
|
|
|
if (cspace == EVAS_COLORSPACE_ETC1 && gc->shared->info.etc2)
|
|
|
|
cspace = EVAS_COLORSPACE_RGB8_ETC2;
|
2014-06-25 05:46:49 -07:00
|
|
|
|
2014-03-20 03:29:57 -07:00
|
|
|
im_im->cache_entry.space = cspace;
|
|
|
|
}
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references = 1;
|
|
|
|
im->im = im_im;
|
|
|
|
im->gc = gc;
|
|
|
|
im->cached = 1;
|
2014-03-20 03:29:57 -07:00
|
|
|
im->cs.space = cspace;
|
2015-04-22 02:25:38 -07:00
|
|
|
im->orient = EVAS_IMAGE_ORIENT_NONE;
|
2009-11-12 23:22:31 -08:00
|
|
|
im->alpha = im->im->cache_entry.flags.alpha;
|
|
|
|
im->w = im->im->cache_entry.w;
|
|
|
|
im->h = im->im->cache_entry.h;
|
2006-08-18 07:45:26 -07:00
|
|
|
if (lo) im->load_opts = *lo;
|
2009-10-13 02:40:39 -07:00
|
|
|
gc->shared->images = eina_list_prepend(gc->shared->images, im);
|
2014-03-20 03:29:57 -07:00
|
|
|
return im;
|
2013-05-07 23:37:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error)
|
|
|
|
{
|
|
|
|
RGBA_Image *im_im;
|
|
|
|
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cserve2_use_get())
|
|
|
|
{
|
|
|
|
im_im = (RGBA_Image *) evas_cache2_image_open
|
|
|
|
(evas_common_image_cache2_get(), file, key, lo, error);
|
|
|
|
if (im_im)
|
|
|
|
{
|
|
|
|
*error = evas_cache2_image_open_wait(&im_im->cache_entry);
|
|
|
|
if ((*error != EVAS_LOAD_ERROR_NONE)
|
|
|
|
&& im_im->cache_entry.animated.animated)
|
|
|
|
{
|
|
|
|
evas_cache2_image_close(&im_im->cache_entry);
|
|
|
|
im_im = NULL;
|
|
|
|
}
|
|
|
|
else
|
2016-01-04 00:48:48 -08:00
|
|
|
return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
|
2013-10-01 23:07:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-07 23:37:37 -07:00
|
|
|
im_im = evas_common_load_image_from_file(file, key, lo, error);
|
|
|
|
if (!im_im) return NULL;
|
|
|
|
|
2016-01-04 00:48:48 -08:00
|
|
|
return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
|
2013-05-07 23:37:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *key, Evas_Image_Load_Opts *lo, int *error)
|
|
|
|
{
|
|
|
|
RGBA_Image *im_im;
|
|
|
|
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cserve2_use_get() && !eina_file_virtual(f))
|
|
|
|
{
|
|
|
|
im_im = (RGBA_Image *) evas_cache2_image_open
|
|
|
|
(evas_common_image_cache2_get(), eina_file_filename_get(f), key, lo, error);
|
|
|
|
if (im_im)
|
|
|
|
{
|
|
|
|
*error = evas_cache2_image_open_wait(&im_im->cache_entry);
|
|
|
|
if ((*error != EVAS_LOAD_ERROR_NONE)
|
|
|
|
&& im_im->cache_entry.animated.animated)
|
|
|
|
{
|
|
|
|
evas_cache2_image_close(&im_im->cache_entry);
|
|
|
|
im_im = NULL;
|
|
|
|
}
|
|
|
|
else
|
2016-01-04 00:48:48 -08:00
|
|
|
return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
|
2013-10-01 23:07:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-07 23:37:37 -07:00
|
|
|
im_im = evas_common_load_image_from_mmap(f, key, lo, error);
|
|
|
|
if (!im_im) return NULL;
|
|
|
|
|
2016-01-04 00:48:48 -08:00
|
|
|
return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
|
2003-09-07 04:24:48 -07:00
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI Evas_GL_Image *
|
2014-04-08 01:19:38 -07:00
|
|
|
evas_gl_common_image_new_from_data(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-10-25 05:14:48 -07:00
|
|
|
if (((int)w > gc->shared->info.max_texture_size) ||
|
|
|
|
((int)h > gc->shared->info.max_texture_size))
|
2011-10-20 23:10:15 -07:00
|
|
|
return NULL;
|
|
|
|
|
2010-08-25 02:29:56 -07:00
|
|
|
if (data)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2010-08-25 02:29:56 -07:00
|
|
|
EINA_LIST_FOREACH(gc->shared->images, l, im)
|
|
|
|
{
|
|
|
|
if (((void *)(im->im->image.data) == (void *)data) &&
|
|
|
|
(im->im->cache_entry.w == w) &&
|
|
|
|
(im->im->cache_entry.h == h))
|
|
|
|
{
|
|
|
|
gc->shared->images = eina_list_remove_list(gc->shared->images, l);
|
|
|
|
gc->shared->images = eina_list_prepend(gc->shared->images, im);
|
2011-02-10 22:23:10 -08:00
|
|
|
evas_gl_common_image_ref(im);
|
2010-08-25 02:29:56 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
}
|
|
|
|
im = calloc(1, sizeof(Evas_GL_Image));
|
2006-09-30 03:18:37 -07:00
|
|
|
if (!im) return NULL;
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references = 1;
|
2008-04-11 17:32:30 -07:00
|
|
|
im->im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
|
|
|
|
w, h, data, alpha, cspace);
|
2003-09-07 04:24:48 -07:00
|
|
|
if (!im->im)
|
|
|
|
{
|
|
|
|
free(im);
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-12-17 07:48:52 -08:00
|
|
|
im->gc = gc;
|
|
|
|
im->cs.space = cspace;
|
2009-11-12 23:22:31 -08:00
|
|
|
im->alpha = im->im->cache_entry.flags.alpha;
|
|
|
|
im->w = im->im->cache_entry.w;
|
|
|
|
im->h = im->im->cache_entry.h;
|
2006-12-17 07:48:52 -08:00
|
|
|
switch (cspace)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
2014-03-20 03:29:57 -07:00
|
|
|
case EVAS_COLORSPACE_GRY8:
|
|
|
|
case EVAS_COLORSPACE_AGRY88:
|
2006-12-17 07:48:52 -08:00
|
|
|
break;
|
2014-03-26 21:12:12 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1:
|
2014-07-07 04:14:02 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1_ALPHA:
|
2014-04-24 22:51:42 -07:00
|
|
|
if (gc->shared->info.etc1 && !gc->shared->info.etc2) break;
|
2014-03-26 21:12:12 -07:00
|
|
|
ERR("We don't know what to do with ETC1 on this hardware. You need to add a software converter here.");
|
|
|
|
break;
|
2014-04-24 22:51:42 -07:00
|
|
|
case EVAS_COLORSPACE_RGB8_ETC2:
|
|
|
|
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
|
|
|
if (gc->shared->info.etc2) break;
|
|
|
|
ERR("We don't know what to do with ETC2 on this hardware. You need to add a software converter here.");
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
|
|
|
im->cs.data = data;
|
|
|
|
im->cs.no_free = 1;
|
|
|
|
break;
|
|
|
|
default:
|
2016-09-04 21:53:00 -07:00
|
|
|
ERR("color space not supported: %d", cspace);
|
2006-12-17 07:48:52 -08:00
|
|
|
break;
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
2014-04-08 01:19:38 -07:00
|
|
|
evas_gl_common_image_new_from_copied_data(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-10-25 05:14:48 -07:00
|
|
|
if (((int)w > gc->shared->info.max_texture_size) ||
|
|
|
|
((int)h > gc->shared->info.max_texture_size))
|
2011-10-20 23:10:15 -07:00
|
|
|
return NULL;
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
im = calloc(1, sizeof(Evas_GL_Image));
|
2006-09-30 03:18:37 -07:00
|
|
|
if (!im) return NULL;
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references = 1;
|
2008-04-11 17:32:30 -07:00
|
|
|
im->im = (RGBA_Image *) evas_cache_image_copied_data(evas_common_image_cache_get(),
|
|
|
|
w, h, data, alpha, cspace);
|
2003-09-07 04:24:48 -07:00
|
|
|
if (!im->im)
|
|
|
|
{
|
|
|
|
free(im);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-09-11 21:15:20 -07:00
|
|
|
im->gc = gc;
|
2006-12-17 07:48:52 -08:00
|
|
|
im->cs.space = cspace;
|
2009-11-12 23:22:31 -08:00
|
|
|
im->alpha = im->im->cache_entry.flags.alpha;
|
|
|
|
im->w = im->im->cache_entry.w;
|
|
|
|
im->h = im->im->cache_entry.h;
|
2006-12-17 07:48:52 -08:00
|
|
|
switch (cspace)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
2014-01-16 18:19:02 -08:00
|
|
|
case EVAS_COLORSPACE_GRY8:
|
2014-03-20 03:29:57 -07:00
|
|
|
case EVAS_COLORSPACE_AGRY88:
|
2014-01-16 18:19:02 -08:00
|
|
|
break;
|
2014-03-26 21:12:12 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1:
|
2014-07-07 04:14:02 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1_ALPHA:
|
2014-04-24 22:51:42 -07:00
|
|
|
if (gc->shared->info.etc1 && !gc->shared->info.etc2) break;
|
2014-03-26 21:12:12 -07:00
|
|
|
ERR("We don't know what to do with ETC1 on this hardware. You need to add a software converter here.");
|
|
|
|
break;
|
2014-04-24 22:51:42 -07:00
|
|
|
case EVAS_COLORSPACE_RGB8_ETC2:
|
|
|
|
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
|
|
|
if (gc->shared->info.etc2) break;
|
|
|
|
ERR("We don't know what to do with ETC2 on this hardware. You need to add a software converter here.");
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
2010-03-01 07:03:13 -08:00
|
|
|
if (im->im->cache_entry.h > 0)
|
|
|
|
im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
|
2006-12-17 07:48:52 -08:00
|
|
|
if ((data) && (im->cs.data))
|
2014-01-16 18:19:02 -08:00
|
|
|
memcpy(im->cs.data, data, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
default:
|
2016-09-04 21:53:00 -07:00
|
|
|
ERR("color space not supported: %d", cspace);
|
2014-01-16 18:19:02 -08:00
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
2014-04-08 01:19:38 -07:00
|
|
|
evas_gl_common_image_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_Colorspace cspace)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-10-25 05:14:48 -07:00
|
|
|
if (((int)w > gc->shared->info.max_texture_size) ||
|
|
|
|
((int)h > gc->shared->info.max_texture_size))
|
2011-10-20 23:10:15 -07:00
|
|
|
return NULL;
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
im = calloc(1, sizeof(Evas_GL_Image));
|
2006-09-30 03:18:37 -07:00
|
|
|
if (!im) return NULL;
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references = 1;
|
2010-03-01 07:51:22 -08:00
|
|
|
im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
2003-09-07 04:24:48 -07:00
|
|
|
if (!im->im)
|
|
|
|
{
|
|
|
|
free(im);
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-06-02 08:30:59 -07:00
|
|
|
im->gc = gc;
|
2008-06-03 02:09:39 -07:00
|
|
|
im->im->cache_entry.flags.alpha = alpha ? 1 : 0;
|
2009-11-12 23:22:31 -08:00
|
|
|
im->cs.space = cspace;
|
|
|
|
im->alpha = im->im->cache_entry.flags.alpha;
|
2010-03-01 07:51:22 -08:00
|
|
|
im->im->cache_entry.w = w;
|
|
|
|
im->im->cache_entry.h = h;
|
2009-11-12 23:22:31 -08:00
|
|
|
im->w = im->im->cache_entry.w;
|
|
|
|
im->h = im->im->cache_entry.h;
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_cache_image_colorspace(&im->im->cache_entry, cspace);
|
2010-03-01 07:51:22 -08:00
|
|
|
im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, w, h);
|
2007-06-02 08:30:59 -07:00
|
|
|
switch (cspace)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
2014-03-20 03:29:57 -07:00
|
|
|
case EVAS_COLORSPACE_GRY8:
|
|
|
|
case EVAS_COLORSPACE_AGRY88:
|
|
|
|
break;
|
2014-03-26 21:12:12 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1:
|
2014-07-07 04:14:02 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1_ALPHA:
|
2014-04-24 22:51:42 -07:00
|
|
|
if (gc->shared->info.etc1 && !gc->shared->info.etc2) break;
|
2014-03-26 21:12:12 -07:00
|
|
|
ERR("We don't know what to do with ETC1 on this hardware. You need to add a software converter here.");
|
|
|
|
break;
|
2014-04-24 22:51:42 -07:00
|
|
|
case EVAS_COLORSPACE_RGB8_ETC2:
|
|
|
|
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
|
|
|
if (gc->shared->info.etc2) break;
|
|
|
|
ERR("We don't know what to do with ETC2 on this hardware. You need to add a software converter here.");
|
|
|
|
break;
|
2007-06-02 08:30:59 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
2011-09-04 14:15:04 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
2007-06-02 08:30:59 -07:00
|
|
|
// if (im->tex) evas_gl_common_texture_free(im->tex);
|
|
|
|
im->tex = NULL;
|
|
|
|
im->cs.no_free = 0;
|
2010-03-01 07:03:13 -08:00
|
|
|
if (im->im->cache_entry.h > 0)
|
|
|
|
im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
|
2007-06-02 08:30:59 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2010-02-21 07:49:44 -08:00
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha)
|
|
|
|
{
|
|
|
|
if (!im) return NULL;
|
|
|
|
if (im->alpha == alpha) return im;
|
|
|
|
im->alpha = alpha;
|
|
|
|
if (!im->im) return im;
|
2013-10-16 01:20:14 -07:00
|
|
|
evas_gl_common_image_alloc_ensure(im);
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_load_data(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_load_data(&im->im->cache_entry);
|
2010-02-21 07:49:44 -08:00
|
|
|
im->im->cache_entry.flags.alpha = alpha ? 1 : 0;
|
2012-09-07 01:31:19 -07:00
|
|
|
|
2013-06-13 23:51:18 -07:00
|
|
|
if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2012-09-07 01:31:19 -07:00
|
|
|
if (im->tex_only)
|
2010-02-21 07:49:44 -08:00
|
|
|
{
|
2012-09-07 01:31:19 -07:00
|
|
|
im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h,
|
|
|
|
im->alpha, im);
|
2010-02-21 07:49:44 -08:00
|
|
|
}
|
2012-09-07 01:31:19 -07:00
|
|
|
else
|
2012-09-06 22:57:22 -07:00
|
|
|
{
|
2015-04-22 06:15:08 -07:00
|
|
|
im->tex = evas_gl_common_texture_new(im->gc, im->im, EINA_FALSE);
|
2013-07-14 18:59:29 -07:00
|
|
|
if (im->tex) evas_gl_common_texture_update(im->tex, im->im);
|
2012-09-06 22:57:22 -07:00
|
|
|
}
|
2010-02-21 07:49:44 -08:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI void
|
2010-01-21 00:44:11 -08:00
|
|
|
evas_gl_common_image_native_enable(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
if (im->cs.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
im->cs.data = NULL;
|
|
|
|
}
|
|
|
|
im->cs.no_free = 0;
|
|
|
|
if (im->cached)
|
|
|
|
{
|
2011-02-08 03:41:38 -08:00
|
|
|
if (im->references == 0)
|
2011-02-10 22:23:10 -08:00
|
|
|
im->gc->shared->images_size -= (im->csize);
|
2010-01-21 00:44:11 -08:00
|
|
|
im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
|
|
|
|
im->cached = 0;
|
|
|
|
}
|
|
|
|
if (im->im)
|
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_close(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
2010-01-21 00:44:11 -08:00
|
|
|
im->im = NULL;
|
|
|
|
}
|
|
|
|
if (im->tex)
|
|
|
|
{
|
2013-06-13 23:51:18 -07:00
|
|
|
evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex = NULL;
|
|
|
|
}
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2010-01-21 00:44:11 -08:00
|
|
|
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
2010-01-23 21:11:54 -08:00
|
|
|
im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha, im);
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex_only = 1;
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI void
|
2010-01-21 00:44:11 -08:00
|
|
|
evas_gl_common_image_native_disable(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
if (im->im)
|
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (!evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_close(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
2010-01-21 00:44:11 -08:00
|
|
|
im->im = NULL;
|
|
|
|
}
|
|
|
|
if (im->tex)
|
|
|
|
{
|
2013-06-13 23:51:18 -07:00
|
|
|
evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex = NULL;
|
|
|
|
}
|
|
|
|
im->tex_only = 0;
|
|
|
|
im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
|
|
|
im->im->cache_entry.flags.alpha = im->alpha;
|
|
|
|
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
|
|
|
evas_cache_image_colorspace(&im->im->cache_entry, im->cs.space);
|
2013-10-16 01:20:14 -07:00
|
|
|
/*
|
2010-01-21 00:44:11 -08:00
|
|
|
im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, im->w, im->h);
|
2010-02-21 07:49:44 -08:00
|
|
|
if (!im->tex)
|
|
|
|
im->tex = evas_gl_common_texture_new(im->gc, im->im);
|
2013-10-16 01:20:14 -07:00
|
|
|
*/
|
2010-01-21 00:44:11 -08:00
|
|
|
}
|
|
|
|
|
2010-08-11 23:11:13 -07:00
|
|
|
void
|
|
|
|
evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hint)
|
|
|
|
{
|
|
|
|
im->scale_hint = hint;
|
|
|
|
// FIXME: take advantage of this even in gl (eg if image is
|
|
|
|
// 1600x1200 but we always use it at 800x600 or even less - drop
|
|
|
|
// the texture res down for "non dynamic" stuff to save memory)
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint)
|
|
|
|
{
|
2010-08-13 03:34:51 -07:00
|
|
|
if (im->content_hint == hint) return;
|
2010-08-13 04:08:57 -07:00
|
|
|
im->content_hint = hint;
|
2010-08-13 03:34:51 -07:00
|
|
|
if (!im->gc) return;
|
2010-08-18 02:53:14 -07:00
|
|
|
if (!im->gc->shared->info.bgra) return;
|
2010-08-13 03:34:51 -07:00
|
|
|
// does not handle yuv yet.
|
2014-07-07 04:14:02 -07:00
|
|
|
// TODO: Check this list of cspaces
|
|
|
|
switch (im->cs.space)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
|
|
|
case EVAS_COLORSPACE_RGB565_A5P:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
|
|
|
case EVAS_COLORSPACE_ETC1_ALPHA:
|
|
|
|
return;
|
|
|
|
default: break;
|
|
|
|
}
|
2010-08-13 03:34:51 -07:00
|
|
|
if (im->content_hint == EVAS_IMAGE_CONTENT_HINT_DYNAMIC)
|
|
|
|
{
|
2015-11-11 00:06:44 -08:00
|
|
|
if ((!im->gc->shared->info.sec_image_map) &&
|
|
|
|
((!im->gc->shared->info.sec_tbm_surface) || (!im->gc->shared->info.egl_tbm_ext))) return;
|
2010-08-13 03:34:51 -07:00
|
|
|
if (im->cs.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
im->cs.data = NULL;
|
|
|
|
}
|
|
|
|
im->cs.no_free = 0;
|
|
|
|
if (im->cached)
|
|
|
|
{
|
2011-02-08 03:41:38 -08:00
|
|
|
if (im->references == 0)
|
2011-02-10 22:23:10 -08:00
|
|
|
im->gc->shared->images_size -= im->csize;
|
2010-08-13 03:34:51 -07:00
|
|
|
im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
|
|
|
|
im->cached = 0;
|
|
|
|
}
|
|
|
|
if (im->im)
|
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_close(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
2010-08-13 03:34:51 -07:00
|
|
|
im->im = NULL;
|
|
|
|
}
|
|
|
|
if (im->tex)
|
|
|
|
{
|
2013-06-13 23:51:18 -07:00
|
|
|
evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2010-08-13 03:34:51 -07:00
|
|
|
im->tex = NULL;
|
|
|
|
}
|
2015-11-10 23:15:24 -08:00
|
|
|
im->tex = evas_gl_common_texture_dynamic_new(im->gc, im);
|
2010-08-13 03:34:51 -07:00
|
|
|
im->tex_only = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (im->im)
|
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_close(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
2010-08-13 03:34:51 -07:00
|
|
|
im->im = NULL;
|
|
|
|
}
|
|
|
|
if (im->tex)
|
|
|
|
{
|
2013-06-13 23:51:18 -07:00
|
|
|
evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2010-08-13 03:34:51 -07:00
|
|
|
im->tex = NULL;
|
|
|
|
}
|
|
|
|
im->tex_only = 0;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2010-08-13 03:34:51 -07:00
|
|
|
im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
|
|
|
im->im->cache_entry.flags.alpha = im->alpha;
|
2014-03-20 03:29:57 -07:00
|
|
|
im->im->cache_entry.space = im->cs.space;
|
2010-08-13 03:34:51 -07:00
|
|
|
evas_cache_image_colorspace(&im->im->cache_entry, im->cs.space);
|
|
|
|
im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, im->w, im->h);
|
|
|
|
if (!im->tex)
|
2015-04-22 06:15:08 -07:00
|
|
|
im->tex = evas_gl_common_texture_new(im->gc, im->im, EINA_FALSE);
|
2010-08-13 03:34:51 -07:00
|
|
|
}
|
2010-08-11 23:11:13 -07:00
|
|
|
}
|
|
|
|
|
2011-02-08 03:41:38 -08:00
|
|
|
void
|
2011-03-16 10:32:49 -07:00
|
|
|
evas_gl_common_image_cache_flush(Evas_Engine_GL_Context *gc)
|
2011-02-08 03:41:38 -08:00
|
|
|
{
|
|
|
|
_evas_gl_image_cache_trim(gc);
|
|
|
|
}
|
|
|
|
|
2014-07-11 06:10:53 -07:00
|
|
|
EAPI void
|
2003-09-07 04:24:48 -07:00
|
|
|
evas_gl_common_image_free(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
im->references--;
|
|
|
|
if (im->references > 0) return;
|
2017-03-08 02:33:15 -08:00
|
|
|
|
2017-03-29 18:26:24 -07:00
|
|
|
if (im->gc && (im->gc->pipe[0].shader.surface == im))
|
|
|
|
evas_gl_common_context_target_surface_set(im->gc, im->gc->def_surface);
|
|
|
|
|
2017-03-08 02:33:15 -08:00
|
|
|
if (im->fglyph)
|
|
|
|
{
|
|
|
|
im->gc->font_glyph_images = eina_list_remove(im->gc->font_glyph_images, im);
|
|
|
|
im->fglyph->ext_dat = NULL;
|
|
|
|
im->fglyph->ext_dat_free = NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:14:22 -07:00
|
|
|
evas_gl_common_context_flush(im->gc);
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2017-01-01 05:15:24 -08:00
|
|
|
evas_gl_common_image_preload_unwatch(im);
|
|
|
|
|
2015-02-25 02:05:12 -08:00
|
|
|
if (im->scaled.origin)
|
2015-02-26 22:57:36 -08:00
|
|
|
{
|
|
|
|
evas_gl_common_image_free(im->scaled.origin);
|
|
|
|
im->scaled.origin = NULL;
|
|
|
|
}
|
2015-02-25 02:05:12 -08:00
|
|
|
|
2010-01-21 00:44:11 -08:00
|
|
|
if (im->native.func.free)
|
2016-03-30 23:55:15 -07:00
|
|
|
im->native.func.free(im);
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2006-12-17 07:48:52 -08:00
|
|
|
if (im->cs.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
}
|
2011-02-08 03:41:38 -08:00
|
|
|
if (im->cached)
|
|
|
|
{
|
|
|
|
if (_evas_gl_image_cache_add(im)) return;
|
|
|
|
}
|
2016-03-11 13:04:56 -08:00
|
|
|
if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
2013-10-01 23:07:25 -07:00
|
|
|
if (im->im)
|
|
|
|
{
|
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
evas_cache2_image_close(&im->im->cache_entry);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
|
|
|
}
|
2011-04-18 22:47:56 -07:00
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
free(im);
|
|
|
|
}
|
|
|
|
|
2009-11-12 23:22:31 -08:00
|
|
|
Evas_GL_Image *
|
2016-11-16 13:14:48 -08:00
|
|
|
evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, int stencil)
|
2009-11-12 23:22:31 -08:00
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
|
|
|
|
2011-10-25 05:14:48 -07:00
|
|
|
if (((int)w > gc->shared->info.max_texture_size) ||
|
|
|
|
((int)h > gc->shared->info.max_texture_size))
|
2011-10-20 23:10:15 -07:00
|
|
|
return NULL;
|
|
|
|
|
2009-11-12 23:22:31 -08:00
|
|
|
im = calloc(1, sizeof(Evas_GL_Image));
|
|
|
|
if (!im) return NULL;
|
|
|
|
im->references = 1;
|
|
|
|
im->gc = gc;
|
|
|
|
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
|
|
|
im->alpha = alpha;
|
|
|
|
im->w = w;
|
|
|
|
im->h = h;
|
2016-11-16 13:14:48 -08:00
|
|
|
im->tex = evas_gl_common_texture_render_new(gc, w, h, alpha, stencil);
|
2009-11-12 23:22:31 -08:00
|
|
|
im->tex_only = 1;
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2016-11-16 19:26:46 -08:00
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_surface_noscale_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha)
|
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
|
|
|
|
|
|
|
if (((int)w > gc->shared->info.max_texture_size) ||
|
|
|
|
((int)h > gc->shared->info.max_texture_size))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
im = calloc(1, sizeof(Evas_GL_Image));
|
|
|
|
if (!im) return NULL;
|
|
|
|
im->references = 1;
|
|
|
|
im->gc = gc;
|
|
|
|
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
|
|
|
im->alpha = alpha;
|
|
|
|
im->w = w;
|
|
|
|
im->h = h;
|
|
|
|
im->tex = evas_gl_common_texture_render_noscale_new(gc, w, h, alpha);
|
|
|
|
im->tex_only = 1;
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
void
|
2010-09-18 16:16:25 -07:00
|
|
|
evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2009-12-19 22:23:13 -08:00
|
|
|
if ((w == 0) && (h == 0) && (x == 0) && (y == 0))
|
|
|
|
{
|
|
|
|
w = im->w;
|
|
|
|
h = im->h;
|
|
|
|
}
|
2009-11-12 23:22:31 -08:00
|
|
|
if (im->im)
|
|
|
|
{
|
2013-10-16 01:20:14 -07:00
|
|
|
evas_gl_common_image_alloc_ensure(im);
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
if (evas_cache2_image_cached(&im->im->cache_entry))
|
|
|
|
im->im = (RGBA_Image *)evas_cache2_image_dirty(&im->im->cache_entry, x, y, w, h);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
im->im = (RGBA_Image *)evas_cache_image_dirty(&im->im->cache_entry, x, y, w, h);
|
2009-11-12 23:22:31 -08:00
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
im->dirty = 1;
|
|
|
|
}
|
|
|
|
|
2011-04-18 22:47:56 -07:00
|
|
|
void
|
|
|
|
evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2011-11-03 08:20:30 -07:00
|
|
|
Image_Entry *ie;
|
2009-11-12 23:22:31 -08:00
|
|
|
if (!im->im) return;
|
2014-11-19 01:54:36 -08:00
|
|
|
|
2015-03-24 15:09:28 -07:00
|
|
|
// alloc ensure can change im->im, so only get the local variable later.
|
|
|
|
ie = &im->im->cache_entry;
|
2017-01-01 05:15:24 -08:00
|
|
|
if (!im->tex)
|
|
|
|
{
|
|
|
|
if (ie->preload) return;
|
|
|
|
im->w = ie->w;
|
|
|
|
im->h = ie->h;
|
|
|
|
}
|
|
|
|
evas_gl_common_image_alloc_ensure(im);
|
2011-06-17 00:47:28 -07:00
|
|
|
/*
|
2009-10-09 05:10:27 -07:00
|
|
|
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
|
|
|
|
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
|
2007-12-25 03:12:39 -08:00
|
|
|
{
|
2009-10-09 05:10:27 -07:00
|
|
|
// SOFTWARE convert. do multi texture later
|
2007-12-25 03:12:39 -08:00
|
|
|
if ((im->cs.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
if (im->dirty || !im->im->image.data)
|
2007-12-25 03:12:39 -08:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
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)
|
2015-05-27 04:17:20 -07:00
|
|
|
evas_common_convert_yuv_422p_601_rgba(im->cs.data,
|
2008-04-11 17:32:30 -07:00
|
|
|
(void *)im->im->image.data,
|
|
|
|
im->im->cache_entry.w, im->im->cache_entry.h);
|
2007-12-25 03:12:39 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
space = EVAS_COLORSPACE_ARGB8888;
|
|
|
|
}
|
|
|
|
else
|
2009-10-10 06:24:15 -07:00
|
|
|
*/
|
2014-11-19 01:54:36 -08:00
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
switch (im->cs.space)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2006-12-17 07:48:52 -08:00
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
2014-03-20 03:29:57 -07:00
|
|
|
case EVAS_COLORSPACE_GRY8:
|
|
|
|
case EVAS_COLORSPACE_AGRY88:
|
2014-03-26 21:12:12 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1:
|
2014-04-24 22:51:42 -07:00
|
|
|
case EVAS_COLORSPACE_RGB8_ETC2:
|
|
|
|
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
2014-06-29 23:10:07 -07:00
|
|
|
case EVAS_COLORSPACE_RGB_S3TC_DXT1:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT1:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT2:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT3:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT4:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT5:
|
2011-11-03 08:20:30 -07:00
|
|
|
if ((im->tex) &&
|
2013-06-23 19:41:32 -07:00
|
|
|
((im->dirty) || (ie->animated.animated) || (ie->flags.updated_data)))
|
2010-04-12 01:23:53 -07:00
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
2014-11-19 01:54:36 -08:00
|
|
|
if (evas_cache2_image_cached(ie))
|
2013-10-01 23:07:25 -07:00
|
|
|
{
|
2014-11-19 02:19:56 -08:00
|
|
|
evas_cache2_image_load_data(ie);
|
|
|
|
evas_gl_common_texture_update(im->tex, im->im);
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_cache2_image_unload_data(ie);
|
2013-10-01 23:07:25 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2014-11-19 02:19:56 -08:00
|
|
|
evas_cache_image_load_data(ie);
|
|
|
|
evas_gl_common_texture_update(im->tex, im->im);
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_cache_image_unload_data(ie);
|
2013-10-01 23:07:25 -07:00
|
|
|
}
|
2013-06-23 19:41:32 -07:00
|
|
|
ie->flags.updated_data = 0;
|
2010-04-12 01:23:53 -07:00
|
|
|
}
|
2014-11-19 02:45:04 -08:00
|
|
|
else if (!im->tex && !ie->load_error)
|
2010-04-12 01:23:53 -07:00
|
|
|
{
|
2013-10-01 23:07:25 -07:00
|
|
|
#ifdef EVAS_CSERVE2
|
2014-11-19 01:54:36 -08:00
|
|
|
if (evas_cache2_image_cached(ie))
|
2013-10-01 23:07:25 -07:00
|
|
|
{
|
2014-11-19 02:19:56 -08:00
|
|
|
evas_cache2_image_load_data(ie);
|
2015-04-22 06:15:08 -07:00
|
|
|
im->tex = evas_gl_common_texture_new(gc, im->im, im->disable_atlas);
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_cache2_image_unload_data(ie);
|
2013-10-01 23:07:25 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2014-11-19 02:19:56 -08:00
|
|
|
evas_cache_image_load_data(ie);
|
2015-04-22 06:15:08 -07:00
|
|
|
im->tex = evas_gl_common_texture_new(gc, im->im, im->disable_atlas);
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_cache_image_unload_data(ie);
|
2013-10-01 23:07:25 -07:00
|
|
|
}
|
2010-04-12 01:23:53 -07:00
|
|
|
}
|
2009-12-19 22:23:13 -08:00
|
|
|
im->dirty = 0;
|
2009-10-10 06:24:15 -07:00
|
|
|
if (!im->tex) return;
|
2006-12-17 07:48:52 -08:00
|
|
|
break;
|
2014-07-07 04:14:02 -07:00
|
|
|
case EVAS_COLORSPACE_ETC1_ALPHA:
|
|
|
|
if ((im->tex) && (im->dirty))
|
|
|
|
{
|
2014-11-19 02:19:56 -08:00
|
|
|
evas_cache_image_load_data(ie);
|
|
|
|
evas_gl_common_texture_rgb_a_pair_update(im->tex, im->im);
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_cache_image_unload_data(ie);
|
2014-07-07 04:14:02 -07:00
|
|
|
}
|
2014-11-19 02:45:04 -08:00
|
|
|
else if (!im->tex && !ie->load_error)
|
2014-07-07 04:14:02 -07:00
|
|
|
{
|
2014-11-19 02:19:56 -08:00
|
|
|
evas_cache_image_load_data(ie);
|
|
|
|
im->tex = evas_gl_common_texture_rgb_a_pair_new(gc, im->im);
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_cache_image_unload_data(ie);
|
2014-07-07 04:14:02 -07:00
|
|
|
}
|
|
|
|
im->dirty = 0;
|
|
|
|
if (!im->tex) return;
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
2009-10-10 06:24:15 -07:00
|
|
|
if ((im->tex) && (im->dirty))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_gl_common_texture_yuv_update(im->tex, im->cs.data, ie->w, ie->h);
|
2009-10-10 06:24:15 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
im->tex = evas_gl_common_texture_yuv_new(gc, im->cs.data, ie->w, ie->h);
|
2009-10-10 06:24:15 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if (!im->tex) return;
|
|
|
|
break;
|
2011-08-23 08:13:40 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
|
|
|
if ((im->tex) && (im->dirty))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_gl_common_texture_yuy2_update(im->tex, im->cs.data, ie->w, ie->h);
|
2011-08-23 08:13:40 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
im->tex = evas_gl_common_texture_yuy2_new(gc, im->cs.data, ie->w, ie->h);
|
2011-08-23 08:13:40 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if (!im->tex) return;
|
|
|
|
break;
|
2011-08-29 13:56:48 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
|
|
|
if ((im->tex) && (im->dirty))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_gl_common_texture_nv12_update(im->tex, im->cs.data, ie->w, ie->h);
|
2011-08-29 13:56:48 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
im->tex = evas_gl_common_texture_nv12_new(gc, im->cs.data, ie->w, ie->h);
|
2011-08-29 13:56:48 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if (!im->tex) return;
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
|
|
|
if ((im->tex) && (im->dirty))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
evas_gl_common_texture_nv12tiled_update(im->tex, im->cs.data, ie->w, ie->h);
|
2011-08-29 13:56:48 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
{
|
2014-11-19 01:54:36 -08:00
|
|
|
im->tex = evas_gl_common_texture_nv12tiled_new(gc, im->cs.data, ie->w, ie->h);
|
2011-08-29 13:56:48 -07:00
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if (!im->tex) return;
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
default:
|
2011-08-23 08:13:40 -07:00
|
|
|
ERR("unhandled img format colorspace=%d", im->cs.space);
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
}
|
2009-11-11 03:39:25 -08:00
|
|
|
}
|
|
|
|
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
Evas_GL_Image *
|
2017-01-23 21:23:03 -08:00
|
|
|
evas_gl_common_image_surface_update(Evas_GL_Image *im)
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
{
|
2017-01-23 21:23:03 -08:00
|
|
|
Evas_Engine_GL_Context *gc;
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
Evas_GL_Image *glim = NULL;
|
|
|
|
Eina_Bool alpha;
|
|
|
|
int w, h;
|
|
|
|
|
2017-01-23 21:23:03 -08:00
|
|
|
if (!im || !im->gc || !im->im || !im->im->image.data)
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_ARGB8888)
|
|
|
|
alpha = EINA_FALSE;
|
|
|
|
else if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_GRY8)
|
|
|
|
alpha = EINA_TRUE;
|
|
|
|
else goto fail;
|
|
|
|
|
2017-01-23 21:23:03 -08:00
|
|
|
gc = im->gc;
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
w = im->im->cache_entry.w;
|
|
|
|
h = im->im->cache_entry.h;
|
|
|
|
glim = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE);
|
|
|
|
if (!glim) goto fail;
|
|
|
|
|
|
|
|
if (alpha)
|
|
|
|
{
|
|
|
|
RGBA_Image *image;
|
|
|
|
uint32_t *rgba;
|
|
|
|
uint8_t *gry8;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
image = evas_common_image_new(w, h, EINA_TRUE);
|
|
|
|
if (!image) goto fail;
|
|
|
|
|
|
|
|
rgba = image->image.data;
|
|
|
|
gry8 = im->im->image.data8;
|
|
|
|
for (k = 0; k < (w * h); k++)
|
|
|
|
{
|
|
|
|
const int c = *gry8++;
|
|
|
|
*rgba++ = ARGB_JOIN(c, c, c, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
glim->im = image;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_cache_image_ref(&im->im->cache_entry);
|
|
|
|
glim->im = im->im;
|
|
|
|
}
|
|
|
|
|
|
|
|
glim->dirty = EINA_TRUE;
|
|
|
|
evas_gl_common_image_update(gc, glim);
|
|
|
|
evas_gl_common_image_free(im);
|
|
|
|
|
|
|
|
return glim;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
ERR("Failed to update surface pixels!");
|
|
|
|
if (glim) evas_gl_common_image_free(glim);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-01-23 00:55:17 -08:00
|
|
|
Evas_GL_Image *
|
2017-01-23 21:23:03 -08:00
|
|
|
evas_gl_common_image_surface_detach(Evas_GL_Image *im)
|
2017-01-23 00:55:17 -08:00
|
|
|
{
|
|
|
|
if (!im || !im->im) return im;
|
|
|
|
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
|
|
|
im->im = NULL;
|
|
|
|
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2017-01-23 21:23:03 -08:00
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_virtual_scaled_get(Evas_GL_Image *scaled, Evas_GL_Image *image,
|
|
|
|
int dst_w, int dst_h, Eina_Bool smooth)
|
|
|
|
{
|
|
|
|
Evas_GL_Image *dst = scaled, *newdst;
|
|
|
|
Evas_GL_Image *src = image;
|
|
|
|
Evas_Engine_GL_Context *gc;
|
|
|
|
Eina_Bool reffed = EINA_FALSE;
|
|
|
|
|
|
|
|
if (!src) return NULL;
|
|
|
|
|
|
|
|
// masking will work only with single texture images
|
|
|
|
switch (src->cs.space)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_AGRY88:
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
|
|
|
case EVAS_COLORSPACE_GRY8:
|
|
|
|
case EVAS_COLORSPACE_RGBA8_ETC2_EAC:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT1:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT2:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT3:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT4:
|
|
|
|
case EVAS_COLORSPACE_RGBA_S3TC_DXT5:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBG("cspace %d can't be used for masking's fast path", src->cs.space);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gc = src->gc;
|
|
|
|
if (dst && (dst->scaled.origin == src) &&
|
|
|
|
(dst->w == dst_w) && (dst->h == dst_h))
|
|
|
|
return dst;
|
|
|
|
|
|
|
|
evas_gl_common_image_update(gc, src);
|
|
|
|
if (!src->tex)
|
|
|
|
{
|
|
|
|
ERR("No source texture.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
newdst = calloc(1, sizeof(Evas_GL_Image));
|
|
|
|
if (!newdst) return NULL;
|
|
|
|
|
|
|
|
if (dst)
|
|
|
|
{
|
|
|
|
if (dst->scaled.origin == src)
|
|
|
|
{
|
|
|
|
if (dst->references == 1)
|
|
|
|
{
|
|
|
|
dst->w = dst_w;
|
|
|
|
dst->h = dst_h;
|
|
|
|
dst->scaled.smooth = smooth;
|
|
|
|
free(newdst);
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
src->references++;
|
|
|
|
reffed = EINA_TRUE;
|
|
|
|
}
|
|
|
|
evas_gl_common_image_free(dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
newdst->references = 1;
|
|
|
|
newdst->gc = gc;
|
|
|
|
newdst->cs.space = src->cs.space;
|
|
|
|
newdst->alpha = src->alpha;
|
|
|
|
newdst->w = dst_w;
|
|
|
|
newdst->h = dst_h;
|
|
|
|
newdst->tex = src->tex;
|
|
|
|
newdst->tex->references++;
|
|
|
|
newdst->tex_only = 1;
|
|
|
|
|
|
|
|
if (!reffed) src->references++;
|
|
|
|
newdst->scaled.origin = src;
|
|
|
|
newdst->scaled.smooth = smooth;
|
|
|
|
|
|
|
|
return newdst;
|
|
|
|
}
|
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
void
|
2011-06-17 00:47:28 -07:00
|
|
|
evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
|
2012-11-04 03:51:42 -08:00
|
|
|
int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED)
|
2009-11-11 03:39:25 -08:00
|
|
|
{
|
2015-02-26 03:42:45 -08:00
|
|
|
int mx = 0, my = 0, mw = 0, mh = 0;
|
|
|
|
RGBA_Draw_Context *dc = gc->dc;
|
|
|
|
Eina_Bool mask_smooth = EINA_FALSE;
|
|
|
|
Evas_GL_Image *mask = dc->clip.mask;
|
2015-03-31 18:54:45 -07:00
|
|
|
Evas_GL_Texture *mtex = NULL;
|
2017-01-23 21:23:03 -08:00
|
|
|
Eina_Bool mask_color = EINA_FALSE;
|
2009-11-11 03:39:25 -08:00
|
|
|
int r, g, b, a;
|
|
|
|
int c, cx, cy, cw, ch;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
if (dc->mul.use)
|
|
|
|
{
|
|
|
|
a = (dc->mul.col >> 24) & 0xff;
|
|
|
|
r = (dc->mul.col >> 16) & 0xff;
|
|
|
|
g = (dc->mul.col >> 8 ) & 0xff;
|
|
|
|
b = (dc->mul.col ) & 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = g = b = a = 255;
|
|
|
|
}
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2011-04-18 22:47:56 -07:00
|
|
|
evas_gl_common_image_update(gc, im);
|
2009-11-13 21:08:00 -08:00
|
|
|
|
2012-08-16 21:43:23 -07:00
|
|
|
c = dc->clip.use;
|
|
|
|
cx = dc->clip.x; cy = dc->clip.y;
|
|
|
|
cw = dc->clip.w; ch = dc->clip.h;
|
2013-07-15 03:02:13 -07:00
|
|
|
if (!im->tex) return;
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex->im = im;
|
2011-08-29 13:56:48 -07:00
|
|
|
|
2015-03-31 18:54:45 -07:00
|
|
|
if (mask)
|
2015-01-13 21:56:38 -08:00
|
|
|
{
|
2015-03-31 18:54:45 -07:00
|
|
|
evas_gl_common_image_update(gc, mask);
|
|
|
|
mtex = mask->tex;
|
|
|
|
if (mtex && mtex->pt && mtex->pt->w && mtex->pt->h)
|
|
|
|
{
|
|
|
|
// canvas coords
|
|
|
|
mx = gc->dc->clip.mask_x;
|
|
|
|
my = gc->dc->clip.mask_y;
|
|
|
|
mw = mask->w;
|
|
|
|
mh = mask->h;
|
|
|
|
mask_smooth = mask->scaled.smooth;
|
2017-01-23 21:23:03 -08:00
|
|
|
mask_color = dc->clip.mask_color;
|
2015-03-31 18:54:45 -07:00
|
|
|
}
|
|
|
|
else mtex = NULL;
|
2015-01-13 21:56:38 -08:00
|
|
|
}
|
|
|
|
|
2011-02-09 22:52:53 -08:00
|
|
|
evas_gl_common_context_image_map_push(gc, im->tex, npoints, p,
|
2011-06-17 00:47:28 -07:00
|
|
|
c, cx, cy, cw, ch,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2011-02-09 22:52:53 -08:00
|
|
|
r, g, b, a, smooth, im->tex_only,
|
2011-08-29 13:56:48 -07:00
|
|
|
im->cs.space);
|
2009-11-11 03:39:25 -08:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-07-07 04:14:02 -07:00
|
|
|
static void
|
|
|
|
_evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
|
|
|
|
int dx, int dy, int dw, int dh,
|
|
|
|
int sx, int sy, int sw, int sh,
|
|
|
|
int cx, int cy, int cw, int ch,
|
2014-11-24 03:24:25 -08:00
|
|
|
int r, int g, int b, int a,
|
2015-03-31 02:58:51 -07:00
|
|
|
Evas_GL_Image *mask,
|
2014-11-24 03:24:25 -08:00
|
|
|
Eina_Bool smooth,
|
2015-05-27 04:17:20 -07:00
|
|
|
Eina_Bool yuv, Eina_Bool yuv_709,
|
|
|
|
Eina_Bool yuy2, Eina_Bool nv12,
|
2014-07-07 04:14:02 -07:00
|
|
|
Eina_Bool rgb_a_pair)
|
2013-09-09 02:59:21 -07:00
|
|
|
{
|
2015-03-31 02:58:51 -07:00
|
|
|
int mx = 0, my = 0, mw = 0, mh = 0;
|
2013-09-09 02:59:21 -07:00
|
|
|
double ssx, ssy, ssw, ssh;
|
2015-03-31 18:54:45 -07:00
|
|
|
Evas_GL_Texture *mtex = NULL;
|
2015-02-25 02:05:12 -08:00
|
|
|
Eina_Bool mask_smooth = EINA_FALSE;
|
2017-01-23 21:23:03 -08:00
|
|
|
Eina_Bool mask_color = EINA_FALSE;
|
2013-09-09 02:59:21 -07:00
|
|
|
int nx, ny, nw, nh;
|
|
|
|
|
|
|
|
nx = dx; ny = dy; nw = dw; nh = dh;
|
|
|
|
RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
|
|
|
|
cx, cy, cw, ch);
|
|
|
|
if ((nw < 1) || (nh < 1)) return;
|
2013-10-16 01:20:14 -07:00
|
|
|
if (!im->tex) return;
|
2014-11-24 03:24:25 -08:00
|
|
|
|
2015-03-31 18:54:45 -07:00
|
|
|
if (mask)
|
2014-12-01 01:26:47 -08:00
|
|
|
{
|
2015-03-31 18:54:45 -07:00
|
|
|
evas_gl_common_image_update(gc, mask);
|
|
|
|
mtex = mask->tex;
|
|
|
|
if (mtex && mtex->pt && mtex->pt->w && mtex->pt->h)
|
|
|
|
{
|
|
|
|
// canvas coords
|
|
|
|
mx = gc->dc->clip.mask_x;
|
|
|
|
my = gc->dc->clip.mask_y;
|
|
|
|
mw = mask->w;
|
|
|
|
mh = mask->h;
|
|
|
|
mask_smooth = mask->scaled.smooth;
|
2017-01-23 21:23:03 -08:00
|
|
|
mask_color = gc->dc->clip.mask_color;
|
2015-03-31 18:54:45 -07:00
|
|
|
}
|
|
|
|
else mtex = NULL;
|
2014-12-01 01:26:47 -08:00
|
|
|
}
|
|
|
|
|
2013-09-09 02:59:21 -07:00
|
|
|
if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
|
|
|
|
{
|
2014-12-01 01:26:47 -08:00
|
|
|
if (yuv)
|
2013-09-09 02:59:21 -07:00
|
|
|
evas_gl_common_context_yuv_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2015-05-27 04:17:20 -07:00
|
|
|
else if (yuv_709)
|
|
|
|
evas_gl_common_context_yuv_709_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2015-05-27 04:17:20 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2013-09-09 02:59:21 -07:00
|
|
|
else if (yuy2)
|
|
|
|
evas_gl_common_context_yuy2_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
|
|
|
else if (nv12)
|
|
|
|
evas_gl_common_context_nv12_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2014-07-07 04:14:02 -07:00
|
|
|
else if (rgb_a_pair)
|
|
|
|
evas_gl_common_context_rgb_a_pair_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2014-07-07 04:14:02 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2013-09-09 02:59:21 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth, im->tex_only);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
|
|
|
|
ssy = (double)sy + ((double)(sh * (ny - dy)) / (double)(dh));
|
|
|
|
ssw = ((double)sw * (double)(nw)) / (double)(dw);
|
|
|
|
ssh = ((double)sh * (double)(nh)) / (double)(dh);
|
|
|
|
|
2014-12-01 01:26:47 -08:00
|
|
|
if (yuv)
|
2013-09-09 02:59:21 -07:00
|
|
|
evas_gl_common_context_yuv_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2015-05-27 04:17:20 -07:00
|
|
|
else if (yuv_709)
|
|
|
|
evas_gl_common_context_yuv_709_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2015-05-27 04:17:20 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2013-09-09 02:59:21 -07:00
|
|
|
else if (yuy2)
|
|
|
|
evas_gl_common_context_yuy2_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
|
|
|
else if (nv12)
|
|
|
|
evas_gl_common_context_nv12_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2014-07-07 04:14:02 -07:00
|
|
|
else if (rgb_a_pair)
|
|
|
|
evas_gl_common_context_rgb_a_pair_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2014-07-07 04:14:02 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2013-09-09 02:59:21 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
2017-01-23 21:23:03 -08:00
|
|
|
mtex, mx, my, mw, mh, mask_smooth, mask_color,
|
2013-09-09 02:59:21 -07:00
|
|
|
r, g, b, a,
|
|
|
|
smooth, im->tex_only);
|
|
|
|
}
|
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
void
|
2011-03-16 10:32:49 -07:00
|
|
|
evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth)
|
2009-11-11 03:39:25 -08:00
|
|
|
{
|
|
|
|
RGBA_Draw_Context *dc;
|
|
|
|
int r, g, b, a;
|
|
|
|
Cutout_Rect *rct;
|
|
|
|
int c, cx, cy, cw, ch;
|
|
|
|
int i;
|
2014-07-07 04:14:02 -07:00
|
|
|
Eina_Bool yuv = EINA_FALSE;
|
2015-05-27 04:17:20 -07:00
|
|
|
Eina_Bool yuv_709 = EINA_FALSE;
|
2014-07-07 04:14:02 -07:00
|
|
|
Eina_Bool yuy2 = EINA_FALSE;
|
|
|
|
Eina_Bool nv12 = EINA_FALSE;
|
|
|
|
Eina_Bool rgb_a_pair = EINA_FALSE;
|
2014-11-24 03:24:25 -08:00
|
|
|
Evas_GL_Image *mask;
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
if (sw < 1) sw = 1;
|
|
|
|
if (sh < 1) sh = 1;
|
|
|
|
dc = gc->dc;
|
|
|
|
if (dc->mul.use)
|
|
|
|
{
|
|
|
|
a = (dc->mul.col >> 24) & 0xff;
|
|
|
|
r = (dc->mul.col >> 16) & 0xff;
|
|
|
|
g = (dc->mul.col >> 8 ) & 0xff;
|
|
|
|
b = (dc->mul.col ) & 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = g = b = a = 255;
|
|
|
|
}
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2011-04-18 22:47:56 -07:00
|
|
|
evas_gl_common_image_update(gc, im);
|
2010-06-02 02:15:01 -07:00
|
|
|
if (!im->tex)
|
|
|
|
{
|
|
|
|
evas_gl_common_rect_draw(gc, dx, dy, dw, dh);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-12 23:22:31 -08:00
|
|
|
|
2015-03-31 18:54:45 -07:00
|
|
|
mask = gc->dc->clip.mask;
|
|
|
|
|
2014-07-07 04:14:02 -07:00
|
|
|
switch (im->cs.space)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
yuv = EINA_TRUE;
|
|
|
|
break;
|
2015-05-27 04:17:20 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
|
|
|
yuv_709 = EINA_TRUE;
|
|
|
|
break;
|
2014-07-07 04:14:02 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
|
|
|
yuy2 = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
|
|
|
nv12 = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_ETC1_ALPHA:
|
|
|
|
rgb_a_pair = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2011-04-20 23:22:06 -07:00
|
|
|
|
2013-07-11 01:37:56 -07:00
|
|
|
if ((sw == dw) && (sh == dh)) smooth = 0;
|
|
|
|
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex->im = im;
|
2011-04-20 23:22:06 -07:00
|
|
|
if ((!gc->dc->cutout.rects) ||
|
2010-08-25 18:41:48 -07:00
|
|
|
((gc->shared->info.tune.cutout.max > 0) &&
|
|
|
|
(gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
|
2009-02-20 19:13:49 -08:00
|
|
|
{
|
2015-01-04 20:44:32 -08:00
|
|
|
if (mask || gc->dc->clip.use)
|
2009-10-09 05:10:27 -07:00
|
|
|
{
|
2014-07-07 04:14:02 -07:00
|
|
|
_evas_gl_common_image_push(gc, im,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
gc->dc->clip.x, gc->dc->clip.y,
|
|
|
|
gc->dc->clip.w, gc->dc->clip.h,
|
2014-11-24 03:24:25 -08:00
|
|
|
r, g, b, a,
|
2015-03-31 02:58:51 -07:00
|
|
|
mask,
|
2014-11-24 03:24:25 -08:00
|
|
|
smooth,
|
2015-05-27 04:17:20 -07:00
|
|
|
yuv, yuv_709, yuy2, nv12, rgb_a_pair);
|
2009-10-09 05:10:27 -07:00
|
|
|
}
|
2009-02-20 19:13:49 -08:00
|
|
|
else
|
2009-10-09 05:10:27 -07:00
|
|
|
{
|
2014-07-07 04:14:02 -07:00
|
|
|
_evas_gl_common_image_push(gc, im,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2014-11-24 03:24:25 -08:00
|
|
|
r, g, b, a,
|
2015-03-31 02:58:51 -07:00
|
|
|
mask,
|
2014-11-24 03:24:25 -08:00
|
|
|
smooth,
|
2015-05-27 04:17:20 -07:00
|
|
|
yuv, yuv_709, yuy2, nv12, rgb_a_pair);
|
2009-10-09 05:10:27 -07:00
|
|
|
}
|
2009-02-20 19:13:49 -08:00
|
|
|
return;
|
|
|
|
}
|
2011-06-17 00:47:28 -07:00
|
|
|
|
2009-02-20 19:13:49 -08:00
|
|
|
/* save out clip info */
|
|
|
|
c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h;
|
2012-04-12 01:01:13 -07:00
|
|
|
evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->shared->w, gc->shared->h);
|
2009-02-20 19:13:49 -08:00
|
|
|
evas_common_draw_context_clip_clip(gc->dc, dx, dy, dw, dh);
|
|
|
|
/* our clip is 0 size.. abort */
|
|
|
|
if ((gc->dc->clip.w <= 0) || (gc->dc->clip.h <= 0))
|
|
|
|
{
|
|
|
|
gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
|
|
|
|
return;
|
|
|
|
}
|
2014-08-07 02:13:07 -07:00
|
|
|
_evas_gl_common_cutout_rects = evas_common_draw_context_apply_cutouts(dc, _evas_gl_common_cutout_rects);
|
|
|
|
for (i = 0; i < _evas_gl_common_cutout_rects->active; ++i)
|
2009-02-20 19:13:49 -08:00
|
|
|
{
|
2014-08-07 02:13:07 -07:00
|
|
|
rct = _evas_gl_common_cutout_rects->rects + i;
|
2013-09-09 02:59:21 -07:00
|
|
|
|
2014-07-07 04:14:02 -07:00
|
|
|
_evas_gl_common_image_push(gc, im,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
rct->x, rct->y, rct->w, rct->h,
|
2014-11-24 03:24:25 -08:00
|
|
|
r, g, b, a,
|
2015-03-31 02:58:51 -07:00
|
|
|
mask,
|
2014-11-24 03:24:25 -08:00
|
|
|
smooth,
|
2015-05-27 04:17:20 -07:00
|
|
|
yuv, yuv_709, yuy2, nv12, rgb_a_pair);
|
2009-02-20 19:13:49 -08:00
|
|
|
}
|
2014-08-07 02:13:07 -07:00
|
|
|
evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects);
|
2009-02-20 19:13:49 -08:00
|
|
|
/* restore clip info */
|
|
|
|
gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
|
2003-09-07 04:24:48 -07:00
|
|
|
}
|