{
EVAS_COLORSPACE_ARGB8888, /**< ARGB 32 bits per pixel, high-byte is Alpha, accessed 1 32bit word at a time */
/* these are not currently supported - but planned for the future */
- EVAS_COLORSPACE_YCBCR422P601, /**< YCbCr 4:2:2 Planar with Planes in order Y, Cb and Cr, ITU.BT-601 specifications */
- EVAS_COLORSPACE_YCBCR422P709 /**< YCbCr 4:2:2 Planar with Planes in order Y, Cb and Cr, ITU-BT-709 specifications */
+ EVAS_COLORSPACE_YCBCR422P601_PL, /**< YCbCr 4:2:2 Planar, ITU.BT-601 specifications. The data poitned to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
+ EVAS_COLORSPACE_YCBCR422P709_PL /**< YCbCr 4:2:2 Planar, ITU.BT-709 specifications. The data poitned to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
} Evas_Colorspace; /**< Colorspaces for pixel data supported by Evas */
typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
const char *file;
const char *key;
+ int cspace;
char smooth_scale : 1;
char has_alpha :1;
o->engine_data, &w, &h);
o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output,
o->engine_data);
+ o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
+ o->engine_data);
o->cur.image.w = w;
o->cur.image.h = h;
}
{
o->load_error = EVAS_LOAD_ERROR_GENERIC;
o->cur.has_alpha = 1;
+ o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
o->cur.image.w = 0;
o->cur.image.h = 0;
}
o->engine_data,
w, h);
else
- o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data(obj->layer->evas->engine.data.output,
- w, h, NULL);
+ o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data
+ (obj->layer->evas->engine.data.output, w, h, NULL, o->cur.has_alpha,
+ o->cur.cspace);
+/* FIXME - in engine call above
if (o->engine_data)
o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
o->engine_data,
o->cur.has_alpha);
+ */
EVAS_OBJECT_IMAGE_FREE_FILE_AND_KEY(o);
o->changed = 1;
evas_object_change(obj);
o->engine_data = obj->layer->evas->engine.func->image_new_from_data(obj->layer->evas->engine.data.output,
o->cur.image.w,
o->cur.image.h,
- data);
+ data,
+ o->cur.has_alpha,
+ o->cur.cspace);
}
else
{
o->cur.image.h = 0;
o->engine_data = NULL;
}
+/* FIXME - in engine call above
if (o->engine_data)
o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
o->engine_data,
o->cur.has_alpha);
+ */
if (o->pixels_checked_out > 0) o->pixels_checked_out--;
if (p_data != o->engine_data)
{
o->engine_data = obj->layer->evas->engine.func->image_new_from_copied_data(obj->layer->evas->engine.data.output,
o->cur.image.w,
o->cur.image.h,
- data);
+ data,
+ o->cur.has_alpha,
+ o->cur.cspace);
if (o->engine_data)
o->engine_data = obj->layer->evas->engine.func->image_alpha_set(obj->layer->evas->engine.data.output,
o->engine_data,
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
return;
MAGIC_CHECK_END();
- obj->layer->evas->engine.func->image_colorspace_set(obj->layer->evas->engine.data.output,
- o->engine_data,
- cspace);
+ o->cur.cspace = cspace;
+ if (o->engine_data)
+ obj->layer->evas->engine.func->image_colorspace_set(obj->layer->evas->engine.data.output,
+ o->engine_data,
+ cspace);
}
/**
o->engine_data = NULL;
o->load_error = EVAS_LOAD_ERROR_NONE;
o->cur.has_alpha = 1;
+ o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
o->cur.image.w = 0;
o->cur.image.h = 0;
}
o->engine_data, &w, &h);
o->cur.has_alpha = obj->layer->evas->engine.func->image_alpha_get(obj->layer->evas->engine.data.output,
o->engine_data);
+ o->cur.cspace = obj->layer->evas->engine.func->image_colorspace_get(obj->layer->evas->engine.data.output,
+ o->engine_data);
o->cur.image.w = w;
o->cur.image.h = h;
}
o->cur.fill.h = 32.0;
o->cur.smooth_scale = 1;
o->cur.border.fill = 1;
+ o->cur.cspace = EVAS_COLORSPACE_ARGB8888;
o->prev = o->cur;
return o;
}
if ((o->cur.image.w != o->prev.image.w) ||
(o->cur.image.h != o->prev.image.h) ||
(o->cur.has_alpha != o->prev.has_alpha) ||
+ (o->cur.cspace != o->prev.cspace) ||
(o->cur.smooth_scale != o->prev.smooth_scale))
{
updates = evas_object_render_pre_prev_cur_add(updates, obj);
if (!im) return NULL;
im->flags = RGBA_IMAGE_NOTHING;
im->ref = 1;
+ im->cs.space = EVAS_COLORSPACE_ARGB8888;
return im;
}
{
im->ref--;
if (im->ref > 0) return;
+ if (im->cs.data != im->image->data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ }
+ im->cs.data = NULL;
evas_common_pipe_free(im);
if (im->image) evas_common_image_surface_free(im->image);
if (im->info.file) evas_stringshare_del(im->info.file);
}
EAPI void
+evas_common_image_colorspace_normalize(RGBA_Image *im)
+{
+ if ((!im->cs.data) || (!im->cs.dirty)) return;
+ switch (im->cs.space)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ if (im->image->data != im->cs.data)
+ {
+ if (!im->image->no_free) free(im->image->data);
+ im->image->data = im->cs.data;
+ im->cs.no_free = im->image->no_free;
+ }
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ if ((im->image->data) && (*((unsigned char **)im->cs.data)))
+ evas_common_convert_yuv_420p_601_rgba(im->cs.data, im->image->data,
+ im->image->w, im->image->h);
+ break;
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ break;
+ default:
+ break;
+ }
+ im->cs.dirty = 0;
+}
+
+EAPI void
+evas_common_image_colorspace_dirty(RGBA_Image *im)
+{
+ im->cs.dirty = 1;
+}
+
+EAPI void
evas_common_image_cache(RGBA_Image *im)
{
int ram;
unsigned char scale;
RGBA_Pipe *pipe;
int ref;
+ struct {
+ void *data;
+ int space;
+ unsigned char no_free : 1;
+ unsigned char dirty : 1;
+ } cs;
};
struct _RGBA_Gradient_Color_Stop
EAPI void evas_common_image_surface_free (RGBA_Surface *is);/*2*/
EAPI void evas_common_image_surface_alloc (RGBA_Surface *is);/*2*/
EAPI void evas_common_image_surface_dealloc (RGBA_Surface *is);/*2*/
+EAPI void evas_common_image_colorspace_normalize(RGBA_Image *im);
+EAPI void evas_common_image_colorspace_dirty (RGBA_Image *im);
EAPI void evas_common_image_cache (RGBA_Image *im); /*2*/
EAPI void evas_common_image_uncache (RGBA_Image *im); /*2*/
EAPI void evas_common_image_store (RGBA_Image *im); /*2*/
void (*gradient_draw) (void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h);
void *(*image_load) (void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo);
- void *(*image_new_from_data) (void *data, int w, int h, DATA32 *image_data);
- void *(*image_new_from_copied_data) (void *data, int w, int h, DATA32 *image_data);
+ void *(*image_new_from_data) (void *data, int w, int h, DATA32 *image_data, int alpha, int cspace);
+ void *(*image_new_from_copied_data) (void *data, int w, int h, DATA32 *image_data, int alpha, int cspace);
void (*image_free) (void *data, void *image);
void (*image_size_get) (void *data, void *image, int *w, int *h);
void *(*image_size_set) (void *data, void *image, int w, int h);
static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h);
static void *eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo);
-static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data);
-static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data);
+static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace);
+static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace);
static void eng_image_free(void *data, void *image);
static void eng_image_size_get(void *data, void *image, int *w, int *h);
static void *eng_image_size_set(void *data, void *image, int w, int h);
}
static void *
-eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
Evas_Cairo_Image *im;
}
static void *
-eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
Evas_Cairo_Image *im;
void *
evas_engine_directfb_image_new_from_data(void *data, int w, int h,
- DATA32 * image_data)
+ DATA32 * image_data, int alpha, int cspace)
{
/* FIXME document this peculiarity */
return evas_engine_directfb_image_new_from_copied_data(data, w, h, image_data);
void *
evas_engine_directfb_image_new_from_copied_data(void *data, int w, int h,
- DATA32 * image_data)
+ DATA32 * image_data, int alpha, int cspace)
{
Render_Engine *re;
mode->fb_var.yres +
mode->fb_var.lower_margin +
mode->fb_var.vsync_len;
- clockrate =
- 1000000 / mode->fb_var.pixclock;
- mode->refresh = clockrate * 1000000 / (lines * hpix);
+ if (mode->fb_var.pixclock > 0)
+ clockrate = 1000000 / mode->fb_var.pixclock;
+ else
+ clockrate = 0;
+ if ((lines > 0) && (hpix > 0))
+ mode->refresh = clockrate * 1000000 / (lines * hpix);
switch (mode->fb_var.bits_per_pixel)
{
case 1:
int tw, th;
int uw, uh;
- GLuint texture;
+ GLuint texture, texture2, texture3;
+ GLhandleARB prog;
unsigned char smooth : 1;
unsigned char changed : 1;
RGBA_Image_Loadopts load_opts;
int putcount;
int references;
+ struct {
+ int space;
+ void *data;
+ unsigned char no_free : 1;
+ } cs;
unsigned char dirty : 1;
unsigned char cached : 1;
};
void evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int smooth);
Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key, Evas_Image_Load_Opts *lo);
-Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data);
-Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data);
-Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h);
+Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace);
+Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace);
+Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspace);
void evas_gl_common_image_free(Evas_GL_Image *im);
void evas_gl_common_image_dirty(Evas_GL_Image *im);
ext = glGetString(GL_EXTENSIONS);
if (ext)
{
- if (strstr(ext, "GL_SGIS_generate_mipmap")) gc->ext.sgis_generate_mipmap = 1;
- if (strstr(ext, "GL_NV_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
- if (strstr(ext, "GL_EXT_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
+// if (strstr(ext, "GL_SGIS_generate_mipmap")) gc->ext.sgis_generate_mipmap = 1;
+// if (strstr(ext, "GL_NV_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
+// if (strstr(ext, "GL_EXT_texture_rectangle")) gc->ext.nv_texture_rectangle = 1;
if (strstr(ext, "GL_ARB_texture_non_power_of_two")) gc->ext.arb_texture_non_power_of_two = 1;
printf("GL EXT supported: GL_SGIS_generate_mipmap = %x\n", gc->ext.sgis_generate_mipmap);
printf("GL EXT supported: GL_NV_texture_rectangle = %x\n", gc->ext.nv_texture_rectangle);
// changing textures a lot (doing video). so we wont do anything with this
// for now, but it does work.
// gc->ext.arb_texture_non_power_of_two = 0; printf("DISABLE GL_ARB_texture_non_power_of_two\n");
- gc->ext.nv_texture_rectangle = 0; printf("DISABLE GL_NV_texture_rectangle\n");
+// gc->ext.nv_texture_rectangle = 0; printf("DISABLE GL_NV_texture_rectangle\n");
}
else
{
if (!gc->change.texture) return;
if (gc->font_texture > 0)
{
+ glUseProgramObjectARB(0);
if (gc->font_texture_rectangle)
{
glEnable(GL_TEXTURE_2D);
else
{
if (gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, gc->texture->texture);
+ if ((gc->texture->prog) &&
+ (gc->texture->texture2) && (gc->texture->texture3))
+ {
+ int i;
+
+ glActiveTexture(GL_TEXTURE1);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, gc->texture->texture2);
+
+ glActiveTexture(GL_TEXTURE2);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, gc->texture->texture3);
+
+ glActiveTexture(GL_TEXTURE0);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, gc->texture->texture);
+
+ glUseProgramObjectARB(gc->texture->prog);
+ }
+ else
+ {
+ glUseProgramObjectARB(0);
+
+ glActiveTexture(GL_TEXTURE1);
+ glDisable(GL_TEXTURE_2D);
+ glActiveTexture(GL_TEXTURE2);
+ glDisable(GL_TEXTURE_2D);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, gc->texture->texture);
+ glEnable(GL_TEXTURE_2D);
+ }
}
if (gc->texture->rectangle)
{
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- if (gc->texture->have_mipmaps)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- else
+// if (gc->texture->have_mipmaps)
+// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+// else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
else
im->gc = gc;
im->references = 1;
im->cached = 1;
+ im->cs.space = EVAS_COLORSPACE_ARGB8888;
if (lo) im->load_opts = *lo;
gc->images = evas_list_prepend(gc->images, im);
return im;
}
Evas_GL_Image *
-evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data)
+evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace)
{
Evas_GL_Image *im;
Evas_List *l;
free(im);
return NULL;
}
+ im->gc = gc;
im->im->image->w = w;
im->im->image->h = h;
- im->im->image->data = data;
- im->im->image->no_free = 1;
- im->gc = gc;
-/*
- im->cached = 1;
- gc->images = evas_list_prepend(gc->images, im);
- */
+ im->cs.space = cspace;
+ if (alpha)
+ im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ else
+ im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ switch (cspace)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ im->im->image->data = data;
+ im->im->image->no_free = 1;
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ 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;
+ }
+ /*
+ im->cached = 1;
+ gc->images = evas_list_prepend(gc->images, im);
+ */
return im;
}
Evas_GL_Image *
-evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data)
+evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data, int alpha, int cspace)
{
Evas_GL_Image *im;
free(im);
return NULL;
}
- if (data)
- memcpy(im->im->image->data, data, w * h * sizeof(DATA32));
im->gc = gc;
+ im->cs.space = cspace;
+ if (alpha)
+ im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ else
+ im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ switch (cspace)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ if (data)
+ memcpy(im->im->image->data, data, w * h * sizeof(DATA32));
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ evas_common_image_surface_dealloc(im->im->image);
+ im->im->image->data = NULL;
+ if (im->tex) evas_gl_common_texture_free(im->tex);
+ im->tex = NULL;
+ im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
+ if ((data) && (im->cs.data))
+ memcpy(im->cs.data, data, im->im->image->h * sizeof(unsigned char *) * 2);
+ break;
+ default:
+ abort();
+ break;
+ }
return im;
}
Evas_GL_Image *
-evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h)
+evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspace)
{
Evas_GL_Image *im;
im->references--;
if (im->references > 0) return;
- if (im->cached)
- im->gc->images = evas_list_remove(im->gc->images, im);
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ }
+ if (im->cached) im->gc->images = evas_list_remove(im->gc->images, im);
if (im->im) evas_common_image_unref(im->im);
if (im->tex) evas_gl_common_texture_free(im->tex);
free(im);
r = g = b = a = 255;
}
evas_common_load_image_data_from_file(im->im);
- if ((im->tex) && (im->dirty))
- {
- evas_gl_common_texture_update(im->tex, im->im, im->tex->smooth);
- im->dirty = 0;
- }
- if (!im->tex)
- im->tex = evas_gl_common_texture_new(gc, im->im, smooth);
- ow = (dw * im->tex->tw) / sw;
- oh = (dh * im->tex->th) / sh;
- evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh);
- if ((!im->tex->have_mipmaps) && (smooth) &&
- ((im->tex->uw < im->tex->tw) || (im->tex->uh < im->tex->th)) &&
- (!gc->ext.sgis_generate_mipmap))
- evas_gl_common_texture_mipmaps_build(im->tex, im->im, smooth);
-
- if (im->tex->rectangle)
- {
- tx1 = sx;
- ty1 = sy;
- tx2 = sx + sw;
- ty2 = sy + sh;
- }
- else
+ switch (im->cs.space)
{
+ case EVAS_COLORSPACE_ARGB8888:
+ if ((im->tex) && (im->dirty))
+ {
+ evas_gl_common_texture_update(im->tex, im->im, im->tex->smooth);
+ im->dirty = 0;
+ }
+ if (!im->tex)
+ im->tex = evas_gl_common_texture_new(gc, im->im, smooth);
+ ow = (dw * im->tex->tw) / sw;
+ oh = (dh * im->tex->th) / sh;
+ if (im->tex->rectangle)
+ {
+ tx1 = sx;
+ ty1 = sy;
+ tx2 = sx + sw;
+ ty2 = sy + sh;
+ }
+ else
+ {
+ tx1 = (double)(sx ) / (double)(im->tex->w);
+ ty1 = (double)(sy ) / (double)(im->tex->h);
+ tx2 = (double)(sx + sw) / (double)(im->tex->w);
+ ty2 = (double)(sy + sh) / (double)(im->tex->h);
+ }
+ evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh);
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ if ((im->tex) && (im->dirty))
+ {
+ evas_gl_common_ycbcr601pl_texture_update(im->tex, im->cs.data, im->im->image->w, im->im->image->h);
+ im->dirty = 0;
+ }
+ if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
+ im->tex = evas_gl_common_ycbcr601pl_texture_new(gc, im->cs.data, im->im->image->w, im->im->image->h);
+ if (!im->tex) return;
+ ow = (dw * im->tex->tw) / sw;
+ oh = (dh * im->tex->th) / sh;
tx1 = (double)(sx ) / (double)(im->tex->w);
ty1 = (double)(sy ) / (double)(im->tex->h);
tx2 = (double)(sx + sw) / (double)(im->tex->w);
ty2 = (double)(sy + sh) / (double)(im->tex->h);
- }
+ evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh);
+ break;
+ default:
+ abort();
+ break;
+ }
+// if ((!im->tex->have_mipmaps) && (smooth) &&
+// ((im->tex->uw < im->tex->tw) || (im->tex->uh < im->tex->th)) &&
+// (!gc->ext.sgis_generate_mipmap))
+// evas_gl_common_texture_mipmaps_build(im->tex, im->im, smooth);
+
evas_gl_common_context_color_set(gc, r, g, b, a);
if ((a < 255) || (im->im->flags & RGBA_IMAGE_HAS_ALPHA))
evas_gl_common_context_blend_set(gc, 1);
gc->change.texture = 1;
tex->references++;
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0,
texfmt, tw, th, 0,
pixfmt, NATIVE_PIX_UNIT, NULL);
+/*
{
int ttw, tth;
int l;
pixfmt, NATIVE_PIX_UNIT, NULL);
}
}
+ */
if (gc->ext.sgis_generate_mipmap)
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
tex->gc->change.texture = 1;
}
glDeleteTextures(1, &tex->texture);
+ if (tex->texture2) glDeleteTextures(1, &tex->texture2);
+ if (tex->texture3) glDeleteTextures(1, &tex->texture3);
+ if (tex->prog)
+ glDeleteObjectARB(tex->prog);
free(tex);
}
if (mmx) evas_common_cpu_end_opt();
#endif
}
+
+Evas_GL_Texture *
+evas_gl_common_ycbcr601pl_texture_new(Evas_GL_Context *gc, unsigned char **rows, int w, int h)
+{
+ Evas_GL_Texture *tex;
+ int im_w, im_h;
+ int tw, th;
+ GLenum pixfmt, texfmt;
+ GLhandleARB fshad;
+
+ if (!gc->ext.arb_texture_non_power_of_two) return NULL;
+
+ tex = calloc(1, sizeof(Evas_GL_Texture));
+ if (!tex) return NULL;
+
+ tw = w;
+ th = h;
+ tex->gc = gc;
+ tex->w = tw;
+ tex->h = th;
+ tex->tw = w;
+ tex->th = h;
+ tex->references = 0;
+ tex->smooth = 0;
+ tex->changed = 1;
+
+ tex->prog = glCreateProgramObjectARB();
+ fshad = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
+
+ {
+ const char *code =
+ "uniform sampler2D Ytex, Utex, Vtex;\n"
+ "void main(void) {\n"
+
+ " float r, g, b, y, u, v;\n"
+
+ " y = texture2D(Ytex, gl_TexCoord[0].st).r;\n"
+ " u = texture2D(Utex, gl_TexCoord[0].st).r;\n"
+ " v = texture2D(Vtex, gl_TexCoord[0].st).r;\n"
+
+#if 0 // enable this to direct-test y u and v values
+ " gl_FragColor = vec4(y, u, v, 1.0);\n"
+#else
+ " y = (y - 0.0625) * 1.164;\n"
+ " u = u - 0.5;\n"
+ " v = v - 0.5;\n"
+
+ " r = y + (1.402 * v);\n"
+ " g = y - (0.34414 * u) - (0.71414 * v);\n"
+ " b = y + (1.772 * u);\n"
+
+ " gl_FragColor = vec4(r, g, b, 1.0);\n"
+#endif
+ "}\n";
+ glShaderSourceARB(fshad, 1, &code, NULL);
+ }
+
+ glCompileShaderARB(fshad);
+ glAttachObjectARB(tex->prog, fshad);
+ glLinkProgramARB(tex->prog);
+
+ glEnable(GL_TEXTURE_2D);
+ texfmt = GL_LUMINANCE;
+
+ glGenTextures(1, &(tex->texture));
+ glUniform1iARB(glGetUniformLocationARB(tex->prog, "Ytex", tex->texture));
+ glBindTexture(GL_TEXTURE_2D, tex->texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ texfmt, tw, th, 0,
+ texfmt, GL_UNSIGNED_BYTE, rows[0]);
+
+ glGenTextures(1, &(tex->texture2));
+ glUniform1iARB(glGetUniformLocationARB(tex->prog, "Utex", tex->texture2));
+ glBindTexture(GL_TEXTURE_2D, tex->texture2);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ texfmt, tw / 2, th / 2, 0,
+ texfmt, GL_UNSIGNED_BYTE, rows[th]);
+
+ glGenTextures(1, &(tex->texture3));
+ glUniform1iARB(glGetUniformLocationARB(tex->prog, "Vtex", 2));
+ glBindTexture(GL_TEXTURE_2D, tex->texture3);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ texfmt, tw / 2, th / 2, 0,
+ texfmt, GL_UNSIGNED_BYTE, rows[th + (th / 2)]);
+
+ if (gc->texture) gc->texture->references--;
+ gc->texture = tex;
+ gc->change.texture = 1;
+ tex->references++;
+
+ /* FIXME: should use subimage */
+/*
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ 0, 0, im_w, im_h,
+ pixfmt, NATIVE_PIX_UNIT,
+ im_data);
+ */
+ return tex;
+}
+
+void
+evas_gl_common_ycbcr601pl_texture_update(Evas_GL_Texture *tex, unsigned char **rows, int w, int h)
+{
+ int texfmt;
+
+ return;
+ /* FIXME: should use subimage */
+ glEnable(GL_TEXTURE_2D);
+ texfmt = GL_LUMINANCE;
+
+ glBindTexture(GL_TEXTURE_2D, tex->texture);
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ texfmt, tex->w, tex->h, 0,
+ texfmt, GL_UNSIGNED_BYTE, rows[0]);
+
+ glBindTexture(GL_TEXTURE_2D, tex->texture2);
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ texfmt, tex->w / 2, tex->h / 2, 0,
+ texfmt, GL_UNSIGNED_BYTE, rows[tex->h]);
+
+ glBindTexture(GL_TEXTURE_2D, tex->texture3);
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ texfmt, tex->w / 2, tex->h / 2, 0,
+ texfmt, GL_UNSIGNED_BYTE, rows[tex->h + (tex->h / 2)]);
+
+ if (tex->gc->texture) tex->gc->texture->references--;
+ tex->gc->texture = tex;
+ tex->gc->change.texture = 1;
+ tex->references++;
+}
evas_gl_common_gradient_draw(re->win->gl_context, gradient, x, y, w, h);
}
+static int
+eng_image_alpha_get(void *data, void *image)
+{
+ Render_Engine *re;
+ Evas_GL_Image *im;
+
+ re = (Render_Engine *)data;
+ im = image;
+ /* FIXME: can move to gl_common */
+ switch (im->cs.space)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int
+eng_image_colorspace_get(void *data, void *image)
+{
+ Render_Engine *re;
+ Evas_GL_Image *im;
+
+ re = (Render_Engine *)data;
+ im = image;
+ return im->cs.space;
+}
+
+static void *
+eng_image_alpha_set(void *data, void *image, int has_alpha)
+{
+ Render_Engine *re;
+ Evas_GL_Image *im;
+
+ re = (Render_Engine *)data;
+ eng_window_use(re->win);
+ im = image;
+ /* FIXME: can move to gl_common */
+ if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
+ if ((has_alpha) && (im->im->flags & RGBA_IMAGE_HAS_ALPHA)) return image;
+ else if ((!has_alpha) && (!(im->im->flags & RGBA_IMAGE_HAS_ALPHA))) return image;
+ if (im->references > 1)
+ {
+ Evas_GL_Image *im_new;
+
+ im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data,
+ eng_image_alpha_get(data, image),
+ eng_image_colorspace_get(data, image));
+ if (!im_new) return im;
+ evas_gl_common_image_free(im);
+ im = im_new;
+ }
+ else
+ evas_gl_common_image_dirty(im);
+ if (has_alpha)
+ im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ else
+ im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ return image;
+}
+
+static void *
+eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
+{
+ Render_Engine *re;
+
+ re = (Render_Engine *)data;
+ return image;
+}
+
+static void
+eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
+{
+ Render_Engine *re;
+
+ re = (Render_Engine *)data;
+}
+
+static char *
+eng_image_comment_get(void *data, void *image, char *key)
+{
+ Render_Engine *re;
+ Evas_GL_Image *im;
+
+ re = (Render_Engine *)data;
+ im = image;
+ return im->im->info.comment;
+}
+
+static char *
+eng_image_format_get(void *data, void *image)
+{
+ Render_Engine *re;
+ Evas_GL_Image *im;
+
+ re = (Render_Engine *)data;
+ im = image;
+ return NULL;
+}
+
+static void
+eng_image_colorspace_set(void *data, void *image, int cspace)
+{
+ Render_Engine *re;
+ Evas_GL_Image *im;
+
+ re = (Render_Engine *)data;
+ im = image;
+ /* FIXME: can move to gl_common */
+ if (im->cs.space == cspace) return;
+ switch (cspace)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ im->cs.data = NULL;
+ im->cs.no_free = 0;
+ }
+ if (!im->im->image->no_free)
+ evas_common_image_surface_alloc(im->im->image);
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ evas_common_image_surface_dealloc(im->im->image);
+ im->im->image->data = NULL;
+ if (im->tex) evas_gl_common_texture_free(im->tex);
+ im->tex = NULL;
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ }
+ im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
+ im->cs.no_free = 0;
+ break;
+ default:
+ abort();
+ break;
+ }
+ im->cs.space = cspace;
+}
+
+static void
+eng_image_native_set(void *data, void *image, void *native)
+{
+}
+
+static void *
+eng_image_native_get(void *data, void *image)
+{
+ return NULL;
+}
+
static void *
eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo)
{
}
static void *
-eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->win);
- return evas_gl_common_image_new_from_data(re->win->gl_context, w, h, image_data);
+ return evas_gl_common_image_new_from_data(re->win->gl_context, w, h, image_data, alpha, cspace);
}
static void *
-eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->win);
- return evas_gl_common_image_new_from_copied_data(re->win->gl_context, w, h, image_data);
+ return evas_gl_common_image_new_from_copied_data(re->win->gl_context, w, h, image_data, alpha, cspace);
}
static void
im_old = image;
if ((im_old) && (im_old->im->image->w == w) && (im_old->im->image->h == h))
return image;
- im = evas_gl_common_image_new(re->win->gl_context, w, h);
if (im_old)
{
+ im = evas_gl_common_image_new(re->win->gl_context, w, h,
+ eng_image_alpha_get(data, image),
+ eng_image_colorspace_get(data, image));
+/*
evas_common_load_image_data_from_file(im_old->im);
if (im_old->im->image->data)
{
evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
evas_common_cpu_end_opt();
}
+ */
evas_gl_common_image_free(im_old);
}
+ else
+ im = evas_gl_common_image_new(re->win->gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888);
return im;
}
im = image;
eng_window_use(re->win);
evas_common_load_image_data_from_file(im->im);
- if (to_write)
+ switch (im->cs.space)
{
- if (im->references > 1)
+ case EVAS_COLORSPACE_ARGB8888:
+ if (to_write)
{
- Evas_GL_Image *im_new;
-
- im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data);
- if (!im_new)
+ if (im->references > 1)
{
- return im;
- *image_data = NULL;
+ Evas_GL_Image *im_new;
+
+ im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data,
+ eng_image_alpha_get(data, image),
+ eng_image_colorspace_get(data, image));
+ if (!im_new)
+ {
+ return im;
+ *image_data = NULL;
+ }
+ im = im_new;
}
- im = im_new;
+ else
+ evas_gl_common_image_dirty(im);
}
- else
- evas_gl_common_image_dirty(im);
+ *image_data = im->im->image->data;
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ *image_data = im->cs.data;
+ break;
+ default:
+ abort();
+ break;
}
- *image_data = im->im->image->data;
return im;
}
re = (Render_Engine *)data;
im = image;
eng_window_use(re->win);
- if (image_data != im->im->image->data)
+ switch (im->cs.space)
{
- int w, h;
-
- w = im->im->image->w;
- h = im->im->image->h;
- evas_gl_common_image_free(im);
- return eng_image_new_from_data(data, w, h, image_data);
+ case EVAS_COLORSPACE_ARGB8888:
+ if (image_data != im->im->image->data)
+ {
+ int w, h;
+
+ w = im->im->image->w;
+ h = im->im->image->h;
+ evas_gl_common_image_free(im);
+ return eng_image_new_from_data(data, w, h, image_data,
+ eng_image_alpha_get(data, image),
+ eng_image_colorspace_get(data, image));
+ }
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ if (image_data != im->cs.data)
+ {
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ }
+ im->cs.data = image_data;
+ }
+ break;
+ default:
+ abort();
+ break;
}
/* hmmm - but if we wrote... why bother? */
evas_gl_common_image_dirty(im);
return im;
}
-static void *
-eng_image_alpha_set(void *data, void *image, int has_alpha)
-{
- Render_Engine *re;
- Evas_GL_Image *im;
-
- re = (Render_Engine *)data;
- eng_window_use(re->win);
- im = image;
- if ((has_alpha) && (im->im->flags & RGBA_IMAGE_HAS_ALPHA)) return image;
- else if ((!has_alpha) && (!(im->im->flags & RGBA_IMAGE_HAS_ALPHA))) return image;
- if (im->references > 1)
- {
- Evas_GL_Image *im_new;
-
- im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data);
- if (!im_new) return im;
- evas_gl_common_image_free(im);
- im = im_new;
- }
- else
- evas_gl_common_image_dirty(im);
- if (has_alpha)
- im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
- else
- im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
- return image;
-}
-
-static int
-eng_image_alpha_get(void *data, void *image)
-{
- Render_Engine *re;
- Evas_GL_Image *im;
-
- re = (Render_Engine *)data;
- im = image;
- eng_window_use(re->win);
- if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
- return 0;
-}
-
-static void *
-eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
-{
- Render_Engine *re;
-
- re = (Render_Engine *)data;
- return image;
-}
-
-static void
-eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
-{
- Render_Engine *re;
-
- re = (Render_Engine *)data;
-}
-
static void
eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{
smooth);
}
-static char *
-eng_image_comment_get(void *data, void *image, char *key)
-{
- Render_Engine *re;
- Evas_GL_Image *im;
-
- re = (Render_Engine *)data;
- im = image;
- return im->im->info.comment;
-}
-
-static char *
-eng_image_format_get(void *data, void *image)
-{
- Render_Engine *re;
- Evas_GL_Image *im;
-
- re = (Render_Engine *)data;
- im = image;
- return NULL;
-}
-
-static void
-eng_image_colorspace_set(void *data, void *image, int cspace)
-{
-}
-
-static int
-eng_image_colorspace_get(void *data, void *image)
-{
- return EVAS_COLORSPACE_ARGB8888;
-}
-
-static void
-eng_image_native_set(void *data, void *image, void *native)
-{
-}
-
-static void *
-eng_image_native_get(void *data, void *image)
-{
- return NULL;
-}
-
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text)
{
}
}
+static int
+eng_image_alpha_get(void *data, void *image)
+{
+ RGBA_Image *im;
+
+ im = image;
+ switch (im->cs.space)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ if (im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int
+eng_image_colorspace_get(void *data, void *image)
+{
+ RGBA_Image *im;
+
+ im = image;
+ return im->cs.space;
+}
+
+static void *
+eng_image_alpha_set(void *data, void *image, int has_alpha)
+{
+ RGBA_Image *im;
+
+ im = image;
+ if (im->cs.space != EVAS_COLORSPACE_ARGB8888)
+ {
+ im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ return im;
+ }
+ if (im->references > 1)
+ {
+ RGBA_Image *im_new;
+
+ im_new = evas_common_image_create(im->image->w, im->image->h);
+ if (!im_new) return im;
+ evas_common_load_image_data_from_file(im);
+ evas_common_image_colorspace_normalize(im);
+ evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0);
+ evas_common_cpu_end_opt();
+ evas_common_image_unref(im);
+ im = im_new;
+ }
+ else
+ {
+ evas_common_image_dirty(im);
+ evas_common_image_colorspace_dirty(im);
+ }
+ if (has_alpha)
+ im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ else
+ im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ return im;
+}
+
+static void *
+eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
+{
+ RGBA_Image *im;
+
+ im = image;
+ return im;
+}
+
+static void
+eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
+{
+ RGBA_Image *im;
+
+ im = image;
+}
+
+static char *
+eng_image_comment_get(void *data, void *image, char *key)
+{
+ RGBA_Image *im;
+
+ im = image;
+ return im->info.comment;
+}
+
+static char *
+eng_image_format_get(void *data, void *image)
+{
+ return NULL;
+}
+
+static void
+eng_image_colorspace_set(void *data, void *image, int cspace)
+{
+ RGBA_Image *im;
+
+ im = image;
+ if (im->cs.space == cspace) return;
+ switch (cspace)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ im->cs.data = NULL;
+ im->cs.no_free = 0;
+ }
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ if (im->image->no_free)
+ {
+ im->image->data = NULL;
+ im->image->no_free = 0;
+ evas_common_image_surface_alloc(im->image);
+ }
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ }
+ im->cs.data = calloc(1, im->image->h * sizeof(unsigned char *) * 2);
+ im->cs.no_free = 0;
+ break;
+ default:
+ abort();
+ break;
+ }
+ im->cs.space = cspace;
+ evas_common_image_colorspace_dirty(im);
+}
+
+static void
+eng_image_native_set(void *data, void *image, void *native)
+{
+}
+
+static void *
+eng_image_native_get(void *data, void *image)
+{
+ return NULL;
+}
+
static void *
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
{
}
static void *
-eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
RGBA_Image *im;
evas_common_image_free(im);
return NULL;
}
- im->image->w = w;
- im->image->h = h;
- im->image->data = image_data;
- im->image->no_free = 1;
+ switch (cspace)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ im->image->w = w;
+ im->image->h = h;
+ im->image->data = image_data;
+ im->image->no_free = 1;
+ if (alpha)
+ im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ else
+ im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ im->image->w = w;
+ im->image->h = h;
+ evas_common_image_surface_alloc(im->image);
+ im->cs.data = image_data;
+ im->cs.no_free = 1;
+ break;
+ default:
+ abort();
+ break;
+ }
+ im->cs.space = cspace;
+ evas_common_image_colorspace_dirty(im);
return im;
}
static void *
-eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
RGBA_Image *im;
- im = evas_common_image_create(w, h);
- if (!im) return NULL;
- if (image_data)
- memcpy(im->image->data, image_data, w * h * sizeof(DATA32));
+ switch (cspace)
+ {
+ case EVAS_COLORSPACE_ARGB8888:
+ im = evas_common_image_create(w, h);
+ if (!im) return NULL;
+ if (alpha)
+ im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ else
+ im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
+ if (image_data)
+ memcpy(im->image->data, image_data, w * h * sizeof(DATA32));
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ im = evas_common_image_create(w, h);
+ im->cs.data = calloc(1, im->image->h * sizeof(unsigned char *) * 2);
+ if ((image_data) && (im->cs.data))
+ memcpy(im->cs.data, image_data, im->image->h * sizeof(unsigned char *) * 2);
+ break;
+ default:
+ abort();
+ break;
+ }
+ im->cs.space = cspace;
+ evas_common_image_colorspace_dirty(im);
return im;
}
if (!im) return im_old;
if (im_old)
{
+ im->cs.space = im_old->cs.space;
+/*
evas_common_load_image_data_from_file(im_old);
+ evas_common_image_colorspace_normalize(im);
if (im_old->image->data)
{
evas_common_blit_rectangle(im_old, im, 0, 0, w, h, 0, 0);
evas_common_cpu_end_opt();
}
+ */
evas_common_image_unref(im_old);
}
return im;
eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
{
evas_common_image_dirty(image);
+ evas_common_image_colorspace_dirty(image);
return image;
}
im = image;
evas_common_load_image_data_from_file(im);
- if (to_write)
+ switch (im->cs.space)
{
- if (im->references > 1)
+ case EVAS_COLORSPACE_ARGB8888:
+ if (to_write)
{
- RGBA_Image *im_new;
-
- im_new = evas_common_image_create(im->image->w, im->image->h);
- if (!im_new) return im;
- evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0);
- evas_common_cpu_end_opt();
- evas_common_image_unref(im);
- im = im_new;
+ if (im->references > 1)
+ {
+ RGBA_Image *im_new;
+
+ im_new = evas_common_image_create(im->image->w, im->image->h);
+ if (!im_new) return im;
+ evas_common_image_colorspace_normalize(im);
+ evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0);
+ evas_common_cpu_end_opt();
+ evas_common_image_unref(im);
+ im = im_new;
+ }
+ else
+ evas_common_image_dirty(im);
}
- else
- evas_common_image_dirty(im);
+ *image_data = im->image->data;
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ *image_data = im->cs.data;
+ break;
+ default:
+ abort();
+ break;
}
- *image_data = im->image->data;
return im;
}
RGBA_Image *im;
im = image;
- if (image_data != im->image->data)
+ switch (im->cs.space)
{
- int w, h;
-
- w = im->image->w;
- h = im->image->h;
- evas_common_image_unref(im);
- return eng_image_new_from_data(data, w, h, image_data);
- }
- return im;
-}
-
-static void *
-eng_image_alpha_set(void *data, void *image, int has_alpha)
-{
- RGBA_Image *im;
-
- im = image;
- if (im->references > 1)
- {
- RGBA_Image *im_new;
-
- im_new = evas_common_image_create(im->image->w, im->image->h);
- if (!im_new) return im;
- evas_common_load_image_data_from_file(im);
- evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0);
- evas_common_cpu_end_opt();
- evas_common_image_unref(im);
- im = im_new;
+ case EVAS_COLORSPACE_ARGB8888:
+ if (image_data != im->image->data)
+ {
+ int w, h;
+
+ w = im->image->w;
+ h = im->image->h;
+ evas_common_image_unref(im);
+ return eng_image_new_from_data(data, w, h, image_data,
+ eng_image_alpha_get(data, image),
+ eng_image_colorspace_get(data, image));
+ }
+ break;
+ case EVAS_COLORSPACE_YCBCR422P601_PL:
+ case EVAS_COLORSPACE_YCBCR422P709_PL:
+ if (image_data != im->cs.data)
+ {
+ if (im->cs.data)
+ {
+ if (!im->cs.no_free) free(im->cs.data);
+ }
+ im->cs.data = image_data;
+ evas_common_image_colorspace_dirty(im);
+ }
+ break;
+ default:
+ abort();
+ break;
}
- else
- evas_common_image_dirty(im);
- if (has_alpha)
- im->flags |= RGBA_IMAGE_HAS_ALPHA;
- else
- im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
- return im;
-}
-
-
-static int
-eng_image_alpha_get(void *data, void *image)
-{
- RGBA_Image *im;
-
- im = image;
- if (im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
- return 0;
-}
-
-static void *
-eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
-{
- RGBA_Image *im;
-
- im = image;
return im;
}
static void
-eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
+eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{
RGBA_Image *im;
-
+
im = image;
-}
-
-static void
-eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
-{
- evas_common_load_image_data_from_file(image);
+ if (im->cs.space == EVAS_COLORSPACE_ARGB8888)
+ evas_common_load_image_data_from_file(im);
+ evas_common_image_colorspace_normalize(im);
#ifdef BUILD_PTHREAD
if (cpunum > 1)
- evas_common_pipe_image_draw(image, surface, context, smooth,
+ evas_common_pipe_image_draw(im, surface, context, smooth,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);
else
#endif
{
if (smooth)
- evas_common_scale_rgba_in_to_out_clip_smooth(image, surface, context,
+ evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);
else
- evas_common_scale_rgba_in_to_out_clip_sample(image, surface, context,
+ evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h);
evas_common_cpu_end_opt();
}
}
-static char *
-eng_image_comment_get(void *data, void *image, char *key)
-{
- RGBA_Image *im;
-
- im = image;
- return im->info.comment;
-}
-
-static char *
-eng_image_format_get(void *data, void *image)
-{
- return NULL;
-}
-
-static void
-eng_image_colorspace_set(void *data, void *image, int cspace)
-{
-}
-
-static int
-eng_image_colorspace_get(void *data, void *image)
-{
- return EVAS_COLORSPACE_ARGB8888;
-}
-
-static void
-eng_image_native_set(void *data, void *image, void *native)
-{
-}
-
-static void *
-eng_image_native_get(void *data, void *image)
-{
- return NULL;
-}
-
static void
eng_image_cache_flush(void *data)
{
}
static void *
-eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
XR_Image *im;
re = (Render_Engine *)data;
- im = _xre_image_new_from_data(re->xinf, w, h, image_data);
+ im = _xre_image_new_from_data(re->xinf, w, h, image_data, alpha, cspace);
return im;
}
static void *
-eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
XR_Image *im;
re = (Render_Engine *)data;
- im = _xre_image_new_from_copied_data(re->xinf, w, h, image_data);
+ im = _xre_image_new_from_copied_data(re->xinf, w, h, image_data, alpha, cspace);
return im;
}
{
if (!image)
{
- image = _xre_image_new_from_data(old_image->xinf, old_image->w, old_image->h, image_data);
+ image = _xre_image_new_from_data(old_image->xinf, old_image->w, old_image->h, image_data, old_image->alpha, EVAS_COLORSPACE_ARGB8888);
if (image)
{
((XR_Image *)image)->alpha = old_image->alpha;
};
XR_Image *_xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image_Load_Opts *lo);
-XR_Image *_xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data);
-XR_Image *_xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data);
+XR_Image *_xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data, int alpha, int cspace);
+XR_Image *_xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data, int alpha, int cspace);
XR_Image *_xre_image_new(Ximage_Info *xinf, int w, int h);
void _xre_image_resize(XR_Image *im, int w, int h);
void _xre_image_free(XR_Image *im);
}
XR_Image *
-_xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data)
+_xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data, int alpha, int cspace)
{
XR_Image *im;
im->h = h;
im->references = 1;
im->data = data;
- im->alpha = 1;
+ im->alpha = alpha;
im->dirty = 1;
__xre_image_dirty_hash_add(im);
return im;
}
XR_Image *
-_xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data)
+_xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data, int alpha, int cspace)
{
XR_Image *im;
im->xinf = xinf;
im->xinf->references++;
im->free_data = 1;
- im->alpha = 1;
+ im->alpha = alpha;
im->dirty = 1;
__xre_image_dirty_hash_add(im);
return im;
}
}
if (!data) return NULL;
- im2 = _xre_image_new_from_copied_data(im->xinf, im->w, im->h, data);
+ im2 = _xre_image_new_from_copied_data(im->xinf, im->w, im->h, data, im->alpha, EVAS_COLORSPACE_ARGB8888);
if (im2) im2->alpha = im->alpha;
if ((im->im) && (!im->dirty))
{
}
static void *
-eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
XR_Image *im;
}
static void *
-eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data)
+eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
XR_Image *im;