2003-09-07 04:24:48 -07:00
|
|
|
#include "evas_gl_private.h"
|
2003-09-04 00:40:34 -07:00
|
|
|
|
2010-04-12 01:23:53 -07:00
|
|
|
void
|
|
|
|
evas_gl_common_image_all_unload(Evas_GL_Context *gc)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_GL_Image *im;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(gc->shared->images, l, im)
|
|
|
|
{
|
|
|
|
if (im->im) evas_cache_image_unload_data(&im->im->cache_entry);
|
|
|
|
if (im->tex) evas_gl_common_texture_free(im->tex);
|
|
|
|
im->tex = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
Evas_GL_Image *
|
2009-12-22 15:11:57 -08:00
|
|
|
evas_gl_common_image_load(Evas_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
Evas_GL_Image *im;
|
|
|
|
RGBA_Image *im_im;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-12-22 15:11:57 -08:00
|
|
|
im_im = evas_common_load_image_from_file(file, key, lo, error);
|
2003-09-07 04:24:48 -07:00
|
|
|
if (!im_im) return NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-10-13 02:40:39 -07:00
|
|
|
EINA_LIST_FOREACH(gc->shared->images, l, im)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
|
|
|
if (im->im == im_im)
|
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_cache_image_drop(&im_im->cache_entry);
|
2009-10-13 02:40:39 -07:00
|
|
|
gc->shared->images = eina_list_remove_list(gc->shared->images, l);
|
|
|
|
gc->shared->images = eina_list_prepend(gc->shared->images, im);
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references++;
|
2009-12-22 15:11:57 -08:00
|
|
|
*error = EVAS_LOAD_ERROR_NONE;
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references = 1;
|
|
|
|
im->im = im_im;
|
|
|
|
im->gc = gc;
|
|
|
|
im->references = 1;
|
|
|
|
im->cached = 1;
|
2006-12-17 07:48:52 -08:00
|
|
|
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
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);
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int 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
|
|
|
|
2009-10-13 02:40:39 -07:00
|
|
|
EINA_LIST_FOREACH(gc->shared->images, l, im)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
if (((void *)(im->im->image.data) == (void *)data) &&
|
|
|
|
(im->im->cache_entry.w == w) &&
|
|
|
|
(im->im->cache_entry.h == h))
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2009-10-13 02:40:39 -07:00
|
|
|
gc->shared->images = eina_list_remove_list(gc->shared->images, l);
|
|
|
|
gc->shared->images = eina_list_prepend(gc->shared->images, im);
|
2003-09-07 04:24:48 -07:00
|
|
|
im->references++;
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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:
|
|
|
|
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.data = data;
|
|
|
|
im->cs.no_free = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
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:
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
|
|
|
if (im->tex) evas_gl_common_texture_free(im->tex);
|
2009-11-11 03:39:25 -08:00
|
|
|
im->tex = NULL;
|
2006-12-28 19:32:46 -08:00
|
|
|
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);
|
2006-12-17 07:48:52 -08:00
|
|
|
if ((data) && (im->cs.data))
|
2008-04-11 17:32:30 -07:00
|
|
|
memcpy(im->cs.data, data, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
|
2006-12-17 07:48:52 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
2003-09-07 04:24:48 -07:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_GL_Image *
|
2006-12-17 07:48:52 -08:00
|
|
|
evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspace)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
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:
|
|
|
|
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;
|
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;
|
|
|
|
im->im->cache_entry.flags.alpha = alpha ? 1 : 0;
|
|
|
|
if (im->tex)
|
|
|
|
{
|
|
|
|
evas_gl_common_texture_free(im->tex);
|
|
|
|
im->tex = NULL;
|
|
|
|
}
|
|
|
|
if (!im->tex)
|
|
|
|
im->tex = evas_gl_common_texture_new(im->gc, im->im);
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2010-01-21 00:44:11 -08:00
|
|
|
void
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
|
|
|
|
im->cached = 0;
|
|
|
|
}
|
|
|
|
if (im->im)
|
|
|
|
{
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
|
|
|
im->im = NULL;
|
|
|
|
}
|
|
|
|
if (im->tex)
|
|
|
|
{
|
|
|
|
evas_gl_common_texture_free(im->tex);
|
|
|
|
im->tex = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_gl_common_image_native_disable(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
if (im->im)
|
|
|
|
{
|
|
|
|
evas_cache_image_drop(&im->im->cache_entry);
|
|
|
|
im->im = NULL;
|
|
|
|
}
|
|
|
|
if (im->tex)
|
|
|
|
{
|
|
|
|
evas_gl_common_texture_free(im->tex);
|
|
|
|
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);
|
|
|
|
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);
|
2010-01-21 00:44:11 -08:00
|
|
|
}
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
void
|
|
|
|
evas_gl_common_image_free(Evas_GL_Image *im)
|
|
|
|
{
|
|
|
|
im->references--;
|
|
|
|
if (im->references > 0) return;
|
2010-01-21 00:44:11 -08:00
|
|
|
|
|
|
|
if (im->native.func.free)
|
|
|
|
im->native.func.free(im->native.func.data, im);
|
|
|
|
|
2006-12-17 07:48:52 -08:00
|
|
|
if (im->cs.data)
|
|
|
|
{
|
|
|
|
if (!im->cs.no_free) free(im->cs.data);
|
|
|
|
}
|
2009-10-13 02:40:39 -07:00
|
|
|
if (im->cached) im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
|
2008-04-11 17:32:30 -07:00
|
|
|
if (im->im) evas_cache_image_drop(&im->im->cache_entry);
|
2003-09-07 04:24:48 -07:00
|
|
|
if (im->tex) evas_gl_common_texture_free(im->tex);
|
|
|
|
free(im);
|
|
|
|
}
|
|
|
|
|
2009-11-12 23:22:31 -08:00
|
|
|
Evas_GL_Image *
|
|
|
|
evas_gl_common_image_surface_new(Evas_GL_Context *gc, int w, int h, int alpha)
|
|
|
|
{
|
|
|
|
Evas_GL_Image *im;
|
|
|
|
|
|
|
|
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_new(gc, w, h, alpha);
|
|
|
|
im->tex_only = 1;
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2003-09-07 04:24:48 -07:00
|
|
|
void
|
2009-12-19 22:23:13 -08:00
|
|
|
evas_gl_common_image_dirty(Evas_GL_Image *im, int x, int y, int w, 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)
|
|
|
|
{
|
2009-12-19 22:23:13 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
static void
|
2009-11-12 23:22:31 -08:00
|
|
|
_evas_gl_common_image_update(Evas_GL_Context *gc, Evas_GL_Image *im)
|
2003-09-07 04:24:48 -07:00
|
|
|
{
|
2009-11-12 23:22:31 -08:00
|
|
|
if (!im->im) return;
|
2009-10-10 06:24:15 -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)
|
2007-12-25 03:12:39 -08:00
|
|
|
evas_common_convert_yuv_420p_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
|
|
|
*/
|
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:
|
|
|
|
if ((im->tex) && (im->dirty))
|
2010-04-12 01:23:53 -07:00
|
|
|
{
|
|
|
|
evas_cache_image_load_data(&im->im->cache_entry);
|
|
|
|
evas_gl_common_texture_update(im->tex, im->im);
|
|
|
|
evas_cache_image_unload_data(&im->im->cache_entry);
|
|
|
|
}
|
2006-12-17 07:48:52 -08:00
|
|
|
if (!im->tex)
|
2010-04-12 01:23:53 -07:00
|
|
|
{
|
|
|
|
evas_cache_image_load_data(&im->im->cache_entry);
|
|
|
|
im->tex = evas_gl_common_texture_new(gc, im->im);
|
|
|
|
evas_cache_image_unload_data(&im->im->cache_entry);
|
|
|
|
}
|
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;
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
2009-10-10 06:24:15 -07:00
|
|
|
if ((im->tex) && (im->dirty))
|
|
|
|
{
|
|
|
|
evas_gl_common_texture_yuv_update(im->tex, im->cs.data,
|
|
|
|
im->im->cache_entry.w,
|
|
|
|
im->im->cache_entry.h);
|
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
|
|
|
|
{
|
|
|
|
im->tex = evas_gl_common_texture_yuv_new(gc, im->cs.data,
|
|
|
|
im->im->cache_entry.w,
|
|
|
|
im->im->cache_entry.h);
|
|
|
|
im->dirty = 0;
|
|
|
|
}
|
|
|
|
if (!im->tex) return;
|
|
|
|
break;
|
2006-12-17 07:48:52 -08:00
|
|
|
default:
|
2009-10-09 05:10:27 -07:00
|
|
|
printf("unhandled img format\n");
|
2006-12-17 07:48:52 -08:00
|
|
|
break;
|
|
|
|
}
|
2009-11-11 03:39:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im,
|
|
|
|
RGBA_Map_Point *p, int smooth, int level)
|
|
|
|
{
|
|
|
|
RGBA_Draw_Context *dc;
|
|
|
|
int r, g, b, a;
|
|
|
|
int c, cx, cy, cw, ch;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-11-12 23:22:31 -08:00
|
|
|
_evas_gl_common_image_update(gc, im);
|
2009-11-13 21:08:00 -08:00
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
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;
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex->im = im;
|
2009-11-11 03:39:25 -08:00
|
|
|
evas_gl_common_context_image_map4_push(gc, im->tex, p,
|
|
|
|
c, cx, cy, cw, ch,
|
2009-11-12 23:22:31 -08:00
|
|
|
r, g, b, a, smooth, im->tex_only);
|
2009-11-11 03:39:25 -08:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
void
|
|
|
|
evas_gl_common_image_draw(Evas_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)
|
|
|
|
{
|
|
|
|
RGBA_Draw_Context *dc;
|
|
|
|
int r, g, b, a;
|
|
|
|
double ssx, ssy, ssw, ssh;
|
|
|
|
Cutout_Rects *rects;
|
|
|
|
Cutout_Rect *rct;
|
|
|
|
int c, cx, cy, cw, ch;
|
|
|
|
int i;
|
|
|
|
int yuv = 0;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-11-12 23:22:31 -08: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
|
|
|
|
2009-11-11 03:39:25 -08:00
|
|
|
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
|
|
|
|
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
|
|
|
|
yuv = 1;
|
|
|
|
|
2010-01-21 00:44:11 -08:00
|
|
|
im->tex->im = im;
|
2010-08-01 23:46:38 -07:00
|
|
|
if ((!gc->dc->cutout.rects) ||
|
|
|
|
((gc->shared->info.cutout_max > 0) &&
|
|
|
|
(gc->dc->cutout.active > gc->shared->info.cutout_max)))
|
2009-02-20 19:13:49 -08:00
|
|
|
{
|
|
|
|
if (gc->dc->clip.use)
|
2009-10-09 05:10:27 -07:00
|
|
|
{
|
|
|
|
int nx, ny, nw, nh;
|
|
|
|
|
|
|
|
nx = dx; ny = dy; nw = dw; nh = dh;
|
|
|
|
RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
|
|
|
|
gc->dc->clip.x, gc->dc->clip.y,
|
|
|
|
gc->dc->clip.w, gc->dc->clip.h);
|
|
|
|
if ((nw < 1) || (nh < 1)) return;
|
|
|
|
if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
|
|
|
|
{
|
2009-10-10 06:24:15 -07:00
|
|
|
if (yuv)
|
|
|
|
evas_gl_common_context_yuv_push(gc,
|
2009-10-09 05:10:27 -07:00
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2009-10-10 06:24:15 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
r, g, b, a,
|
2010-01-21 00:44:11 -08:00
|
|
|
smooth, im->tex_only);
|
2009-10-09 05:10:27 -07:00
|
|
|
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);
|
2009-10-10 06:24:15 -07:00
|
|
|
if (yuv)
|
|
|
|
evas_gl_common_context_yuv_push(gc,
|
2009-10-09 05:10:27 -07:00
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2009-10-10 06:24:15 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
|
|
|
r, g, b, a,
|
2010-01-21 00:44:11 -08:00
|
|
|
smooth, im->tex_only);
|
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
|
|
|
{
|
2009-10-10 06:24:15 -07:00
|
|
|
if (yuv)
|
|
|
|
evas_gl_common_context_yuv_push(gc,
|
2009-10-09 05:10:27 -07:00
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2009-10-10 06:24:15 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
r, g, b, a,
|
2010-01-21 00:44:11 -08:00
|
|
|
smooth, im->tex_only);
|
2009-10-09 05:10:27 -07:00
|
|
|
}
|
2009-02-20 19:13:49 -08:00
|
|
|
return;
|
|
|
|
}
|
2009-10-09 05:10:27 -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;
|
|
|
|
evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->w, gc->h);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
rects = evas_common_draw_context_apply_cutouts(dc);
|
|
|
|
for (i = 0; i < rects->active; ++i)
|
|
|
|
{
|
2009-10-09 05:10:27 -07:00
|
|
|
int nx, ny, nw, nh;
|
|
|
|
|
2009-02-20 19:13:49 -08:00
|
|
|
rct = rects->rects + i;
|
2009-10-09 05:10:27 -07:00
|
|
|
nx = dx; ny = dy; nw = dw; nh = dh;
|
|
|
|
RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h);
|
|
|
|
if ((nw < 1) || (nh < 1)) continue;
|
|
|
|
if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
|
|
|
|
{
|
2009-10-10 06:24:15 -07:00
|
|
|
if (yuv)
|
|
|
|
evas_gl_common_context_yuv_push(gc,
|
2009-10-22 01:53:25 -07:00
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
2009-10-09 05:10:27 -07:00
|
|
|
r, g, b, a,
|
2009-10-22 01:53:25 -07:00
|
|
|
smooth);
|
2009-10-10 06:24:15 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
sx, sy, sw, sh,
|
|
|
|
dx, dy, dw, dh,
|
|
|
|
r, g, b, a,
|
2010-01-21 00:44:11 -08:00
|
|
|
smooth, im->tex_only);
|
2009-10-09 05:10:27 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
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);
|
2009-10-10 06:24:15 -07:00
|
|
|
if (yuv)
|
|
|
|
evas_gl_common_context_yuv_push(gc,
|
2009-10-09 05:10:27 -07:00
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
|
|
|
r, g, b, a,
|
|
|
|
smooth);
|
2009-10-10 06:24:15 -07:00
|
|
|
else
|
|
|
|
evas_gl_common_context_image_push(gc,
|
|
|
|
im->tex,
|
|
|
|
ssx, ssy, ssw, ssh,
|
|
|
|
nx, ny, nw, nh,
|
|
|
|
r, g, b, a,
|
2010-01-21 00:44:11 -08:00
|
|
|
smooth, im->tex_only);
|
2009-02-20 19:13:49 -08:00
|
|
|
}
|
|
|
|
evas_common_draw_context_apply_clear_cutouts(rects);
|
|
|
|
/* 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
|
|
|
}
|