diff options
author | Kim Woelders <kim@woelders.dk> | 2019-12-23 19:17:47 +0100 |
---|---|---|
committer | Kim Woelders <kim@woelders.dk> | 2019-12-28 12:06:22 +0100 |
commit | 0c7464f0dbabc0ead76e37fff306517f47ff97a3 (patch) | |
tree | 9b5d0201c1b9b08fe31682ee4657e16d23765f61 | |
parent | 6a7eb67f46064f9133ce0a54d17aebd92c61f0a5 (diff) | |
download | imlib2-0c7464f0dbabc0ead76e37fff306517f47ff97a3.tar.gz |
image.c/h: Cleanups
- Make a number of functions static
- Shuffle prototypes around for nicer grouping
- Remove unused __imlib_SetImageAlphaFlag()
- Remove __imlib_FlushCache() prototype (not implemented)
-rw-r--r-- | src/lib/api.c | 2 | ||||
-rw-r--r-- | src/lib/image.c | 60 | ||||
-rw-r--r-- | src/lib/image.h | 80 |
3 files changed, 59 insertions, 83 deletions
diff --git a/src/lib/api.c b/src/lib/api.c index 3476aa1..2827c3a 100644 --- a/src/lib/api.c +++ b/src/lib/api.c @@ -1691,7 +1691,9 @@ imlib_image_set_border(Imlib_Border * border) im->border.right = MAX(0, border->right); im->border.top = MAX(0, border->top); im->border.bottom = MAX(0, border->bottom); +#ifdef BUILD_X11 __imlib_DirtyPixmapsForImage(im); +#endif } /** diff --git a/src/lib/image.c b/src/lib/image.c index d46871f..1a2c8fb 100644 --- a/src/lib/image.c +++ b/src/lib/image.c @@ -169,26 +169,8 @@ __imlib_FreeAllTags(ImlibImage * im) } } -/* set the cache size */ -void -__imlib_SetCacheSize(int size) -{ - cache_size = size; - __imlib_CleanupImageCache(); -#ifdef BUILD_X11 - __imlib_CleanupImagePixmapCache(); -#endif -} - -/* return the cache size */ -int -__imlib_GetCacheSize(void) -{ - return cache_size; -} - /* create an image data struct and fill it in */ -ImlibImage * +static ImlibImage * __imlib_ProduceImage(void) { ImlibImage *im; @@ -200,7 +182,7 @@ __imlib_ProduceImage(void) } /* free an image struct */ -void +static void __imlib_ConsumeImage(ImlibImage * im) { #ifdef BUILD_X11 @@ -234,7 +216,7 @@ __imlib_ConsumeImage(ImlibImage * im) #endif } -ImlibImage * +static ImlibImage * __imlib_FindCachedImage(const char *file) { ImlibImage *im, *previous_im; @@ -264,7 +246,7 @@ __imlib_FindCachedImage(const char *file) } /* add an image to the cache of images (at the start) */ -void +static void __imlib_AddImageToCache(ImlibImage * im) { im->next = images; @@ -272,7 +254,7 @@ __imlib_AddImageToCache(ImlibImage * im) } /* remove (unlink) an image from the cache of images */ -void +static void __imlib_RemoveImageFromCache(ImlibImage * im) { ImlibImage *current_im, *previous_im; @@ -385,8 +367,8 @@ __imlib_CurrentCacheSize(void) return current_cache; } -/* clean out images fromthe cache if the cache is overgrown */ -void +/* clean out images from the cache if the cache is overgrown */ +static void __imlib_CleanupImageCache(void) { ImlibImage *im, *im_last; @@ -431,6 +413,24 @@ __imlib_CleanupImageCache(void) } } +/* set the cache size */ +void +__imlib_SetCacheSize(int size) +{ + cache_size = size; + __imlib_CleanupImageCache(); +#ifdef BUILD_X11 + __imlib_CleanupImagePixmapCache(); +#endif +} + +/* return the cache size */ +int +__imlib_GetCacheSize(void) +{ + return cache_size; +} + #ifdef BUILD_X11 /* create a pixmap cache data struct */ ImlibImagePixmap * @@ -835,16 +835,6 @@ __imlib_ErrorFromErrno(int err, int save) } } -/* set or unset the alpha flag on the umage (alpha = 1 / 0 ) */ -void -__imlib_SetImageAlphaFlag(ImlibImage * im, char alpha) -{ - if (alpha) - SET_FLAG(im->flags, F_HAS_ALPHA); - else - UNSET_FLAG(im->flags, F_HAS_ALPHA); -} - /* create a new image struct from data passed that is wize w x h then return */ /* a pointer to that image sturct */ ImlibImage * diff --git a/src/lib/image.h b/src/lib/image.h index 5d6804d..cec85e3 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -104,28 +104,30 @@ struct _imlibloader { ImlibLoader *next; }; +void __imlib_RemoveAllLoaders(void); +ImlibLoader *__imlib_FindBestLoaderForFile(const char *file, + int for_save); +ImlibLoader *__imlib_FindBestLoaderForFormat(const char *format, + int for_save); + +ImlibImage *__imlib_CreateImage(int w, int h, DATA32 * data); +ImlibImage *__imlib_LoadImage(const char *file, + ImlibProgressFunction progress, + char progress_granularity, + char immediate_load, char dont_cache, + ImlibLoadError * er); +int __imlib_LoadImageData(ImlibImage * im); +void __imlib_DirtyImage(ImlibImage * im); +void __imlib_FreeImage(ImlibImage * im); +void __imlib_SaveImage(ImlibImage * im, const char *file, + ImlibProgressFunction progress, + char progress_granularity, + ImlibLoadError * er); + DATA32 *__imlib_AllocateData(ImlibImage * im); void __imlib_FreeData(ImlibImage * im); void __imlib_ReplaceData(ImlibImage * im, DATA32 * new_data); -void __imlib_AttachTag(ImlibImage * im, const char *key, - int val, void *data, - ImlibDataDestructorFunction destructor); -ImlibImageTag *__imlib_GetTag(ImlibImage * im, const char *key); -ImlibImageTag *__imlib_RemoveTag(ImlibImage * im, const char *key); -void __imlib_FreeTag(ImlibImage * im, ImlibImageTag * t); -void __imlib_FreeAllTags(ImlibImage * im); - -void __imlib_SetCacheSize(int size); -int __imlib_GetCacheSize(void); -ImlibImage *__imlib_ProduceImage(void); -void __imlib_ConsumeImage(ImlibImage * im); -ImlibImage *__imlib_FindCachedImage(const char *file); -void __imlib_AddImageToCache(ImlibImage * im); -void __imlib_RemoveImageFromCache(ImlibImage * im); -int __imlib_CurrentCacheSize(void); -void __imlib_CleanupImageCache(void); - #ifdef BUILD_X11 ImlibImagePixmap *__imlib_ProduceImagePixmap(void); void __imlib_ConsumeImagePixmap(ImlibImagePixmap * ip); @@ -139,41 +141,23 @@ ImlibImagePixmap *__imlib_FindCachedImagePixmapByID(Display * d, Pixmap p); void __imlib_AddImagePixmapToCache(ImlibImagePixmap * ip); void __imlib_RemoveImagePixmapFromCache(ImlibImagePixmap * ip); void __imlib_CleanupImagePixmapCache(void); -#endif -void __imlib_RemoveAllLoaders(void); -ImlibLoader *__imlib_FindBestLoaderForFile(const char *file, - int for_save); -ImlibLoader *__imlib_FindBestLoaderForFormat(const char *format, - int for_save); -void __imlib_SetImageAlphaFlag(ImlibImage * im, char alpha); -ImlibImage *__imlib_CreateImage(int w, int h, DATA32 * data); -ImlibImage *__imlib_LoadImage(const char *file, - ImlibProgressFunction progress, - char progress_granularity, - char immediate_load, char dont_cache, - ImlibLoadError * er); -int __imlib_LoadImageData(ImlibImage * im); -#ifdef BUILD_X11 ImlibImagePixmap *__imlib_FindImlibImagePixmapByID(Display * d, Pixmap p); -#endif -void __imlib_FreeImage(ImlibImage * im); - -#ifdef BUILD_X11 void __imlib_FreePixmap(Display * d, Pixmap p); -#endif -void __imlib_FlushCache(void); - -#ifdef BUILD_X11 void __imlib_DirtyPixmapsForImage(ImlibImage * im); -#else -#define __imlib_DirtyPixmapsForImage(x) /* x */ #endif -void __imlib_DirtyImage(ImlibImage * im); -void __imlib_SaveImage(ImlibImage * im, const char *file, - ImlibProgressFunction progress, - char progress_granularity, - ImlibLoadError * er); + +void __imlib_AttachTag(ImlibImage * im, const char *key, + int val, void *data, + ImlibDataDestructorFunction destructor); +ImlibImageTag *__imlib_GetTag(ImlibImage * im, const char *key); +ImlibImageTag *__imlib_RemoveTag(ImlibImage * im, const char *key); +void __imlib_FreeTag(ImlibImage * im, ImlibImageTag * t); +void __imlib_FreeAllTags(ImlibImage * im); + +void __imlib_SetCacheSize(int size); +int __imlib_GetCacheSize(void); +int __imlib_CurrentCacheSize(void); #define IMAGE_HAS_ALPHA(im) ((im)->flags & F_HAS_ALPHA) #define IMAGE_IS_UNLOADED(im) ((im)->flags & F_UNLOADED) |