From 97b3aa9b9bb99faff53b31beb89dcb83f0efb39e Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Fri, 4 Mar 2022 14:34:48 +0100 Subject: [PATCH] Introduce types.h Avoiding more conveluted header file inclusion order issues. --- src/lib/Makefile.am | 1 + src/lib/blend.h | 4 +--- src/lib/colormod.h | 7 +++---- src/lib/common.h | 7 +------ src/lib/dynamic_filters.c | 1 - src/lib/ellipse.c | 1 - src/lib/filter.c | 2 -- src/lib/font.h | 2 +- src/lib/font_draw.c | 1 - src/lib/font_load.c | 5 ----- src/lib/font_main.c | 5 ----- src/lib/font_query.c | 5 ----- src/lib/grad.c | 1 - src/lib/grad.h | 2 +- src/lib/image.h | 10 +--------- src/lib/line.c | 1 - src/lib/loaders.c | 1 - src/lib/loaders.h | 2 +- src/lib/modules.c | 1 - src/lib/polygon.c | 1 - src/lib/rectangle.c | 1 - src/lib/rgbadraw.c | 4 ---- src/lib/rgbadraw.h | 3 +-- src/lib/rotate.c | 1 + src/lib/rotate.h | 5 +---- src/lib/scale.c | 2 -- src/lib/scale.h | 2 +- src/lib/script.c | 1 - src/lib/script.h | 3 +-- src/lib/span.c | 2 -- src/lib/span.h | 2 +- src/lib/types.h | 25 +++++++++++++++++++++++++ src/lib/updates.h | 4 ++-- src/lib/x11_color.h | 3 ++- src/lib/x11_context.c | 1 - src/lib/x11_context.h | 3 ++- src/lib/x11_grab.h | 3 ++- src/lib/x11_pixmap.c | 3 +++ src/lib/x11_pixmap.h | 4 +--- src/lib/x11_rend.h | 3 +-- src/lib/x11_rgba.h | 2 +- src/modules/filters/filter_bumpmap.c | 1 - 42 files changed, 55 insertions(+), 83 deletions(-) create mode 100644 src/lib/types.h diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 4d8537c..3574d09 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -42,6 +42,7 @@ rotate.c rotate.h \ scale.c scale.h \ script.c script.h \ span.c span.h \ +types.h \ updates.c updates.h MMX_SRCS = \ diff --git a/src/lib/blend.h b/src/lib/blend.h index 8da573c..0854a00 100644 --- a/src/lib/blend.h +++ b/src/lib/blend.h @@ -1,7 +1,7 @@ #ifndef __BLEND #define __BLEND 1 -#include "colormod.h" +#include "types.h" #define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \ ((x < (xx + ww)) && \ @@ -337,8 +337,6 @@ enum _imlibop { OP_RESHADE }; -typedef enum _imlibop ImlibOp; - typedef void (*ImlibBlendFunction)(DATA32 *, int, DATA32 *, int, int, int, ImlibColorModifier *); diff --git a/src/lib/colormod.h b/src/lib/colormod.h index aeb0384..6393ea5 100644 --- a/src/lib/colormod.h +++ b/src/lib/colormod.h @@ -1,16 +1,15 @@ #ifndef __COLORMOD #define __COLORMOD 1 -#include "common.h" -#include "image.h" +#include "types.h" -typedef struct { +struct _ImlibColorModifier { DATA8 red_mapping[256]; DATA8 green_mapping[256]; DATA8 blue_mapping[256]; DATA8 alpha_mapping[256]; DATABIG modification_count; -} ImlibColorModifier; +}; #define CMOD_APPLY_RGB(cm, r, g, b) \ (r) = (cm)->red_mapping[(int)(r)]; \ diff --git a/src/lib/common.h b/src/lib/common.h index d4df73e..b0c0271 100644 --- a/src/lib/common.h +++ b/src/lib/common.h @@ -2,6 +2,7 @@ #define __COMMON 1 #include "config.h" +#include "types.h" #if __GNUC__ #define __PRINTF_N__(no) __attribute__((__format__(__printf__, (no), (no)+1))) @@ -13,12 +14,6 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -#define DATABIG unsigned long long -#define DATA64 unsigned long long -#define DATA32 unsigned int -#define DATA16 unsigned short -#define DATA8 unsigned char - #define SWAP32(x) \ ((((x) & 0x000000ff ) << 24) | \ (((x) & 0x0000ff00 ) << 8) | \ diff --git a/src/lib/dynamic_filters.c b/src/lib/dynamic_filters.c index 275d25c..24c1cc2 100644 --- a/src/lib/dynamic_filters.c +++ b/src/lib/dynamic_filters.c @@ -14,7 +14,6 @@ #include "dynamic_filters.h" #include "file.h" -#include "image.h" #include "script.h" static ImlibExternalFilter *filters = NULL; diff --git a/src/lib/ellipse.c b/src/lib/ellipse.c index 5d70984..2d8ee65 100644 --- a/src/lib/ellipse.c +++ b/src/lib/ellipse.c @@ -1,7 +1,6 @@ #include "common.h" #include "blend.h" -#include "colormod.h" #include "image.h" #include "rgbadraw.h" #include "span.h" diff --git a/src/lib/filter.c b/src/lib/filter.c index 94cc9af..922b36f 100644 --- a/src/lib/filter.c +++ b/src/lib/filter.c @@ -2,8 +2,6 @@ #include -#include "blend.h" -#include "colormod.h" #include "filter.h" #include "image.h" diff --git a/src/lib/font.h b/src/lib/font.h index d281d97..012dc6f 100644 --- a/src/lib/font.h +++ b/src/lib/font.h @@ -5,8 +5,8 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include "common.h" #include "object.h" +#include "types.h" typedef struct _Imlib_Font { Imlib_Object_List _list_data; diff --git a/src/lib/font_draw.c b/src/lib/font_draw.c index 45fba3f..4621097 100644 --- a/src/lib/font_draw.c +++ b/src/lib/font_draw.c @@ -8,7 +8,6 @@ #include #include "blend.h" -#include "colormod.h" #include "font.h" #include "image.h" #include "rgbadraw.h" diff --git a/src/lib/font_load.c b/src/lib/font_load.c index 9abe41b..2a7864f 100644 --- a/src/lib/font_load.c +++ b/src/lib/font_load.c @@ -7,13 +7,8 @@ #include #include -#include "blend.h" -#include "colormod.h" #include "file.h" #include "font.h" -#include "image.h" -#include "rgbadraw.h" -#include "rotate.h" extern FT_Library ft_lib; diff --git a/src/lib/font_main.c b/src/lib/font_main.c index 766f80f..93fe318 100644 --- a/src/lib/font_main.c +++ b/src/lib/font_main.c @@ -7,12 +7,7 @@ #include #include -#include "blend.h" -#include "colormod.h" #include "font.h" -#include "image.h" -#include "rgbadraw.h" -#include "rotate.h" FT_Library ft_lib; diff --git a/src/lib/font_query.c b/src/lib/font_query.c index 4ebad1e..0a211f6 100644 --- a/src/lib/font_query.c +++ b/src/lib/font_query.c @@ -7,12 +7,7 @@ #include #include -#include "blend.h" -#include "colormod.h" -#include "image.h" #include "font.h" -#include "rgbadraw.h" -#include "rotate.h" extern FT_Library ft_lib; diff --git a/src/lib/grad.c b/src/lib/grad.c index 16b4bbc..8a1dc70 100644 --- a/src/lib/grad.c +++ b/src/lib/grad.c @@ -4,7 +4,6 @@ #include #include "blend.h" -#include "colormod.h" #include "color_helpers.h" #include "grad.h" #include "image.h" diff --git a/src/lib/grad.h b/src/lib/grad.h index a2f1e08..21aea8e 100644 --- a/src/lib/grad.h +++ b/src/lib/grad.h @@ -1,7 +1,7 @@ #ifndef __GRAD #define __GRAD 1 -#include "common.h" +#include "types.h" typedef struct _ImlibRangeColor { DATA8 red, green, blue, alpha; diff --git a/src/lib/image.h b/src/lib/image.h index 4a01859..201c15d 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -5,16 +5,10 @@ #include #include -#include "common.h" +#include "types.h" typedef struct _imlibldctx ImlibLdCtx; -typedef struct _ImlibLoader ImlibLoader; -typedef struct _ImlibImage ImlibImage; - -typedef int (*ImlibProgressFunction)(ImlibImage * im, char percent, - int update_x, int update_y, - int update_w, int update_h); typedef void (*ImlibDataDestructorFunction)(ImlibImage * im, void *data); typedef void *(*ImlibImageDataMemoryFunction)(void *, size_t size); @@ -28,8 +22,6 @@ enum _iflags { F_FORMAT_IRRELEVANT = (1 << 5), }; -typedef enum _iflags ImlibImageFlags; - /* Must match the ones in Imlib2.h.in */ #define FF_IMAGE_ANIMATED (1 << 0) /* Frames are an animated sequence */ #define FF_FRAME_BLEND (1 << 1) /* Blend current onto previous frame */ diff --git a/src/lib/line.c b/src/lib/line.c index 75f4946..653700a 100644 --- a/src/lib/line.c +++ b/src/lib/line.c @@ -3,7 +3,6 @@ #include #include "blend.h" -#include "colormod.h" #include "image.h" #include "rgbadraw.h" #include "span.h" diff --git a/src/lib/loaders.c b/src/lib/loaders.c index 4fad851..9d79538 100644 --- a/src/lib/loaders.c +++ b/src/lib/loaders.c @@ -8,7 +8,6 @@ #include "debug.h" #include "file.h" -#include "image.h" #include "loaders.h" #define DBG_PFX "LOAD" diff --git a/src/lib/loaders.h b/src/lib/loaders.h index 2ce3fd5..f323e23 100644 --- a/src/lib/loaders.h +++ b/src/lib/loaders.h @@ -1,7 +1,7 @@ #ifndef __LOADERS #define __LOADERS 1 -#include "image.h" +#include "types.h" struct _ImlibLoader { char *file; diff --git a/src/lib/modules.c b/src/lib/modules.c index b0109fe..c563fcf 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -5,7 +5,6 @@ #include #include "file.h" -#include "image.h" static const char * __imlib_PathToModules(void) diff --git a/src/lib/polygon.c b/src/lib/polygon.c index b0aa8eb..dd89cc4 100644 --- a/src/lib/polygon.c +++ b/src/lib/polygon.c @@ -4,7 +4,6 @@ #include #include "blend.h" -#include "colormod.h" #include "image.h" #include "rgbadraw.h" #include "span.h" diff --git a/src/lib/rectangle.c b/src/lib/rectangle.c index 9029389..343e82a 100644 --- a/src/lib/rectangle.c +++ b/src/lib/rectangle.c @@ -1,7 +1,6 @@ #include "common.h" #include "blend.h" -#include "colormod.h" #include "image.h" #include "rgbadraw.h" #include "span.h" diff --git a/src/lib/rgbadraw.c b/src/lib/rgbadraw.c index 8a6748a..697db80 100644 --- a/src/lib/rgbadraw.c +++ b/src/lib/rgbadraw.c @@ -4,12 +4,8 @@ #include #include -#include "blend.h" -#include "colormod.h" #include "image.h" #include "rgbadraw.h" -#include "scale.h" -#include "updates.h" void __imlib_FlipImageHoriz(ImlibImage * im) diff --git a/src/lib/rgbadraw.h b/src/lib/rgbadraw.h index 4a6d35d..2c0fc6e 100644 --- a/src/lib/rgbadraw.h +++ b/src/lib/rgbadraw.h @@ -1,8 +1,7 @@ #ifndef __RGBADRAW #define __RGBADRAW 1 -#include "common.h" -#include "updates.h" +#include "types.h" #define IN_SEGMENT(x, sx, sw) \ ((unsigned)((x) - (sx)) < (unsigned)(sw)) diff --git a/src/lib/rotate.c b/src/lib/rotate.c index 6df65d4..ee06d24 100644 --- a/src/lib/rotate.c +++ b/src/lib/rotate.c @@ -4,6 +4,7 @@ #include "asm_c.h" #include "blend.h" +#include "image.h" #include "rotate.h" /*\ Linear interpolation functions \*/ diff --git a/src/lib/rotate.h b/src/lib/rotate.h index aa93ea3..4435365 100644 --- a/src/lib/rotate.h +++ b/src/lib/rotate.h @@ -1,10 +1,7 @@ #ifndef __ROTATE #define __ROTATE 1 -#include "common.h" -#include "image.h" -#include "colormod.h" -#include "blend.h" +#include "types.h" /*\ Calc precision \*/ #define _ROTATE_PREC 12 diff --git a/src/lib/scale.c b/src/lib/scale.c index d104344..18cb85b 100644 --- a/src/lib/scale.c +++ b/src/lib/scale.c @@ -5,8 +5,6 @@ #include #include "asm_c.h" -#include "blend.h" -#include "colormod.h" #include "image.h" #include "scale.h" diff --git a/src/lib/scale.h b/src/lib/scale.h index 1ebd845..cf287a2 100644 --- a/src/lib/scale.h +++ b/src/lib/scale.h @@ -1,7 +1,7 @@ #ifndef __SCALE #define __SCALE 1 -#include "common.h" +#include "types.h" typedef struct _imlib_scale_info ImlibScaleInfo; diff --git a/src/lib/script.c b/src/lib/script.c index ff56c8a..573b369 100644 --- a/src/lib/script.c +++ b/src/lib/script.c @@ -14,7 +14,6 @@ #include #include "dynamic_filters.h" -#include "image.h" #include "script.h" /* diff --git a/src/lib/script.h b/src/lib/script.h index 5abc1e9..59d0822 100644 --- a/src/lib/script.h +++ b/src/lib/script.h @@ -2,8 +2,7 @@ #define _DYN_FUNCTION_H_ #include -#include "common.h" -#include "image.h" +#include "types.h" #define VAR_CHAR 1 #define VAR_PTR 2 diff --git a/src/lib/span.c b/src/lib/span.c index 2ab920a..b9ef4a7 100644 --- a/src/lib/span.c +++ b/src/lib/span.c @@ -3,8 +3,6 @@ #include #include "blend.h" -#include "colormod.h" -#include "image.h" #include "span.h" #define ADD_COPY(r, g, b, dest) \ diff --git a/src/lib/span.h b/src/lib/span.h index 2d4497c..0d589bc 100644 --- a/src/lib/span.h +++ b/src/lib/span.h @@ -1,7 +1,7 @@ #ifndef __SPAN #define __SPAN 1 -#include "common.h" +#include "types.h" typedef void (*ImlibPointDrawFunction)(DATA32, DATA32 *); diff --git a/src/lib/types.h b/src/lib/types.h new file mode 100644 index 0000000..5a09b8a --- /dev/null +++ b/src/lib/types.h @@ -0,0 +1,25 @@ +#ifndef TYPES_H +#define TYPES_H 1 + +#define DATABIG unsigned long long +#define DATA64 unsigned long long +#define DATA32 unsigned int +#define DATA16 unsigned short +#define DATA8 unsigned char + +typedef struct _ImlibLoader ImlibLoader; + +typedef struct _ImlibImage ImlibImage; +typedef unsigned int ImlibImageFlags; + +typedef int (*ImlibProgressFunction)(ImlibImage * im, char percent, + int update_x, int update_y, + int update_w, int update_h); + +typedef int ImlibOp; + +typedef struct _ImlibColorModifier ImlibColorModifier; + +typedef struct _ImlibUpdate ImlibUpdate; + +#endif /* TYPES_H */ diff --git a/src/lib/updates.h b/src/lib/updates.h index ed2b250..f5378cc 100644 --- a/src/lib/updates.h +++ b/src/lib/updates.h @@ -1,10 +1,10 @@ #ifndef __UPDATES #define __UPDATES 1 -typedef struct _ImlibUpdate { +struct _ImlibUpdate { int x, y, w, h; struct _ImlibUpdate *next; -} ImlibUpdate; +}; ImlibUpdate *__imlib_AddUpdate(ImlibUpdate * u, int x, int y, int w, int h); diff --git a/src/lib/x11_color.h b/src/lib/x11_color.h index 8368918..117108d 100644 --- a/src/lib/x11_color.h +++ b/src/lib/x11_color.h @@ -1,7 +1,8 @@ #ifndef X11_COLOR_H #define X11_COLOR_H 1 -#include "common.h" +#include +#include "types.h" typedef enum { PAL_TYPE_332, /* 0 */ diff --git a/src/lib/x11_context.c b/src/lib/x11_context.c index 248bfe2..da5df67 100644 --- a/src/lib/x11_context.c +++ b/src/lib/x11_context.c @@ -3,7 +3,6 @@ #include #include -#include "image.h" #include "x11_color.h" #include "x11_context.h" #include "x11_rgba.h" diff --git a/src/lib/x11_context.h b/src/lib/x11_context.h index 65613de..981ec65 100644 --- a/src/lib/x11_context.h +++ b/src/lib/x11_context.h @@ -1,7 +1,8 @@ #ifndef X11_CONTEXT_H #define X11_CONTEXT_H 1 -#include "common.h" +#include +#include "types.h" typedef struct _Context { int last_use; diff --git a/src/lib/x11_grab.h b/src/lib/x11_grab.h index 1e3e3dd..4af7994 100644 --- a/src/lib/x11_grab.h +++ b/src/lib/x11_grab.h @@ -1,7 +1,8 @@ #ifndef X11_GRAB_H #define X11_GRAB_H 1 -#include "common.h" +#include +#include "types.h" int __imlib_GrabDrawableToRGBA(DATA32 * data, int x_dst, int y_dst, int w_dst, int h_dst, diff --git a/src/lib/x11_pixmap.c b/src/lib/x11_pixmap.c index 566c8e1..9badd1a 100644 --- a/src/lib/x11_pixmap.c +++ b/src/lib/x11_pixmap.c @@ -4,6 +4,9 @@ #include #include +#include "blend.h" +#include "colormod.h" +#include "image.h" #include "x11_pixmap.h" #include "x11_rend.h" diff --git a/src/lib/x11_pixmap.h b/src/lib/x11_pixmap.h index 7d83a1d..958bc3c 100644 --- a/src/lib/x11_pixmap.h +++ b/src/lib/x11_pixmap.h @@ -3,7 +3,7 @@ #include -#include "image.h" +#include "types.h" void __imlib_CleanupImagePixmapCache(void); int __imlib_PixmapCacheSize(void); @@ -12,8 +12,6 @@ void __imlib_FreePixmap(Display * d, Pixmap p); void __imlib_DirtyPixmapsForImage(const ImlibImage * im); void __imlib_PixmapUnrefImage(const ImlibImage * im); -#include "colormod.h" - char __imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth, Colormap cm, ImlibImage * im, diff --git a/src/lib/x11_rend.h b/src/lib/x11_rend.h index d3e87b3..72f7c8c 100644 --- a/src/lib/x11_rend.h +++ b/src/lib/x11_rend.h @@ -1,8 +1,7 @@ #ifndef X11_REND_H #define X11_REND_H 1 -#include "common.h" -#include "blend.h" +#include "types.h" DATA32 __imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm, int depth, DATA8 r, diff --git a/src/lib/x11_rgba.h b/src/lib/x11_rgba.h index b749809..4b72da5 100644 --- a/src/lib/x11_rgba.h +++ b/src/lib/x11_rgba.h @@ -1,7 +1,7 @@ #ifndef X11_RGBA_H #define X11_RGBA_H 1 -#include "common.h" +#include "types.h" #define DM_BS1 (8 + 3) #define DM_BS2 (8) diff --git a/src/modules/filters/filter_bumpmap.c b/src/modules/filters/filter_bumpmap.c index 10118ab..b9c1b9f 100644 --- a/src/modules/filters/filter_bumpmap.c +++ b/src/modules/filters/filter_bumpmap.c @@ -6,7 +6,6 @@ #include #include "filter_common.h" -#include "colormod.h" #include "blend.h" #define PI (4 * atan(1))