removes some unused struct members (should remove more though) and fixes up

modular loaders


SVN revision: 19814
This commit is contained in:
Carsten Haitzler 2006-01-15 06:21:05 +00:00
parent 155364de9c
commit d410036b81
13 changed files with 90 additions and 97 deletions

View File

@ -27,75 +27,6 @@
* @brief These routines are used for Evas library interaction.
*/
/* the evas module api */
/***********************/
/* the module api version */
#define EVAS_MODULE_API_VERSION 1
/* the module types */
typedef enum _Evas_Module_Type
{
EVAS_MODULE_TYPE_ENGINE,
EVAS_MODULE_TYPE_IMAGE_LOADER,
EVAS_MODULE_TYPE_OBJECT
} Evas_Module_Type;
/* the module api structure, all modules should define this struct */
typedef struct _Evas_Module_Api Evas_Module_Api;
struct _Evas_Module_Api
{
int version;
Evas_Module_Type type;
const char *name;
const char *author;
};
/* the module structure */
typedef struct _Evas_Module Evas_Module;
struct _Evas_Module
{
Evas_Module_Api *api;
void *handle; /* the dlopen handle */
char *path; /* the path where this modules is */
char *name; /* the name of the dir where this module is */
Evas_Module_Type type; /* the type detected by the path */
struct
{
int (*open)(Evas_Module *);
void (*close)(Evas_Module *);
} func;
unsigned char loaded : 1;
void *functions; /* this are the functions exported by the module */
void *data; /* some internal data for the module i.e the id for engines */
};
/* the internals of the module api use this struct to reference a path with a module type
* instead of deduce the type from the path.
* */
typedef struct _Evas_Module_Path Evas_Module_Path;
struct _Evas_Module_Path
{
Evas_Module_Type type;
const char *path;
};
typedef struct _Evas_Module_Engine Evas_Module_Engine;
struct _Evas_Module_Engine
{
int id;
};
typedef struct _Evas_Module_Image_Loader Evas_Module_Image_Loader;
struct _Evas_Module_Image_Loader
{
int id;
};
/* end of evas module api */
/**************************/
typedef enum _Evas_Callback_Type
{
EVAS_CALLBACK_MOUSE_IN, /**< Mouse In Event */

View File

@ -3,18 +3,16 @@
extern Evas_List *evas_modules;
static Evas_Image_Load_Func *evas_image_load_func = NULL;
RGBA_Image *
evas_common_load_image_from_file(const char *file, const char *key)
{
Evas_Image_Load_Func *evas_image_load_func = NULL;
Evas_List *l;
RGBA_Image *im;
char *p;
char *loader = NULL;
if (file == NULL)
return NULL;
if (file == NULL) return NULL;
im = evas_common_image_find(file, key, 0);
if (im)
@ -23,10 +21,7 @@ evas_common_load_image_from_file(const char *file, const char *key)
return im;
}
im = evas_common_image_new();
if (!im)
{
return NULL;
}
if (!im) return NULL;
p = strrchr(file, '.');
if (p)
@ -81,7 +76,8 @@ evas_common_load_image_from_file(const char *file, const char *key)
evas_common_image_free(im);
return NULL;
ok:
im->info.loader = (void *)evas_image_load_func;
im->info.file = (char *)evas_stringshare_add(file);
if (key) im->info.key = (char *)evas_stringshare_add(key);
evas_common_image_ref(im);
@ -91,8 +87,11 @@ evas_common_load_image_from_file(const char *file, const char *key)
void
evas_common_load_image_data_from_file(RGBA_Image *im)
{
Evas_Image_Load_Func *evas_image_load_func = NULL;
if (im->image->data) return;
evas_image_load_func = im->info.loader;
if (!evas_image_load_func->file_data(im, im->info.file, im->info.key))
{
evas_common_image_surface_alloc(im->image);

View File

@ -235,7 +235,7 @@ evas_common_image_free(RGBA_Image *im)
if (im->info.file) evas_stringshare_del(im->info.file);
// if (im->info.real_file) evas_stringshare_del(im->info.real_file);
if (im->info.key) evas_stringshare_del(im->info.key);
if (im->info.comment) evas_stringshare_del(im->info.comment);
// if (im->info.comment) evas_stringshare_del(im->info.comment);
free(im);
}
@ -345,7 +345,7 @@ evas_common_image_store(RGBA_Image *im)
if (im->info.file) l1 = strlen(im->info.file);
l2 = 0;
if (im->info.key) l2 = strlen(im->info.key);
snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp);
l3 = strlen(buf);
key = alloca(l1 + 5 + l2 + 5 + l3 +1);
key[0] = 0;
@ -375,7 +375,7 @@ evas_common_image_unstore(RGBA_Image *im)
if (im->info.file) l1 = strlen(im->info.file);
l2 = 0;
if (im->info.key) l2 = strlen(im->info.key);
snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp);
l3 = strlen(buf);
key = alloca(l1 + 5 + l2 + 5 + l3 +1);
key[0] = 0;
@ -409,7 +409,7 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
else if (filename) l1 = strlen(filename);
l2 = 0;
if (key) l2 = strlen(key);
snprintf(buf, sizeof(buf), "%llx", timestamp);
// snprintf(buf, sizeof(buf), "%llx", timestamp);
l3 = strlen(buf);
str = alloca(l1 + 5 + l2 + 5 + l3 +1);
str[0] = 0;
@ -454,9 +454,9 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
ok++;
if ((!key) && (!im->info.key))
ok++;
if (im->timestamp == timestamp)
ok++;
if (ok >= 3)
// if (im->timestamp == timestamp)
// ok++;
if (ok >= 2)
{
// if (real_filename) free(real_filename);
return im;
@ -475,7 +475,7 @@ evas_common_image_ram_usage(RGBA_Image *im)
if (im->info.file) ram += strlen(im->info.file);
// if (im->info.real_file) ram += strlen(im->info.real_file);
if (im->info.key) ram += strlen(im->info.key);
if (im->info.comment) ram += strlen(im->info.comment);
// if (im->info.comment) ram += strlen(im->info.comment);
if ((im->image) && (im->image->data) && (!im->image->no_free))
ram += im->image->w * im->image->h * sizeof(DATA32);
return ram;

View File

@ -236,14 +236,15 @@ struct _RGBA_Image
RGBA_Image_Flags flags;
struct
{
int format;
void *loader;
// int format;
char *file;
char *real_file;
char *key;
char *comment;
} info;
int references;
DATA64 timestamp;
// DATA64 timestamp;
void *extended_info;
};

View File

@ -7,6 +7,69 @@
#include "Evas.h"
/* the evas module api */
/***********************/
/* the module api version */
#define EVAS_MODULE_API_VERSION 1
/* the module types */
typedef enum _Evas_Module_Type
{
EVAS_MODULE_TYPE_ENGINE,
EVAS_MODULE_TYPE_IMAGE_LOADER,
EVAS_MODULE_TYPE_OBJECT
} Evas_Module_Type;
/* the module api structure, all modules should define this struct */
typedef struct _Evas_Module_Api Evas_Module_Api;
struct _Evas_Module_Api
{
int version;
Evas_Module_Type type;
const char *name;
const char *author;
};
/* the module structure */
typedef struct _Evas_Module Evas_Module;
struct _Evas_Module
{
Evas_Module_Api *api;
void *handle; /* the dlopen handle */
char *path; /* the path where this modules is */
char *name; /* the name of the dir where this module is */
Evas_Module_Type type; /* the type detected by the path */
struct
{
int (*open)(Evas_Module *);
void (*close)(Evas_Module *);
} func;
unsigned char loaded : 1;
void *functions; /* this are the functions exported by the module */
void *data; /* some internal data for the module i.e the id for engines */
};
/* the internals of the module api use this struct to reference a path with a module type
* instead of deduce the type from the path.
* */
typedef struct _Evas_Module_Path Evas_Module_Path;
struct _Evas_Module_Path
{
Evas_Module_Type type;
const char *path;
};
typedef struct _Evas_Module_Engine Evas_Module_Engine;
struct _Evas_Module_Engine
{
int id;
};
/* end of evas module api */
/**************************/
/* complain when peole pass in wrong object types etc. */
#define MAGIC_DEBUG

View File

@ -1020,7 +1020,7 @@ evas_engine_buffer_image_format_get(void *data, void *image)
re = (Render_Engine *)data;
im = image;
if (im->info.format == 1) return "png";
// if (im->info.format == 1) return "png";
return NULL;
}

View File

@ -519,8 +519,7 @@ evas_engine_directfb_image_format_get(void *data, void *image)
re = (Render_Engine *) data;
im = image;
if (im->info.format == 1)
return "png";
// if (im->info.format == 1) return "png";
return NULL;
}

View File

@ -931,7 +931,7 @@ evas_engine_fb_image_format_get(void *data, void *image)
re = (Render_Engine *)data;
im = image;
if (im->info.format == 1) return "png";
// if (im->info.format == 1) return "png";
return NULL;
}

View File

@ -940,7 +940,7 @@ evas_engine_gl_x11_image_format_get(void *data, void *image)
re = (Render_Engine *)data;
im = image;
if (im->im->info.format == 1) return "png";
// if (im->im->info.format == 1) return "png";
return NULL;
}

View File

@ -952,7 +952,7 @@ evas_engine_software_qtopia_image_format_get(void *data, void *image)
re = (Render_Engine *)data;
im = image;
if (im->info.format == 1) return "png";
// if (im->info.format == 1) return "png";
return NULL;
}

View File

@ -1003,7 +1003,7 @@ evas_engine_software_x11_image_format_get(void *data, void *image)
re = (Render_Engine *)data;
im = image;
if (im->info.format == 1) return "png";
// if (im->info.format == 1) return "png";
return NULL;
}

View File

@ -1027,7 +1027,7 @@ evas_engine_software_xcb_image_format_get(void *data, void *image)
re = (Render_Engine *)data;
im = image;
if (im->info.format == 1) return "png";
// if (im->info.format == 1) return "png";
return NULL;
}

View File

@ -99,7 +99,7 @@ _xre_image_load(Ximage_Info *xinf, char *file, char *key)
im->h = im->im->image->h;
im->references = 1;
if (im->im->info.comment) im->comment = evas_stringshare_add(im->im->info.comment);
if (im->im->info.format == 1) im->format = evas_stringshare_add("png");
// if (im->im->info.format == 1) im->format = evas_stringshare_add("png");
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) im->alpha = 1;
_xr_image_hash = evas_hash_direct_add(_xr_image_hash, im->fkey, im);
return im;