put this in HEAD too


			
			
				devs/devilhorns/wayland_egl
			
			
		
rephorm 21 years ago committed by rephorm
parent d0ddb5b0ab
commit c475e48ead
  1. 8
      legacy/evas/src/Evas.h
  2. 2
      legacy/evas/src/Makefile.am
  3. 117
      legacy/evas/src/evas_fileless_image.c
  4. 19
      legacy/evas/src/evas_fileless_image.h
  5. 12
      legacy/evas/src/evas_gl_routines.c
  6. 250
      legacy/evas/src/evas_image.c
  7. 7
      legacy/evas/src/evas_image_routines.c
  8. 7
      legacy/evas/src/evas_imlib_routines.c
  9. 5
      legacy/evas/src/evas_render_routines.c
  10. 5
      legacy/evas/src/evas_x11_routines.c

@ -118,8 +118,8 @@ Evas_List evas_get_clip_list(Evas e, Evas_Object o);
void evas_del_object(Evas e, Evas_Object o);
/* adding objects */
Evas_Object evas_add_image_from_file(Evas e, char *file);
/* ** ** not implimented yet ** ** */Evas_Object evas_add_image_from_data(Evas e, void *data, Evas_Image_Format format, int w, int h);
Evas_Object evas_add_image_from_file(Evas e, const char *file);
Evas_Object evas_add_image_from_data(Evas e, void *data, Evas_Image_Format format, int w, int h);
Evas_Object evas_add_text(Evas e, char *font, int size, char *text);
Evas_Object evas_add_rectangle(Evas e);
Evas_Object evas_add_line(Evas e);
@ -127,8 +127,8 @@ Evas_Object evas_add_gradient_box(Evas e);
Evas_Object evas_add_poly(Evas e);
/* set object settings */
void evas_set_image_file(Evas e, Evas_Object o, char *file);
/* ** ** not implimented yet ** ** */void evas_set_image_data(Evas e, Evas_Object o, void *data, Evas_Image_Format format, int w, int h);
void evas_set_image_file(Evas e, Evas_Object o, const char *file);
void evas_set_image_data(Evas e, Evas_Object o, void *data, Evas_Image_Format format, int w, int h);
void evas_set_image_fill(Evas e, Evas_Object o, double x, double y, double w, double h);
void evas_set_image_border(Evas e, Evas_Object o, int l, int r, int t, int b);
void evas_set_color(Evas e, Evas_Object o, int r, int g, int b, int a);

@ -34,6 +34,7 @@ Evas.h
libevas_la_SOURCES = \
evas_callbacks.c \
evas_events.c \
evas_fileless_image.c \
evas_gl_routines.c \
evas_gradient.c \
evas_image.c \
@ -49,6 +50,7 @@ evas_render.c \
evas_text.c \
evas_gl_routines.h \
evas_x11_routines.c \
evas_fileless_image.h \
evas_image_routines.h \
evas_imlib_routines.h \
evas_x11_routines.h \

@ -0,0 +1,117 @@
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <time.h>
#include "evas_fileless_image.h"
//#define MYDEBUG 1
Evas_List fileless_images = NULL;
char* _evas_generate_filename(void){
char buf[100];
char *p;
int i,j;
struct timeval tv;
gettimeofday(&tv,NULL);
srand(tv.tv_usec);
i = rand();
srand(tv.tv_sec);
j = rand();
sprintf(buf, "s%d%d.mem", i, j);
p = (char*)malloc(strlen(buf)+1);
strcpy(p, buf);
#ifdef MYDEBUG
fprintf(stderr,"fli: generated: %s\n", p);
#endif
return p;
}
void _evas_add_fileless_image(Imlib_Image im, char* file){
Evas_Fileless_Image *fli;
Imlib_Image prev_im;
if(!file) return;
fli = (Evas_Fileless_Image*)malloc(sizeof(Evas_Fileless_Image));
fli->file = (char*)malloc(strlen(file)+1);
strcpy(fli->file, file);
prev_im = imlib_context_get_image();
imlib_context_set_image(im);
fli->im = imlib_clone_image();
imlib_context_set_image(prev_im);
fileless_images = evas_list_append(fileless_images,(void*)fli);
#ifdef MYDEBUG
fprintf(stderr,"fli: added: %s\n", file);
#endif
}
void _evas_remove_fileless_image(char*file){
Evas_List l;
Imlib_Image prev_im;
if(!file) return;
for( l = fileless_images; l ; l = l -> next ){
Evas_Fileless_Image *fli;
fli = l->data;
if(!strcmp(fli->file, file)){
free(fli->file);
prev_im = imlib_context_get_image();
imlib_context_set_image(fli->im);
imlib_free_image();
imlib_context_set_image(prev_im);
fileless_images = evas_list_remove(fileless_images, fli);
#ifdef MYDEBUG
fprintf(stderr,"fli: removed: %s\n", file);
#endif
free(fli);
return;
}
}
}
Imlib_Image _evas_find_fileless_image(char*file){
Evas_List l;
Imlib_Image prev_im, res_im = NULL;
if(!file) return;
for( l = fileless_images ; l ; l = l -> next ){
Evas_Fileless_Image *fli;
fli = l -> data;
if(!strcmp(fli->file, file)){
prev_im = imlib_context_get_image();
imlib_context_set_image(fli->im);
res_im = imlib_clone_image();
#ifdef MYDEBUG
fprintf(stderr, "fli: found: %s\n", file);
#endif
imlib_context_set_image(prev_im);
}
}
return res_im;
}

@ -0,0 +1,19 @@
#include "Evas.h"
typedef struct _Evas_Fileless_Image Evas_Fileless_Image;
struct _Evas_Fileless_Image{
char *file;
Imlib_Image im;
};
Imlib_Image _evas_find_fileless_image(char*file);
char* _evas_generate_filename(void);
void _evas_add_fileless_image(Imlib_Image im, char*file);
void _evas_remove_fileless_image(char*file);

@ -1,4 +1,5 @@
#include "evas_gl_routines.h"
#include "evas_fileless_image.h"
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
@ -628,7 +629,10 @@ __evas_gl_make_image_textures(Evas_GL_Window *w, Evas_GL_Image *image)
tm->context = w->context;
image->textures = evas_list_prepend(image->textures, tm);
if ((!image->im) && (image->file))
image->im = _evas_find_fileless_image(image->file);
if ((!image->im) && (image->file))
{
image->im = imlib_load_image(image->file);
@ -764,8 +768,10 @@ __evas_gl_image_alloc(char *file)
{
Evas_GL_Image *image;
Imlib_Image im, prev_im;
im = imlib_load_image(file);
im = _evas_find_fileless_image(file);
if (!im)
im = imlib_load_image(file);
if (!im) return NULL;
imlib_context_set_image(im);
imlib_image_set_changes_on_disk();

@ -12,6 +12,7 @@ _evas_free_image(Evas_Object o)
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
if (oo->current.file) _evas_remove_fileless_image(oo->current.file);
if (oo->current.file) free(oo->current.file);
free(o);
}
@ -49,7 +50,7 @@ _evas_free_image_renderer_data(Evas e, Evas_Object o)
/* adding objects */
Evas_Object
evas_add_image_from_file(Evas e, char *file)
evas_add_image_from_file(Evas e, const char *file)
{
Evas_Object_Image oo;
Evas_Object_Any o;
@ -147,13 +148,132 @@ evas_add_image_from_file(Evas e, char *file)
Evas_Object
evas_add_image_from_data(Evas e, void *data, Evas_Image_Format format, int w, int h)
{
/* FIXME: not implimented */
return NULL;
Evas_Object_Image oo;
Evas_Object_Any o;
Evas_List l;
Evas_Layer layer;
if (!e) return NULL;
o = oo = malloc(sizeof(struct _Evas_Object_Image));
memset(o, 0, sizeof(struct _Evas_Object_Image));
o->type = OBJECT_IMAGE;
o->object_free = _evas_free_image;
o->object_renderer_data_free = _evas_free_image_renderer_data;
oo->load_error = IMLIB_LOAD_ERROR_NONE;
if (data)
{
oo->current.file = _evas_generate_filename();
{
Imlib_Image im;
im = imlib_create_image(w,h);
if (im)
{
DATA32 *p;
unsigned char *p1, *p2;
int i, j, k;
imlib_context_set_image(im);
if((format==IMAGE_FORMAT_ARGB)||(format==IMAGE_FORMAT_ARGB))
imlib_image_set_has_alpha(1);
imlib_image_clear();
p = imlib_image_get_data();
p2 = (unsigned char*)p;
p1 = (unsigned char*)data;
if(format==IMAGE_FORMAT_ARGB)memcpy(p, data, w*h*4);
for(i=0; i<w*h;i++){
switch(format){
case IMAGE_FORMAT_BGRA:
j = i*4;
p2[j+3]=p1[j];
p2[j+2]=p1[j+1];
p2[j+1]=p1[j+2];
p2[j]=p1[j+3];
break;
case IMAGE_FORMAT_ARGB: break;
case IMAGE_FORMAT_RGB:
j = i*4;
k = i*3;
p2[j+3] = 255;
p2[j+2] = p1[k+2];
p2[j+1] = p1[k+1];
p2[j] = p1[k];
break;
case IMAGE_FORMAT_GRAY:
j = i*4;
p2[j+3] = 255;
p2[j+2] = p1[i];
p2[j+1] = p1[i];
p2[j] = p1[i];
break;
default:;
}
}
imlib_image_put_back_data(p);
_evas_add_fileless_image(im,oo->current.file);
oo->current.image.w = imlib_image_get_width();
oo->current.image.h = imlib_image_get_height();
oo->current.alpha = imlib_image_has_alpha();
imlib_free_image();
}
else
{
oo->current.alpha = 1;
}
}
}
oo->current.fill.x = 0;
oo->current.fill.y = 0;
oo->current.fill.w = (double)oo->current.image.w;
oo->current.fill.h = (double)oo->current.image.h;
oo->current.color.r = 255;
oo->current.color.g = 255;
oo->current.color.b = 255;
oo->current.color.a = 255;
o->current.x = 0;
o->current.y = 0;
o->current.w = (double)oo->current.image.w;
o->current.h = (double)oo->current.image.h;
for (l = e->layers; l; l = l->next)
{
layer = l->data;
if (layer->layer == o->current.layer)
{
layer->objects = evas_list_append(layer->objects, o);
return o;
}
if (layer->layer > o->current.layer)
{
Evas_Layer layer_new;
layer_new = malloc(sizeof(struct _Evas_Layer));
memset(layer_new, 0, sizeof(struct _Evas_Layer));
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
layer_new->objects = evas_list_append(layer_new->objects, o);
layer_new->layer = o->current.layer;
return o;
}
}
layer = malloc(sizeof(struct _Evas_Layer));
memset(layer, 0, sizeof(struct _Evas_Layer));
e->layers = evas_list_append(e->layers, layer);
layer->objects = evas_list_append(layer->objects, o);
return o;
}
/* set object settings */
void
evas_set_image_file(Evas e, Evas_Object o, char *file)
evas_set_image_file(Evas e, Evas_Object o, const char *file)
{
Evas_Object_Image oo;
@ -253,7 +373,127 @@ evas_set_image_file(Evas e, Evas_Object o, char *file)
void
evas_set_image_data(Evas e, Evas_Object o, void *data, Evas_Image_Format format, int w, int h)
{
/* FIXME: not implimented */
Evas_Object_Image oo;
if (!e) return;
if (!o) return;
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
if (data)
{
_evas_free_image_renderer_data(e, o);
if (oo->current.file) _evas_remove_fileless_image(oo->current.file);
if (oo->current.file) free(oo->current.file);
oo->previous.file = NULL;
oo->current.file = _evas_generate_filename();
{
Imlib_Image im;
im = imlib_create_image(w,h);
if (im)
{
DATA32 *p;
unsigned char *p1, *p2;
int i, j, k;
imlib_context_set_image(im);
if((format==IMAGE_FORMAT_ARGB)||(format==IMAGE_FORMAT_ARGB))
imlib_image_set_has_alpha(1);
imlib_image_clear();
p = imlib_image_get_data();
p2 = (unsigned char*)p;
p1 = (unsigned char*)data;
if(format==IMAGE_FORMAT_ARGB)memcpy(p, data, w*h*4);
for(i=0; i<w*h;i++){
switch(format){
case IMAGE_FORMAT_BGRA:
j = i*4;
p2[j+3]=p1[j];
p2[j+2]=p1[j+1];
p2[j+1]=p1[j+2];
p2[j]=p1[j+3];
break;
case IMAGE_FORMAT_ARGB: break;
case IMAGE_FORMAT_RGB:
j = i*4;
k = i*3;
p2[j+3] = 255;
p2[j+2] = p1[k+2];
p2[j+1] = p1[k+1];
p2[j] = p1[k];
break;
case IMAGE_FORMAT_GRAY:
j = i*4;
p2[j+3] = 255;
p2[j+2] = p1[i];
p2[j+1] = p1[i];
p2[j] = p1[i];
break;
default:;
}
}
imlib_image_put_back_data(p);
_evas_add_fileless_image(im,oo->current.file);
oo->current.image.w = imlib_image_get_width();
oo->current.image.h = imlib_image_get_height();
oo->current.alpha = imlib_image_has_alpha();
imlib_free_image();
evas_resize(e, o,
(double)oo->current.image.w,
(double)oo->current.image.h);
oo->current.fill.x = 0;
oo->current.fill.y = 0;
oo->current.fill.w = (double)oo->current.image.w;
oo->current.fill.h = (double)oo->current.image.h;
}
else
{
oo->current.image.w = 0;
oo->current.image.h = 0;
evas_resize(e, o,
(double)oo->current.image.w,
(double)oo->current.image.h);
oo->current.fill.x = 0;
oo->current.fill.y = 0;
oo->current.fill.w = (double)oo->current.image.w;
oo->current.fill.h = (double)oo->current.image.h;
oo->current.alpha = 1;
}
}
o->changed = 1;
e->changed = 1;
}
else if (!data)
{
if (oo->current.file)
free(oo->current.file);
oo->previous.file = NULL;
oo->current.file = NULL;
oo->current.image.w = 0;
oo->current.image.h = 0;
oo->current.alpha = 1;
evas_resize(e, o,
(double)oo->current.image.w,
(double)oo->current.image.h);
oo->current.fill.x = 0;
oo->current.fill.y = 0;
oo->current.fill.w = (double)oo->current.image.w;
oo->current.fill.h = (double)oo->current.image.h;
oo->load_error = IMLIB_LOAD_ERROR_NONE;
o->changed = 1;
e->changed = 1;
}
else
{
}
}
void

@ -1,4 +1,5 @@
#include "evas_image_routines.h"
#include "evas_fileless_image.h"
static void __evas_image_image_cache_flush(Display *disp);
static int __evas_anti_alias = 1;
@ -36,9 +37,11 @@ __evas_image_image_cache_flush(Display *disp)
Evas_Image_Image *
__evas_image_image_new_from_file(Display *disp, char *file)
{
Imlib_Image im;
Imlib_Image im = NULL;
im = imlib_load_image(file);
im = _evas_find_fileless_image(file);
if (!im)
im = imlib_load_image(file);
if (im)
{
imlib_context_set_image(im);

@ -1,4 +1,5 @@
#include "evas_imlib_routines.h"
#include "evas_fileless_image.h"
static void __evas_imlib_image_cache_flush(Display *disp);
static Evas_Imlib_Image *__evas_imlib_image_cache_find(char *file);
@ -41,8 +42,10 @@ __evas_imlib_image_new_from_file(Display *disp, char *file)
{
Evas_Imlib_Image *im;
Imlib_Image image;
image = imlib_load_image(file);
image = _evas_find_fileless_image(file);
if (!image)
image = imlib_load_image(file);
if (!image) return NULL;
imlib_context_set_image(image);
imlib_image_set_changes_on_disk();

@ -1,4 +1,5 @@
#include "evas_render_routines.h"
#include "evas_fileless_image.h"
#ifdef HAVE_RENDER
@ -403,7 +404,9 @@ __evas_render_image_new_from_file(Display *disp, char *file)
/* need to look for image i local cache */
/* not found - load */
screen = 0;
i = imlib_load_image(file);
i = _evas_find_fileless_image(file);
if (!i)
i = imlib_load_image(file);
if (!i) return NULL;
imlib_context_set_image(i);
im = malloc(sizeof(Evas_Render_Image));

@ -1,4 +1,5 @@
#include "evas_x11_routines.h"
#include "evas_fileless_image.h"
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
@ -134,7 +135,9 @@ __evas_x11_image_new_from_file(Display *disp, char *file)
}
im = malloc(sizeof(Evas_X11_Image));
memset(im, 0, sizeof(Evas_X11_Image));
im->image = imlib_load_image(file);
im->image = _evas_find_fileless_image(file);
if (!im->image)
im->image = imlib_load_image(file);
if (!im->image)
{
free(im);

Loading…
Cancel
Save