From 9b35bc26f31219887d0c4344261bdd79bb8c22b2 Mon Sep 17 00:00:00 2001 From: doursse Date: Thu, 10 Jul 2008 16:38:54 +0000 Subject: [PATCH] * move evas_mempool from main.c to it's own file in data/ as it's only used by evas_list * add a header files for evas_cache, evas_path and evas_module * remove trailing spaces in evas_list.c SVN revision: 35052 --- legacy/evas/src/lib/cache/Makefile.am | 2 + legacy/evas/src/lib/cache/evas_cache.h | 153 +++++++++++++++++ legacy/evas/src/lib/data/Makefile.am | 5 +- legacy/evas/src/lib/data/evas_list.c | 16 +- legacy/evas/src/lib/data/evas_mempool.c | 183 +++++++++++++++++++++ legacy/evas/src/lib/data/evas_mempool.h | 21 +++ legacy/evas/src/lib/file/Makefile.am | 2 + legacy/evas/src/lib/file/evas_module.h | 83 ++++++++++ legacy/evas/src/lib/file/evas_path.h | 15 ++ legacy/evas/src/lib/include/evas_common.h | 146 +--------------- legacy/evas/src/lib/include/evas_private.h | 101 +----------- legacy/evas/src/lib/main.c | 181 -------------------- 12 files changed, 475 insertions(+), 433 deletions(-) create mode 100644 legacy/evas/src/lib/cache/evas_cache.h create mode 100644 legacy/evas/src/lib/data/evas_mempool.c create mode 100644 legacy/evas/src/lib/data/evas_mempool.h create mode 100644 legacy/evas/src/lib/file/evas_module.h create mode 100644 legacy/evas/src/lib/file/evas_path.h diff --git a/legacy/evas/src/lib/cache/Makefile.am b/legacy/evas/src/lib/cache/Makefile.am index 45a4456c0e..30b7943227 100644 --- a/legacy/evas/src/lib/cache/Makefile.am +++ b/legacy/evas/src/lib/cache/Makefile.am @@ -15,3 +15,5 @@ evas_cache_image.c \ evas_cache_engine_image.c libevas_cache_la_DEPENDENCIES = $(top_builddir)/config.h + +EXTRA_DIST = evas_cache.h diff --git a/legacy/evas/src/lib/cache/evas_cache.h b/legacy/evas/src/lib/cache/evas_cache.h new file mode 100644 index 0000000000..aceb5459a7 --- /dev/null +++ b/legacy/evas/src/lib/cache/evas_cache.h @@ -0,0 +1,153 @@ +#ifndef _EVAS_CACHE_H +#define _EVAS_CACHE_H + + +typedef struct _Evas_Cache_Image Evas_Cache_Image; +typedef struct _Evas_Cache_Image_Func Evas_Cache_Image_Func; +typedef struct _Evas_Cache_Engine_Image Evas_Cache_Engine_Image; +typedef struct _Evas_Cache_Engine_Image_Func Evas_Cache_Engine_Image_Func; + + +struct _Evas_Cache_Image_Func +{ + Image_Entry *(*alloc)(void); + void (*dealloc)(Image_Entry *im); + + /* The cache provide some helpers for surface manipulation. */ + int (*surface_alloc)(Image_Entry *im, int w, int h); + void (*surface_delete)(Image_Entry *im); + DATA32 *(*surface_pixels)(Image_Entry *im); + + /* The cache is doing the allocation and deallocation, you must just do the rest. */ + int (*constructor)(Image_Entry *im); + void (*destructor)(Image_Entry *im); + + void (*dirty_region)(Image_Entry *im, int x, int y, int w, int h); + /* Only called when references > 0. Need to provide a fresh copie of im. */ + /* The destination surface does have a surface, but no allocated pixel data. */ + int (*dirty)(Image_Entry *dst, const Image_Entry *src); + /* Only called when references == 1. We will call drop on `im'. */ + /* The destination surface does not have any surface. */ + int (*size_set)(Image_Entry *dst, const Image_Entry *src, int w, int h); + + /* The destination surface does not have any surface. */ + int (*copied_data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace); + /* The destination surface does not have any surface. */ + int (*data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace); + int (*color_space)(Image_Entry *dst, int cspace); + + /* This function need to update im->w and im->h. */ + int (*load)(Image_Entry *im); + int (*mem_size_get)(Image_Entry *im); + void (*debug)(const char *context, Image_Entry *im); +}; + +struct _Evas_Cache_Image +{ + Evas_Cache_Image_Func func; + + Evas_Object_List *dirty; + + Evas_Object_List *lru; + Evas_Object_List *lru_nodata; + Evas_Hash *inactiv; + Evas_Hash *activ; + void *data; + + int usage; + int limit; + int references; +}; + +struct _Evas_Cache_Engine_Image_Func +{ + /* Must return a char* allocated with evas_stringshare_add. */ + char* (*key)(Image_Entry *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error); + + Engine_Image_Entry* (*alloc)(void); + void (*dealloc)(Engine_Image_Entry *eim); + + int (*constructor)(Engine_Image_Entry *eim, void* data); + void (*destructor)(Engine_Image_Entry *eim); + + void (*dirty_region)(Engine_Image_Entry *eim, int x, int y, int w, int h); + /* Only called when references > 0. Need to provide a fresh copie of im. */ + int (*dirty)(Engine_Image_Entry *dst, const Engine_Image_Entry *src); + /* Only called when references == 1. We will call drop on `im'. */ + int (*size_set)(Engine_Image_Entry *dst, const Engine_Image_Entry *src); + + int (*update_data)(Engine_Image_Entry* dst, void* data); + + void (*load)(Engine_Image_Entry *eim, const Image_Entry* im); + int (*mem_size_get)(Engine_Image_Entry *eim); + void (*debug)(const char* context, Engine_Image_Entry *eim); +}; + +struct _Evas_Cache_Engine_Image +{ + Evas_Cache_Engine_Image_Func func; + + Evas_Object_List* dirty; + + Evas_Hash* activ; + Evas_Hash* inactiv; + Evas_Object_List* lru; + + Evas_Cache_Image* parent; + Evas_Cache_Engine_Image* brother; + + int usage; + int limit; + + int references; +}; + + +EAPI Evas_Cache_Image* evas_cache_image_init(const Evas_Cache_Image_Func *cb); +EAPI void evas_cache_image_shutdown(Evas_Cache_Image *cache); +EAPI Image_Entry* evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error); +EAPI void evas_cache_image_drop(Image_Entry *im); +EAPI void evas_cache_image_data_not_needed(Image_Entry *im); +EAPI int evas_cache_image_flush(Evas_Cache_Image *cache); +EAPI void evas_cache_private_set(Evas_Cache_Image *cache, const void *data); +EAPI void* evas_cache_private_get(Evas_Cache_Image *cache); +EAPI void* evas_cache_private_from_image_entry_get(Image_Entry *im); + +EAPI int evas_cache_image_usage_get(Evas_Cache_Image *cache); +EAPI int evas_cache_image_get(Evas_Cache_Image *cache); +EAPI void evas_cache_image_set(Evas_Cache_Image *cache, int size); + +EAPI Image_Entry* evas_cache_image_alone(Image_Entry *im); +EAPI Image_Entry* evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h); +EAPI void evas_cache_image_load_data(Image_Entry *im); +EAPI void evas_cache_image_surface_alloc(Image_Entry *im, int w, int h); +EAPI DATA32* evas_cache_image_pixels(Image_Entry *im); +EAPI Image_Entry* evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace); +EAPI Image_Entry* evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace); +EAPI void evas_cache_image_colorspace(Image_Entry *im, int cspace); +EAPI Image_Entry* evas_cache_image_empty(Evas_Cache_Image *cache); +EAPI Image_Entry* evas_cache_image_size_set(Image_Entry *im, int w, int h); + +EAPI Evas_Cache_Engine_Image* evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent); +EAPI void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache); + +EAPI void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache); +EAPI int evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache); +EAPI int evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache); +EAPI void evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit); + +EAPI Engine_Image_Entry* evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, void *engine_data, int *error); +EAPI void evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim); +EAPI Engine_Image_Entry* evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data); +EAPI void evas_cache_engine_image_drop(Engine_Image_Entry *eim); +EAPI Engine_Image_Entry* evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data); +EAPI Engine_Image_Entry* evas_cache_engine_image_dirty(Engine_Image_Entry *eim, int x, int y, int w, int h); +EAPI Engine_Image_Entry* evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data); +EAPI Engine_Image_Entry* evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data); +EAPI void evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data); +EAPI Engine_Image_Entry* evas_cache_engine_image_size_set(Engine_Image_Entry *eim, int w, int h); + +EAPI void evas_cache_engine_image_load_data(Engine_Image_Entry *eim); + + +#endif /* _EVAS_CACHE_H */ diff --git a/legacy/evas/src/lib/data/Makefile.am b/legacy/evas/src/lib/data/Makefile.am index 20c97077d2..d298d9c993 100644 --- a/legacy/evas/src/lib/data/Makefile.am +++ b/legacy/evas/src/lib/data/Makefile.am @@ -16,6 +16,9 @@ evas_list.c \ evas_array.c \ evas_object_list.c \ evas_stringshare.c \ -evas_array_hash.c +evas_array_hash.c \ +evas_mempool.c libevas_data_la_DEPENDENCIES = $(top_builddir)/config.h + +EXTRA_DIST = evas_mempool.h diff --git a/legacy/evas/src/lib/data/evas_list.c b/legacy/evas/src/lib/data/evas_list.c index dc784a466b..e4a41c2613 100644 --- a/legacy/evas/src/lib/data/evas_list.c +++ b/legacy/evas/src/lib/data/evas_list.c @@ -2,7 +2,7 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ #include "evas_common.h" -#include "evas_private.h" +#include "evas_mempool.h" typedef struct _Evas_List_Accounting Evas_List_Accounting; @@ -26,7 +26,7 @@ static Evas_Mempool _evas_list_accounting_mempool = 80, 0, NULL, NULL }; - + /** * @defgroup Evas_List_Data_Group Linked List Creation Functions * @@ -211,7 +211,7 @@ EAPI Evas_List * evas_list_append_relative_list(Evas_List *list, const void *data, Evas_List *relative) { Evas_List *new_l; - + if ((!list) || (!relative)) return evas_list_append(list, data); _evas_list_alloc_error = 0; new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List)); @@ -228,7 +228,7 @@ evas_list_append_relative_list(Evas_List *list, const void *data, Evas_List *rel } else new_l->next = NULL; - + relative->next = new_l; new_l->prev = relative; new_l->accounting = list->accounting; @@ -300,7 +300,7 @@ EAPI Evas_List * evas_list_prepend_relative_list(Evas_List *list, const void *data, Evas_List *relative) { Evas_List *new_l; - + if ((!list) || (!relative)) return evas_list_prepend(list, data); _evas_list_alloc_error = 0; new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List)); @@ -748,7 +748,7 @@ EAPI void * evas_list_nth(const Evas_List *list, int n) { Evas_List *l; - + l = evas_list_nth_list(list, n); return l ? l->data : NULL; } @@ -782,7 +782,7 @@ evas_list_nth_list(const Evas_List *list, int n) const Evas_List *l; /* check for non-existing nodes */ - if ((!list) || (n < 0) || + if ((!list) || (n < 0) || (n > (list->accounting->count - 1))) return NULL; @@ -793,7 +793,7 @@ evas_list_nth_list(const Evas_List *list, int n) { for (i = list->accounting->count - 1, l = list->accounting->last; - l; + l; l = l->prev, i--) { if (i == n) return (Evas_List *)l; diff --git a/legacy/evas/src/lib/data/evas_mempool.c b/legacy/evas/src/lib/data/evas_mempool.c new file mode 100644 index 0000000000..f6e06cbf83 --- /dev/null +++ b/legacy/evas/src/lib/data/evas_mempool.c @@ -0,0 +1,183 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + +#include +#include + +#include "evas_mempool.h" + +//#define NOPOOL + +typedef struct _Pool Pool; + +struct _Pool +{ + int usage; + void *base; + Pool *prev, *next; +}; + + +Pool * +_evas_mp_pool_new(Evas_Mempool *pool) +#ifdef NOPOOL +{ + static Pool thepool; + return &thepool; +} +#else +{ + Pool *p; + void **ptr; + int item_alloc, i; + + item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *); + p = malloc(sizeof(Pool) + (pool->pool_size * item_alloc)); + ptr = (void **)(((unsigned char *)p) + sizeof(Pool)); + p->usage = 0; + p->base = ptr; + for (i = 0; i < pool->pool_size - 1; i++) + { + *ptr = (void **)(((unsigned char *)ptr) + item_alloc); + ptr = *ptr; + } + *ptr = NULL; + return p; +} +#endif + +void +_evas_mp_pool_free(Pool *p) +#ifdef NOPOOL +{ +} +#else +{ + free(p); +} +#endif + +void * +evas_mempool_malloc(Evas_Mempool *pool, int size) +#ifdef NOPOOL +{ + return malloc(size); +} +#else +{ + Pool *p; + void *mem; + + for (p = pool->first; p; p = p->next) // look 4 pool from 2nd bucket on + { + if (p->base) // base is not NULL - has a free slot + { + if (p->prev) + { + if (pool->last == p) pool->last = p->prev; + p->prev->next = p->next; + p->prev = NULL; + p->next = pool->first; + p->next->prev = p; + pool->first = p; + } + break; + } + } + if (!p) // we have reached the end of the list - no free pools + { + p = _evas_mp_pool_new(pool); + if (!p) return NULL; + p->prev = NULL; + p->next = pool->first; + if (p->next) p->next->prev = p; + if (!pool->last) pool->last = p; + pool->first = p; + } + mem = p->base; // this points to the next free block - so take it + p->base = *((void **)mem); // base now points to the next free block + if (!p->base) // move to end - it just filled up + { + if (p->next) + { + if (p->prev) p->prev->next = p->next; + else pool->first = p->next; + p->next->prev = p->prev; + ((Pool *)pool->last)->next = p; + p->prev = pool->last; + p->next = NULL; + pool->last = p; + } + } + p->usage++; + pool->usage++; + return mem; +} +#endif + +void +evas_mempool_free(Evas_Mempool *pool, void *ptr) +#ifdef NOPOOL +{ + free(ptr); +} +#else +{ + Pool *p; + void *pmem; + int item_alloc, psize; + + item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *); + psize = item_alloc * pool->pool_size; + for (p = (Pool *)(pool->first); p; p = p->next) // look 4 pool + { + pmem = (void *)(((unsigned char *)p) + sizeof(Pool)); // pool mem base + if ((ptr >= pmem) && ((unsigned char *)ptr < (((unsigned char *)pmem) + psize))) // is it in pool mem? + { + *((void **)ptr) = p->base; // freed node points to prev free node + p->base = ptr; // next free node is now the one we freed + p->usage--; + pool->usage--; + if (p->usage == 0) // free bucket + { + if (p->prev) p->prev->next = p->next; + if (p->next) p->next->prev = p->prev; + if (pool->last == p) pool->last = p->prev; + if (pool->first == p) pool->first = p->next; + _evas_mp_pool_free(p); + } + else + { + if (p->prev) // if not the first - move to front + { + p->prev->next = p->next; + if (p->next) p->next->prev = p->prev; + if (pool->last == p) pool->last = p->prev; + p->prev = NULL; + p->next = pool->first; + p->next->prev = p; + pool->first = p; + } + } + break; + } + } +} +#endif + +void * +evas_mempool_calloc(Evas_Mempool *pool, int size) +#ifdef NOPOOL +{ + return calloc(1, size); +} +#else +{ + void *mem; + + mem = evas_mempool_malloc(pool, size); + memset(mem, 0, size); + return mem; +} +#endif diff --git a/legacy/evas/src/lib/data/evas_mempool.h b/legacy/evas/src/lib/data/evas_mempool.h new file mode 100644 index 0000000000..1cda041142 --- /dev/null +++ b/legacy/evas/src/lib/data/evas_mempool.h @@ -0,0 +1,21 @@ +#ifndef _EVAS_MEMPOOL_H +#define _EVAS_MEMPOOL_H + + +typedef struct _Evas_Mempool Evas_Mempool; + +struct _Evas_Mempool +{ + int item_size; + int pool_size; + int usage; + void *first, *last; +}; + + +void *evas_mempool_malloc(Evas_Mempool *pool, int size); +void evas_mempool_free(Evas_Mempool *pool, void *ptr); +void *evas_mempool_calloc(Evas_Mempool *pool, int size); + + +#endif /* _EVAS_MEMPOOL_H */ diff --git a/legacy/evas/src/lib/file/Makefile.am b/legacy/evas/src/lib/file/Makefile.am index 1556304118..686dd83832 100644 --- a/legacy/evas/src/lib/file/Makefile.am +++ b/legacy/evas/src/lib/file/Makefile.am @@ -19,3 +19,5 @@ evas_path.c \ evas_module.c libevas_file_la_LIBADD = @EVIL_LIBS@ libevas_file_la_DEPENDENCIES = $(top_builddir)/config.h + +EXTRA_DIST = evas_module.h evas_path.h diff --git a/legacy/evas/src/lib/file/evas_module.h b/legacy/evas/src/lib/file/evas_module.h new file mode 100644 index 0000000000..06765dfa2e --- /dev/null +++ b/legacy/evas/src/lib/file/evas_module.h @@ -0,0 +1,83 @@ +#ifndef _EVAS_MODULE_H +#define _EVAS_MODULE_H + + +/* 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_IMAGE_SAVER, + EVAS_MODULE_TYPE_OBJECT +} Evas_Module_Type; + + +typedef struct _Evas_Module_Api Evas_Module_Api; +typedef struct _Evas_Module Evas_Module; +typedef struct _Evas_Module_Path Evas_Module_Path; +typedef struct _Evas_Module_Engine Evas_Module_Engine; + +/* the module api structure, all modules should define this struct */ +struct _Evas_Module_Api +{ + int version; + Evas_Module_Type type; + const char *name; + const char *author; +}; + +/* the module structure */ +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 */ + struct + { + int (*open)(Evas_Module *); + void (*close)(Evas_Module *); + } func; + void *functions; /* this are the functions exported by the module */ + void *data; /* some internal data for the module i.e the id for engines */ + + Evas_Module_Type type; /* the type detected by the path */ + + int ref; /* how many refs */ + int last_used; /* the cycle count when it was last used */ + + unsigned char loaded : 1; +}; + + +/* 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. + * */ +struct _Evas_Module_Path +{ + Evas_Module_Type type; + char *path; +}; + +struct _Evas_Module_Engine +{ + int id; +}; + +void evas_module_paths_init (void); +void evas_module_init (void); +Evas_Module *evas_module_find_type (Evas_Module_Type type, const char *name); +int evas_module_load (Evas_Module *em); +void evas_module_unload (Evas_Module *em); +void evas_module_ref (Evas_Module *em); +void evas_module_unref (Evas_Module *em); +void evas_module_use (Evas_Module *em); +void evas_module_clean (void); +void evas_module_shutdown (void); + + +#endif /* _EVAS_MODULE_H */ diff --git a/legacy/evas/src/lib/file/evas_path.h b/legacy/evas/src/lib/file/evas_path.h new file mode 100644 index 0000000000..9874675abc --- /dev/null +++ b/legacy/evas/src/lib/file/evas_path.h @@ -0,0 +1,15 @@ +#ifndef _EVAS_PATH_H +#define _EVAS_PATH_H + + +int evas_file_path_is_full_path (const char *path); +char *evas_file_path_join (const char *path, const char *end); +int evas_file_path_exists (const char *path); +int evas_file_path_is_file (const char *path); +int evas_file_path_is_dir (const char *path); +Evas_List *evas_file_path_list (char *path, const char *match, int match_case); +DATA64 evas_file_modified_time (const char *file); +char *evas_file_path_resolve (const char *file); + + +#endif /* _EVAS_PATH_H */ diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index 1351d0c0d2..3ab40ab61d 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -166,11 +166,6 @@ typedef struct _Regionbuf Regionbuf; typedef struct _Regionspan Regionspan; */ -typedef struct _Evas_Cache_Image Evas_Cache_Image; -typedef struct _Evas_Cache_Image_Func Evas_Cache_Image_Func; -typedef struct _Evas_Cache_Engine_Image Evas_Cache_Engine_Image; -typedef struct _Evas_Cache_Engine_Image_Func Evas_Cache_Engine_Image_Func; - typedef void (*RGBA_Gfx_Func) (DATA32 *src, DATA8 *mask, DATA32 col, DATA32 *dst, int len); typedef void (*RGBA_Gfx_Pt_Func) (DATA32 src, DATA8 mask, DATA32 col, DATA32 *dst); typedef void (*Gfx_Func_Copy) (DATA32 *src, DATA32 *dst, int len); @@ -182,6 +177,8 @@ typedef void (*Gfx_Func_Gradient_Fill)(DATA32 *src, int src_len, int x, int y, int axx, int axy, int ayx, int ayy, void *geom_data); +#include "../cache/evas_cache.h" + /*****************************************************************************/ typedef enum _RGBA_Image_Flags @@ -725,99 +722,6 @@ struct _Convert_Pal }; /****/ -struct _Evas_Cache_Image_Func -{ - Image_Entry *(*alloc)(void); - void (*dealloc)(Image_Entry *im); - - /* The cache provide some helpers for surface manipulation. */ - int (*surface_alloc)(Image_Entry *im, int w, int h); - void (*surface_delete)(Image_Entry *im); - DATA32 *(*surface_pixels)(Image_Entry *im); - - /* The cache is doing the allocation and deallocation, you must just do the rest. */ - int (*constructor)(Image_Entry *im); - void (*destructor)(Image_Entry *im); - - void (*dirty_region)(Image_Entry *im, int x, int y, int w, int h); - /* Only called when references > 0. Need to provide a fresh copie of im. */ - /* The destination surface does have a surface, but no allocated pixel data. */ - int (*dirty)(Image_Entry *dst, const Image_Entry *src); - /* Only called when references == 1. We will call drop on `im'. */ - /* The destination surface does not have any surface. */ - int (*size_set)(Image_Entry *dst, const Image_Entry *src, int w, int h); - - /* The destination surface does not have any surface. */ - int (*copied_data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace); - /* The destination surface does not have any surface. */ - int (*data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace); - int (*color_space)(Image_Entry *dst, int cspace); - - /* This function need to update im->w and im->h. */ - int (*load)(Image_Entry *im); - int (*mem_size_get)(Image_Entry *im); - void (*debug)(const char *context, Image_Entry *im); -}; - -struct _Evas_Cache_Image -{ - Evas_Cache_Image_Func func; - - Evas_Object_List *dirty; - - Evas_Object_List *lru; - Evas_Object_List *lru_nodata; - Evas_Hash *inactiv; - Evas_Hash *activ; - void *data; - - int usage; - int limit; - int references; -}; - -struct _Evas_Cache_Engine_Image_Func -{ - /* Must return a char* allocated with evas_stringshare_add. */ - char* (*key)(Image_Entry *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error); - - Engine_Image_Entry* (*alloc)(void); - void (*dealloc)(Engine_Image_Entry *eim); - - int (*constructor)(Engine_Image_Entry *eim, void* data); - void (*destructor)(Engine_Image_Entry *eim); - - void (*dirty_region)(Engine_Image_Entry *eim, int x, int y, int w, int h); - /* Only called when references > 0. Need to provide a fresh copie of im. */ - int (*dirty)(Engine_Image_Entry *dst, const Engine_Image_Entry *src); - /* Only called when references == 1. We will call drop on `im'. */ - int (*size_set)(Engine_Image_Entry *dst, const Engine_Image_Entry *src); - - int (*update_data)(Engine_Image_Entry* dst, void* data); - - void (*load)(Engine_Image_Entry *eim, const Image_Entry* im); - int (*mem_size_get)(Engine_Image_Entry *eim); - void (*debug)(const char* context, Engine_Image_Entry *eim); -}; - -struct _Evas_Cache_Engine_Image -{ - Evas_Cache_Engine_Image_Func func; - - Evas_Object_List* dirty; - - Evas_Hash* activ; - Evas_Hash* inactiv; - Evas_Object_List* lru; - - Evas_Cache_Image* parent; - Evas_Cache_Engine_Image* brother; - - int usage; - int limit; - - int references; -}; /*****************************************************************************/ #include "evas_macros.h" @@ -1260,52 +1164,6 @@ EAPI void evas_common_pipe_image_draw(RGBA_Image *src, RGBA_Image *dst, RGBA_Dra void evas_font_dir_cache_free(void); /****/ -EAPI Evas_Cache_Image* evas_cache_image_init(const Evas_Cache_Image_Func *cb); -EAPI void evas_cache_image_shutdown(Evas_Cache_Image *cache); -EAPI Image_Entry* evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error); -EAPI void evas_cache_image_drop(Image_Entry *im); -EAPI void evas_cache_image_data_not_needed(Image_Entry *im); -EAPI int evas_cache_image_flush(Evas_Cache_Image *cache); -EAPI void evas_cache_private_set(Evas_Cache_Image *cache, const void *data); -EAPI void* evas_cache_private_get(Evas_Cache_Image *cache); -EAPI void* evas_cache_private_from_image_entry_get(Image_Entry *im); - -EAPI int evas_cache_image_usage_get(Evas_Cache_Image *cache); -EAPI int evas_cache_image_get(Evas_Cache_Image *cache); -EAPI void evas_cache_image_set(Evas_Cache_Image *cache, int size); - -EAPI Image_Entry* evas_cache_image_alone(Image_Entry *im); -EAPI Image_Entry* evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h); -EAPI void evas_cache_image_load_data(Image_Entry *im); -EAPI void evas_cache_image_surface_alloc(Image_Entry *im, int w, int h); -EAPI DATA32* evas_cache_image_pixels(Image_Entry *im); -EAPI Image_Entry* evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace); -EAPI Image_Entry* evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace); -EAPI void evas_cache_image_colorspace(Image_Entry *im, int cspace); -EAPI Image_Entry* evas_cache_image_empty(Evas_Cache_Image *cache); -EAPI Image_Entry* evas_cache_image_size_set(Image_Entry *im, int w, int h); - -EAPI Evas_Cache_Engine_Image* evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent); -EAPI void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache); - -EAPI void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache); -EAPI int evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache); -EAPI int evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache); -EAPI void evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit); - -EAPI Engine_Image_Entry* evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key, - RGBA_Image_Loadopts *lo, void *engine_data, int *error); -EAPI void evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim); -EAPI Engine_Image_Entry* evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data); -EAPI void evas_cache_engine_image_drop(Engine_Image_Entry *eim); -EAPI Engine_Image_Entry* evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data); -EAPI Engine_Image_Entry* evas_cache_engine_image_dirty(Engine_Image_Entry *eim, int x, int y, int w, int h); -EAPI Engine_Image_Entry* evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data); -EAPI Engine_Image_Entry* evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data); -EAPI void evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data); -EAPI Engine_Image_Entry* evas_cache_engine_image_size_set(Engine_Image_Entry *eim, int w, int h); - -EAPI void evas_cache_engine_image_load_data(Engine_Image_Entry *eim); /*****************************************************************************/ diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h index f1c148c85c..a7124a977e 100644 --- a/legacy/evas/src/lib/include/evas_private.h +++ b/legacy/evas/src/lib/include/evas_private.h @@ -7,73 +7,9 @@ #include "Evas.h" -/* the evas module api */ -/***********************/ -/* the module api version */ -#define EVAS_MODULE_API_VERSION 1 +#include "../file/evas_module.h" +#include "../file/evas_path.h" -/* the module types */ -typedef enum _Evas_Module_Type -{ - EVAS_MODULE_TYPE_ENGINE, - EVAS_MODULE_TYPE_IMAGE_LOADER, - EVAS_MODULE_TYPE_IMAGE_SAVER, - 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 */ - struct - { - int (*open)(Evas_Module *); - void (*close)(Evas_Module *); - } func; - void *functions; /* this are the functions exported by the module */ - void *data; /* some internal data for the module i.e the id for engines */ - - Evas_Module_Type type; /* the type detected by the path */ - - int ref; /* how many refs */ - int last_used; /* the cycle count when it was last used */ - - unsigned char loaded : 1; -}; - - -/* 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; - 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 @@ -728,14 +664,6 @@ int evas_object_was_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y); int evas_object_clippers_was_visible(Evas_Object *obj); void evas_object_event_callback_call(Evas_Object *obj, Evas_Callback_Type type, void *event_info); Evas_List *evas_event_objects_event_list(Evas *e, Evas_Object *stop, int x, int y); -int evas_file_path_is_full_path(const char *path); -char *evas_file_path_join(const char *path, const char *end); -int evas_file_path_exists(const char *path); -int evas_file_path_is_file(const char *path); -int evas_file_path_is_dir(const char *path); -Evas_List *evas_file_path_list(char *path, const char *match, int match_case); -DATA64 evas_file_modified_time(const char *file); -char *evas_file_path_resolve(const char *file); int evas_mem_free(int mem_required); int evas_mem_degrade(int mem_required); void evas_debug_error(void); @@ -801,31 +729,6 @@ struct _Evas_Imaging_Font RGBA_Font *font; }; -typedef struct _Evas_Mempool Evas_Mempool; - -struct _Evas_Mempool -{ - int item_size; - int pool_size; - int usage; - void *first, *last; -}; - -void *evas_mempool_malloc(Evas_Mempool *pool, int size); -void evas_mempool_free(Evas_Mempool *pool, void *ptr); -void *evas_mempool_calloc(Evas_Mempool *pool, int size); - -void evas_module_paths_init(void); -void evas_module_init(void); -Evas_Module * evas_module_find_type(Evas_Module_Type type, const char *name); -int evas_module_load(Evas_Module *em); -void evas_module_unload(Evas_Module *em); -void evas_module_ref(Evas_Module *em); -void evas_module_unref(Evas_Module *em); -void evas_module_use(Evas_Module *em); -void evas_module_clean(void); -void evas_module_shutdown(void); - int evas_async_events_init(void); int evas_async_events_shutdown(void); diff --git a/legacy/evas/src/lib/main.c b/legacy/evas/src/lib/main.c index 07cd789601..3578cc40af 100644 --- a/legacy/evas/src/lib/main.c +++ b/legacy/evas/src/lib/main.c @@ -207,184 +207,3 @@ evas_debug_magic_string_get(DATA32 magic) }; return ""; } - - - - - - - - -//#define NOPOOL - -typedef struct _Pool Pool; - -struct _Pool -{ - int usage; - void *base; - Pool *prev, *next; -}; - -Pool * -_evas_mp_pool_new(Evas_Mempool *pool) -#ifdef NOPOOL -{ - static Pool thepool; - return &thepool; -} -#else -{ - Pool *p; - void **ptr; - int item_alloc, i; - - item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *); - p = malloc(sizeof(Pool) + (pool->pool_size * item_alloc)); - ptr = (void **)(((unsigned char *)p) + sizeof(Pool)); - p->usage = 0; - p->base = ptr; - for (i = 0; i < pool->pool_size - 1; i++) - { - *ptr = (void **)(((unsigned char *)ptr) + item_alloc); - ptr = *ptr; - } - *ptr = NULL; - return p; -} -#endif - -void -_evas_mp_pool_free(Pool *p) -#ifdef NOPOOL -{ -} -#else -{ - free(p); -} -#endif - -void * -evas_mempool_malloc(Evas_Mempool *pool, int size) -#ifdef NOPOOL -{ - return malloc(size); -} -#else -{ - Pool *p; - void *mem; - - for (p = pool->first; p; p = p->next) // look 4 pool from 2nd bucket on - { - if (p->base) // base is not NULL - has a free slot - { - if (p->prev) - { - if (pool->last == p) pool->last = p->prev; - p->prev->next = p->next; - p->prev = NULL; - p->next = pool->first; - p->next->prev = p; - pool->first = p; - } - break; - } - } - if (!p) // we have reached the end of the list - no free pools - { - p = _evas_mp_pool_new(pool); - if (!p) return NULL; - p->prev = NULL; - p->next = pool->first; - if (p->next) p->next->prev = p; - if (!pool->last) pool->last = p; - pool->first = p; - } - mem = p->base; // this points to the next free block - so take it - p->base = *((void **)mem); // base now points to the next free block - if (!p->base) // move to end - it just filled up - { - if (p->next) - { - if (p->prev) p->prev->next = p->next; - else pool->first = p->next; - p->next->prev = p->prev; - ((Pool *)pool->last)->next = p; - p->prev = pool->last; - p->next = NULL; - pool->last = p; - } - } - p->usage++; - pool->usage++; - return mem; -} -#endif - -void -evas_mempool_free(Evas_Mempool *pool, void *ptr) -#ifdef NOPOOL -{ - free(ptr); -} -#else -{ - Pool *p; - void *pmem; - int item_alloc, psize; - - item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *); - psize = item_alloc * pool->pool_size; - for (p = (Pool *)(pool->first); p; p = p->next) // look 4 pool - { - pmem = (void *)(((unsigned char *)p) + sizeof(Pool)); // pool mem base - if ((ptr >= pmem) && ((unsigned char *)ptr < (((unsigned char *)pmem) + psize))) // is it in pool mem? - { - *((void **)ptr) = p->base; // freed node points to prev free node - p->base = ptr; // next free node is now the one we freed - p->usage--; - pool->usage--; - if (p->usage == 0) // free bucket - { - if (p->prev) p->prev->next = p->next; - if (p->next) p->next->prev = p->prev; - if (pool->last == p) pool->last = p->prev; - if (pool->first == p) pool->first = p->next; - _evas_mp_pool_free(p); - } - else - { - if (p->prev) // if not the first - move to front - { - p->prev->next = p->next; - if (p->next) p->next->prev = p->prev; - if (pool->last == p) pool->last = p->prev; - p->prev = NULL; - p->next = pool->first; - p->next->prev = p; - pool->first = p; - } - } - break; - } - } -} -#endif - -void * -evas_mempool_calloc(Evas_Mempool *pool, int size) -#ifdef NOPOOL -{ - return calloc(1, size); -} -#else -{ - void *mem; - - mem = evas_mempool_malloc(pool, size); - memset(mem, 0, size); - return mem; -} -#endif