2012-01-04 03:45:22 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
#include <assert.h>
|
|
|
|
|
2008-07-19 11:32:32 -07:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
2011-04-22 17:35:42 -07:00
|
|
|
#include "evas_image.h"
|
2008-07-19 11:32:32 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
int
|
|
|
|
evas_common_rgba_image_from_data(Image_Entry* ie_dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *dst = (RGBA_Image *) ie_dst;
|
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
switch (cspace)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->cache_entry.w = w;
|
|
|
|
dst->cache_entry.h = h;
|
|
|
|
dst->image.data = image_data;
|
|
|
|
dst->image.no_free = 1;
|
2008-06-03 02:09:39 -07:00
|
|
|
dst->cache_entry.flags.alpha = alpha ? 1 : 0;
|
2007-07-16 00:25:35 -07:00
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
2011-07-21 03:36:05 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
2011-09-04 07:31:24 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
2007-07-16 00:25:35 -07:00
|
|
|
w &= ~0x1;
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->cache_entry.w = w;
|
|
|
|
dst->cache_entry.h = h;
|
2007-07-16 00:25:35 -07:00
|
|
|
dst->cs.data = image_data;
|
|
|
|
dst->cs.no_free = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->cache_entry.space = cspace;
|
2007-07-16 00:25:35 -07:00
|
|
|
evas_common_image_colorspace_dirty(dst);
|
2011-04-22 04:47:14 -07:00
|
|
|
_evas_common_rgba_image_post_surface(ie_dst);
|
2007-07-16 00:25:35 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
int
|
|
|
|
evas_common_rgba_image_from_copied_data(Image_Entry* ie_dst, int w, int h, DATA32 *image_data, int alpha, int cspace)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *dst = (RGBA_Image *) ie_dst;
|
|
|
|
|
|
|
|
/* FIXME: Is dst->image.data valid. */
|
2007-07-16 00:25:35 -07:00
|
|
|
switch (cspace)
|
|
|
|
{
|
2011-09-04 07:31:24 -07:00
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
|
|
|
dst->cache_entry.flags.alpha = alpha ? 1 : 0;
|
|
|
|
if (image_data)
|
|
|
|
memcpy(dst->image.data, image_data, w * h * sizeof(DATA32));
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
|
|
|
dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char*) * 2);
|
|
|
|
if (image_data && (dst->cs.data))
|
|
|
|
memcpy(dst->cs.data, image_data, dst->cache_entry.h * sizeof(unsigned char*) * 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->cache_entry.space = cspace;
|
2007-07-16 00:25:35 -07:00
|
|
|
evas_common_image_colorspace_dirty(dst);
|
2011-04-22 04:47:14 -07:00
|
|
|
_evas_common_rgba_image_post_surface(ie_dst);
|
2007-07-16 00:25:35 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
int
|
2010-09-18 16:16:25 -07:00
|
|
|
evas_common_rgba_image_size_set(Image_Entry *ie_dst, const Image_Entry *ie_im, unsigned int w, unsigned int h __UNUSED__)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *dst = (RGBA_Image *) ie_dst;
|
|
|
|
RGBA_Image *im = (RGBA_Image *) ie_im;
|
|
|
|
|
|
|
|
if ((im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
|
2011-07-21 03:36:05 -07:00
|
|
|
(im->cache_entry.space == EVAS_COLORSPACE_YCBCR422P709_PL) ||
|
2011-09-04 07:31:24 -07:00
|
|
|
(im->cache_entry.space == EVAS_COLORSPACE_YCBCR422601_PL) ||
|
|
|
|
(im->cache_entry.space == EVAS_COLORSPACE_YCBCR420TM12601_PL) ||
|
|
|
|
(im->cache_entry.space == EVAS_COLORSPACE_YCBCR420NV12601_PL))
|
|
|
|
{
|
|
|
|
w &= ~0x1;
|
|
|
|
dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
|
|
|
|
}
|
2007-07-16 00:25:35 -07:00
|
|
|
|
|
|
|
dst->flags = im->flags;
|
|
|
|
dst->cs.no_free = 0;
|
|
|
|
evas_common_image_colorspace_dirty(dst);
|
|
|
|
|
2011-04-22 04:47:14 -07:00
|
|
|
_evas_common_rgba_image_post_surface(ie_dst);
|
2007-07-16 00:25:35 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
int
|
|
|
|
evas_common_rgba_image_colorspace_set(Image_Entry* ie_dst, int cspace)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2008-04-11 17:32:30 -07:00
|
|
|
RGBA_Image *dst = (RGBA_Image *) ie_dst;
|
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
switch (cspace)
|
|
|
|
{
|
|
|
|
case EVAS_COLORSPACE_ARGB8888:
|
|
|
|
if (dst->cs.data)
|
|
|
|
{
|
|
|
|
if (!dst->cs.no_free) free(dst->cs.data);
|
|
|
|
dst->cs.data = NULL;
|
|
|
|
dst->cs.no_free = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
2011-07-21 03:36:05 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR422601_PL:
|
2011-09-04 07:31:24 -07:00
|
|
|
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
|
|
|
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
2008-04-11 17:32:30 -07:00
|
|
|
if (dst->image.no_free)
|
2007-07-16 00:25:35 -07:00
|
|
|
{
|
2010-12-14 02:22:06 -08:00
|
|
|
ie_dst->allocated.w = 0;
|
|
|
|
ie_dst->allocated.h = 0;
|
2010-12-18 02:09:58 -08:00
|
|
|
#ifdef BUILD_ASYNC_PRELOAD
|
2010-12-14 02:22:06 -08:00
|
|
|
ie_dst->flags.preload_done = 0;
|
2010-12-18 02:09:58 -08:00
|
|
|
#endif
|
2010-12-14 02:22:06 -08:00
|
|
|
ie_dst->flags.loaded = 0;
|
|
|
|
dst->image.data = NULL;
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->image.no_free = 0;
|
|
|
|
/* FIXME: Must allocate image.data surface cleanly. */
|
2007-07-16 00:25:35 -07:00
|
|
|
}
|
|
|
|
if (dst->cs.data)
|
|
|
|
{
|
|
|
|
if (!dst->cs.no_free) free(dst->cs.data);
|
|
|
|
}
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->cs.data = calloc(1, dst->cache_entry.h * sizeof(unsigned char *) * 2);
|
2007-07-16 00:25:35 -07:00
|
|
|
dst->cs.no_free = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
2008-04-11 17:32:30 -07:00
|
|
|
dst->cache_entry.space = cspace;
|
2007-07-16 00:25:35 -07:00
|
|
|
evas_common_image_colorspace_dirty(dst);
|
|
|
|
|
2011-04-22 04:47:14 -07:00
|
|
|
_evas_common_rgba_image_post_surface(ie_dst);
|
2007-07-16 00:25:35 -07:00
|
|
|
return 0;
|
|
|
|
}
|