From: <enl...@li...> - 2003-07-13 01:09:49
|
Enlightenment CVS committal Author : mej Project : e17 Module : libs/imlib2 Dir : e17/libs/imlib2/src Modified Files: Makefile.am api.c blend.c color.c color_helpers.c colormod.c context.c draw.c dynamic_filters.c file.c filter.c font.h grab.c grad.c image.c rend.c rgba.c rgbadraw.c rotate.c scale.c script.c updates.c ximage.c Log Message: Sat Jul 12 21:06:14 EDT 2003 (KainX) Patch from Yuri Hudobin <gla...@us...> for Freetype2 support. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/imlib2/src/Makefile.am,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- Makefile.am 3 Apr 2003 19:08:17 -0000 1.22 +++ Makefile.am 13 Jul 2003 01:09:16 -0000 1.23 @@ -9,7 +9,8 @@ INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/src \ -I$(top_srcdir)/loaders -I$(top_srcdir)/libltdl \ -I/usr/X11R6/include $(X_CFLAGS) \ - -I$(prefix)/include -I$(includedir) + -I$(prefix)/include -I$(includedir) \ + $(freetype_cflags) MMX_SRCS = asm_blend.S asm_rgba.S asm_scale.S asm_rotate.S \ asm_blend_cmod.S MMX_OBJS = $(MMX_SRCS:.S=.lo) @@ -17,12 +18,13 @@ lib_LTLIBRARIES = libImlib2.la include_HEADERS = Imlib2.h libImlib2_la_SOURCES = scale.c image.c blend.c file.c rgbadraw.c api.c \ - updates.c colormod.c font.c format.c grad.c rotate.c \ + updates.c colormod.c format.c grad.c rotate.c \ filter.c script.c dynamic_filters.c color_helpers.c \ + font_main.c font_load.c font_query.c font_draw.c \ Imlib2.h image.h scale.h blend.h updates.h colormod.h \ file.h common.h rgbadraw.h font.h format.h \ rotate.h grad.h filter.h script.h dynamic_filters.h \ - color_helpers.h + color_helpers.h EXTRA_libImlib2_la_SOURCES = rend.c ximage.c rgba.c color.c grab.c draw.c \ context.c color.h context.h draw.h grab.h rend.h \ @@ -32,12 +34,12 @@ if HAVE_MMX libImlib2_la_LIBADD = $(X_OBJS) @DLLDFLAGS@ $(MMX_OBJS) \ $(top_builddir)/libltdl/libltdlc.la \ - $(x_libs) -lttf $(LDFLAGS) + $(x_libs) $(freetype_libs) $(LDFLAGS) libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h $(X_OBJS) $(MMX_OBJS) else libImlib2_la_LIBADD = $(X_OBJS) @DLLDFLAGS@ \ $(top_builddir)/libltdl/libltdlc.la \ - $(x_libs) -lttf $(LDFLAGS) + $(x_libs) $(freetype_libs) $(LDFLAGS) libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h $(X_OBJS) endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/imlib2/src/api.c,v retrieving revision 1.90 retrieving revision 1.91 diff -u -3 -r1.90 -r1.91 --- api.c 5 Jun 2002 03:01:14 -0000 1.90 +++ api.c 13 Jul 2003 01:09:17 -0000 1.91 @@ -24,13 +24,16 @@ #include "updates.h" #include "rgbadraw.h" #include "Imlib2.h" -#ifdef HAVE_FREETYPE1_FREETYPE_FREETYPE_H +#include <ft2build.h> +#include FT_FREETYPE_H +/*#ifdef HAVE_FREETYPE1_FREETYPE_FREETYPE_H #include <freetype1/freetype/freetype.h> #elif defined(HAVE_FREETYPE_FREETYPE_H) #include <freetype/freetype.h> #else #include <freetype.h> #endif +*/ #include "font.h" #include "grad.h" #include "rotate.h" @@ -70,129 +73,136 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /* internal typedefs for function pointers */ -typedef void (*Imlib_Internal_Progress_Function) (void *, char, int, int, int, - - int); -typedef void (*Imlib_Internal_Data_Destructor_Function) (void *, void *); +typedef void (*Imlib_Internal_Progress_Function) (void *, char, int, int, + int, int); +typedef void (*Imlib_Internal_Data_Destructor_Function) (void *, void *); struct _imlibcontext; typedef struct _imlibcontext ImlibContext; -struct _imlibcontext -{ +struct _imlibcontext { #ifndef X_DISPLAY_MISSING - Display *display; - Visual *visual; - Colormap colormap; - int depth; - Drawable drawable; - Pixmap mask; + Display *display; + Visual *visual; + Colormap colormap; + int depth; + Drawable drawable; + Pixmap mask; #endif - char anti_alias; - char dither; - char blend; - Imlib_Color_Modifier color_modifier; - Imlib_Operation operation; - Imlib_Font font; - Imlib_Text_Direction direction; - double angle; - Imlib_Color color; - Imlib_Color_Range color_range; - Imlib_Image image; - Imlib_Progress_Function progress_func; - char progress_granularity; - char dither_mask; - Imlib_Filter filter; - Imlib_Rectangle cliprect; - Imlib_TTF_Encoding encoding; + char anti_alias; + char dither; + char blend; + Imlib_Color_Modifier color_modifier; + Imlib_Operation operation; + Imlib_Font font; + Imlib_Text_Direction direction; + double angle; + Imlib_Color color; + Imlib_Color_Range color_range; + Imlib_Image image; + Imlib_Progress_Function progress_func; + char progress_granularity; + char dither_mask; + Imlib_Filter filter; + Imlib_Rectangle cliprect; + Imlib_TTF_Encoding encoding; - int references; - char dirty; + int references; + char dirty; }; struct _imlibcontextitem; typedef struct _imlibcontextitem ImlibContextItem; -struct _imlibcontextitem -{ - ImlibContext *context; - ImlibContextItem *below; +struct _imlibcontextitem { + ImlibContext *context; + ImlibContextItem *below; }; /* a stack of contexts -- only used by context-handling functions. */ -static ImlibContextItem *contexts = NULL;/* (ImlibContext*) imlib_context_new(); */ +static ImlibContextItem *contexts = NULL; /* (ImlibContext*) imlib_context_new(); */ + /* this is the context all functions use rely on */ -static ImlibContext *ctx = NULL; /* contexts->context; */ +static ImlibContext *ctx = NULL; /* contexts->context; */ /* frees the given context including all its members */ -void -__imlib_free_context(ImlibContext *context) +void +__imlib_free_context(ImlibContext * context) { - ImlibContextItem *next = contexts; + ImlibContextItem *next = contexts; + + if (ctx == context) + { + next = contexts->below; + free(contexts); + contexts = next; + } + + ctx = context; - if ( ctx == context ) { - next = contexts->below; - free(contexts); - contexts = next; - } - - ctx = context; - - if (ctx->image) { - imlib_free_image(); - ctx->image = NULL; - } - if (ctx->font) { - imlib_free_font(); - ctx->font = NULL; - } - if (ctx->color_modifier) { - imlib_free_color_modifier(); - ctx->color_modifier = NULL; - } - if (ctx->filter) { - imlib_free_filter(); - ctx->filter = NULL; - } + if (ctx->image) + { + imlib_free_image(); + ctx->image = NULL; + } + if (ctx->font) + { + imlib_free_font(); + ctx->font = NULL; + } + if (ctx->color_modifier) + { + imlib_free_color_modifier(); + ctx->color_modifier = NULL; + } + if (ctx->filter) + { + imlib_free_filter(); + ctx->filter = NULL; + } - free (ctx); - ctx = next->context; + free(ctx); + ctx = next->context; } Imlib_Context imlib_context_new(void) { - ImlibContext *context = malloc(sizeof(ImlibContext)); + ImlibContext *context = malloc(sizeof(ImlibContext)); #ifndef X_DISPLAY_MISSING - context->display = NULL; - context->visual = NULL; - context->colormap = 0; - context->depth = 0; - context->drawable = 0; - context->mask = 0; + context->display = NULL; + context->visual = NULL; + context->colormap = 0; + context->depth = 0; + context->drawable = 0; + context->mask = 0; #endif - context->anti_alias = 1; - context->dither = 0; - context->blend = 1; - context->color_modifier = NULL; - context->operation = IMLIB_OP_COPY; - context->font = NULL; - context->direction = IMLIB_TEXT_TO_RIGHT; - context->angle = 0.0; - context->color = (Imlib_Color) { 255, 255, 255, 255 }; - context->color_range = NULL; - context->image = NULL; - context->progress_func = NULL; - context->progress_granularity = 0; - context->dither_mask = 0; - context->filter = NULL; - context->cliprect = (Imlib_Rectangle) { 0, 0, 0, 0 }; - context->encoding = IMLIB_TTF_ENCODING_ISO_8859_1; - - context->references = 0; - context->dirty = 0; - - return (Imlib_Context) context; + context->anti_alias = 1; + context->dither = 0; + context->blend = 1; + context->color_modifier = NULL; + context->operation = IMLIB_OP_COPY; + context->font = NULL; + context->direction = IMLIB_TEXT_TO_RIGHT; + context->angle = 0.0; + context->color = (Imlib_Color) + { + 255, 255, 255, 255}; + context->color_range = NULL; + context->image = NULL; + context->progress_func = NULL; + context->progress_granularity = 0; + context->dither_mask = 0; + context->filter = NULL; + context->cliprect = (Imlib_Rectangle) + { + 0, 0, 0, 0}; + context->encoding = IMLIB_TTF_ENCODING_ISO_8859_1; + + context->references = 0; + context->dirty = 0; + + return (Imlib_Context) context; } /* frees the given context if it doesn't have any reference anymore. The @@ -200,57 +210,59 @@ If context is the current context, the context below will be made the current context. */ -void +void imlib_context_free(Imlib_Context context) { - ImlibContext *c = (ImlibContext*) context; - CHECK_PARAM_POINTER("imlib_context_free", "context", context); - if (c == ctx && !contexts->below) - return; - - if (c->references == 0) - __imlib_free_context(c); - else - c->dirty = 1; + ImlibContext *c = (ImlibContext *) context; + + CHECK_PARAM_POINTER("imlib_context_free", "context", context); + if (c == ctx && !contexts->below) + return; + + if (c->references == 0) + __imlib_free_context(c); + else + c->dirty = 1; } - -void + +void imlib_context_push(Imlib_Context context) { - ImlibContextItem *item; - CHECK_PARAM_POINTER("imlib_context_push", "context", context); - ctx = (ImlibContext*) context; - - item = malloc(sizeof(ImlibContextItem)); - item->context = ctx; - item->below = contexts; - contexts = item; - - ctx->references++; + ImlibContextItem *item; + + CHECK_PARAM_POINTER("imlib_context_push", "context", context); + ctx = (ImlibContext *) context; + + item = malloc(sizeof(ImlibContextItem)); + item->context = ctx; + item->below = contexts; + contexts = item; + + ctx->references++; } -void +void imlib_context_pop(void) { - ImlibContextItem *item = contexts; - ImlibContext *current_ctx = item->context; + ImlibContextItem *item = contexts; + ImlibContext *current_ctx = item->context; - if (!item->below) - return; + if (!item->below) + return; - contexts = item->below; - ctx = contexts->context; - current_ctx->references--; - if (current_ctx->dirty && current_ctx->references <= 0) - __imlib_free_context(current_ctx); + contexts = item->below; + ctx = contexts->context; + current_ctx->references--; + if (current_ctx->dirty && current_ctx->references <= 0) + __imlib_free_context(current_ctx); - free(item); + free(item); } Imlib_Context imlib_context_get(void) { - return (Imlib_Context) ctx; + return (Imlib_Context) ctx; } /* context setting/getting functions */ @@ -258,7 +270,8 @@ void imlib_context_set_cliprect(int x, int y, int w, int h) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->cliprect.x = x; ctx->cliprect.y = y; ctx->cliprect.w = w; @@ -268,7 +281,8 @@ void imlib_context_get_cliprect(int *x, int *y, int *w, int *h) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); *x = ctx->cliprect.x; *y = ctx->cliprect.y; *w = ctx->cliprect.w; @@ -279,71 +293,81 @@ void imlib_context_set_display(Display * display) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->display = display; } -Display * +Display * imlib_context_get_display(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->display; } void imlib_context_set_visual(Visual * visual) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->visual = visual; ctx->depth = imlib_get_visual_depth(ctx->display, ctx->visual); } -Visual * +Visual * imlib_context_get_visual(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->visual; } void imlib_context_set_colormap(Colormap colormap) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->colormap = colormap; } Colormap imlib_context_get_colormap(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->colormap; } void imlib_context_set_drawable(Drawable drawable) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->drawable = drawable; } Drawable imlib_context_get_drawable(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->drawable; } void imlib_context_set_mask(Pixmap mask) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->mask = mask; } Pixmap imlib_context_get_mask(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->mask; } #endif @@ -351,133 +375,152 @@ void imlib_context_set_dither_mask(char dither_mask) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->dither_mask = dither_mask; } char imlib_context_get_dither_mask(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->dither_mask; } void imlib_context_set_anti_alias(char anti_alias) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->anti_alias = anti_alias; } char imlib_context_get_anti_alias(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->anti_alias; } void imlib_context_set_dither(char dither) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->dither = dither; } char imlib_context_get_dither(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->dither; } void imlib_context_set_blend(char blend) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->blend = blend; } char imlib_context_get_blend(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->blend; } void imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->color_modifier = color_modifier; } Imlib_Color_Modifier imlib_context_get_color_modifier(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->color_modifier; } void imlib_context_set_operation(Imlib_Operation operation) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->operation = operation; } Imlib_Operation imlib_context_get_operation(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->operation; } void imlib_context_set_font(Imlib_Font font) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->font = font; } Imlib_Font imlib_context_get_font(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->font; } void imlib_context_set_direction(Imlib_Text_Direction direction) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->direction = direction; } void imlib_context_set_angle(double angle) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->angle = angle; } double imlib_context_get_angle(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->angle; } Imlib_Text_Direction imlib_context_get_direction(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->direction; } void imlib_context_set_color(int red, int green, int blue, int alpha) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->color.red = red; ctx->color.green = green; ctx->color.blue = blue; @@ -487,52 +530,58 @@ void imlib_context_get_color(int *red, int *green, int *blue, int *alpha) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); *red = ctx->color.red; *green = ctx->color.green; *blue = ctx->color.blue; *alpha = ctx->color.alpha; } -Imlib_Color * +Imlib_Color * imlib_context_get_imlib_color(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return &ctx->color; } void -imlib_context_set_color_hsva(float hue, float saturation, float value, int alpha) +imlib_context_set_color_hsva(float hue, float saturation, float value, + int alpha) { - int r,g,b; + int r, g, b; - __imlib_hsv_to_rgb(hue, saturation, value, &r, &g, &b); - imlib_context_set_color(r, g, b, alpha); + __imlib_hsv_to_rgb(hue, saturation, value, &r, &g, &b); + imlib_context_set_color(r, g, b, alpha); } void -imlib_context_get_color_hsva(float *hue, float *saturation, float *value, int *alpha) +imlib_context_get_color_hsva(float *hue, float *saturation, float *value, + int *alpha) { - int r,g,b,f; - float i,j,k,max,min,d; + int r, g, b, f; + float i, j, k, max, min, d; imlib_context_get_color(&r, &g, &b, alpha); - __imlib_rgb_to_hsv(r, g, b, hue, saturation, value); + __imlib_rgb_to_hsv(r, g, b, hue, saturation, value); } void -imlib_context_set_color_hlsa(float hue, float lightness, float saturation, int alpha) +imlib_context_set_color_hlsa(float hue, float lightness, float saturation, + int alpha) { - int r,g,b; + int r, g, b; __imlib_hls_to_rgb(hue, lightness, saturation, &r, &g, &b); imlib_context_set_color(r, g, b, alpha); } void -imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation, int *alpha) +imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation, + int *alpha) { - int r,g,b; + int r, g, b; imlib_context_get_color(&r, &g, &b, alpha); __imlib_rgb_to_hls(r, g, b, hue, lightness, saturation); @@ -541,7 +590,8 @@ void imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->color.red = 255 - cyan; ctx->color.green = 255 - magenta; ctx->color.blue = 255 - yellow; @@ -551,7 +601,8 @@ void imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); *cyan = 255 - ctx->color.red; *magenta = 255 - ctx->color.green; *yellow = 255 - ctx->color.blue; @@ -561,95 +612,107 @@ void imlib_context_set_color_range(Imlib_Color_Range color_range) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->color_range = color_range; } Imlib_Color_Range imlib_context_get_color_range(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->color_range; } void imlib_context_set_progress_function(Imlib_Progress_Function progress_function) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->progress_func = progress_function; } Imlib_Progress_Function imlib_context_get_progress_function(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->progress_func; } void imlib_context_set_progress_granularity(char progress_granularity) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->progress_granularity = progress_granularity; } char imlib_context_get_progress_granularity(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->progress_granularity; } void imlib_context_set_image(Imlib_Image image) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->image = image; } Imlib_Image imlib_context_get_image(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return ctx->image; } -void -imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding) +void +imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ctx->encoding = encoding; - __imlib_set_TTF_encoding(encoding); } -Imlib_TTF_Encoding -imlib_context_get_TTF_encoding(void) +Imlib_TTF_Encoding +imlib_context_get_TTF_encoding(void) { - if (!ctx) ctx = imlib_context_new(); - return ctx->encoding; + if (!ctx) + ctx = imlib_context_new(); + return ctx->encoding; } /* imlib api */ int imlib_get_cache_size(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); return __imlib_GetCacheSize(); } void imlib_set_cache_size(int bytes) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); __imlib_SetCacheSize(bytes); } int imlib_get_color_usage(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); #ifndef X_DISPLAY_MISSING - return (int) _max_colors; + return (int)_max_colors; #else return 256; #endif @@ -658,7 +721,8 @@ void imlib_set_color_usage(int max) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); #ifndef X_DISPLAY_MISSING if (max < 2) max = 2; @@ -671,7 +735,8 @@ void imlib_flush_loaders(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); __imlib_RemoveAllLoaders(); LTDL_Exit(); } @@ -680,17 +745,18 @@ int imlib_get_visual_depth(Display * display, Visual * visual) { - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "display", display, - 0); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "display", display, 0); CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "visual", visual, 0); return __imlib_XActualDepth(display, visual); } -Visual * +Visual * imlib_get_best_visual(Display * display, int screen, int *depth_return) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "display", display, NULL); CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "depth_return", @@ -702,15 +768,15 @@ Imlib_Image imlib_load_image(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_load_image", "file", file, NULL); prev_ctxt_image = ctx->image; - im = - __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, - ctx->progress_granularity, 0, 0, NULL); + im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, + ctx->progress_granularity, 0, 0, NULL); ctx->image = prev_ctxt_image; return (Imlib_Image) im; } @@ -718,16 +784,16 @@ Imlib_Image imlib_load_image_immediately(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately", "file", file, NULL); prev_ctxt_image = ctx->image; - im = - __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, - ctx->progress_granularity, 1, 0, NULL); + im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, + ctx->progress_granularity, 1, 0, NULL); ctx->image = prev_ctxt_image; return (Imlib_Image) im; } @@ -735,16 +801,16 @@ Imlib_Image imlib_load_image_without_cache(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file", - file, NULL); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file", + file, NULL); prev_ctxt_image = ctx->image; - im = - __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, - ctx->progress_granularity, 0, 1, NULL); + im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, + ctx->progress_granularity, 0, 1, NULL); ctx->image = prev_ctxt_image; return (Imlib_Image) im; } @@ -752,16 +818,16 @@ Imlib_Image imlib_load_image_immediately_without_cache(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately_without_cache", "file", file, NULL); prev_ctxt_image = ctx->image; - im = - __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, - ctx->progress_granularity, 1, 1, NULL); + im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func, + ctx->progress_granularity, 1, 1, NULL); ctx->image = prev_ctxt_image; return (Imlib_Image) im; } @@ -770,51 +836,52 @@ imlib_load_image_with_error_return(const char *file, Imlib_Load_Error * error_return) { - Imlib_Image im = NULL; - ImlibLoadError er; - Imlib_Image prev_ctxt_image; + Imlib_Image im = NULL; + ImlibLoadError er; + Imlib_Image prev_ctxt_image; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_load_image_with_error_return", "file", file, NULL); if (!__imlib_FileExists(file)) - { - *error_return = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; - return NULL; - } + { + *error_return = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; + return NULL; + } if (__imlib_FileIsDir(file)) - { - *error_return = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY; - return NULL; - } + { + *error_return = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY; + return NULL; + } if (!__imlib_FileCanRead(file)) - { - *error_return = IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ; - return NULL; - } + { + *error_return = IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ; + return NULL; + } prev_ctxt_image = ctx->image; - im = - (Imlib_Image) __imlib_LoadImage(file, - (ImlibProgressFunction) - ctx->progress_func, - ctx->progress_granularity, 1, 0, &er); + im = (Imlib_Image) __imlib_LoadImage(file, + (ImlibProgressFunction) + ctx->progress_func, + ctx->progress_granularity, 1, 0, &er); ctx->image = prev_ctxt_image; if (im) *error_return = IMLIB_LOAD_ERROR_NONE; else - { - if (er == IMLIB_LOAD_ERROR_NONE) - *error_return = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT; - else - *error_return = (Imlib_Load_Error) er; - } + { + if (er == IMLIB_LOAD_ERROR_NONE) + *error_return = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT; + else + *error_return = (Imlib_Load_Error) er; + } return im; } void imlib_free_image(void) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_free_image", "image", ctx->image); __imlib_FreeImage(ctx->image); ctx->image = NULL; @@ -823,9 +890,10 @@ void imlib_free_image_and_decache(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_free_image_and_decache", "image", ctx->image); CAST_IMAGE(im, ctx->image); SET_FLAG(im->flags, F_INVALID); @@ -836,11 +904,11 @@ int imlib_image_get_width(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER_RETURN("imlib_image_get_width", "image", ctx->image, - 0); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER_RETURN("imlib_image_get_width", "image", ctx->image, 0); CAST_IMAGE(im, ctx->image); return im->w; } @@ -848,34 +916,36 @@ int imlib_image_get_height(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER_RETURN("imlib_image_get_height", "image", ctx->image, - 0); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER_RETURN("imlib_image_get_height", "image", ctx->image, 0); CAST_IMAGE(im, ctx->image); return im->h; } -const char * +const char * imlib_image_get_filename(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_image_get_filename", "image", ctx->image, 0); CAST_IMAGE(im, ctx->image); /* strdup() the returned value if you want to alter it! */ - return (const char *) (im->file); + return (const char *)(im->file); } -DATA32 * +DATA32 * imlib_image_get_data(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_image_get_data", "image", ctx->image, NULL); CAST_IMAGE(im, ctx->image); @@ -888,12 +958,13 @@ return im->data; } -DATA32 * +DATA32 * imlib_image_get_data_for_reading_only(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_image_get_data_for_reading_only", "image", ctx->image, NULL); CAST_IMAGE(im, ctx->image); @@ -907,9 +978,10 @@ void imlib_image_put_back_data(DATA32 * data) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_put_back_data", "image", ctx->image); CHECK_PARAM_POINTER("imlib_image_put_back_data", "data", data); CAST_IMAGE(im, ctx->image); @@ -921,11 +993,11 @@ char imlib_image_has_alpha(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER_RETURN("imlib_image_has_alpha", "image", ctx->image, - 0); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER_RETURN("imlib_image_has_alpha", "image", ctx->image, 0); CAST_IMAGE(im, ctx->image); if (IMAGE_HAS_ALPHA(im)) return 1; @@ -935,9 +1007,10 @@ void imlib_image_set_changes_on_disk(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_set_never_changes_on_disk", "image", ctx->image); CAST_IMAGE(im, ctx->image); @@ -947,9 +1020,10 @@ void imlib_image_get_border(Imlib_Border * border) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_get_border", "image", ctx->image); CHECK_PARAM_POINTER("imlib_image_get_border", "border", border); CAST_IMAGE(im, ctx->image); @@ -962,9 +1036,10 @@ void imlib_image_set_border(Imlib_Border * border) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_set_border", "image", ctx->image); CHECK_PARAM_POINTER("imlib_image_set_border", "border", border); CAST_IMAGE(im, ctx->image); @@ -983,9 +1058,10 @@ void imlib_image_set_format(const char *format) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_set_format", "image", ctx->image); CHECK_PARAM_POINTER("imlib_image_set_format", "format", format); CAST_IMAGE(im, ctx->image); @@ -993,80 +1069,82 @@ free(im->format); if (format) im->format = strdup(format); - else + else im->format = NULL; if (!(im->flags & F_FORMAT_IRRELEVANT)) - { - __imlib_DirtyImage(im); - __imlib_DirtyPixmapsForImage(im); - } + { + __imlib_DirtyImage(im); + __imlib_DirtyPixmapsForImage(im); + } } void imlib_image_set_irrelevant_format(char irrelevant) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_set_irrelevant_format", "image", ctx->image); CAST_IMAGE(im, ctx->image); if (irrelevant) - { - SET_FLAG(im->flags, F_FORMAT_IRRELEVANT); - } + { + SET_FLAG(im->flags, F_FORMAT_IRRELEVANT); + } else - { - UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT); - } + { + UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT); + } } void imlib_image_set_irrelevant_border(char irrelevant) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_set_irrelevant_border", "image", ctx->image); CAST_IMAGE(im, ctx->image); if (irrelevant) - { - SET_FLAG(im->flags, F_BORDER_IRRELEVANT); - } + { + SET_FLAG(im->flags, F_BORDER_IRRELEVANT); + } else - { - UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT); - } + { + UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT); + } } void imlib_image_set_irrelevant_alpha(char irrelevant) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER("imlib_image_set_irrelevant_alpha", "image", - ctx->image); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER("imlib_image_set_irrelevant_alpha", "image", ctx->image); CAST_IMAGE(im, ctx->image); if (irrelevant) - { - SET_FLAG(im->flags, F_ALPHA_IRRELEVANT); - } + { + SET_FLAG(im->flags, F_ALPHA_IRRELEVANT); + } else - { - UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT); - } + { + UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT); + } } -char * +char * imlib_image_format(void) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); - CHECK_PARAM_POINTER_RETURN("imlib_image_format", "image", ctx->image, - NULL); + if (!ctx) + ctx = imlib_context_new(); + CHECK_PARAM_POINTER_RETURN("imlib_image_format", "image", ctx->image, NULL); CAST_IMAGE(im, ctx->image); return im->format; } @@ -1074,9 +1152,10 @@ void imlib_image_set_has_alpha(char has_alpha) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_image_set_has_alpha", "image", ctx->image); CAST_IMAGE(im, ctx->image); if (has_alpha) @@ -1090,9 +1169,10 @@ imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return, Pixmap * mask_return) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "image", ctx->image); CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", @@ -1116,9 +1196,10 @@ Pixmap * mask_return, int width, int height) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", "image", ctx->image); CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", @@ -1141,16 +1222,18 @@ void imlib_free_pixmap_and_mask(Pixmap pixmap) { - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); __imlib_FreePixmap(ctx->display, pixmap); } void imlib_render_image_on_drawable(int x, int y) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_render_image_on_drawable", "image", ctx->image); CAST_IMAGE(im, ctx->image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -1166,9 +1249,10 @@ void imlib_render_image_on_drawable_at_size(int x, int y, int width, int height) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_size", "image", ctx->image); CAST_IMAGE(im, ctx->image); @@ -1189,9 +1273,10 @@ int source_height, int x, int y, int width, int height) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_render_image_part_on_drawable_at_size", "image", ctx->image); CAST_IMAGE(im, ctx->image); @@ -1209,11 +1294,13 @@ DATA32 imlib_render_get_pixel_color(void) { - if (!ctx) ctx = imlib_context_new(); - return __imlib_RenderGetPixel(ctx->display, ctx->drawable, ctx->visual, ctx->colormap, ctx->depth, - (DATA8)ctx->color.red, - (DATA8)ctx->color.green, - (DATA8)ctx->color.blue); + if (!ctx) + ctx = imlib_context_new(); + return __imlib_RenderGetPixel(ctx->display, ctx->drawable, ctx->visual, + ctx->colormap, ctx->depth, + (DATA8) ctx->color.red, + (DATA8) ctx->color.green, + (DATA8) ctx->color.blue); } #endif @@ -1225,10 +1312,11 @@ int destination_y, int destination_width, int destination_height) { - ImlibImage *im_src, *im_dst; - int aa; - - if (!ctx) ctx = imlib_context_new(); + ImlibImage *im_src, *im_dst; + int aa; + + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "source_image", source_image); CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "image", ctx->image); @@ -1247,22 +1335,24 @@ /* FIXME: hack to get around infinite loops for scaling down too far */ aa = ctx->anti_alias; if ((abs(destination_width) < (source_width >> 7)) - || (abs(destination_height) < (source_height >> 7))) aa = 0; + || (abs(destination_height) < (source_height >> 7))) + aa = 0; __imlib_BlendImageToImage(im_src, im_dst, aa, ctx->blend, - merge_alpha, source_x, source_y, source_width, - source_height, destination_x, destination_y, - destination_width, destination_height, - ctx->color_modifier, ctx->operation, - ctx->cliprect.x, ctx->cliprect.y, - ctx->cliprect.w, ctx->cliprect.h); + merge_alpha, source_x, source_y, source_width, + source_height, destination_x, destination_y, + destination_width, destination_height, + ctx->color_modifier, ctx->operation, + ctx->cliprect.x, ctx->cliprect.y, + ctx->cliprect.w, ctx->cliprect.h); } Imlib_Image imlib_create_image(int width, int height) { - DATA32 *data; + DATA32 *data; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); if ((width <= 0) || (height <= 0)) return NULL; data = malloc(width * height * sizeof(DATA32)); @@ -1274,9 +1364,10 @@ Imlib_Image imlib_create_image_using_data(int width, int height, DATA32 * data) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_data", "data", data, NULL); if ((width <= 0) || (height <= 0)) @@ -1290,9 +1381,10 @@ Imlib_Image imlib_create_image_using_copied_data(int width, int height, DATA32 * data) { - ImlibImage *im; + ImlibImage *im; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_copied_data", "data", data, NULL); if ((width <= 0) || (height <= 0)) @@ -1302,10 +1394,10 @@ return NULL; im->data = malloc(width * height * sizeof(DATA32)); if (data) - { - memcpy(im->data, data, width * height * sizeof(DATA32)); - return (Imlib_Image) im; - } + { + memcpy(im->data, data, width * height * sizeof(DATA32)); + return (Imlib_Image) im; + } else __imlib_FreeImage(im); return NULL; @@ -1316,10 +1408,11 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width, int height, char need_to_grab_x) { - ImlibImage *im; - char domask = 0; + ImlibImage *im; + char domask = 0; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); if (mask) domask = 1; im = __imlib_CreateImage(width, height, NULL); @@ -1332,21 +1425,21 @@ } Imlib_Image -imlib_create_image_from_ximage(XImage *image, XImage *mask, int x, int y, int width, - int height, char need_to_grab_x) +imlib_create_image_from_ximage(XImage * image, XImage * mask, int x, int y, + int width, int height, char need_to_grab_x) { - ImlibImage *im; - char domask = 0; + ImlibImage *im; + char domask = 0; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); if (mask) domask = 1; im = __imlib_CreateImage(width, height, NULL); im->data = malloc(width * height * sizeof(DATA32)); __imlib_GrabXImageToRGBA(im->data, 0, 0, width, height, - ctx->display, image, mask, ctx->visual, - ctx->depth, x, y, - width, height, need_to_grab_x); + ctx->display, image, mask, ctx->visual, + ctx->depth, x, y, width, height, need_to_grab_x); return (Imlib_Image) im; } @@ -1359,73 +1452,72 @@ char need_to_grab_x, char get_mask_from_shape) { - ImlibImage *im; - char domask = 0, tmpmask = 0; - int x, xx; - XGCValues gcv; - GC gc = 0, mgc = 0; - Pixmap p, m; + ImlibImage *im; + char domask = 0, tmpmask = 0; + int x, xx; + XGCValues gcv; + GC gc = 0, mgc = 0; + Pixmap p, m; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); if ((mask) || (get_mask_from_shape)) domask = 1; - p = - XCreatePixmap(ctx->display, ctx->drawable, destination_width, - source_height, ctx->depth); + p = XCreatePixmap(ctx->display, ctx->drawable, destination_width, + source_height, ctx->depth); gcv.foreground = 0; gcv.subwindow_mode = IncludeInferiors; if (domask) - { - m = - XCreatePixmap(ctx->display, ctx->drawable, destination_width, - source_height, 1); - mgc = XCreateGC(ctx->display, m, GCForeground, &gcv); - } + { + m = XCreatePixmap(ctx->display, ctx->drawable, destination_width, + source_height, 1); + mgc = XCreateGC(ctx->display, m, GCForeground, &gcv); + } else m = None; gc = XCreateGC(ctx->display, ctx->drawable, GCSubwindowMode, &gcv); if ((domask) && (!mask)) - { - XRectangle *rect; - int rect_num, rect_ord; + { + XRectangle *rect; + int rect_num, rect_ord; - tmpmask = 1; - mask = - XCreatePixmap(ctx->display, ctx->drawable, source_width, - source_height, 1); - rect = - XShapeGetRectangles(ctx->display, ctx->drawable, ShapeBounding, - &rect_num, &rect_ord); - XFillRectangle(ctx->display, mask, mgc, 0, 0, source_width, - source_height); - if (rect) - { - XSetForeground(ctx->display, mgc, 1); - for (x = 0; x < rect_num; x++) - XFillRectangle(ctx->display, mask, mgc, rect[x].x, rect[x].y, - rect[x].width, rect[x].height); - XFree(rect); - } - /* build mask from window shape rects */ - } + tmpmask = 1; + mask = + XCreatePixmap(ctx->display, ctx->drawable, source_width, + source_height, 1); + rect = + XShapeGetRectangles(ctx->display, ctx->drawable, ShapeBounding, + &rect_num, &rect_ord); + XFillRectangle(ctx->display, mask, mgc, 0, 0, source_width, + source_height); + if (rect) + { + XSetForeground(ctx->display, mgc, 1); + for (x = 0; x < rect_num; x++) + XFillRectangle(ctx->display, mask, mgc, rect[x].x, rect[x].y, + rect[x].width, rect[x].height); + XFree(rect); + } + /* build mask from window shape rects */ + } for (x = 0; x < destination_width; x++) - { - xx = (source_width * x) / destination_width; - XCopyArea(ctx->display, ctx->drawable, p, gc, source_x + xx, 0, 1, - source_height, xx, 0); - if (m != None) - XCopyArea(ctx->display, mask, m, mgc, xx, 0, 1, source_height, xx, - 0); - } + { + xx = (source_width * x) / destination_width; + XCopyArea(ctx->display, ctx->drawable, p, gc, source_x + xx, 0, 1, + source_height, xx, 0); + if (m != None) + XCopyArea(ctx->display, mask, m, mgc, xx, 0, 1, source_height, xx, + 0); + } for (x = 0; x < destination_height; x++) - { - xx = (source_height * x) / destination_height; - XCopyArea(ctx->display, ctx->drawable, p, gc, 0, source_y + xx, - destination_width, 1, 0, xx); - if (m != None) - XCopyArea(ctx->display, mask, m, mgc, 0, source_y + xx, - destination_width, 1, 0, xx); - } + { + xx = (source_height * x) / destination_height; + XCopyArea(ctx->display, ctx->drawable, p, gc, 0, source_y + xx, + destination_width, 1, 0, xx); + if (m != None) + XCopyArea(ctx->display, mask, m, mgc, 0, source_y + xx, + destination_width, 1, 0, xx); + } im = __imlib_CreateImage(destination_width, destination_height, NULL); im->data = malloc(destination_width * destination_height * sizeof(DATA32)); __imlib_GrabDrawableToRGBA(im->data, 0, 0, destination_width, @@ -1435,12 +1527,12 @@ need_to_grab_x); XFreePixmap(ctx->display, p); if (m != None) - { - XFreeGC(ctx->display, mgc); - XFreePixmap(ctx->display, m); - if (tmpmask) - XFreePixmap(ctx->display, mask); - } + { + XFreeGC(ctx->display, mgc); + XFreePixmap(ctx->display, m); + if (tmpmask) + XFreePixmap(ctx->display, mask); + } XFreeGC(ctx->display, gc); return (Imlib_Image) im; } @@ -1450,11 +1542,12 @@ int destination_x, int destination_y, char need_to_grab_x) { - ImlibImage *im; - char domask = 0; - int pre_adj; + ImlibImage *im; + char domask = 0; + int pre_adj; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_copy_drawable_to_image", "image", ctx->image, 0); if (mask) @@ -1468,37 +1561,37 @@ pre_adj = 0; if (x < 0) - { - width += x; - pre_adj = x; - x = 0; - } + { + width += x; + pre_adj = x; + x = 0; + } if (width < 0) width = 0; if (destination_x < 0) - { - width += destination_x; - x -= destination_x - pre_adj; - destination_x = 0; - } + { + width += destination_x; + x -= destination_x - pre_adj; + destination_x = 0; + } if ((destination_x + width) >= im->w) width = im->w - destination_x; pre_adj = 0; if (y < 0) - { - height += y; - pre_adj = y; - y = 0; - } + { + height += y; + pre_adj = y; + y = 0; + } if (height < 0) height = 0; if (destination_y < 0) - { - height += destination_y; - y -= destination_y - pre_adj; - destination_y = 0; - } + { + height += destination_y; + y -= destination_y - pre_adj; + destination_y = 0; + } if ((destination_y + height) >= im->h) height = im->h - destination_y; @@ -1517,9 +1610,10 @@ Imlib_Image imlib_clone_image(void) { - ImlibImage *im, *im_old; + ImlibImage *im, *im_old; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_clone_image", "image", ctx->image, NULL); CAST_IMAGE(im_old, ctx->image); if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load)) @@ -1531,10 +1625,10 @@ return NULL; im->data = malloc(im->w * im->h * sizeof(DATA32)); if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } + { + __imlib_FreeImage(im); + return NULL; + } memcpy(im->data, im_old->data, im->w * im->h * sizeof(DATA32)); im->flags = im_old->flags; SET_FLAG(im->flags, F_UNCACHEABLE); @@ -1542,24 +1636,25 @@ im->border = im_old->border; im->loader = im_old->loader; if (im_old->format) - { - im->format = malloc(strlen(im_old->format) + 1); - strcpy(im->format, im_old->format); - } + { + im->format = malloc(strlen(im_old->format) + 1); + strcpy(im->format, im_old->format); + } if (im_old->file) - { - im->file = malloc(strlen(im_old->file) + 1); - strcpy(im->file, im_old->file); - } + { + im->file = malloc(strlen(im_old->file) + 1); + strcpy(im->file, im_old->file); + } return (Imlib_Image) im; } Imlib_Image imlib_create_cropped_image(int x, int y, int width, int height) { - ImlibImage *im, *im_old; + ImlibImage *im, *im_old; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_image", "image", ctx->image, NULL); CAST_IMAGE(im_old, ctx->image); @@ -1570,27 +1665,27 @@ im = __imlib_CreateImage(abs(width), abs(height), NULL); im->data = malloc(abs(width * height) * sizeof(DATA32)); if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } + { + __imlib_FreeImage(im); + return NULL; + } __imlib_BlendImageToImage(im_old, im, 0, 0, 0, x, y, abs(width), abs(height), 0, 0, width, height, NULL, IMLIB_OP_COPY, - ctx->cliprect.x, ctx->cliprect.y, - ctx->cliprect.w, ctx->cliprect.h); + ctx->cliprect.x, ctx->cliprect.y, + ctx->cliprect.w, ctx->cliprect.h); return (Imlib_Image) im; } Imlib_Image imlib_create_cropped_scaled_image(int source_x, int source_y, int source_width, int source_height, - int destination_width, - int destination_height) + int destination_width, int destination_height) { - ImlibImage *im, *im_old; + ImlibImage *im, *im_old; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_scaled_image", "image", ctx->image, NULL); CAST_IMAGE(im_old, ctx->image); @@ -1598,44 +1693,44 @@ im_old->loader->load(im_old, NULL, 0, 1); if (!(im_old->data)) return NULL; - im = - __imlib_CreateImage(abs(destination_width), abs(destination_height), - NULL); + im = __imlib_CreateImage(abs(destination_width), abs(destination_height), + NULL); im->data = - malloc(abs(destination_width * destination_height) * sizeof(DATA32)); + malloc(abs(destination_width * destination_height) * sizeof(DATA32)); if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } + { + __imlib_FreeImage(im); + return NULL; + } if (IMAGE_HAS_ALPHA(im_old)) - { - SET_FLAG(im->flags, F_HAS_ALPHA); - __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 1, source_x, - source_y, source_width, source_height, 0, 0, - destination_width, destination_height, NULL, - IMLIB_OP_COPY, - ctx->cliprect.x, ctx->cliprect.y, - ctx->cliprect.w, ctx->cliprect.h); - } + { + SET_FLAG(im->flags, F_HAS_ALPHA); + __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 1, source_x, + source_y, source_width, source_height, 0, 0, + destination_width, destination_height, NULL, + IMLIB_OP_COPY, + ctx->cliprect.x, ctx->cliprect.y, + ctx->cliprect.w, ctx->cliprect.h); + } else - { - __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 0, source_x, - source_y, source_width, source_height, 0, 0, - destination_width, destination_height, NULL, - IMLIB_OP_COPY, - ctx->cliprect.x, ctx->cliprect.y, - ctx->cliprect.w, ctx->cliprect.h); - } + { + __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 0, source_x, + source_y, source_width, source_height, 0, 0, + destination_width, destination_height, NULL, + IMLIB_OP_COPY, + ctx->cliprect.x, ctx->cliprect.y, + ctx->cliprect.w, ctx->cliprect.h); + } return (Imlib_Image) im; } Imlib_Updates imlib_updates_clone(Imlib_Updates updates) { - ImlibUpdate *u; + ImlibUpdate *u; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); u = (ImlibUpdate *) updates; return (Imlib_Updates) __imlib_DupUpdates(u); } @@ -1643,9 +1738,10 @@ Imlib_Updates imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h) { - ImlibUpdate *u; + ImlibUpdate *u; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); u = (ImlibUpdate *) updates; return (Imlib_Updates) __imlib_AddUpdate(u, x, y, w, h); } @@ -1653,9 +1749,10 @@ Imlib_Updates imlib_updates_merge(Imlib_Updates updates, int w, int h) { - ImlibUpdate *u; + ImlibUpdate *u; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); u = (ImlibUpdate *) updates; return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 0); } @@ -1663,9 +1760,10 @@ Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h) { - ImlibUpdate *u; + ImlibUpdate *u; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); u = (ImlibUpdate *) updates; return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 3); } @@ -1673,9 +1771,10 @@ void imlib_updates_free(Imlib_Updates updates) { - ImlibUpdate *u; + ImlibUpdate *u; - if (!ctx) ctx = imlib_context_new(); + if (!ctx) + ctx = imlib_context_new(); ... [truncated message content] |